From f0d1c1d15d0bb98888c966bb30767d57f1e72c55 Mon Sep 17 00:00:00 2001 From: AndyWhiteVega Date: Thu, 23 Jun 2022 14:43:17 +0100 Subject: [PATCH] test(token-e2e): lint --- .../flow/staking.add-stake.test.js | 156 ++++++++++------- .../flow/staking.rem-stake.test.js | 162 +++++++++++------- .../src/integration/flow/staking.test.js | 143 ++++++++++------ .../src/locators/navigation.locators.js | 18 +- .../src/locators/staking.locators.js | 16 +- .../token-e2e/src/locators/wallet.locators.js | 10 +- .../src/support/staking.functions.js | 20 ++- .../token-e2e/src/support/wallet.functions.js | 76 ++++---- 8 files changed, 350 insertions(+), 251 deletions(-) diff --git a/apps/token-e2e/src/integration/flow/staking.add-stake.test.js b/apps/token-e2e/src/integration/flow/staking.add-stake.test.js index 93bf347a4..d3496703f 100644 --- a/apps/token-e2e/src/integration/flow/staking.add-stake.test.js +++ b/apps/token-e2e/src/integration/flow/staking.add-stake.test.js @@ -4,72 +4,104 @@ import staking from '../../locators/staking.locators'; import '../../support/staking.functions'; import '../../support/wallet.functions'; -context('Staking Tab - with vega wallet connected', function() { +context('Staking Tab - with vega wallet connected', function () { + before('visit staking tab and connect vega wallet', function () { + cy.visit('/'); + cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); + cy.get(navigation.staking).first().click(); + cy.walletVega_connect(); + cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist'); + cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); + cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); + }); - before('visit staking tab and connect vega wallet', function() { - cy.visit('/'); - cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); - cy.get(navigation.staking).first().click() - cy.walletVega_connect(); - cy.get(navigation.spinner, {timeout : 20000}).should('not.exist') - cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); - cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); - }) + describe('vega wallet contains VEGA tokens', function () { + before('ensure environment fit for test', function () { + assert.isAtLeast( + parseInt(this.initialUnstakedBalance), + 0.1, + 'Checking we have at least 0.1 unstaked vega to play with' + ); + assert.isAtLeast( + this.validatorNames.length, + 2, + 'Checking we have at least 2 validators' + ); + // Ensure we are not in last minute - as this adds flake + cy.get(staking.epochEndingText) + .contains('Next epoch in 1 minutes', { timeout: 65000 }) + .should('not.exist'); + }); - describe('vega wallet contains VEGA tokens', function() { + before('drill into a specific validator - and note values', function () { + cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); + cy.contains('Manage your stake').should('be.visible'); + cy.get(staking.stakeNextEpochValue) + .invoke('text') + .as('initialStakeNextEpoch'); + cy.get(staking.stakeThisEpochValue) + .invoke('text') + .as('initialStakeThisEpoch'); + cy.contains('OWN STAKE (THIS EPOCH)') + .parent() + .siblings() + .invoke('text') + .as('initialValidatorStake'); + }); - before('ensure environment fit for test', function() { - assert.isAtLeast(parseInt(this.initialUnstakedBalance), 0.1, 'Checking we have at least 0.1 unstaked vega to play with'); - assert.isAtLeast(this.validatorNames.length, 2, 'Checking we have at least 2 validators'); - // Ensure we are not in last minute - as this adds flake - cy.get(staking.epochEndingText).contains('Next epoch in 1 minutes', {timeout:65000}).should('not.exist'); - }) + describe('Able to stake against a validator', function () { + it('Check - ability to fill in fields and request a stake of 0.1 tokens', function () { + cy.get(staking.addStakeRadioButton).click({ force: true }); + cy.get(staking.tokenAmountInput).type('0.1'); + cy.get('button').contains('Add 0.1 $VEGA tokens').click(); + }); - before('drill into a specific validator - and note values', function() { - cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); - cy.contains('Manage your stake').should('be.visible'); - cy.get(staking.stakeNextEpochValue).invoke('text').as('initialStakeNextEpoch'); - cy.get(staking.stakeThisEpochValue).invoke('text').as('initialStakeThisEpoch'); - cy.contains('OWN STAKE (THIS EPOCH)').parent().siblings().invoke('text').as('initialValidatorStake'); - }) + it('Check - relevant successfull feedback provided after staking', function () { + // Wallet auto approves at this stage + cy.contains( + `Adding 0.1 $VEGA to validator ${this.validatorNames[0]}` + ).should('be.visible'); + cy.contains( + 'Waiting for confirmation that your change in nomination has been received' + ).should('be.visible'); + cy.contains( + 'Waiting for confirmation that your change in nomination has been received', + { timeout: 120000 } + ).should('not.exist'); + cy.contains( + 'At the beginning of the next epoch your $VEGA will be nominated to the validator' + ); + }); - describe('Able to stake against a validator', function() { + it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function () { + let expectedStakeNextEpochValue = + parseFloat(this.initialStakeNextEpoch) + 0.1; + cy.get(staking.stakeNextEpochValue, { timeout: 10000 }).contains( + expectedStakeNextEpochValue.toFixed(2), + { timeout: 10000 } + ); + }); - it('Check - ability to fill in fields and request a stake of 0.1 tokens', function() { - cy.get(staking.addStakeRadioButton).click({force:true}); - cy.get(staking.tokenAmountInput).type('0.1'); - cy.get('button').contains('Add 0.1 $VEGA tokens').click(); - }) - - it('Check - relevant successfull feedback provided after staking', function() { - // Wallet auto approves at this stage - cy.contains(`Adding 0.1 $VEGA to validator ${this.validatorNames[0]}`).should('be.visible'); - cy.contains('Waiting for confirmation that your change in nomination has been received').should('be.visible'); - cy.contains('Waiting for confirmation that your change in nomination has been received', {timeout: 120000}).should('not.exist'); - cy.contains('At the beginning of the next epoch your $VEGA will be nominated to the validator'); - }) + it('Check - wallet - next epoch amount - updates balance for validator', function () { + let expectedValStakeNextEpochValue = + parseFloat(this.initialStakeNextEpoch) + 0.1; + cy.walletVega_getNextEpochStakeForSpecifiedValidator( + this.validatorNames[0] + ).then((actualNextEpochStake) => { + assert.equal( + parseFloat(actualNextEpochStake).toPrecision(12), + parseFloat(expectedValStakeNextEpochValue).toPrecision(12) + ); + }); + }); - it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function() { - let expectedStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1; - cy.get(staking.stakeNextEpochValue, {timeout:10000}) - .contains(expectedStakeNextEpochValue.toFixed(2), {timeout:10000}) - }) - - it('Check - wallet - next epoch amount - updates balance for validator', function() { - let expectedValStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1; - cy.walletVega_getNextEpochStakeForSpecifiedValidator(this.validatorNames[0]) - .then(actualNextEpochStake => { - assert.equal( - parseFloat(actualNextEpochStake).toPrecision(12), - parseFloat(expectedValStakeNextEpochValue).toPrecision(12) - ) - }) - }) - - it.skip('Check - wallet - unstaked amount - updates balance', function() { - // Skipping until capsule can enable this test - cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1) - }) - }) - }) -}) \ No newline at end of file + it.skip('Check - wallet - unstaked amount - updates balance', function () { + // Skipping until capsule can enable this test + cy.walletVega_getUnstakedAmount().should( + 'equal', + this.initialUnstakedBalance - 0.1 + ); + }); + }); + }); +}); diff --git a/apps/token-e2e/src/integration/flow/staking.rem-stake.test.js b/apps/token-e2e/src/integration/flow/staking.rem-stake.test.js index 3a88abee5..0b7c7d127 100644 --- a/apps/token-e2e/src/integration/flow/staking.rem-stake.test.js +++ b/apps/token-e2e/src/integration/flow/staking.rem-stake.test.js @@ -4,77 +4,107 @@ import staking from '../../locators/staking.locators'; import '../../support/staking.functions'; import '../../support/wallet.functions'; -context('Staking Tab - with vega wallet connected', function() { +context('Staking Tab - with vega wallet connected', function () { + before('visit staking tab and connect vega wallet', function () { + cy.visit('/'); + cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); + cy.get(navigation.staking).first().click(); + cy.walletVega_connect(); + cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist'); + cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); + cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); + }); - before('visit staking tab and connect vega wallet', function() { - cy.visit('/'); - cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); - cy.get(navigation.staking).first().click(); - cy.walletVega_connect(); - cy.get(navigation.spinner, {timeout : 20000}).should('not.exist'); - cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); - cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); - }) + describe('vega wallet contains VEGA tokens', function () { + before('ensure environment fit for test', function () { + assert.isAtLeast( + this.validatorNames.length, + 2, + 'Checking we have at least 2 validators' + ); + // Ensure we are not in last minute - as this adds flake + cy.get(staking.epochEndingText) + .contains('Next epoch in 1 minutes', { timeout: 65000 }) + .should('not.exist'); + }); - describe('vega wallet contains VEGA tokens', function() { + before('drill into a specific validator - and note values', function () { + cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); + cy.contains('Manage your stake').should('be.visible'); + cy.get(staking.stakeNextEpochValue) + .invoke('text') + .as('initialStakeNextEpoch'); + cy.get(staking.stakeThisEpochValue) + .invoke('text') + .as('initialStakeThisEpoch'); + cy.contains('OWN STAKE (THIS EPOCH)') + .parent() + .siblings() + .invoke('text') + .as('initialValidatorStake'); + }); - before('ensure environment fit for test', function() { - assert.isAtLeast(this.validatorNames.length, 2, 'Checking we have at least 2 validators'); - // Ensure we are not in last minute - as this adds flake - cy.get(staking.epochEndingText).contains('Next epoch in 1 minutes', {timeout:65000}).should('not.exist'); - }) + describe('Able to remove a stake against a validator', function () { + it('Check - validator has tokens to remove', function () { + let tokensToRemove = parseFloat(this.initialStakeNextEpoch); + assert.isAtLeast( + tokensToRemove, + 0.1, + 'Checking we have tokens to remove' + ); + }); - before('drill into a specific validator - and note values', function() { - cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); - cy.contains('Manage your stake').should('be.visible'); - cy.get(staking.stakeNextEpochValue).invoke('text').as('initialStakeNextEpoch'); - cy.get(staking.stakeThisEpochValue).invoke('text').as('initialStakeThisEpoch'); - cy.contains('OWN STAKE (THIS EPOCH)').parent().siblings().invoke('text').as('initialValidatorStake'); - }) + it('Check - ability to fill in fields and request a stake of 0.1 tokens', function () { + cy.get(staking.removeStakeRadioButton).click({ force: true }); + cy.get(staking.tokenAmountInput).type('0.1'); + cy.get('button').contains('Remove 0.1 $VEGA tokens').click(); + }); - describe('Able to remove a stake against a validator', function() { + it('Check - relevant successfull feedback provided after staking', function () { + // Wallet auto approves at this stage + cy.contains( + `Removing 0.1 $VEGA from validator ${this.validatorNames[0]}` + ).should('be.visible'); + cy.contains( + 'Waiting for confirmation that your change in nomination has been received' + ).should('be.visible'); + cy.contains( + 'Waiting for confirmation that your change in nomination has been received', + { timeout: 120000 } + ).should('not.exist'); + cy.contains( + `0.1 $VEGA has been removed from validator ${this.validatorNames[0]}` + ); + }); - it('Check - validator has tokens to remove', function() { - let tokensToRemove = parseFloat(this.initialStakeNextEpoch); - assert.isAtLeast(tokensToRemove, 0.10, 'Checking we have tokens to remove'); - }) + it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function () { + let expectedStakeNextEpochValue = + parseFloat(this.initialStakeNextEpoch) - 0.1; + cy.get(staking.stakeNextEpochValue, { timeout: 10000 }) + .contains(expectedStakeNextEpochValue.toFixed(2), { timeout: 10000 }) + .should('be.visible'); + }); - it('Check - ability to fill in fields and request a stake of 0.1 tokens', function() { - cy.get(staking.removeStakeRadioButton).click({force:true}); - cy.get(staking.tokenAmountInput).type('0.1'); - cy.get('button').contains('Remove 0.1 $VEGA tokens').click(); - }) - - it('Check - relevant successfull feedback provided after staking', function() { - // Wallet auto approves at this stage - cy.contains(`Removing 0.1 $VEGA from validator ${this.validatorNames[0]}`).should('be.visible'); - cy.contains('Waiting for confirmation that your change in nomination has been received').should('be.visible'); - cy.contains('Waiting for confirmation that your change in nomination has been received', {timeout: 120000}).should('not.exist'); - cy.contains(`0.1 $VEGA has been removed from validator ${this.validatorNames[0]}`); - }) + it('Check - wallet - next epoch amount - updates balance for validator', function () { + let expectedValStakeNextEpochValue = + parseFloat(this.initialStakeNextEpoch) - 0.1; + cy.walletVega_getNextEpochStakeForSpecifiedValidator( + this.validatorNames[0] + ).then((actualNextEpochStake) => { + assert.equal( + parseFloat(actualNextEpochStake).toPrecision(12), + parseFloat(expectedValStakeNextEpochValue).toPrecision(12) + ); + }); + }); - it('Check - staking page - stake on node (next epoch) - updates to reflect stake', function() { - let expectedStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) - 0.1; - cy.get(staking.stakeNextEpochValue, {timeout:10000}) - .contains(expectedStakeNextEpochValue.toFixed(2), {timeout:10000}) - .should('be.visible') - }) - - it('Check - wallet - next epoch amount - updates balance for validator', function() { - let expectedValStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) - 0.1; - cy.walletVega_getNextEpochStakeForSpecifiedValidator(this.validatorNames[0]) - .then(actualNextEpochStake => { - assert.equal( - parseFloat(actualNextEpochStake).toPrecision(12), - parseFloat(expectedValStakeNextEpochValue).toPrecision(12) - ) - }) - }) - - it.skip('Check - wallet - unstaked amount - updates balance', function() { - // Skipping until capsule can enable this test - cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1) - }) - }) - }) -}) \ No newline at end of file + it.skip('Check - wallet - unstaked amount - updates balance', function () { + // Skipping until capsule can enable this test + cy.walletVega_getUnstakedAmount().should( + 'equal', + this.initialUnstakedBalance - 0.1 + ); + }); + }); + }); +}); diff --git a/apps/token-e2e/src/integration/flow/staking.test.js b/apps/token-e2e/src/integration/flow/staking.test.js index 1012df24c..8dd489c11 100644 --- a/apps/token-e2e/src/integration/flow/staking.test.js +++ b/apps/token-e2e/src/integration/flow/staking.test.js @@ -4,67 +4,96 @@ import staking from '../../locators/staking.locators'; import '../../support/staking.functions'; import '../../support/wallet.functions'; -context('Staking Tab - with vega wallet connected', function() { +context('Staking Tab - with vega wallet connected', function () { + before('visit staking tab and connect vega wallet', function () { + cy.visit('/'); + cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); + cy.get(navigation.staking).first().click(); + cy.walletVega_connect(); + cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist'); + cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); + cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); + }); - before('visit staking tab and connect vega wallet', function() { - cy.visit('/'); - cy.get(navigation.section, { timeout: 20000 }).should('be.visible'); - cy.get(navigation.staking).first().click() - cy.walletVega_connect(); - cy.get(navigation.spinner, {timeout : 20000}).should('not.exist') - cy.walletVega_getUnstakedAmount().as('initialUnstakedBalance'); - cy.stakingPage_getValidatorNamesSorted().as('validatorNames'); - }) + describe('vega wallet contains VEGA tokens', function () { + before('ensure environment fit for test', function () { + assert.isAtLeast( + parseInt(this.initialUnstakedBalance), + 0.1, + 'Checking we have at least 0.1 unstaked vega to play with' + ); + assert.isAtLeast( + this.validatorNames.length, + 2, + 'Checking we have at least 2 validators' + ); + // Ensure we are not in last minute - as this adds flake + cy.get(staking.epochEndingText) + .contains('Next epoch in 1 minutes', { timeout: 65000 }) + .should('not.exist'); + }); - describe('vega wallet contains VEGA tokens', function() { + before('drill into a specific validator - and note values', function () { + cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); + cy.contains('Manage your stake').should('be.visible'); + cy.get(staking.stakeNextEpochValue) + .invoke('text') + .as('initialStakeNextEpoch'); + cy.get(staking.stakeThisEpochValue) + .invoke('text') + .as('initialStakeThisEpoch'); + cy.contains('OWN STAKE (THIS EPOCH)') + .parent() + .siblings() + .invoke('text') + .as('initialValidatorStake'); + }); - before('ensure environment fit for test', function() { - assert.isAtLeast(parseInt(this.initialUnstakedBalance), 0.1, 'Checking we have at least 0.1 unstaked vega to play with'); - assert.isAtLeast(this.validatorNames.length, 2, 'Checking we have at least 2 validators'); - // Ensure we are not in last minute - as this adds flake - cy.get(staking.epochEndingText).contains('Next epoch in 1 minutes', {timeout:65000}).should('not.exist'); - }) + describe('Able to stake against a validator', function () { + it('Able to stake against a validator', function () { + // Check - ability to fill in fields and request a stake of 0.1 tokens + cy.get(staking.addStakeRadioButton).click({ force: true }); + cy.get(staking.tokenAmountInput).type('0.1'); + cy.get('button').contains('Add 0.1 $VEGA tokens').click(); - before('drill into a specific validator - and note values', function() { - cy.get(staking.validatorNames).contains(this.validatorNames[0]).click(); - cy.contains('Manage your stake').should('be.visible'); - cy.get(staking.stakeNextEpochValue).invoke('text').as('initialStakeNextEpoch'); - cy.get(staking.stakeThisEpochValue).invoke('text').as('initialStakeThisEpoch'); - cy.contains('OWN STAKE (THIS EPOCH)').parent().siblings().invoke('text').as('initialValidatorStake'); - }) + // Check - relevant successfull feedback provided after staking - Note: Wallet auto approves at this stage + cy.contains( + `Adding 0.1 $VEGA to validator ${this.validatorNames[0]}` + ).should('be.visible'); + cy.contains( + 'Waiting for confirmation that your change in nomination has been received' + ).should('be.visible'); + cy.contains( + 'Waiting for confirmation that your change in nomination has been received', + { timeout: 120000 } + ).should('not.exist'); + cy.contains( + 'At the beginning of the next epoch your $VEGA will be nominated to the validator' + ); - describe('Able to stake against a validator', function() { + // Check - staking page - stake on node (next epoch) - updates to reflect stake + let expectedStakeNextEpochValue = + parseFloat(this.initialStakeNextEpoch) + 0.1; + cy.get(staking.stakeNextEpochValue, { timeout: 10000 }).contains( + expectedStakeNextEpochValue.toFixed(2), + { timeout: 10000 } + ); - it('Able to stake against a validator', function() { - // Check - ability to fill in fields and request a stake of 0.1 tokens - cy.get(staking.addStakeRadioButton).click({force:true}); - cy.get(staking.tokenAmountInput).type('0.1'); - cy.get('button').contains('Add 0.1 $VEGA tokens').click(); + //Check - wallet staked amount - updates balance for validator + let expectedValStakeNextEpochValue = + parseFloat(this.initialStakeNextEpoch) + 0.1; + cy.walletVega_getNextEpochStakeForSpecifiedValidator( + this.validatorNames[0] + ).then((actualNextEpochStake) => { + assert.equal( + parseFloat(actualNextEpochStake).toPrecision(12), + parseFloat(expectedValStakeNextEpochValue).toPrecision(12) + ); + }); - // Check - relevant successfull feedback provided after staking - Note: Wallet auto approves at this stage - cy.contains(`Adding 0.1 $VEGA to validator ${this.validatorNames[0]}`).should('be.visible'); - cy.contains('Waiting for confirmation that your change in nomination has been received').should('be.visible'); - cy.contains('Waiting for confirmation that your change in nomination has been received', {timeout: 120000}).should('not.exist'); - cy.contains('At the beginning of the next epoch your $VEGA will be nominated to the validator'); - - // Check - staking page - stake on node (next epoch) - updates to reflect stake - let expectedStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1; - cy.get(staking.stakeNextEpochValue, {timeout:10000}) - .contains(expectedStakeNextEpochValue.toFixed(2), {timeout:10000}) - - //Check - wallet staked amount - updates balance for validator - let expectedValStakeNextEpochValue = parseFloat(this.initialStakeNextEpoch) + 0.1; - cy.walletVega_getNextEpochStakeForSpecifiedValidator(this.validatorNames[0]) - .then(actualNextEpochStake => { - assert.equal( - parseFloat(actualNextEpochStake).toPrecision(12), - parseFloat(expectedValStakeNextEpochValue).toPrecision(12) - ) - }) - - //Check - wallet unstaked amount - updates balance - Note: Skipping until capsule can enable this test - // cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1); - }) - }) - }) -}) \ No newline at end of file + //Check - wallet unstaked amount - updates balance - Note: Skipping until capsule can enable this test + // cy.walletVega_getUnstakedAmount().should('equal', this.initialUnstakedBalance - 0.1); + }); + }); + }); +}); diff --git a/apps/token-e2e/src/locators/navigation.locators.js b/apps/token-e2e/src/locators/navigation.locators.js index fe52013f4..cdcbb25fd 100644 --- a/apps/token-e2e/src/locators/navigation.locators.js +++ b/apps/token-e2e/src/locators/navigation.locators.js @@ -1,10 +1,10 @@ export default { - section: 'nav', - home: '[href="/"]', - vesting: '[href="/vesting"]', - staking: '[href="/staking"]', - rewards: '[href="/rewards"]', - withdraw: '[href="/withdraw"]', - governance: '[href="/governance"]', - spinner: 'splash-loader' -}; \ No newline at end of file + section: 'nav', + home: '[href="/"]', + vesting: '[href="/vesting"]', + staking: '[href="/staking"]', + rewards: '[href="/rewards"]', + withdraw: '[href="/withdraw"]', + governance: '[href="/governance"]', + spinner: 'splash-loader', +}; diff --git a/apps/token-e2e/src/locators/staking.locators.js b/apps/token-e2e/src/locators/staking.locators.js index 3372a99a1..77964d149 100644 --- a/apps/token-e2e/src/locators/staking.locators.js +++ b/apps/token-e2e/src/locators/staking.locators.js @@ -1,10 +1,10 @@ export default { - validatorNames: '[data-testid="node-list-item"] > :nth-child(1)', - epochEndingText: '[data-testid="epoch-countdown"]', - addStakeRadioButton: '[data-testid="add-stake-radio"]', - removeStakeRadioButton: '[data-testid="remove-stake-radio"]', - tokenAmountInput: '[data-testid="token-amount-input"]', - stakedAmounts: '[data-testid="staked-validator-item"]', - stakeNextEpochValue: '[data-testid="stake-next-epoch"]', - stakeThisEpochValue: '[data-testid="stake-this-epoch"]', + validatorNames: '[data-testid="node-list-item"] > :nth-child(1)', + epochEndingText: '[data-testid="epoch-countdown"]', + addStakeRadioButton: '[data-testid="add-stake-radio"]', + removeStakeRadioButton: '[data-testid="remove-stake-radio"]', + tokenAmountInput: '[data-testid="token-amount-input"]', + stakedAmounts: '[data-testid="staked-validator-item"]', + stakeNextEpochValue: '[data-testid="stake-next-epoch"]', + stakeThisEpochValue: '[data-testid="stake-this-epoch"]', }; diff --git a/apps/token-e2e/src/locators/wallet.locators.js b/apps/token-e2e/src/locators/wallet.locators.js index 71d013bee..5e8af4668 100644 --- a/apps/token-e2e/src/locators/wallet.locators.js +++ b/apps/token-e2e/src/locators/wallet.locators.js @@ -1,6 +1,6 @@ export default { - connectRestForm: '[data-testid="rest-connector-form"]', - name: '#wallet', - passphrase: '#passphrase', - vegawallet: '.vega-wallet' -}; \ No newline at end of file + connectRestForm: '[data-testid="rest-connector-form"]', + name: '#wallet', + passphrase: '#passphrase', + vegawallet: '.vega-wallet', +}; diff --git a/apps/token-e2e/src/support/staking.functions.js b/apps/token-e2e/src/support/staking.functions.js index 9eb5ba730..786e4fed3 100644 --- a/apps/token-e2e/src/support/staking.functions.js +++ b/apps/token-e2e/src/support/staking.functions.js @@ -1,10 +1,12 @@ - import staking from '../locators/staking.locators'; +import staking from '../locators/staking.locators'; - Cypress.Commands.add("stakingPage_getValidatorNamesSorted", function() { - let validatorNames = []; - cy.get(staking.validatorNames) - .each(($validatorName) => { - validatorNames.push($validatorName.text()); - }) - .then(() => {return validatorNames.sort()}) - }) \ No newline at end of file +Cypress.Commands.add('stakingPage_getValidatorNamesSorted', function () { + let validatorNames = []; + cy.get(staking.validatorNames) + .each(($validatorName) => { + validatorNames.push($validatorName.text()); + }) + .then(() => { + return validatorNames.sort(); + }); +}); diff --git a/apps/token-e2e/src/support/wallet.functions.js b/apps/token-e2e/src/support/wallet.functions.js index c662bd867..37a12a6b9 100644 --- a/apps/token-e2e/src/support/wallet.functions.js +++ b/apps/token-e2e/src/support/wallet.functions.js @@ -1,47 +1,53 @@ import wallet from '../locators/wallet.locators'; - -Cypress.Commands.add("walletVega_connect", function () { - const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME'); - const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE'); - const walletTruncatedKey = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY'); +Cypress.Commands.add('walletVega_connect', function () { + const walletName = Cypress.env('TRADING_TEST_VEGA_WALLET_NAME'); + const walletPassphrase = Cypress.env('TRADING_TEST_VEGA_WALLET_PASSPHRASE'); + const walletTruncatedKey = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY'); - cy.get(wallet.vegawallet).within(() => { - cy.get('button') - .contains('Connect Vega wallet to use associated $VEGA') - .should('be.enabled').click(); - }) + cy.get(wallet.vegawallet).within(() => { + cy.get('button') + .contains('Connect Vega wallet to use associated $VEGA') + .should('be.enabled') + .click(); + }); - cy.get('button').contains('rest provider').click(); + cy.get('button').contains('rest provider').click(); - cy.get(wallet.connectRestForm).within(() => { - cy.get(wallet.name).click().type(walletName); - cy.get(wallet.passphrase).click().type(walletPassphrase); - cy.get('button').contains('Connect').click(); - }) + cy.get(wallet.connectRestForm).within(() => { + cy.get(wallet.name).click().type(walletName); + cy.get(wallet.passphrase).click().type(walletPassphrase); + cy.get('button').contains('Connect').click(); + }); - cy.get(wallet.vegawallet).within(() => { - cy.contains(walletTruncatedKey).should('be.visible'); - cy.contains('Assets', {timeout: 20000}).should('be.visible'); - }) -}) + cy.get(wallet.vegawallet).within(() => { + cy.contains(walletTruncatedKey).should('be.visible'); + cy.contains('Assets', { timeout: 20000 }).should('be.visible'); + }); +}); -Cypress.Commands.add("walletVega_getUnstakedAmount", function() { - cy.get(wallet.vegawallet).contains('Unstaked').siblings().invoke('text') -}) +Cypress.Commands.add('walletVega_getUnstakedAmount', function () { + cy.get(wallet.vegawallet).contains('Unstaked').siblings().invoke('text'); +}); -Cypress.Commands.add("walletVega_getNextEpochStakeForSpecifiedValidator", function(validatorName) { +Cypress.Commands.add( + 'walletVega_getNextEpochStakeForSpecifiedValidator', + function (validatorName) { // need to check if validator is present first let fieldPresent = false; cy.get(wallet.vegawallet) - .within(($wallet) => { - if ($wallet.text().includes(`${validatorName} (Next epoch)`)) fieldPresent = true - }) - .then(() => { + .within(($wallet) => { + if ($wallet.text().includes(`${validatorName} (Next epoch)`)) + fieldPresent = true; + }) + .then(() => { if (fieldPresent == true) { - cy.contains(`${validatorName} (Next epoch)`) - .siblings() - .invoke('text')} - else {return "0.000000000000000000"} - }) -}) \ No newline at end of file + cy.contains(`${validatorName} (Next epoch)`) + .siblings() + .invoke('text'); + } else { + return '0.000000000000000000'; + } + }); + } +);