From fdc22ed1f4038e2db4c884bcb0d7545cb0350f1c Mon Sep 17 00:00:00 2001 From: mattrussell36 Date: Thu, 14 Jul 2022 12:05:19 +0000 Subject: [PATCH 1/9] chore: update tranches Signed-off-by: github-actions[bot] --- apps/static/src/assets/mainnet-tranches.json | 100 +++++++++++++----- apps/static/src/assets/stagnet1-tranches.json | 4 +- apps/static/src/assets/testnet-tranches.json | 2 +- 3 files changed, 76 insertions(+), 30 deletions(-) diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index 827845f24..1ca40d86e 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -71,7 +71,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "120687.60294909203186805", + "locked_amount": "120628.175821494197496885", "deposits": [ { "amount": "129999.45", @@ -521,7 +521,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "97499.58", "total_removed": "0", - "locked_amount": "61605.4975572212290407", + "locked_amount": "61547.205080935108177026", "deposits": [ { "amount": "97499.58", @@ -554,7 +554,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "135173.4239508", "total_removed": "0", - "locked_amount": "84204.0794152667057160273426", + "locked_amount": "84124.40366395973881542470388", "deposits": [ { "amount": "135173.4239508", @@ -587,7 +587,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "32499.86", "total_removed": "0", - "locked_amount": "25916.368952284834442322", + "locked_amount": "25891.846314168479319724", "deposits": [ { "amount": "32499.86", @@ -620,7 +620,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "10833.29", "total_removed": "0", - "locked_amount": "8435.52660747719195897", + "locked_amount": "8427.544726732366482208", "deposits": [ { "amount": "10833.29", @@ -708,7 +708,7 @@ "tranche_end": "2022-11-01T00:00:00.000Z", "total_added": "22500", "total_removed": "0", - "locked_amount": "13420.127094655797", + "locked_amount": "13389.4941689311605", "deposits": [ { "amount": "15000", @@ -794,7 +794,7 @@ "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", "total_removed": "179856.049568108351", - "locked_amount": "1715358.109875174368620276", + "locked_amount": "1714026.685158763918450768", "deposits": [ { "amount": "1852091.69", @@ -1846,7 +1846,7 @@ "tranche_end": "2022-09-30T00:00:00.000Z", "total_added": "60916.66666633337", "total_removed": "19238.601152747179372649", - "locked_amount": "12143.787034497502163478850106205", + "locked_amount": "12104.6583446433338195713635496091", "deposits": [ { "amount": "2833.333333", @@ -5395,7 +5395,7 @@ "tranche_end": "2022-09-03T00:00:00.000Z", "total_added": "24284.000000000000000003", "total_removed": "6875.88980798578", - "locked_amount": "3376.2614414003058740004170970319634705", + "locked_amount": "3359.59545294266983908041503814687975661", "deposits": [ { "amount": "25", @@ -15925,7 +15925,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", "total_removed": "106452.6400159857469", - "locked_amount": "2660409.42081862296035011689", + "locked_amount": "2658363.57910906768647063675", "deposits": [ { "amount": "1998.95815", @@ -16659,8 +16659,8 @@ "tranche_start": "2022-06-05T00:00:00.000Z", "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15788853.065470999700000001", - "total_removed": "62889.84066484668888", - "locked_amount": "14657898.8329277585456883041909973431305758", + "total_removed": "63288.646809993954255", + "locked_amount": "14650681.5498171214389897741983021805663693", "deposits": [ { "amount": "16249.93", @@ -17209,6 +17209,11 @@ "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", "tx": "0x148f389a5771abdc96c5a51c1fc0e306d135763c60f6839db6763690022a1a36" }, + { + "amount": "398.806145147265375", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tx": "0x4961efbe6ce942c38f74c5cbf8a5c7f8f6586c1bda1df0a17c7a1fd80aae6905" + }, { "amount": "579.636872035866225", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -17411,6 +17416,12 @@ "tranche_id": 2, "tx": "0x148f389a5771abdc96c5a51c1fc0e306d135763c60f6839db6763690022a1a36" }, + { + "amount": "398.806145147265375", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tranche_id": 2, + "tx": "0x4961efbe6ce942c38f74c5cbf8a5c7f8f6586c1bda1df0a17c7a1fd80aae6905" + }, { "amount": "579.636872035866225", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -17551,8 +17562,8 @@ } ], "total_tokens": "194999.1675", - "withdrawn_tokens": "13652.2521999360072", - "remaining_tokens": "181346.9153000639928" + "withdrawn_tokens": "14051.058345083272575", + "remaining_tokens": "180948.109154916727425" }, { "address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c", @@ -18991,8 +19002,8 @@ "tranche_start": "2021-11-05T00:00:00.000Z", "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", - "total_removed": "2413723.131389663831937297", - "locked_amount": "7880269.64303812390931654596122858", + "total_removed": "2414153.780525405655617797", + "locked_amount": "7873572.40572457510297070076786894", "deposits": [ { "amount": "129284.449", @@ -19276,6 +19287,11 @@ "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "tx": "0x5b2ba568e3f60b624456972f011948b6870274b94ddba2f11eb876b4e875be1a" }, + { + "amount": "430.6491357418236805", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tx": "0x63919ba0a519b04dfe5a5b222e5952117f1cdbb1e6194ae85b22a4ed8cef6fa5" + }, { "amount": "509.31853983395369725", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -21004,6 +21020,12 @@ "tranche_id": 3, "tx": "0x5b2ba568e3f60b624456972f011948b6870274b94ddba2f11eb876b4e875be1a" }, + { + "amount": "430.6491357418236805", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tranche_id": 3, + "tx": "0x63919ba0a519b04dfe5a5b222e5952117f1cdbb1e6194ae85b22a4ed8cef6fa5" + }, { "amount": "509.31853983395369725", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -22350,8 +22372,8 @@ } ], "total_tokens": "359123.469575", - "withdrawn_tokens": "164980.154441085289241", - "remaining_tokens": "194143.315133914710759" + "withdrawn_tokens": "165410.8035768271129215", + "remaining_tokens": "193712.6659981728870785" }, { "address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB", @@ -23415,7 +23437,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "5778205.3912159303", "total_removed": "1543188.041113165491270727", - "locked_amount": "2796638.79189818404440572191528324", + "locked_amount": "2793992.67293104699085161389155315", "deposits": [ { "amount": "552496.6455", @@ -24615,7 +24637,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", "total_removed": "279.2296426169", - "locked_amount": "421557.080277297961550599391172", + "locked_amount": "421232.90496388911995570340233388", "deposits": [ { "amount": "3000", @@ -50413,7 +50435,7 @@ "tranche_start": "2021-12-05T00:00:00.000Z", "tranche_end": "2022-06-05T00:00:00.000Z", "total_added": "171288.42", - "total_removed": "36329.8823647506377", + "total_removed": "36829.8823647506377", "locked_amount": "0", "deposits": [ { @@ -54678,6 +54700,16 @@ "user": "0x5cce57661D758497446B57592D31667aafd60465", "tx": "0x8d9b31eaaecaa4f74f05f93d33e61d0691eba3a6f23a9033dbfcaeca1c9a00c4" }, + { + "amount": "250", + "user": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35", + "tx": "0x3da3cd5b323439c576ad7a3410d833da0da994ee652b29dd751a4c0edbf0ca99" + }, + { + "amount": "250", + "user": "0x5f3Bce4B242d00ED748d48172C1f2D47A0bcB19B", + "tx": "0xc06577f7fd53a100da581edbc8231a870d7b148329c8aa250eb942473004e5e6" + }, { "amount": "60.4448387275", "user": "0xEe3183EcE9ee7d73Fb7bA7F4eB262A2dE68C42B0", @@ -69757,10 +69789,17 @@ "tx": "0xe32a466fc780a0fb3fd84a804f622931ebfaf3f428bff0dc6d141270410e75f8" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "250", + "user": "0x5f3Bce4B242d00ED748d48172C1f2D47A0bcB19B", + "tranche_id": 6, + "tx": "0xc06577f7fd53a100da581edbc8231a870d7b148329c8aa250eb942473004e5e6" + } + ], "total_tokens": "250", - "withdrawn_tokens": "0", - "remaining_tokens": "250" + "withdrawn_tokens": "250", + "remaining_tokens": "0" }, { "address": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35", @@ -69772,10 +69811,17 @@ "tx": "0xe32a466fc780a0fb3fd84a804f622931ebfaf3f428bff0dc6d141270410e75f8" } ], - "withdrawals": [], + "withdrawals": [ + { + "amount": "250", + "user": "0x57a88037954e15AFFDf9bc29097e0B5f5A1BfF35", + "tranche_id": 6, + "tx": "0x3da3cd5b323439c576ad7a3410d833da0da994ee652b29dd751a4c0edbf0ca99" + } + ], "total_tokens": "250", - "withdrawn_tokens": "0", - "remaining_tokens": "250" + "withdrawn_tokens": "250", + "remaining_tokens": "0" }, { "address": "0x949ECa8174BBa367901e9a195B77B2eA7d862c43", diff --git a/apps/static/src/assets/stagnet1-tranches.json b/apps/static/src/assets/stagnet1-tranches.json index 1d41d76ec..7c389c263 100644 --- a/apps/static/src/assets/stagnet1-tranches.json +++ b/apps/static/src/assets/stagnet1-tranches.json @@ -38,7 +38,7 @@ "tranche_end": "2022-11-26T13:48:10.000Z", "total_added": "100", "total_removed": "0", - "locked_amount": "37.074508498224257", + "locked_amount": "37.00587265347539", "deposits": [ { "amount": "100", @@ -242,7 +242,7 @@ "tranche_end": "2022-10-12T00:53:20.000Z", "total_added": "1100", "total_removed": "673.04388635", - "locked_amount": "270.58154807204466", + "locked_amount": "269.826553779807255", "deposits": [ { "amount": "1000", diff --git a/apps/static/src/assets/testnet-tranches.json b/apps/static/src/assets/testnet-tranches.json index 0a0b6b2d2..a24706cdd 100644 --- a/apps/static/src/assets/testnet-tranches.json +++ b/apps/static/src/assets/testnet-tranches.json @@ -69,7 +69,7 @@ "tranche_end": "2022-10-12T00:53:20.000Z", "total_added": "1010.000000000000000001", "total_removed": "668.4622323651", - "locked_amount": "248.4430577752410060002459832255200406", + "locked_amount": "247.74983574327757050024529686707255205", "deposits": [ { "amount": "1000", From 85c3eff31e89233f698645fc9cc0255fb8e418a5 Mon Sep 17 00:00:00 2001 From: AndyWhiteVega <106072061+AndyWhiteVega@users.noreply.github.com> Date: Thu, 14 Jul 2022 15:21:51 +0100 Subject: [PATCH 2/9] Test/746 expand coverage of tfe tests (#759) * test: adding extra checks within tests * test: lint * test: refactor to bring assertions inline with new wallet locators * test: lint * test: lint correction * test: formatting for lint * test: formatting for lint * test: fix test and make use of common functions * test: lint --- .../src/integration/flow/staking-flow.cy.js | 650 ++++++++++++------ .../flow/token-association-flow.cy.js | 162 +++-- .../token-e2e/src/support/common.functions.js | 5 + .../src/support/staking.functions.js | 10 +- .../src/support/wallet-eth.functions.js | 39 -- .../src/support/wallet-teardown.functions.js | 8 +- .../src/support/wallet-vega.functions.js | 21 - .../src/components/eth-wallet/eth-wallet.tsx | 14 +- .../components/vega-wallet/vega-wallet.tsx | 42 +- 9 files changed, 602 insertions(+), 349 deletions(-) diff --git a/apps/token-e2e/src/integration/flow/staking-flow.cy.js b/apps/token-e2e/src/integration/flow/staking-flow.cy.js index 46d5618db..e9e84e398 100644 --- a/apps/token-e2e/src/integration/flow/staking-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/staking-flow.cy.js @@ -1,28 +1,44 @@ -const pageSpinner = 'splash-loader'; -const menuBar = 'nav'; -const validatorList = '[data-testid="node-list-item-name"]'; -const removeStakeRadioButton = '[data-testid="remove-stake-radio"]'; -const tokenAmountInputBox = '[data-testid="token-amount-input"]'; -const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; +/// +const stakeValidatorList = '[data-testid="node-list-item-name"]'; +const stakeValidatorWithinList = '[data-testid="node-list-item"]'; +const stakeRemoveStakeRadioButton = '[data-testid="remove-stake-radio"]'; +const stakeTokenAmountInputBox = '[data-testid="token-amount-input"]'; +const stakeTokenSubmitButton = '[data-testid="token-input-submit-button"]'; const stakeNextEpochValue = '[data-testid="stake-next-epoch"]'; -const vegaWalletContainer = '[data-testid="vega-wallet"]'; - +const stakeThisEpochValue = '[data-testid="stake-this-epoch"]'; +const stakeAddStakeRadioButton = '[data-testid="add-stake-radio"]'; +const stakeMaximumTokens = '[data-testid="token-amount-use-maximum"]'; const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); +const vegaWalletAssociatedBalance = '[data-testid="currency-value"]'; +const vegaWalletUnstakedBalance = + '[data-testid="vega-wallet-balance-unstaked"]'; +const vegaWalletStakedBalances = + '[data-testid="vega-wallet-balance-staked-validators"]'; +const vegaWalletThisEpochBalances = + '[data-testid="vega-wallet-balance-this-epoch"]'; +const vegaWalletNextEpochBalances = + '[data-testid="vega-wallet-balance-next-epoch"]'; +const ethWalletAssociatedBalances = + '[data-testid="eth-wallet-associated-balances"]'; +const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]'; +const ethWalletContainer = '[data-testid="ethereum-wallet"]'; +const txTimeout = { timeout: 40000 }; +const epochTimeout = { timeout: 10000 }; context('Staking Flow - with eth and vega wallets connected', function () { before('visit staking tab and connect vega wallet', function () { cy.vega_wallet_import(); cy.visit('/'); - cy.get(menuBar, { timeout: 20000 }).should('be.visible'); + cy.verify_page_header('The $VEGA token'); cy.vega_wallet_connect(); cy.vega_wallet_set_specified_approval_amount('1000'); cy.reload(); - cy.get(menuBar, { timeout: 20000 }).should('be.visible'); + cy.verify_page_header('The $VEGA token'); cy.ethereum_wallet_connect(); cy.navigate_to('staking'); - cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); - cy.get(validatorList).first().invoke('text').as('validatorName'); - cy.get(validatorList).last().invoke('text').as('otherValidatorName'); + cy.wait_for_spinner(); + cy.get(stakeValidatorList).first().invoke('text').as('validatorName'); + cy.get(stakeValidatorList).last().invoke('text').as('otherValidatorName'); }); describe('Eth wallet - contains VEGA tokens', function () { @@ -36,219 +52,505 @@ context('Staking Flow - with eth and vega wallets connected', function () { it('Able to stake against a validator', function () { cy.staking_page_associate_tokens('3'); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); - cy.ethereum_wallet_check_associated_value_is('3.0'); - cy.ethereum_wallet_check_associated_vega_key_value_is( - vegaWalletPublicKeyShort, - '3.000000000000000000' + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout ); + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('3.0', txTimeout) + .should('be.visible'); + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', 3.0, txTimeout); + cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '2.000000000000000000' + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout ); - cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - vega_wallet_check_validator_staked_value_is( - this.validatorName, - '2.000000000000000000' - ); - staking_validator_page_check_stake_next_epoch_value('2.0'); - staking_validator_page_check_stake_this_epoch_value('2.0'); + + cy.get(vegaWalletStakedBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName); + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.get(stakeThisEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.validatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '2.0') + .and('contain', '100%'); }); it('Able to stake against mulitple validators', function () { cy.staking_page_associate_tokens('5'); - cy.vega_wallet_check_unstaked_value_is('5.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 5.0, + txTimeout + ); + cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - vega_wallet_check_validator_staked_value_is( - this.validatorName, - '2.000000000000000000' - ); + + cy.get(vegaWalletStakedBalances, txTimeout) + .contains(this.validatorName, txTimeout) + .parent() + .should('contain', 2.0, txTimeout); + cy.navigate_to('staking'); - cy.get(validatorList).contains(this.otherValidatorName).click(); + cy.get(stakeValidatorList).contains(this.otherValidatorName).click(); + cy.staking_validator_page_add_stake('1'); - vega_wallet_check_validator_staked_value_is( - this.otherValidatorName, - '1.000000000000000000' + + cy.get(vegaWalletStakedBalances, txTimeout) + .should('have.length', 2, txTimeout) + .contains(this.otherValidatorName, txTimeout) + .parent() + .should('contain', 1.0, txTimeout); + + cy.get(vegaWalletStakedBalances, txTimeout) + .contains(this.validatorName, txTimeout) + .parent() + .should('contain', 2.0, txTimeout); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout ); - cy.vega_wallet_check_unstaked_value_is('2.000000000000000000'); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.validatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '2.0') + .and('contain', '66.67%'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.otherValidatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '1.0') + .and('contain', '33.33%'); }); - it.skip('Able to remove part of a stake against a validator', function () { + it('Able to remove part of a stake against a validator', function () { cy.staking_page_associate_tokens('4'); - cy.vega_wallet_check_unstaked_value_is('4.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 4.0, + txTimeout + ); cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('3'); - staking_validator_page_check_stake_next_epoch_value('3.0'); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '3.000000000000000000' + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(3.0, epochTimeout) + .should('be.visible'); + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 3.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout ); - cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); cy.navigate_to('staking'); - cy.get(validatorList).contains(this.validatorName).click(); + cy.get(stakeValidatorList).contains(this.validatorName).click(); - cy.staking_validator_page_removeStake('1'); - staking_validator_page_check_stake_next_epoch_value('2.0'); - staking_validator_page_check_stake_this_epoch_value('3.0'); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '2.000000000000000000' + cy.staking_validator_page_remove_stake('1'); + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletThisEpochBalances, txTimeout) + .should('contain', 3.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'This Epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout ); - vega_wallet_check_validator_stake_this_epoch_value_is( - this.validatorName, - '3.000000000000000000' - ); - cy.vega_wallet_check_unstaked_value_is('2.000000000000000000'); - vega_wallet_check_validator_staked_value_is( - this.validatorName, - '2.000000000000000000' - ); - staking_validator_page_check_stake_next_epoch_value('2.0'); - staking_validator_page_check_stake_this_epoch_value('2.0'); + + cy.get(vegaWalletStakedBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName); + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.get(stakeThisEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.validatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '2.0') + .and('contain', '100%'); }); it('Able to remove a full stake against a validator', function () { cy.staking_page_associate_tokens('3'); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout + ); cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('1'); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '1.000000000000000000' + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 1.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout ); - cy.vega_wallet_check_unstaked_value_is('2.000000000000000000'); cy.navigate_to('staking'); - cy.get(validatorList).contains(this.validatorName).click(); - cy.staking_validator_page_removeStake('1'); - staking_validator_page_check_stake_next_epoch_value('0.0'); + cy.get(stakeValidatorList).contains(this.validatorName).click(); - vega_wallet_check_validator_stake_this_epoch_value_is( - this.validatorName, - '1.000000000000000000' + cy.staking_validator_page_remove_stake('1'); + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(0.0, epochTimeout) + .should('be.visible'); + + cy.get(vegaWalletThisEpochBalances, txTimeout) + .should('contain', 1.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'This Epoch'); + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 0.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout ); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '0.000000000000000000' - ); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); - staking_validator_page_check_stake_next_epoch_value('0.0'); - staking_validator_page_check_stake_this_epoch_value('0.0'); - vega_wallet_check_validator_no_longer_showing(this.validatorName); + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(0.0, epochTimeout) + .should('be.visible'); + + cy.get(stakeThisEpochValue, epochTimeout) + .contains(0.0, epochTimeout) + .should('be.visible'); + + cy.get(vegaWalletStakedBalances, txTimeout) + .contains(this.validatorName, txTimeout) + .should('not.exist', txTimeout); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.validatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '0.0'); }); - it.skip('Unable to remove a stake with a negative value for a validator', function () { + it('Unable to remove a stake with a negative value for a validator', function () { cy.staking_page_associate_tokens('3'); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout + ); cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - staking_validator_page_check_stake_next_epoch_value('2.0'); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '2.000000000000000000' + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout ); - cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); cy.navigate_to('staking'); - cy.get(validatorList).contains(this.validatorName).click(); - cy.get(removeStakeRadioButton).click({ force: true }); - cy.get(tokenAmountInputBox).type('-0.1'); - cy.contains('Waiting for next epoch to start', { timeout: 10000 }); - cy.get(tokenSubmitButton) - .should('be.disabled', { timeout: 8000 }) + + cy.get(stakeValidatorList).contains(this.validatorName).click(); + + cy.get(stakeRemoveStakeRadioButton).click({ force: true }); + + cy.get(stakeTokenAmountInputBox).type('-0.1'); + + cy.contains('Waiting for next epoch to start', epochTimeout); + + cy.get(stakeTokenSubmitButton) + .should('be.disabled', epochTimeout) .and('contain', `Remove -0.1 $VEGA tokens at the end of epoch`) .and('be.visible'); }); - it.skip('Unable to remove a stake greater than staked amount next epoch for a validator', function () { + it('Unable to remove a stake greater than staked amount next epoch for a validator', function () { cy.staking_page_associate_tokens('3'); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout + ); cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - staking_validator_page_check_stake_next_epoch_value('2.0'); - vega_wallet_check_validator_stake_next_epoch_value_is( - this.validatorName, - '2.000000000000000000' + + cy.get(stakeNextEpochValue, epochTimeout) + .contains(2.0, epochTimeout) + .should('be.visible'); + + cy.get(vegaWalletNextEpochBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName) + .and('contain', 'Next epoch'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout ); - cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); cy.navigate_to('staking'); - cy.get(validatorList).contains(this.validatorName).click(); - cy.get(removeStakeRadioButton).click({ force: true }); - cy.get(tokenAmountInputBox).type(4); - cy.contains('Waiting for next epoch to start', { timeout: 10000 }); - cy.get(tokenSubmitButton) - .should('be.disabled', { timeout: 8000 }) + + cy.get(stakeValidatorList).contains(this.validatorName).click(); + + cy.get(stakeRemoveStakeRadioButton).click({ force: true }); + + cy.get(stakeTokenAmountInputBox).type(4); + + cy.contains('Waiting for next epoch to start', epochTimeout); + + cy.get(stakeTokenSubmitButton) + .should('be.disabled', epochTimeout) .and('contain', `Remove 4 $VEGA tokens at the end of epoch`) .and('be.visible'); }); - it.skip('Disassociating all tokens - removes all staked tokens', function () { + it('Disassociating all tokens - removes all staked tokens', function () { cy.staking_page_associate_tokens('3'); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout + ); cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - vega_wallet_check_validator_staked_value_is( - this.validatorName, - '2.000000000000000000' + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout ); + + cy.get(vegaWalletStakedBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName); + cy.navigate_to('staking'); + cy.staking_page_disassociate_all_tokens(); - cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing( - vegaWalletPublicKeyShort + + cy.get(ethWalletContainer).within(() => { + cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( + 'not.exist' + ); + }); + + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('0.0', txTimeout) + .should('be.visible'); + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + '0.000000000000000000', + txTimeout ); - cy.ethereum_wallet_check_associated_value_is('0.0'); - cy.vega_wallet_check_associated_value_is('0.000000000000000000'); - vega_wallet_check_validator_no_longer_showing(this.validatorName); + + cy.get(vegaWalletStakedBalances, txTimeout) + .contains(this.validatorName, txTimeout) + .should('not.exist', txTimeout); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.validatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '0.0'); }); it('Disassociating some tokens - prioritizes unstaked tokens', function () { cy.staking_page_associate_tokens('3'); - cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout + ); cy.get('button').contains('Select a validator to nominate').click(); - cy.get(validatorList).contains(this.validatorName).click(); + cy.get(stakeValidatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - vega_wallet_check_validator_staked_value_is( - this.validatorName, - '2.000000000000000000' + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout ); + + cy.get(vegaWalletStakedBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName); + cy.navigate_to('staking'); + cy.staking_page_disassociate_tokens('1'); - cy.ethereum_wallet_check_associated_value_is('2.0'); - cy.vega_wallet_check_associated_value_is('2.000000000000000000'); - vega_wallet_check_validator_staked_value_is( - this.validatorName, - '2.000000000000000000' + + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('2.0', txTimeout) + .should('be.visible'); + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + '2.000000000000000000', + txTimeout ); + + cy.get(vegaWalletStakedBalances, txTimeout) + .should('contain', 2.0, txTimeout) + .and('contain', this.validatorName); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorWithinList, epochTimeout) + .contains(this.validatorName) + .parent() + .contains('Total stake') + .parent() + .should('contain', '2.0') + .and('contain', '100%'); + }); + + it('Selecting use maximum where tokens are allready staked - suggests the unstaked token amount', function () { + cy.staking_page_associate_tokens('3'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 3.0, + txTimeout + ); + + cy.get('button').contains('Select a validator to nominate').click(); + cy.get(stakeValidatorList).contains(this.validatorName).click(); + + cy.staking_validator_page_add_stake('2'); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout + ); + + cy.navigate_to('staking'); + + cy.get(stakeValidatorList).contains(this.otherValidatorName).click(); + + cy.get(stakeAddStakeRadioButton).click({ force: true }); + + cy.get(stakeMaximumTokens, { timeout: 60000 }).click(); + + cy.get(stakeTokenSubmitButton).should('contain', 'Add 1 $VEGA tokens'); }); after( @@ -259,77 +561,3 @@ context('Staking Flow - with eth and vega wallets connected', function () { ); }); }); - -function staking_validator_page_check_stake_next_epoch_value(expectedVal) { - cy.highlight( - `Checking Staking Page - Validator Stake Next Epoch Value is ${expectedVal}` - ); - cy.get(stakeNextEpochValue, { timeout: 10000 }) - .contains(expectedVal, { timeout: 10000 }) - .should('be.visible'); -} - -function staking_validator_page_check_stake_this_epoch_value(expectedVal) { - cy.highlight( - `Checking Staking Page - Validator Stake This Epoch Value is ${expectedVal}` - ); - cy.get(stakeNextEpochValue, { timeout: 10000 }) - .contains(expectedVal, { timeout: 10000 }) - .should('be.visible'); -} - -function vega_wallet_check_validator_stake_next_epoch_value_is( - validatorName, - expectedVal -) { - cy.highlight( - `Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}` - ); - cy.get(vegaWalletContainer).within(() => { - cy.contains(`${validatorName} (Next epoch)`, { timeout: 40000 }) - .siblings() - .contains(expectedVal, { timeout: 40000 }) - .should('be.visible'); - }); -} - -function vega_wallet_check_validator_stake_this_epoch_value_is( - validatorName, - expectedVal -) { - cy.highlight( - `Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}` - ); - cy.get(vegaWalletContainer).within(() => { - cy.contains(`${validatorName} (This Epoch)`, { timeout: 40000 }) - .siblings() - .contains(expectedVal, { timeout: 40000 }) - .should('be.visible'); - }); -} - -function vega_wallet_check_validator_no_longer_showing(validatorName) { - cy.highlight( - `Checking Validator and therefore stake removed for ${validatorName}` - ); - cy.get(vegaWalletContainer).within(() => { - cy.contains(`${validatorName}`, { timeout: 40000 }).should('not.exist', { - timeout: 40000, - }); - }); -} - -function vega_wallet_check_validator_staked_value_is( - validatorName, - expectedVal -) { - cy.highlight( - `Checking Validator Stake Value for ${validatorName} is ${expectedVal}` - ); - cy.get(vegaWalletContainer).within(() => { - cy.contains(`${validatorName}`, { timeout: 40000 }) - .siblings() - .contains(expectedVal, { timeout: 40000 }) - .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 7d87be4b4..12074d615 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 @@ -1,7 +1,12 @@ -const pageSpinner = 'splash-loader'; -const menuBar = 'nav'; const validatorList = '[data-testid="node-list-item-name"]'; - +const ethWalletContainer = '[data-testid="ethereum-wallet"]'; +const ethWalletAssociatedBalances = + '[data-testid="eth-wallet-associated-balances"]'; +const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]'; +const vegaWalletAssociatedBalance = '[data-testid="currency-value"]'; +const vegaWalletUnstakedBalance = + '[data-testid="vega-wallet-balance-unstaked"]'; +const txTimeout = { timeout: 40000 }; const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); context( @@ -10,14 +15,14 @@ context( before('visit staking tab and connect vega wallet', function () { cy.vega_wallet_import(); cy.visit('/'); - cy.get(menuBar, { timeout: 20000 }).should('be.visible'); + cy.verify_page_header('The $VEGA token'); cy.vega_wallet_connect(); cy.vega_wallet_set_specified_approval_amount('1000'); cy.reload(); - cy.get(menuBar, { timeout: 20000 }).should('be.visible'); + cy.verify_page_header('The $VEGA token'); cy.ethereum_wallet_connect(); cy.navigate_to('staking'); - cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); + cy.wait_for_spinner(); cy.get(validatorList).first().invoke('text').as('validatorName'); }); @@ -27,71 +32,140 @@ context( function () { cy.vega_wallet_teardown(); cy.navigate_to('staking'); - cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); + cy.wait_for_spinner(); } ); it('Able to associate tokens', function () { cy.staking_page_associate_tokens('2'); - cy.ethereum_wallet_check_associated_vega_key_value_is( - vegaWalletPublicKeyShort, - '2.000000000000000000' + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', 2.0, txTimeout); + + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('2.0', txTimeout) + .should('be.visible'); + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout + ); + + cy.get(vegaWalletUnstakedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout ); - cy.ethereum_wallet_check_associated_value_is('2.0'); - cy.vega_wallet_check_associated_value_is('2.000000000000000000'); - cy.vega_wallet_check_unstaked_value_is('2.000000000000000000'); }); it('Able to disassociate tokens', function () { cy.staking_page_associate_tokens('2'); - cy.ethereum_wallet_check_associated_vega_key_value_is( - vegaWalletPublicKeyShort, - '2.000000000000000000' - ); - cy.vega_wallet_check_associated_value_is('2.000000000000000000'); + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', 2.0, txTimeout); + + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('2.0', txTimeout) + .should('be.visible'); + cy.get('button').contains('Select a validator to nominate').click(); + cy.staking_page_disassociate_tokens('1'); - cy.ethereum_wallet_check_associated_vega_key_value_is( - vegaWalletPublicKeyShort, - '1.000000000000000000' - ); - cy.ethereum_wallet_check_associated_value_is('1.0'); - cy.vega_wallet_check_associated_value_is('1.000000000000000000'); + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', 1.0, txTimeout); + + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('1.0', txTimeout) + .should('be.visible'); }); it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () { cy.staking_page_associate_tokens('1001', true); - cy.ethereum_wallet_check_associated_vega_key_value_is( - vegaWalletPublicKeyShort, - '1,001.000000000000000000' + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', '1,001.000000000000000000', txTimeout); + + cy.get(ethWalletTotalAssociatedBalance, txTimeout) + .contains('1,001.00', txTimeout) + .should('be.visible'); + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + '1,001.000000000000000000', + txTimeout ); - cy.ethereum_wallet_check_associated_value_is('1,001.00'); - cy.vega_wallet_check_associated_value_is('1,001.000000000000000000'); }); it('Able to disassociate a partial amount of tokens currently associated', function () { cy.staking_page_associate_tokens('2'); - cy.vega_wallet_check_associated_value_is('2.000000000000000000'); - cy.get('button').contains('Select a validator to nominate').click(); - cy.staking_page_disassociate_tokens('1'); - cy.ethereum_wallet_check_associated_vega_key_value_is( - vegaWalletPublicKeyShort, - '1.000000000000000000' + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout + ); + + cy.get('button').contains('Select a validator to nominate').click(); + + cy.staking_page_disassociate_tokens('1'); + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', 1.0, txTimeout); + + cy.get(ethWalletAssociatedBalances, txTimeout) + .contains(vegaWalletPublicKeyShort) + .parent() + .should('contain', 1.0, txTimeout); + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 1.0, + txTimeout ); - cy.ethereum_wallet_check_associated_value_is('1.0'); - cy.vega_wallet_check_associated_value_is('1.000000000000000000'); }); it('Able to disassociate all tokens', function () { cy.staking_page_associate_tokens('2'); - cy.vega_wallet_check_associated_value_is('2.000000000000000000'); - cy.get('button').contains('Select a validator to nominate').click(); - cy.staking_page_disassociate_all_tokens(); - cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing( - vegaWalletPublicKeyShort + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 2.0, + txTimeout + ); + + cy.get('button').contains('Select a validator to nominate').click(); + + cy.staking_page_disassociate_all_tokens(); + + cy.get(ethWalletContainer).within(() => { + cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( + 'not.exist' + ); + }); + + cy.get(ethWalletContainer).within(() => { + cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should( + 'not.exist' + ); + }); + + cy.get(vegaWalletAssociatedBalance, txTimeout).should( + 'contain', + 0.0, + txTimeout ); - cy.ethereum_wallet_check_associated_value_is('0.0'); - cy.vega_wallet_check_associated_value_is('0.000000000000000000'); }); }); } diff --git a/apps/token-e2e/src/support/common.functions.js b/apps/token-e2e/src/support/common.functions.js index 3f02096b0..065fd18ae 100644 --- a/apps/token-e2e/src/support/common.functions.js +++ b/apps/token-e2e/src/support/common.functions.js @@ -14,6 +14,7 @@ const navigation = { rewards: '[href="/rewards"]', withdraw: '[href="/withdraw"]', governance: '[href="/governance"]', + pageSpinner: 'splash-loader', }; Cypress.Commands.add('navigate_to', (page) => { @@ -31,3 +32,7 @@ Cypress.Commands.add('verify_tab_highlighted', (page) => { Cypress.Commands.add('verify_page_header', (text) => { return cy.get('header h1').should('be.visible').and('have.text', text); }); + +Cypress.Commands.add('wait_for_spinner', () => { + cy.get(navigation.pageSpinner, { timeout: 20000 }).should('not.exist'); +}); diff --git a/apps/token-e2e/src/support/staking.functions.js b/apps/token-e2e/src/support/staking.functions.js index 42652b3fb..40bd9fa0a 100644 --- a/apps/token-e2e/src/support/staking.functions.js +++ b/apps/token-e2e/src/support/staking.functions.js @@ -9,7 +9,6 @@ const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]'; const stakeMaximumTokens = '[data-testid="token-amount-use-maximum"]'; Cypress.Commands.add('wait_for_begining_of_epoch', () => { - cy.highlight(`Waiting for next epoch to start`); cy.contains('Waiting for next epoch to start', { timeout: 10000 }).should( 'not.exist' ); @@ -26,13 +25,9 @@ Cypress.Commands.add('staking_validator_page_add_stake', (stake) => { .and('contain', `Add ${stake} $VEGA tokens`) .and('be.visible') .click(); - cy.contains( - 'At the beginning of the next epoch your $VEGA will be nominated to the validator', - { timeout: 20000 } - ).should('be.visible'); }); -Cypress.Commands.add('staking_validator_page_removeStake', (stake) => { +Cypress.Commands.add('staking_validator_page_remove_stake', (stake) => { cy.highlight(`Removing a stake of ${stake}`); cy.get(removeStakeRadioButton).click({ force: true }); cy.get(tokenAmountInputBox).type(stake); @@ -42,9 +37,6 @@ Cypress.Commands.add('staking_validator_page_removeStake', (stake) => { .and('contain', `Remove ${stake} $VEGA tokens at the end of epoch`) .and('be.visible') .click(); - cy.contains(`${stake} $VEGA has been removed from validator`).should( - 'be.visible' - ); }); Cypress.Commands.add( diff --git a/apps/token-e2e/src/support/wallet-eth.functions.js b/apps/token-e2e/src/support/wallet-eth.functions.js index 1a4bec47d..73afc921b 100644 --- a/apps/token-e2e/src/support/wallet-eth.functions.js +++ b/apps/token-e2e/src/support/wallet-eth.functions.js @@ -16,42 +16,3 @@ Cypress.Commands.add('ethereum_wallet_connect', () => { cy.contains('Locked', { timeout: 15000 }).should('be.visible'); }); }); - -Cypress.Commands.add( - 'ethereum_wallet_check_associated_value_is', - (expectedVal) => { - cy.highlight(`Checking Eth Wallet - Associated Value is ${expectedVal}`); - cy.get(ethWalletContainer).within(() => { - cy.contains('Associated', { timeout: 20000 }) - .parent() - .siblings() - .contains(expectedVal, { timeout: 40000 }) - .should('be.visible'); - }); - } -); - -Cypress.Commands.add( - 'ethereum_wallet_check_associated_vega_key_value_is', - (vegaShortPublicKey, expectedVal) => { - cy.highlight( - `Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}` - ); - cy.get(ethWalletContainer).within(() => { - cy.contains(vegaShortPublicKey, { timeout: 20000 }) - .parent() - .contains(expectedVal, { timeout: 40000 }) - .should('be.visible'); - }); - } -); - -Cypress.Commands.add( - 'ethereum_wallet_check_associated_vega_key_is_no_longer_showing', - (vegaShortPublicKey) => { - cy.highlight('Checking Eth Wallet - Vega Key Associated is not showing'); - cy.get(ethWalletContainer).within(() => { - cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist'); - }); - } -); diff --git a/apps/token-e2e/src/support/wallet-teardown.functions.js b/apps/token-e2e/src/support/wallet-teardown.functions.js index 5642c07e0..46eabf2f6 100644 --- a/apps/token-e2e/src/support/wallet-teardown.functions.js +++ b/apps/token-e2e/src/support/wallet-teardown.functions.js @@ -5,6 +5,7 @@ import { } from '@vegaprotocol/smart-contracts'; import { ethers, Wallet } from 'ethers'; +const vegaWalletAssociatedBalance = '[data-testid="currency-value"]'; const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic'); const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); @@ -41,7 +42,12 @@ before('Vega wallet teardown prep', function () { Cypress.Commands.add('vega_wallet_teardown', function () { cy.vega_wallet_teardown_staking(this.stakingBridgeContract); cy.vega_wallet_teardown_vesting(this.vestingContract); - cy.vega_wallet_check_associated_value_is('0.000000000000000000'); + + cy.get(vegaWalletAssociatedBalance, { timeout: transactionTimeout }).should( + 'contain', + '0.000000000000000000', + { timeout: transactionTimeout } + ); }); Cypress.Commands.add( diff --git a/apps/token-e2e/src/support/wallet-vega.functions.js b/apps/token-e2e/src/support/wallet-vega.functions.js index 3ab43139d..f77a2759d 100644 --- a/apps/token-e2e/src/support/wallet-vega.functions.js +++ b/apps/token-e2e/src/support/wallet-vega.functions.js @@ -33,24 +33,3 @@ Cypress.Commands.add('vega_wallet_connect', () => { }); cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible'); }); - -Cypress.Commands.add('vega_wallet_check_unstaked_value_is', (expectedVal) => { - cy.highlight(`Checking vega wallet - Unstaked Value is ${expectedVal}`); - cy.get(vegaWalletContainer).within(() => { - cy.contains('Unstaked', { timeout: 40000 }) - .siblings() - .contains(expectedVal, { timeout: 40000 }) - .should('be.visible'); - }); -}); - -Cypress.Commands.add('vega_wallet_check_associated_value_is', (expectedVal) => { - cy.highlight(`Checking vega wallet - Associated Value is ${expectedVal}`); - cy.get(vegaWalletContainer).within(() => { - cy.contains('Associated', { timeout: 40000 }) - .parent() - .siblings() - .contains(expectedVal, { timeout: 40000 }) - .should('be.visible'); - }); -}); diff --git a/apps/token/src/components/eth-wallet/eth-wallet.tsx b/apps/token/src/components/eth-wallet/eth-wallet.tsx index 509542acc..aa0e15280 100644 --- a/apps/token/src/components/eth-wallet/eth-wallet.tsx +++ b/apps/token/src/components/eth-wallet/eth-wallet.tsx @@ -83,12 +83,14 @@ const AssociatedAmounts = ({ /> {vestingAssociationByVegaKey.map(([key, amount]) => { return ( - +
+ +
); })} diff --git a/apps/token/src/components/vega-wallet/vega-wallet.tsx b/apps/token/src/components/vega-wallet/vega-wallet.tsx index 8eac261b9..ff81d2a17 100644 --- a/apps/token/src/components/vega-wallet/vega-wallet.tsx +++ b/apps/token/src/components/vega-wallet/vega-wallet.tsx @@ -154,31 +154,37 @@ const VegaWalletConnected = ({ vegaKeys }: VegaWalletConnectedProps) => { balance={currentStakeAvailable} dark={true} /> - +
+ +
{delegatedNodes.length ? ( ) : null} {delegatedNodes.map((d) => ( -
+
{d.currentEpochStake && d.currentEpochStake.isGreaterThan(0) && ( - +
+ +
)} {d.hasStakePending && ( - +
+ +
)}
))} From 53faf03d4381e5e26911f8b7be47db9381653e65 Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Thu, 14 Jul 2022 16:49:20 +0100 Subject: [PATCH 3/9] test: increase resolution in config files (#750) * test: increase resolution in config files * fix: failing market list test * fix: increase timeout for intermittent failing market test --- apps/explorer-e2e/cypress.config.js | 2 ++ apps/simple-trading-app-e2e/cypress.config.js | 2 ++ .../src/integration/market-selector.test.ts | 5 ++--- apps/stats-e2e/cypress.config.js | 2 ++ apps/token-e2e/cypress.config.js | 2 ++ apps/trading-e2e/cypress.config.js | 2 ++ apps/trading-e2e/src/integration/home.cy.ts | 6 +++--- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/explorer-e2e/cypress.config.js b/apps/explorer-e2e/cypress.config.js index bb5505737..3809d21c9 100644 --- a/apps/explorer-e2e/cypress.config.js +++ b/apps/explorer-e2e/cypress.config.js @@ -15,6 +15,8 @@ module.exports = defineConfig({ videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', chromeWebSecurity: false, + viewportWidth: 1440, + viewportHeight: 900, }, env: { environment: 'CUSTOM', diff --git a/apps/simple-trading-app-e2e/cypress.config.js b/apps/simple-trading-app-e2e/cypress.config.js index 5d4f4da90..1436e587c 100644 --- a/apps/simple-trading-app-e2e/cypress.config.js +++ b/apps/simple-trading-app-e2e/cypress.config.js @@ -15,5 +15,7 @@ module.exports = defineConfig({ videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', chromeWebSecurity: false, + viewportWidth: 1440, + viewportHeight: 900, }, }); diff --git a/apps/simple-trading-app-e2e/src/integration/market-selector.test.ts b/apps/simple-trading-app-e2e/src/integration/market-selector.test.ts index 1b9dc07f9..333ca44b2 100644 --- a/apps/simple-trading-app-e2e/src/integration/market-selector.test.ts +++ b/apps/simple-trading-app-e2e/src/integration/market-selector.test.ts @@ -42,8 +42,8 @@ describe('market selector', () => { .find('[role="button"]') .should('have.length', 1); cy.get('input[placeholder="Search"]').clear(); - cy.get('input[placeholder="Search"]').type('a'); - const filtered = markets.filter((market) => market.name.match(/a/i)); + cy.get('input[placeholder="Search"]').type('app'); + const filtered = markets.filter((market) => market.name.match(/app/i)); cy.getByTestId('market-pane') .children() .find('[role="button"]') @@ -76,7 +76,6 @@ describe('market selector', () => { .children() .find('[role="button"]') .should('have.length', markets.length); - cy.pause(); cy.getByTestId('dialog-close').click(); cy.get('input[placeholder="Search"]').should( 'have.value', diff --git a/apps/stats-e2e/cypress.config.js b/apps/stats-e2e/cypress.config.js index 9070d1a83..dd9c84416 100644 --- a/apps/stats-e2e/cypress.config.js +++ b/apps/stats-e2e/cypress.config.js @@ -15,5 +15,7 @@ module.exports = defineConfig({ videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', chromeWebSecurity: false, + viewportWidth: 1440, + viewportHeight: 900, }, }); diff --git a/apps/token-e2e/cypress.config.js b/apps/token-e2e/cypress.config.js index 0a2bcad52..59465a683 100644 --- a/apps/token-e2e/cypress.config.js +++ b/apps/token-e2e/cypress.config.js @@ -14,6 +14,8 @@ module.exports = defineConfig({ videosFolder: '../../dist/cypress/apps/explorer-e2e/videos', screenshotsFolder: '../../dist/cypress/apps/explorer-e2e/screenshots', chromeWebSecurity: false, + viewportWidth: 1440, + viewportHeight: 900, }, env: { ethProviderUrl: 'http://localhost:8545/', diff --git a/apps/trading-e2e/cypress.config.js b/apps/trading-e2e/cypress.config.js index 467cb94ca..763d95ab5 100644 --- a/apps/trading-e2e/cypress.config.js +++ b/apps/trading-e2e/cypress.config.js @@ -27,6 +27,8 @@ module.exports = defineConfig({ chromeWebSecurity: false, projectId: 'et4snf', defaultCommandTimeout: 10000, + viewportWidth: 1440, + viewportHeight: 900, }, env: { TRADING_TEST_VEGA_WALLET_NAME: 'UI_Trading_Test', diff --git a/apps/trading-e2e/src/integration/home.cy.ts b/apps/trading-e2e/src/integration/home.cy.ts index 62a3b1774..a3e8906df 100644 --- a/apps/trading-e2e/src/integration/home.cy.ts +++ b/apps/trading-e2e/src/integration/home.cy.ts @@ -32,11 +32,11 @@ describe('home', () => { }); cy.visit('/'); - cy.wait('@GQL'); - cy.contains('Loading...').should('be.visible'); cy.contains('Loading...').should('not.exist'); - cy.get('main[data-testid="market"]').should('exist'); // Wait for page to be rendered to before checking url + cy.wait('@GQL'); + + cy.get('main[data-testid="market"]', { timeout: 20000 }).should('exist'); // Wait for page to be rendered to before checking url cy.url().should('include', `/markets/${oldestMarket.id}`); // Should redirect to oldest market }); From b078fc9aad38f4dee45a2d1730117cafce4822db Mon Sep 17 00:00:00 2001 From: PeteWilliams Date: Thu, 14 Jul 2022 17:03:17 +0100 Subject: [PATCH 4/9] chore: ui tweaks (#737) * chore: change tab panel background and spacing * chore: prevent tabs shiting on click, bg tweak * chore: adjust chrome layout/spacing * chore: fix horizontal alignment when accordion chevron rotates * chore: adjusting bold levels and making market name pink on light theme * chore: changing white theme header to black background * chore: re-ordering bottom tabs * chore: tweaking font sizes * chore: adjusting dropdown button hover colour * chore: colour tweaks for accessibility, plus orderbook column widths * Remove redundant style Removed 'bg-white' left by error. * Setting header text to white * chore: alterative fix to prevent tabs moving * chore: fixing header font colours * chore: adding padding to orderbook * chore: preventing modal close icon from moving on focus * chore: remove inner shadow from selectbox * chore: adding padding to orderbook * chore: preventing @ sign from moving when changing order type * chore: fix background colour on smaller responsive view * chore: fix truncated market header on smaller responsive view * chore: reorder tabs in smaller responsive view to match standard view * fix: fix broken test --- .../src/integration/trading-accounts.cy.ts | 2 +- apps/trading/components/navbar/navbar.tsx | 4 +- .../vega-wallet-connect-button.tsx | 6 +- apps/trading/pages/_app.page.tsx | 4 +- apps/trading/pages/markets/trade-grid.tsx | 36 ++++++------ .../components/deal-ticket-limit-amount.tsx | 2 +- .../components/deal-ticket-market-amount.tsx | 7 ++- .../src/components/deal-ticket.tsx | 2 +- .../src/components/info-market.tsx | 2 +- libs/market-depth/src/lib/orderbook-row.tsx | 2 +- libs/market-depth/src/lib/orderbook.tsx | 4 +- .../components/landing/select-market-list.tsx | 6 +- .../react-helpers/src/lib/grid/price-cell.tsx | 4 +- libs/trades/src/lib/trades-table.tsx | 4 +- .../src/components/accordion/accordion.tsx | 2 +- .../src/components/accordion/chevron-down.tsx | 22 +++---- .../src/components/dialog/dialog.tsx | 2 +- .../dropdown-menu/dropdown-menu.tsx | 2 +- .../src/components/form-group/form-group.tsx | 4 +- .../ui-toolkit/src/components/input/input.tsx | 1 + libs/ui-toolkit/src/components/tabs/tabs.tsx | 58 ++++++++++--------- .../src/components/text-area/text-area.tsx | 7 ++- .../theme-switcher/theme-switcher.tsx | 2 +- libs/ui-toolkit/src/utils/shared.ts | 1 - 24 files changed, 103 insertions(+), 83 deletions(-) diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index 388b8102a..5d7da6044 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -11,7 +11,7 @@ beforeEach(() => { describe('accounts', () => { it('renders accounts', () => { - cy.getByTestId('Accounts').click(); + cy.getByTestId('Collateral').click(); cy.getByTestId('tab-accounts').contains('Please connect Vega wallet'); connectVegaWallet(); diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index 2d6dc26c9..c4d2d5d43 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -10,7 +10,7 @@ export const Navbar = () => { {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */} - + {[ @@ -39,7 +39,7 @@ const NavLink = ({ name, path, exact, testId = name }: NavLinkProps) => { 'uppercase xs:text-ui sm:text-body-large md:text-h5 lg:text-h4', { 'bg-vega-pink dark:bg-vega-yellow text-white dark:text-black': isActive, - 'text-black dark:text-white': !isActive, + 'text-white': !isActive, } ); return ( diff --git a/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx b/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx index 2822ea561..67fafec5b 100644 --- a/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx +++ b/apps/trading/components/vega-wallet-connect-button/vega-wallet-connect-button.tsx @@ -24,12 +24,14 @@ export const VegaWalletConnectButton = ({ return ( {isConnected && ( - Vega key: + + Vega key: + )} diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index e5e10d23a..7d5210fe8 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -28,9 +28,9 @@ function AppBody({ Component, pageProps }: AppProps) { return ( -
+
-
+
c !== null); const headerItemClassName = 'whitespace-nowrap flex flex-col'; const itemClassName = - 'font-sans font-normal mb-0 text-dark/80 dark:text-white/80 text-ui-small'; + 'font-sans font-normal mb-0 text-black-60 dark:text-white-80 text-ui-small'; const itemValueClassName = 'capitalize font-sans tracking-tighter text-black dark:text-white text-ui'; const headerClassName = classNames( @@ -66,7 +66,7 @@ export const TradeMarketHeader = ({