From 9465543b2378fd8850fe26a2a6a3f8adf716bbe4 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Wed, 19 Oct 2022 16:48:57 +0100 Subject: [PATCH] Test/1540 fix flow tests (#1788) * fix: local failing tests * chore: remove capsule restart from manual flow * fix: try fix failing wallet test * chore: set capsule teardown to true * chore: revert attempted fix * fix: remove wallet steps * chore: revert investigation changes * chore: move asset wallet faucets * chore: add retry to get asset func * chore: add func for faucet assets without checks * chore: turn off capsule restart after flows * chore: remove commented lines --- .../capsule-cypress-manual-trigger.yml | 2 +- .../workflows/capsule-cypress-night-run.yml | 2 +- .../integration/flow/governance-flow.cy.js | 2 +- .../flow/token-association-flow.cy.js | 2 +- .../src/integration/view/wallet-vega.cy.js | 82 +++++++------------ .../src/support/wallet-vega.functions.js | 18 ++++ 6 files changed, 51 insertions(+), 57 deletions(-) diff --git a/.github/workflows/capsule-cypress-manual-trigger.yml b/.github/workflows/capsule-cypress-manual-trigger.yml index 131b6c048..e85aa8785 100644 --- a/.github/workflows/capsule-cypress-manual-trigger.yml +++ b/.github/workflows/capsule-cypress-manual-trigger.yml @@ -142,7 +142,7 @@ jobs: CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE: ${{ secrets.CYPRESS_TRADING_TEST_VEGA_WALLET_PASSPHRASE }} CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }} - CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: true + CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: false ###### ## Upload logs diff --git a/.github/workflows/capsule-cypress-night-run.yml b/.github/workflows/capsule-cypress-night-run.yml index 2bccebd0b..6078b7cf7 100644 --- a/.github/workflows/capsule-cypress-night-run.yml +++ b/.github/workflows/capsule-cypress-night-run.yml @@ -108,7 +108,7 @@ jobs: CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }} CYPRESS_ETH_WALLET_MNEMONIC: ${{ secrets.CYPRESS_ETH_WALLET_MNEMONIC }} CYPRESS_NIGHTLY_RUN: true - CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: true + CYPRESS_TEARDOWN_NETWORK_AFTER_FLOWS: false ###### ## Upload logs diff --git a/apps/token-e2e/src/integration/flow/governance-flow.cy.js b/apps/token-e2e/src/integration/flow/governance-flow.cy.js index 88a708880..90825de91 100644 --- a/apps/token-e2e/src/integration/flow/governance-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/governance-flow.cy.js @@ -416,7 +416,7 @@ context( cy.get_submitted_proposal_from_proposal_list().within(() => cy.get(viewProposalButton).click() ); - cy.contains('Currently set to fail').should('be.visible'); + cy.contains('currently set to fail').should('be.visible'); cy.contains('Participation: Not Met 0.00 0.00%(0.00% Required)').should( 'be.visible' ); 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 ee9e8aa22..e23351140 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 @@ -294,7 +294,7 @@ context( ); cy.get('[data-testid="manage-vega-wallet"]').click(); - cy.get('[data-testid="select-keypair-button"]').click(); + cy.get('[data-testid="select-keypair-button"]').eq(0).click(); cy.get(connectedVegaKey).should( 'have.text', Cypress.env('vegaWalletPublicKey2') diff --git a/apps/token-e2e/src/integration/view/wallet-vega.cy.js b/apps/token-e2e/src/integration/view/wallet-vega.cy.js index f721a225d..5ccfc294e 100644 --- a/apps/token-e2e/src/integration/view/wallet-vega.cy.js +++ b/apps/token-e2e/src/integration/view/wallet-vega.cy.js @@ -28,6 +28,13 @@ const vegaWalletCurrencyTitle = '[data-testid="currency-title"]'; const vegaWalletPublicKey = Cypress.env('vegaWalletPublicKey'); const txTimeout = Cypress.env('txTimeout'); +const faucetAssets = { + BTCFake: 'fBTC', + DAIFake: 'fDAI', + EUROFake: 'fEURO', + USDCFake: 'fUSDC', +}; + context( 'Vega Wallet - verify elements on widget', { tags: '@regression' }, @@ -138,31 +145,16 @@ context( }); }); - // after('close dialog', function () { - // cy.get(dialogCloseBtn).click().should('not.exist'); - // }); - to be changed when dialog state is fixed - https://github.com/vegaprotocol/frontend-monorepo/issues/838 + after('close dialog', function () { + cy.get(dialogCloseBtn).click().should('not.exist'); + }); }); describe('when vega wallet connected', function () { before('connect vega wallet', function () { cy.vega_wallet_import(); cy.visit('/'); - cy.get(walletContainer).within(() => { - cy.get(connectButton).click(); - }); - cy.get(connectorsList).within(() => { - // using gui option to connect using wallet service V1 - cy.getByTestId('connector-gui').click(); - }); - // cy.vega_wallet_connect(); - to be changed when dialog state is fixed - https://github.com/vegaprotocol/frontend-monorepo/issues/838 - // then code below can be removed - cy.get(restConnectorForm).within(() => { - cy.get('#wallet').click().type(Cypress.env('vegaWalletName')); - cy.get('#passphrase') - .click() - .type(Cypress.env('vegaWalletPassphrase')); - cy.get('button').contains('Connect').click(); - }); + cy.vega_wallet_connect(); }); it('should have VEGA WALLET header visible', function () { @@ -274,7 +266,7 @@ context( cy.get(dialog).within(() => { cy.get(copyPublicKeyBtn) .should('be.visible') - .and('have.text', 'Copy'); + .and('contain.text', 'Copy'); }); }); @@ -305,48 +297,32 @@ context( // 2002-SINC-016 describe('when assets exist in vegawallet', function () { before('send-faucet assets to connected vega wallet', function () { - cy.vega_wallet_receive_fauceted_asset( - 'USDC (fake)', - '10', + cy.vega_wallet_faucet_assets_without_check( + faucetAssets.USDCFake, + '1000000', vegaWalletPublicKey ); - cy.vega_wallet_receive_fauceted_asset( - 'BTC (fake)', - '6', + cy.vega_wallet_faucet_assets_without_check( + faucetAssets.BTCFake, + '600000', vegaWalletPublicKey ); - cy.vega_wallet_receive_fauceted_asset( - 'EURO (fake)', - '8', + cy.vega_wallet_faucet_assets_without_check( + faucetAssets.EUROFake, + '800000', vegaWalletPublicKey ); - cy.vega_wallet_receive_fauceted_asset( - 'DAI (fake)', - '2', + cy.vega_wallet_faucet_assets_without_check( + faucetAssets.DAIFake, + '200000', vegaWalletPublicKey ); - // cy.vega_wallet_connect(); - to be changed when dialog state is fixed - https://github.com/vegaprotocol/frontend-monorepo/issues/838 - // then code below can be removed - cy.get(walletContainer).within(() => { - cy.get('button') - .contains('Connect Vega wallet to use associated $VEGA') - .should('be.enabled') - .and('be.visible') - .click({ force: true }); - }); - cy.getByTestId('connector-gui').click(); - cy.get(restConnectorForm).within(() => { - cy.get('#wallet').click().type(Cypress.env('vegaWalletName')); - cy.get('#passphrase') - .click() - .type(Cypress.env('vegaWalletPassphrase')); - cy.get('button').contains('Connect').click(); - }); + cy.vega_wallet_connect(); cy.ethereum_wallet_connect(); }); it('should see fUSDC assets - within vega wallet', function () { - let currency = { id: 'fUSDC', name: 'USDC (fake)' }; + let currency = { id: faucetAssets.USDCFake, name: 'USDC (fake)' }; cy.get(walletContainer).within(() => { cy.get(vegaWalletCurrencyTitle) .contains(currency.id, txTimeout) @@ -366,7 +342,7 @@ context( }); it('should see fBTC assets - within vega wallet', function () { - let currency = { id: 'fBTC', name: 'BTC (fake)' }; + let currency = { id: faucetAssets.BTCFake, name: 'BTC (fake)' }; cy.get(walletContainer).within(() => { cy.get(vegaWalletCurrencyTitle) .contains(currency.id, txTimeout) @@ -386,7 +362,7 @@ context( }); it('should see fEURO assets - within vega wallet', function () { - let currency = { id: 'fEURO', name: 'EURO (fake)' }; + let currency = { id: faucetAssets.EUROFake, name: 'EURO (fake)' }; cy.get(walletContainer).within(() => { cy.get(vegaWalletCurrencyTitle) .contains(currency.id, txTimeout) @@ -406,7 +382,7 @@ context( }); it('should see fDAI assets - within vega wallet', function () { - let currency = { id: 'fDAI', name: 'DAI (fake)' }; + let currency = { id: faucetAssets.DAIFake, name: 'DAI (fake)' }; cy.get(walletContainer).within(() => { cy.get(vegaWalletCurrencyTitle) .contains(currency.id, txTimeout) diff --git a/apps/token-e2e/src/support/wallet-vega.functions.js b/apps/token-e2e/src/support/wallet-vega.functions.js index 629e11c4f..b6bd53299 100644 --- a/apps/token-e2e/src/support/wallet-vega.functions.js +++ b/apps/token-e2e/src/support/wallet-vega.functions.js @@ -23,3 +23,21 @@ Cypress.Commands.add('vega_wallet_connect', () => { }); cy.get(vegaWalletNameElement).should('be.visible'); }); + +Cypress.Commands.add( + 'vega_wallet_faucet_assets_without_check', + function (asset, amount, vegaWalletPublicKey) { + cy.highlight(`Topping up vega wallet with ${asset}, amount: ${amount}`); + cy.exec( + `curl -X POST -d '{"amount": "${amount}", "asset": "${asset}", "party": "${vegaWalletPublicKey}"}' http://localhost:1790/api/v1/mint` + ) + .its('stdout') + .then((response) => { + assert.include( + response, + `"success":true`, + 'Ensuring curl command was successfully undertaken' + ); + }); + } +);