From fb9505a8a8dbc49991f01144c7c88ed5cdda584e Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Mon, 10 Oct 2022 09:22:41 +0100 Subject: [PATCH] chore: acs updated for token association (#1687) --- apps/token-e2e/cypress.config.js | 3 ++ .../flow/token-association-flow.cy.js | 40 +++++++++++++++++-- .../src/lib/commands/vega-wallet-import.ts | 20 +++++----- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/apps/token-e2e/cypress.config.js b/apps/token-e2e/cypress.config.js index 21bef6e8e..692d5dbd6 100644 --- a/apps/token-e2e/cypress.config.js +++ b/apps/token-e2e/cypress.config.js @@ -40,6 +40,9 @@ module.exports = defineConfig({ vegaWalletPublicKey: '02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65', vegaWalletPublicKeyShort: '02ecea…2f65', + vegaWalletPublicKey2: + '7f9cf07d3a9905b1a61a1069f7a758855da428bc0f4a97de87f48644bfc25535', + vegaWalletPublicKey2Short: '7f9cf0…5535', vegaTokenContractAddress: '0xF41bD86d462D36b997C0bbb4D97a0a3382f205B7', vegaTokenAddress: '0x67175Da1D5e966e40D11c4B2519392B2058373de', txTimeout: { timeout: 70000 }, diff --git a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js index c4ea61709..ee9e8aa22 100644 --- a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js @@ -14,9 +14,11 @@ const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; const ethWalletDissociateButton = '[href="/staking/disassociate"]'; const vestingContractSection = '[data-testid="vega-in-vesting-contract"]'; const vegaInWalletSection = '[data-testid="vega-in-wallet"]'; +const connectedVegaKey = '[data-testid="connected-vega-key"]'; const associatedKey = '[data-test-id="associated-key"]'; const associatedAmount = '[data-test-id="associated-amount"]'; -const disassocitiationWarning = '[data-testid="disassociation-warning"]'; +const associateCompleteText = '[data-testid="transaction-complete-body"]'; +const disassociationWarning = '[data-testid="disassociation-warning"]'; const vegaWallet = '[data-testid="vega-wallet"]'; context( @@ -47,7 +49,8 @@ context( ); it('Able to associate tokens - from wallet', function () { - //1004-ASSO-008 + //1004-ASSO-003 + //1004-ASSO-005 //1004-ASSO-009 //1004-ASSO-030 //1004-ASSO-012 @@ -162,7 +165,7 @@ context( cy.get('button').contains('Select a validator to nominate').click(); cy.get(ethWalletDissociateButton).click(); - cy.get(disassocitiationWarning).should('contain', warningText); + cy.get(disassociationWarning).should('contain', warningText); cy.staking_page_disassociate_all_tokens(); @@ -185,6 +188,8 @@ context( it('Able to associate and disassociate vesting contract tokens', function () { // 1004-ASSO-006 + // 1004-ASSO-007 + // 1004-ASSO-018 // 1004-ASSO-024 // 1004-ASSO-023 @@ -268,15 +273,44 @@ context( }); it('Not able to associate more tokens than owned', function () { + // 1004-ASSO-008 // 1004-ASSO-010 // No warning visible as described in AC, but the button is disabled cy.get(ethWalletAssociateButton).first().click(); cy.get(associateWalletRadioButton, { timeout: 30000 }).click(); + cy.get(tokenSubmitButton, txTimeout).should('be.disabled'); // button disabled with no input cy.get(tokenAmountInputBox, { timeout: 10000 }).type(6500000); cy.get(tokenSubmitButton, txTimeout).should('be.disabled'); }); + // 1004-ASSO-004 + it('Able to associate tokens to different public key of connected vega wallet', function () { + cy.get(ethWalletAssociateButton).first().click(); + cy.get(associateWalletRadioButton).click(); + cy.get(connectedVegaKey).should( + 'have.text', + Cypress.env('vegaWalletPublicKey') + ); + + cy.get('[data-testid="manage-vega-wallet"]').click(); + cy.get('[data-testid="select-keypair-button"]').click(); + cy.get(connectedVegaKey).should( + 'have.text', + Cypress.env('vegaWalletPublicKey2') + ); + cy.staking_page_associate_tokens('2'); + cy.get(vegaWallet).within(() => { + cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); + }); + cy.get(associateCompleteText).should( + 'have.text', + `Vega key ${Cypress.env( + 'vegaWalletPublicKey2Short' + )} can now participate in governance and nominate a validator with your associated $VEGA.` + ); + }); + after( 'teardown environment to prevent test data bleeding into other tests', function () { diff --git a/libs/cypress/src/lib/commands/vega-wallet-import.ts b/libs/cypress/src/lib/commands/vega-wallet-import.ts index 47c81bba4..02cfb7055 100644 --- a/libs/cypress/src/lib/commands/vega-wallet-import.ts +++ b/libs/cypress/src/lib/commands/vega-wallet-import.ts @@ -11,20 +11,20 @@ declare global { export function addVegaWalletImport() { // @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command Cypress.Commands.add('vega_wallet_import', () => { - cy.highlight(`Importing Vega Wallet ${Cypress.env('vegaWalletName')}`); - cy.exec(`vega wallet init -f --home ${Cypress.env('vegaWalletLocation')}`); + const walletName = Cypress.env('vegaWalletName'); + const walletLocation = Cypress.env('vegaWalletLocation'); + + cy.highlight(`Importing Vega Wallet ${walletName}`); + cy.exec(`vega wallet init -f --home ${walletLocation}`); cy.exec( - `vega wallet import -w ${Cypress.env( - 'vegaWalletName' - )} --recovery-phrase-file ./src/fixtures/wallet/recovery -p ./src/fixtures/wallet/passphrase --home ${Cypress.env( - 'vegaWalletLocation' - )}`, + `vega wallet import -w ${walletName} --recovery-phrase-file ./src/fixtures/wallet/recovery -p ./src/fixtures/wallet/passphrase --home ${walletLocation}`, { failOnNonZeroExit: false } ); cy.exec( - `vega wallet service run --network DV --automatic-consent --home ${Cypress.env( - 'vegaWalletLocation' - )}` + `vega wallet key generate -w ${walletName} -p ./src/fixtures/wallet/passphrase --home ${walletLocation}` + ); + cy.exec( + `vega wallet service run --network DV --automatic-consent --home ${walletLocation}` ); }); }