test(2061): token vegawallet v2 (#2150)

* test: use vega wallet v2 connect flow

* test: update tests using wallet v2

* test: fix failing token test

* test: add wait for spinner

* chore: purge capsule teardown
This commit is contained in:
Joe Tsang 2022-11-17 18:22:51 +00:00 committed by GitHub
parent f77fc9e131
commit 6b6c05f04d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 25 additions and 192 deletions

View File

@ -58,4 +58,3 @@ jobs:
gobin: ${{needs.manual.outputs.gobin}} gobin: ${{needs.manual.outputs.gobin}}
skip-cache: ${{needs.manual.outputs.skip-cache}} skip-cache: ${{needs.manual.outputs.skip-cache}}
tags: ${{needs.manual.outputs.tags}} tags: ${{needs.manual.outputs.tags}}
capsule-teardown: false

View File

@ -17,4 +17,3 @@ jobs:
gobin: /home/runner/go/bin gobin: /home/runner/go/bin
tags: --env.grepTags '[ @smoke, @regression, @slow ]' tags: --env.grepTags '[ @smoke, @regression, @slow ]'
night-run: true night-run: true
capsule-teardown: false

View File

@ -24,10 +24,6 @@ on:
required: false required: false
type: boolean type: boolean
default: false default: false
capsule-teardown:
required: false
type: boolean
default: false
jobs: jobs:
explorer-e2e: explorer-e2e:
@ -100,7 +96,6 @@ jobs:
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }} CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }} CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }}
CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: ${{ inputs.capsule-teardown }}
CYPRESS_NIGHTLY_RUN: ${{ inputs.night-run }} CYPRESS_NIGHTLY_RUN: ${{ inputs.night-run }}
###### ######

View File

@ -20,10 +20,6 @@ on:
tags: tags:
required: false required: false
type: string type: string
capsule-teardown:
required: false
type: boolean
default: false
jobs: jobs:
token-e2e: token-e2e:
@ -96,7 +92,6 @@ jobs:
CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }} CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }}
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }} CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }}
CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: ${{ inputs.capsule-teardown }}
###### ######
## Upload logs ## Upload logs

View File

@ -20,9 +20,6 @@ on:
night-run: night-run:
required: false required: false
type: boolean type: boolean
capsule-teardown:
required: false
type: boolean
jobs: jobs:
run-console-lite-e2e: run-console-lite-e2e:
@ -45,7 +42,6 @@ jobs:
skip-cache: ${{ inputs.skip-cache }} skip-cache: ${{ inputs.skip-cache }}
tags: ${{ inputs.tags }} tags: ${{ inputs.tags }}
night-run: ${{ inputs.night-run }} night-run: ${{ inputs.night-run }}
capsule-teardown: ${{ inputs.capsule-teardown }}
run-liquidity-e2e: run-liquidity-e2e:
uses: ./.github/workflows/cypress-liquidity-provision-dashboard-e2e.yml uses: ./.github/workflows/cypress-liquidity-provision-dashboard-e2e.yml
@ -68,7 +64,6 @@ jobs:
gobin: ${{ inputs.gobin }} gobin: ${{ inputs.gobin }}
skip-cache: ${{ inputs.skip-cache }} skip-cache: ${{ inputs.skip-cache }}
tags: ${{ inputs.tags }} tags: ${{ inputs.tags }}
capsule-teardown: ${{ inputs.capsule-teardown }}
run-trading-e2e: run-trading-e2e:
uses: ./.github/workflows/cypress-trading-e2e.yml uses: ./.github/workflows/cypress-trading-e2e.yml

View File

@ -202,15 +202,6 @@ context('Parties page', { tags: '@regression' }, function () {
.and('include', darkThemeSideMenuBackgroundColor); .and('include', darkThemeSideMenuBackgroundColor);
}); });
after(
'teardown environment to prevent test data bleeding into other tests',
function () {
if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) {
cy.restart_vegacapsule_network();
}
}
);
Cypress.Commands.add('get_asset_decimals', (assetID) => { Cypress.Commands.add('get_asset_decimals', (assetID) => {
cy.get_asset_information().then((assetsInfo) => { cy.get_asset_information().then((assetsInfo) => {
const assetDecimals = assetsInfo[assetData[assetID].name].decimals; const assetDecimals = assetsInfo[assetData[assetID].name].decimals;

View File

@ -51,6 +51,5 @@ module.exports = defineConfig({
grepTags: '@regression @smoke @slow', grepTags: '@regression @smoke @slow',
grepFilterSpecs: true, grepFilterSpecs: true,
grepOmitFiltered: true, grepOmitFiltered: true,
TEARDOWN_NETWORK_AFTER_FLOWS: false,
}, },
}); });

View File

@ -54,7 +54,6 @@ context(
{ tags: '@slow' }, { tags: '@slow' },
function () { function () {
before('connect wallets and set approval limit', function () { before('connect wallets and set approval limit', function () {
cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.verify_page_header('The $VEGA token'); cy.verify_page_header('The $VEGA token');
cy.get_network_parameters().then((network_parameters) => { cy.get_network_parameters().then((network_parameters) => {
@ -96,12 +95,7 @@ context(
)[0] )[0]
).as('maxCloseHours'); ).as('maxCloseHours');
}); });
cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000'); cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload();
cy.wait_for_spinner();
cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect();
}); });
describe('Eth wallet - contains VEGA tokens', function () { describe('Eth wallet - contains VEGA tokens', function () {
@ -137,6 +131,10 @@ context(
); );
beforeEach('visit governance tab', function () { beforeEach('visit governance tab', function () {
cy.reload();
cy.wait_for_spinner();
cy.vega_wallet_connect();
cy.ethereum_wallet_connect();
cy.navigate_to('governance'); cy.navigate_to('governance');
cy.wait_for_spinner(); cy.wait_for_spinner();
}); });
@ -846,15 +844,6 @@ context(
const randomNum = Math.floor(Math.random() * 1000) + 1; const randomNum = Math.floor(Math.random() * 1000) + 1;
return randomNum + ': Freeform e2e proposal'; return randomNum + ': Freeform e2e proposal';
} }
after(
'teardown environment to prevent test data bleeding into other tests',
function () {
if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) {
cy.restart_vegacapsule_network();
}
}
);
}); });
} }
); );

View File

@ -40,30 +40,22 @@ context(
{ tags: '@slow' }, { tags: '@slow' },
function () { function () {
before('connect wallets and set approval limit', function () { before('connect wallets and set approval limit', function () {
cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.verify_page_header('The $VEGA token'); cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000'); cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload();
cy.wait_for_spinner();
cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect();
}); });
beforeEach('visit governance tab', function () { beforeEach('visit governance tab', function () {
cy.reload();
cy.wait_for_spinner();
cy.vega_wallet_connect();
cy.ethereum_wallet_connect();
cy.navigate_to('governance'); cy.navigate_to('governance');
cy.wait_for_spinner(); cy.wait_for_spinner();
cy.intercept('POST', '/query', (req) => {
if (req.body.operationName === 'ProposalEvent') {
req.alias = 'proposalSubmissionCompletion';
}
});
cy.ensure_specified_unstaked_tokens_are_associated('1');
}); });
it('Able to submit valid update network parameter proposal', function () { it('Able to submit valid update network parameter proposal', function () {
cy.navigate_to_page_if_not_already_loaded('governance'); cy.ensure_specified_unstaked_tokens_are_associated('1');
cy.go_to_make_new_proposal(governanceProposalType.NETWORK_PARAMETER); cy.go_to_make_new_proposal(governanceProposalType.NETWORK_PARAMETER);
// 3002-PROP-006 // 3002-PROP-006
cy.get(newProposalTitle).type('Test update network parameter proposal'); cy.get(newProposalTitle).type('Test update network parameter proposal');

View File

@ -33,22 +33,19 @@ context(
function () { function () {
// 2001-STKE-002, 2001-STKE-032 // 2001-STKE-002, 2001-STKE-032
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.verify_page_header('The $VEGA token'); cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000'); cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload();
cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect();
cy.navigate_to('staking');
cy.wait_for_spinner();
}); });
describe('Eth wallet - contains VEGA tokens', function () { describe('Eth wallet - contains VEGA tokens', function () {
beforeEach( beforeEach(
'teardown wallet & drill into a specific validator', 'teardown wallet & drill into a specific validator',
function () { function () {
cy.reload();
cy.wait_for_spinner();
cy.vega_wallet_connect();
cy.ethereum_wallet_connect();
cy.vega_wallet_teardown(); cy.vega_wallet_teardown();
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.wait_for_spinner(); cy.wait_for_spinner();
@ -870,15 +867,6 @@ context(
cy.get(stakeTokenSubmitButton).should('contain', 'Add 1 $VEGA tokens'); cy.get(stakeTokenSubmitButton).should('contain', 'Add 1 $VEGA tokens');
}); });
after(
'teardown environment to prevent test data bleeding into other tests',
function () {
if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) {
cy.restart_vegacapsule_network();
}
}
);
}); });
} }
); );

View File

@ -26,22 +26,20 @@ context(
{ tags: '@slow' }, { tags: '@slow' },
function () { function () {
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.verify_page_header('The $VEGA token'); cy.verify_page_header('The $VEGA token');
cy.vega_wallet_connect(); cy.vega_wallet_connect();
cy.vega_wallet_set_specified_approval_amount('1000'); cy.vega_wallet_set_specified_approval_amount('1000');
cy.reload();
cy.verify_page_header('The $VEGA token');
cy.ethereum_wallet_connect();
cy.navigate_to('staking');
cy.wait_for_spinner();
}); });
describe('Eth wallet - contains VEGA tokens', function () { describe('Eth wallet - contains VEGA tokens', function () {
beforeEach( beforeEach(
'teardown wallet & drill into a specific validator', 'teardown wallet & drill into a specific validator',
function () { function () {
cy.reload();
cy.wait_for_spinner();
cy.vega_wallet_connect();
cy.ethereum_wallet_connect();
cy.vega_wallet_teardown(); cy.vega_wallet_teardown();
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.wait_for_spinner(); cy.wait_for_spinner();
@ -310,15 +308,6 @@ context(
)} can now participate in governance and nominate a validator with your associated $VEGA.` )} 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 () {
if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) {
cy.restart_vegacapsule_network();
}
}
);
}); });
} }
); );

View File

@ -27,15 +27,17 @@ context(
function () { function () {
before('visit withdrawals and connect vega wallet', function () { before('visit withdrawals and connect vega wallet', function () {
cy.updateCapsuleMultiSig(); // When running tests locally, will fail if run without restarting capsule cy.updateCapsuleMultiSig(); // When running tests locally, will fail if run without restarting capsule
cy.vega_wallet_import();
cy.deposit_asset(usdcEthAddress); cy.deposit_asset(usdcEthAddress);
}); });
beforeEach('Navigate to withdrawal page', function () { beforeEach('Navigate to withdrawal page', function () {
cy.reload();
cy.visit('/'); cy.visit('/');
cy.navigate_to('withdrawals'); cy.navigate_to('withdrawals');
cy.wait_for_spinner();
cy.vega_wallet_connect(); cy.vega_wallet_connect();
cy.ethereum_wallet_connect(); cy.ethereum_wallet_connect();
cy.vega_wallet_teardown();
}); });
it('Able to open withdrawal form with vega wallet connected', function () { it('Able to open withdrawal form with vega wallet connected', function () {

View File

@ -137,7 +137,6 @@ context('Staking Page - verify elements on page', function () {
{ tags: '@smoke' }, { tags: '@smoke' },
function () { function () {
before('connect wallets and click on validator', function () { before('connect wallets and click on validator', function () {
cy.vega_wallet_import();
cy.vega_wallet_connect(); cy.vega_wallet_connect();
cy.click_on_validator_from_list(0); cy.click_on_validator_from_list(0);
}); });

View File

@ -152,7 +152,6 @@ context(
describe('when vega wallet connected', function () { describe('when vega wallet connected', function () {
before('connect vega wallet', function () { before('connect vega wallet', function () {
cy.vega_wallet_import();
cy.visit('/'); cy.visit('/');
cy.vega_wallet_connect(); cy.vega_wallet_connect();
}); });
@ -400,15 +399,6 @@ context(
.contains(currency.name); .contains(currency.name);
}); });
}); });
after(
'teardown environment to prevent test data bleeding into other tests',
function () {
if (Cypress.env('TEARDOWN_NETWORK_AFTER_FLOWS')) {
cy.restart_vegacapsule_network();
}
}
);
}); });
} }
); );

View File

@ -174,6 +174,8 @@ Cypress.Commands.add('get_sort_order_of_supplied_array', (suppliedArray) => {
Cypress.Commands.add('go_to_make_new_proposal', (proposalType) => { Cypress.Commands.add('go_to_make_new_proposal', (proposalType) => {
cy.navigate_to_page_if_not_already_loaded('governance'); cy.navigate_to_page_if_not_already_loaded('governance');
cy.get(newProposalButton).should('be.visible').click(); cy.get(newProposalButton).should('be.visible').click();
cy.url().should('include', '/governance/propose');
cy.wait_for_spinner();
cy.get('li').contains(proposalType).click(); cy.get('li').contains(proposalType).click();
}); });

View File

@ -98,7 +98,7 @@ Cypress.Commands.add('staking_page_disassociate_tokens', (amount, options) => {
); );
cy.get(ethWalletDissociateButton).first().click(); cy.get(ethWalletDissociateButton).first().click();
cy.get(vegaKeySelector) cy.get(vegaKeySelector, txTimeout)
.invoke('attr', 'disabled') .invoke('attr', 'disabled')
.then((disabled) => { .then((disabled) => {
if (!disabled) { if (!disabled) {

View File

@ -1,12 +1,9 @@
const vegaWalletContainer = '[data-testid="vega-wallet"]'; const vegaWalletContainer = '[data-testid="vega-wallet"]';
const restConnectorForm = '[data-testid="rest-connector-form"]';
const vegaWalletNameElement = '[data-testid="wallet-name"]'; const vegaWalletNameElement = '[data-testid="wallet-name"]';
const vegaWalletName = Cypress.env('vegaWalletName');
const vegaWalletPassphrase = Cypress.env('vegaWalletPassphrase');
Cypress.Commands.add('vega_wallet_connect', () => { Cypress.Commands.add('vega_wallet_connect', () => {
cy.highlight('Connecting Vega Wallet'); cy.highlight('Connecting Vega Wallet');
cy.get(vegaWalletContainer).within(() => { cy.get(vegaWalletContainer, { timeout: 6000 }).within(() => {
cy.get('button') cy.get('button')
.contains('Connect Vega wallet to use associated $VEGA') .contains('Connect Vega wallet to use associated $VEGA')
.should('be.enabled') .should('be.enabled')
@ -15,12 +12,7 @@ Cypress.Commands.add('vega_wallet_connect', () => {
}); });
// Connect with gui as its the v1 service and tests should still pass. This will need // Connect with gui as its the v1 service and tests should still pass. This will need
// to be update to use v2 // to be update to use v2
cy.getByTestId('connector-gui').click(); cy.getByTestId('connector-cli').click();
cy.get(restConnectorForm).within(() => {
cy.get('#wallet').click().type(vegaWalletName);
cy.get('#passphrase').click().type(vegaWalletPassphrase);
cy.get('button').contains('Connect').click();
});
cy.get(vegaWalletNameElement).should('be.visible'); cy.get(vegaWalletNameElement).should('be.visible');
}); });

View File

@ -9,9 +9,7 @@ import { addSlackCommand } from './lib/commands/slack';
import { addHighlightLog } from './lib/commands/highlight-log'; import { addHighlightLog } from './lib/commands/highlight-log';
import { addGetAssetInformation } from './lib/commands/get-asset-information'; import { addGetAssetInformation } from './lib/commands/get-asset-information';
import { addVegaWalletReceiveFaucetedAsset } from './lib/commands/vega-wallet-receive-fauceted-asset'; import { addVegaWalletReceiveFaucetedAsset } from './lib/commands/vega-wallet-receive-fauceted-asset';
import { addVegaWalletImport } from './lib/commands/vega-wallet-import';
import { addContainsExactly } from './lib/commands/contains-exactly'; import { addContainsExactly } from './lib/commands/contains-exactly';
import { addRestartVegacapsuleNetwork } from './lib/commands/restart-vegacapsule-network';
import { addGetNetworkParameters } from './lib/commands/get-network-parameters'; import { addGetNetworkParameters } from './lib/commands/get-network-parameters';
import { addUpdateCapsuleMultiSig } from './lib/commands/add-validators-to-multisig'; import { addUpdateCapsuleMultiSig } from './lib/commands/add-validators-to-multisig';
import { addVegaWalletConnect } from './lib/commands/vega-wallet-connect'; import { addVegaWalletConnect } from './lib/commands/vega-wallet-connect';
@ -25,9 +23,7 @@ addMockWeb3ProviderCommand();
addHighlightLog(); addHighlightLog();
addVegaWalletReceiveFaucetedAsset(); addVegaWalletReceiveFaucetedAsset();
addGetAssetInformation(); addGetAssetInformation();
addVegaWalletImport();
addContainsExactly(); addContainsExactly();
addRestartVegacapsuleNetwork();
addGetNetworkParameters(); addGetNetworkParameters();
addUpdateCapsuleMultiSig(); addUpdateCapsuleMultiSig();
addVegaWalletConnect(); addVegaWalletConnect();

View File

@ -1,49 +0,0 @@
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
restart_vegacapsule_network(): void;
}
}
}
export function addRestartVegacapsuleNetwork() {
Cypress.Commands.add('restart_vegacapsule_network', () => {
Cypress.on('uncaught:exception', () => {
// stopping the network causes errors with pending transactions
// This stops those errors from preventing the teardown
return false;
});
cy.log('Destroying capsule network');
// We stop the network twice - since it does not always shutdown correctly on first attempt
cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false });
cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false })
.its('stderr')
.should('contain', 'Network has been successfully cleaned up');
cy.log('Bootstrapping network');
cy.exec(
'vegacapsule network bootstrap --config-path=../../vegacapsule/config.hcl --force',
{ failOnNonZeroExit: false, timeout: 100000 }
)
.its('stderr')
.then((response) => {
if (!response.includes('Network successfully started')) {
cy.log('Bootstrapping network second time');
cy.exec('vegacapsule network destroy', { failOnNonZeroExit: false })
.its('stderr')
.should('contain', 'Network has been successfully cleaned up');
cy.exec(
'vegacapsule network bootstrap --config-path=../../vegacapsule/config.hcl --force',
{ failOnNonZeroExit: false, timeout: 100000 }
)
.its('stderr')
.then((response) => {
return response;
});
}
})
.should('contain', 'Network successfully started');
});
}

View File

@ -1,30 +0,0 @@
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
vega_wallet_import(): void;
}
}
}
export function addVegaWalletImport() {
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
Cypress.Commands.add('vega_wallet_import', () => {
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 ${walletName} --recovery-phrase-file ./src/fixtures/wallet/recovery -p ./src/fixtures/wallet/passphrase --home ${walletLocation}`,
{ failOnNonZeroExit: false }
);
cy.exec(
`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}`
);
});
}