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 47e25ca80..46d5618db 100644 --- a/apps/token-e2e/src/integration/flow/staking-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/staking-flow.cy.js @@ -1,4 +1,3 @@ -const stakingPageLink = '[href="/staking"]'; const pageSpinner = 'splash-loader'; const menuBar = 'nav'; const validatorList = '[data-testid="node-list-item-name"]'; @@ -6,9 +5,10 @@ const removeStakeRadioButton = '[data-testid="remove-stake-radio"]'; const tokenAmountInputBox = '[data-testid="token-amount-input"]'; const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; const stakeNextEpochValue = '[data-testid="stake-next-epoch"]'; -const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletContainer = '[data-testid="vega-wallet"]'; +const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); + context('Staking Flow - with eth and vega wallets connected', function () { before('visit staking tab and connect vega wallet', function () { cy.vega_wallet_import(); @@ -19,7 +19,7 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.reload(); cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.ethereum_wallet_connect(); - cy.get(stakingPageLink).first().click(); + 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'); @@ -30,7 +30,7 @@ context('Staking Flow - with eth and vega wallets connected', function () { 'teardown wallet & drill into a specific validator', function () { cy.vega_wallet_teardown(); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); } ); @@ -47,17 +47,17 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + vega_wallet_check_validator_stake_next_epoch_value_is( this.validatorName, '2.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.validatorName, '2.000000000000000000' ); - cy.staking_validator_page_check_stake_next_epoch_value('2.0'); - cy.staking_validator_page_check_stake_this_epoch_value('2.0'); + staking_validator_page_check_stake_next_epoch_value('2.0'); + staking_validator_page_check_stake_this_epoch_value('2.0'); }); it('Able to stake against mulitple validators', function () { @@ -67,14 +67,14 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.validatorName, '2.000000000000000000' ); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(validatorList).contains(this.otherValidatorName).click(); cy.staking_validator_page_add_stake('1'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.otherValidatorName, '1.000000000000000000' ); @@ -89,34 +89,34 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('3'); - cy.staking_validator_page_check_stake_next_epoch_value('3.0'); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + staking_validator_page_check_stake_next_epoch_value('3.0'); + vega_wallet_check_validator_stake_next_epoch_value_is( this.validatorName, '3.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_removeStake('1'); - cy.staking_validator_page_check_stake_next_epoch_value('2.0'); - cy.staking_validator_page_check_stake_this_epoch_value('3.0'); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + 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.vega_wallet_check_validator_stake_this_epoch_value_is( + vega_wallet_check_validator_stake_this_epoch_value_is( this.validatorName, '3.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('2.000000000000000000'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.validatorName, '2.000000000000000000' ); - cy.staking_validator_page_check_stake_next_epoch_value('2.0'); - cy.staking_validator_page_check_stake_this_epoch_value('2.0'); + staking_validator_page_check_stake_next_epoch_value('2.0'); + staking_validator_page_check_stake_this_epoch_value('2.0'); }); it('Able to remove a full stake against a validator', function () { @@ -127,30 +127,30 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('1'); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + vega_wallet_check_validator_stake_next_epoch_value_is( this.validatorName, '1.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('2.000000000000000000'); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_removeStake('1'); - cy.staking_validator_page_check_stake_next_epoch_value('0.0'); + staking_validator_page_check_stake_next_epoch_value('0.0'); - cy.vega_wallet_check_validator_stake_this_epoch_value_is( + vega_wallet_check_validator_stake_this_epoch_value_is( this.validatorName, '1.000000000000000000' ); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + vega_wallet_check_validator_stake_next_epoch_value_is( this.validatorName, '0.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); - cy.staking_validator_page_check_stake_next_epoch_value('0.0'); - cy.staking_validator_page_check_stake_this_epoch_value('0.0'); - cy.vega_wallet_check_validator_no_longer_showing(this.validatorName); + 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); }); it.skip('Unable to remove a stake with a negative value for a validator', function () { @@ -161,14 +161,14 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - cy.staking_validator_page_check_stake_next_epoch_value('2.0'); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + staking_validator_page_check_stake_next_epoch_value('2.0'); + vega_wallet_check_validator_stake_next_epoch_value_is( this.validatorName, '2.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(validatorList).contains(this.validatorName).click(); cy.get(removeStakeRadioButton).click({ force: true }); cy.get(tokenAmountInputBox).type('-0.1'); @@ -187,14 +187,14 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.get(validatorList).contains(this.validatorName).click(); cy.staking_validator_page_add_stake('2'); - cy.staking_validator_page_check_stake_next_epoch_value('2.0'); - cy.vega_wallet_check_validator_stake_next_epoch_value_is( + staking_validator_page_check_stake_next_epoch_value('2.0'); + vega_wallet_check_validator_stake_next_epoch_value_is( this.validatorName, '2.000000000000000000' ); cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(validatorList).contains(this.validatorName).click(); cy.get(removeStakeRadioButton).click({ force: true }); cy.get(tokenAmountInputBox).type(4); @@ -214,18 +214,18 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.staking_validator_page_add_stake('2'); cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.validatorName, '2.000000000000000000' ); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.staking_page_disassociate_all_tokens(); cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing( vegaWalletPublicKeyShort ); cy.ethereum_wallet_check_associated_value_is('0.0'); cy.vega_wallet_check_associated_value_is('0.000000000000000000'); - cy.vega_wallet_check_validator_no_longer_showing(this.validatorName); + vega_wallet_check_validator_no_longer_showing(this.validatorName); }); it('Disassociating some tokens - prioritizes unstaked tokens', function () { @@ -237,15 +237,15 @@ context('Staking Flow - with eth and vega wallets connected', function () { cy.staking_validator_page_add_stake('2'); cy.vega_wallet_check_unstaked_value_is('1.000000000000000000'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.validatorName, '2.000000000000000000' ); - cy.get(stakingPageLink).first().click(); + 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'); - cy.vega_wallet_check_validator_staked_value_is( + vega_wallet_check_validator_staked_value_is( this.validatorName, '2.000000000000000000' ); @@ -258,90 +258,78 @@ context('Staking Flow - with eth and vega wallets connected', function () { } ); }); - - Cypress.Commands.add( - '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'); - } - ); - - Cypress.Commands.add( - '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'); - } - ); - - Cypress.Commands.add( - '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'); - }); - } - ); - - Cypress.Commands.add( - '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'); - }); - } - ); - - Cypress.Commands.add( - '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, - } - ); - }); - } - ); - - Cypress.Commands.add( - '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'); - }); - } - ); }); + +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 a60ceb183..7d87be4b4 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,7 @@ -const stakingPageLink = '[href="/staking"]'; const pageSpinner = 'splash-loader'; const menuBar = 'nav'; const validatorList = '[data-testid="node-list-item-name"]'; + const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); context( @@ -16,7 +16,7 @@ context( cy.reload(); cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.ethereum_wallet_connect(); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.get(validatorList).first().invoke('text').as('validatorName'); }); @@ -26,7 +26,7 @@ context( 'teardown wallet & drill into a specific validator', function () { cy.vega_wallet_teardown(); - cy.get(stakingPageLink).first().click(); + cy.navigate_to('staking'); cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); } ); diff --git a/apps/token-e2e/src/integration/governance.cy.js b/apps/token-e2e/src/integration/governance.cy.js index 4e4aef0b4..2f5dff6e0 100644 --- a/apps/token-e2e/src/integration/governance.cy.js +++ b/apps/token-e2e/src/integration/governance.cy.js @@ -1,30 +1,21 @@ -import navigation from '../locators/navigation.locators'; -import governance from '../locators/governance.locators'; +const noProposals = '[data-testid="no-proposals"]'; context('Governance Page - verify elements on page', function () { before('navigate to governance page', function () { - cy.visit('/') - .get(navigation.section) - .within(() => { - cy.get(navigation.governance).click(); - }); + cy.visit('/').navigate_to('governance'); }); describe('with no network change proposals', function () { it('should have governance tab highlighted', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.governance).should('have.attr', 'aria-current'); - }); + cy.verify_tab_highlighted('governance'); }); it('should have GOVERNANCE header visible', function () { - cy.get(governance.pageHeader) - .should('be.visible') - .and('have.text', 'Governance'); + cy.verify_page_header('Governance'); }); it('should have information box visible', function () { - cy.get(governance.noProposals) + cy.get(noProposals) .should('be.visible') .and('have.text', 'There are no active network change proposals'); }); diff --git a/apps/token-e2e/src/integration/home.cy.js b/apps/token-e2e/src/integration/home.cy.js index eae3261a5..f13b3117b 100644 --- a/apps/token-e2e/src/integration/home.cy.js +++ b/apps/token-e2e/src/integration/home.cy.js @@ -1,5 +1,24 @@ -import navigation from '../locators/navigation.locators'; -import home from '../locators/home.locators'; +const navSection = 'nav'; +const navHome = '[href="/"]'; +const navVesting = '[href="/vesting"]'; +const navStaking = '[href="/staking"]'; +const navRewards = '[href="/rewards"]'; +const navWithdraw = '[href="/withdraw"]'; +const navGovernance = '[href="/governance"]'; + +const tokenDetailsTable = '.token-details'; +const address = '[data-testid="token-address"]'; +const contract = '[data-testid="token-contract"]'; +const totalSupply = '[data-testid="total-supply"]'; +const circulatingSupply = '[data-testid="circulating-supply"]'; +const staked = '[data-testid="staked"]'; +const tranchesLink = '[data-testid="tranches-link"]'; +const redeemBtn = '[data-testid="check-vesting-page-btn"]'; +const getVegaWalletLink = '[data-testid="get-vega-wallet-link"]'; +const associateVegaLink = + '[data-testid="associate-vega-tokens-link-on-homepage"]'; +const stakingBtn = '[data-testid="staking-button-on-homepage"]'; +const governanceBtn = '[data-testid="governance-button-on-homepage"]'; const vegaTokenAddress = Cypress.env('vegaTokenAddress'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); @@ -11,111 +30,111 @@ context('Home Page - verify elements on page', function () { describe('with wallets disconnected', function () { before('wait for page to load', function () { - cy.get(navigation.section, { timeout: 10000 }).should('be.visible'); + cy.get(navSection, { timeout: 10000 }).should('be.visible'); }); describe('Navigation tabs', function () { it('should have HOME tab', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.home).should('be.visible'); + cy.get(navSection).within(() => { + cy.get(navHome).should('be.visible'); }); }); it('should have VESTING tab', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.vesting).should('be.visible'); + cy.get(navSection).within(() => { + cy.get(navVesting).should('be.visible'); }); }); it('should have STAKING tab', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.staking).should('be.visible'); + cy.get(navSection).within(() => { + cy.get(navStaking).should('be.visible'); }); }); it('should have REWARDS tab', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.rewards).should('be.visible'); + cy.get(navSection).within(() => { + cy.get(navRewards).should('be.visible'); }); }); it('should have WITHDRAW tab', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.withdraw).should('be.visible'); + cy.get(navSection).within(() => { + cy.get(navWithdraw).should('be.visible'); }); }); it('should have GOVERNANCE tab', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.governance).should('be.visible'); + cy.get(navSection).within(() => { + cy.get(navGovernance).should('be.visible'); }); }); }); describe('THE $VEGA TOKEN table', function () { it('should have TOKEN ADDRESS', function () { - cy.get(home.tokenDetailsTable).within(() => { - cy.get(home.address) + cy.get(tokenDetailsTable).within(() => { + cy.get(address) .should('be.visible') .invoke('text') .should('be.equal', vegaTokenAddress); }); }); it('should have VESTING CONTRACT', function () { - cy.get(home.tokenDetailsTable).within(() => { - cy.get(home.contract) + cy.get(tokenDetailsTable).within(() => { + cy.get(contract) .should('be.visible') .invoke('text') .should('be.equal', vegaTokenContractAddress); }); }); it('should have TOTAL SUPPLY', function () { - cy.get(home.tokenDetailsTable).within(() => { - cy.get(home.totalSupply).should('be.visible'); + cy.get(tokenDetailsTable).within(() => { + cy.get(totalSupply).should('be.visible'); }); }); it('should have CIRCULATING SUPPLY', function () { - cy.get(home.tokenDetailsTable).within(() => { - cy.get(home.circulatingSupply).should('be.visible'); + cy.get(tokenDetailsTable).within(() => { + cy.get(circulatingSupply).should('be.visible'); }); }); it('should have STAKED $VEGA', function () { - cy.get(home.tokenDetailsTable).within(() => { - cy.get(home.staked).should('be.visible'); + cy.get(tokenDetailsTable).within(() => { + cy.get(staked).should('be.visible'); }); }); }); describe('links and buttons', function () { it('should have TRANCHES link', function () { - cy.get(home.tranchesLink) + cy.get(tranchesLink) .should('be.visible') .and('have.attr', 'href') .and('equal', '/tranches'); }); it('should have REDEEM button', function () { - cy.get(home.redeemBtn) + cy.get(redeemBtn) .should('be.visible') .parent() .should('have.attr', 'href') .and('equal', '/vesting'); }); it('should have GET VEGA WALLET link', function () { - cy.get(home.getVegaWalletLink) + cy.get(getVegaWalletLink) .should('be.visible') .and('have.attr', 'href') .and('equal', 'https://vega.xyz/wallet'); }); it('should have ASSOCIATE VEGA TOKENS link', function () { - cy.get(home.associateVegaLink) + cy.get(associateVegaLink) .should('be.visible') .and('have.attr', 'href') .and('equal', '/staking/associate'); }); it('should have STAKING button', function () { - cy.get(home.stakingBtn) + cy.get(stakingBtn) .should('be.visible') .parent() .should('have.attr', 'href') .and('equal', '/staking'); }); it('should have GOVERNANCE button', function () { - cy.get(home.governanceBtn) + cy.get(governanceBtn) .should('be.visible') .parent() .should('have.attr', 'href') diff --git a/apps/token-e2e/src/integration/rewards.cy.js b/apps/token-e2e/src/integration/rewards.cy.js index 5719d2972..a8aa88d03 100644 --- a/apps/token-e2e/src/integration/rewards.cy.js +++ b/apps/token-e2e/src/integration/rewards.cy.js @@ -1,30 +1,22 @@ -import navigation from '../locators/navigation.locators'; -import rewards from '../locators/rewards.locators'; +const connectToVegaBtn = '[data-testid="connect-to-vega-wallet-btn"]'; +const warning = '[data-testid="callout"]'; context('Rewards Page - verify elements on page', function () { before('navigate to rewards page', function () { - cy.visit('/') - .get(navigation.section) - .within(() => { - cy.get(navigation.rewards).click(); - }); + cy.visit('/').navigate_to('rewards'); }); describe('with wallets disconnected', function () { it('should have REWARDS tab highlighted', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.rewards).should('have.attr', 'aria-current'); - }); + cy.verify_tab_highlighted('rewards'); }); it('should have rewards header visible', function () { - cy.get(rewards.pageHeader) - .should('be.visible') - .and('have.text', 'Rewards'); + cy.verify_page_header('Rewards'); }); it('should have epoch warning', function () { - cy.get(rewards.warning) + cy.get(warning) .should('be.visible') .and( 'have.text', @@ -33,7 +25,7 @@ context('Rewards Page - verify elements on page', function () { }); it('should have connect Vega wallet button', function () { - cy.get(rewards.connectToVegaBtn) + cy.get(connectToVegaBtn) .should('be.visible') .and('have.text', 'Connect Vega wallet'); }); diff --git a/apps/token-e2e/src/integration/staking.cy.js b/apps/token-e2e/src/integration/staking.cy.js index 93d75143c..10914a338 100644 --- a/apps/token-e2e/src/integration/staking.cy.js +++ b/apps/token-e2e/src/integration/staking.cy.js @@ -1,31 +1,30 @@ -import navigation from '../locators/navigation.locators'; -import staking from '../locators/staking.locators'; +const guideLink = '[data-testid="staking-guide-link"]'; +const step1 = '[data-testid="staking-step-1"]'; +const step2 = '[data-testid="staking-step-2"]'; +const step3 = '[data-testid="staking-step-3"]'; +const sectionHeader = 'h2'; +const connectToEthBtn = '[data-testid="connect-to-eth-btn"]'; +const connectToVegaBtn = '[data-testid="connect-to-vega-wallet-btn"]'; +const link = '[data-testid="link"]'; +const warning = '[data-testid="callout"]'; context('Staking Page - verify elements on page', function () { before('navigate to staking page', function () { - cy.visit('/') - .get(navigation.section) - .within(() => { - cy.get(navigation.staking).click(); - }); + cy.visit('/').navigate_to('staking'); }); describe('with wallets disconnected', function () { describe('description section', function () { it('should have staking tab highlighted', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.staking).should('have.attr', 'aria-current'); - }); + cy.verify_tab_highlighted('staking'); }); it('should have STAKING ON VEGA header visible', function () { - cy.get(staking.pageHeader) - .should('be.visible') - .and('have.text', 'Staking on Vega'); + cy.verify_page_header('Staking on Vega'); }); it('should have Staking Guide link visible', function () { - cy.get(staking.guideLink) + cy.get(guideLink) .should('be.visible') .and('have.text', 'Read more about staking on Vega') .and( @@ -38,16 +37,16 @@ context('Staking Page - verify elements on page', function () { describe('step 1 section', function () { it('should have header visible', function () { - cy.get(staking.step1).within(() => { - cy.get(staking.sectionHeader) + cy.get(step1).within(() => { + cy.get(sectionHeader) .should('be.visible') .and('have.text', 'Step 1. Connect to a Vega Wallet'); }); }); it('should have text visible', function () { - cy.get(staking.step1).within(() => { - cy.get(staking.link) + cy.get(step1).within(() => { + cy.get(link) .should('be.visible') .and('have.text', 'Vega Wallet') .and('have.attr', 'href', 'https://vega.xyz/wallet'); @@ -55,16 +54,16 @@ context('Staking Page - verify elements on page', function () { }); it('should have connect to eth button visible', function () { - cy.get(staking.step1).within(() => { - cy.get(staking.connectToEthBtn) + cy.get(step1).within(() => { + cy.get(connectToEthBtn) .should('be.visible') .and('have.text', 'Connect Ethereum wallet'); }); }); it('should have connect to vega button visible', function () { - cy.get(staking.step1).within(() => { - cy.get(staking.connectToVegaBtn) + cy.get(step1).within(() => { + cy.get(connectToVegaBtn) .should('be.visible') .and('have.text', 'Connect Vega wallet'); }); @@ -73,16 +72,16 @@ context('Staking Page - verify elements on page', function () { describe('step 2 section', function () { it('should have header visible', function () { - cy.get(staking.step2).within(() => { - cy.get(staking.sectionHeader) + cy.get(step2).within(() => { + cy.get(sectionHeader) .should('be.visible') .and('have.text', 'Step 2. Associate tokens with a Vega Wallet'); }); }); it('should have warning visible', function () { - cy.get(staking.step2).within(() => { - cy.get(staking.warning) + cy.get(step2).within(() => { + cy.get(warning) .should('be.visible') .and( 'have.text', @@ -94,8 +93,8 @@ context('Staking Page - verify elements on page', function () { describe('step 3 section', function () { it('should have header visible', function () { - cy.get(staking.step3).within(() => { - cy.get(staking.sectionHeader) + cy.get(step3).within(() => { + cy.get(sectionHeader) .should('be.visible') .and( 'have.text', diff --git a/apps/token-e2e/src/integration/vesting.cy.js b/apps/token-e2e/src/integration/vesting.cy.js index 0534c230b..264cf63f9 100644 --- a/apps/token-e2e/src/integration/vesting.cy.js +++ b/apps/token-e2e/src/integration/vesting.cy.js @@ -1,34 +1,26 @@ -import navigation from '../locators/navigation.locators'; -import vesting from '../locators/vesting.locators'; +const connectPrompt = '[data-testid="eth-connect-prompt"]'; +const connectButton = '[data-testid="connect-to-eth-btn"]'; context('Vesting Page - verify elements on page', function () { before('navigate to vesting page', function () { - cy.visit('/') - .get(navigation.section) - .within(() => { - cy.get(navigation.vesting).click(); - }); + cy.visit('/').navigate_to('vesting'); }); describe('with wallets disconnected', function () { it('should have vesting tab highlighted', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.vesting).should('have.attr', 'aria-current'); - }); + cy.verify_tab_highlighted('vesting'); }); it('should have VESTING header visible', function () { - cy.get(vesting.pageHeader) - .should('be.visible') - .and('have.text', 'Vesting'); + cy.verify_page_header('Vesting'); }); it('should have connect Eth wallet info', function () { - cy.get(vesting.connectPrompt).should('be.visible'); + cy.get(connectPrompt).should('be.visible'); }); it('should have connect Eth wallet button', function () { - cy.get(vesting.connectButton) + cy.get(connectButton) .should('be.visible') .and('have.text', 'Connect Ethereum wallet'); }); diff --git a/apps/token-e2e/src/integration/wallet-eth.cy.js b/apps/token-e2e/src/integration/wallet-eth.cy.js index a0f7e64ad..d01a48fca 100644 --- a/apps/token-e2e/src/integration/wallet-eth.cy.js +++ b/apps/token-e2e/src/integration/wallet-eth.cy.js @@ -1,5 +1,21 @@ -import ethWallet from '../locators/wallet-eth.locators'; -import '../support/wallet-eth.functions'; +const walletContainer = '[data-testid="ethereum-wallet"]'; +const walletHeader = '[data-testid="wallet-header"] h1'; +const connectToEthButton = '[data-testid="connect-to-eth-wallet-button"]'; +const connectorList = '[data-testid="web3-connector-list"]'; +const associate = '[href="/staking/associate"]'; +const disassociate = '[href="/staking/disassociate"]'; +const disconnect = '[data-testid="disconnect-from-eth-wallet-button"]'; +const accountNo = '[data-testid="ethereum-account-truncated"]'; +const currencyTitle = '[data-testid="currency-title"]'; +const currencyValue = '[data-testid="currency-value"]'; +const vegaInVesting = '[data-testid="vega-in-vesting-contract"]'; +const vegaInWallet = '[data-testid="vega-in-wallet"]'; +const progressBar = '[data-testid="progress-bar"]'; +const currencyLocked = '[data-testid="currency-locked"]'; +const currencyUnlocked = '[data-testid="currency-unlocked"]'; +const dialog = '[role="dialog"]'; +const dialogHeader = '[data-testid="dialog-title"]'; +const dialogCloseBtn = '[data-testid="dialog-close"]'; context('Ethereum Wallet - verify elements on widget', function () { before('visit token home page', function () { @@ -8,22 +24,20 @@ context('Ethereum Wallet - verify elements on widget', function () { describe('with wallets disconnected', function () { before('wait for widget to load', function () { - cy.get(ethWallet.walletContainer, { timeout: 10000 }).should( - 'be.visible' - ); + cy.get(walletContainer, { timeout: 10000 }).should('be.visible'); }); it('should have ETHEREUM KEY header visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.walletHeader) + cy.get(walletContainer).within(() => { + cy.get(walletHeader) .should('be.visible') .and('have.text', 'Ethereum key'); }); }); it('should have Connect Ethereum button visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.connectToEthButton) + cy.get(walletContainer).within(() => { + cy.get(connectToEthButton) .should('be.visible') .and('have.text', 'Connect Ethereum wallet to associate $VEGA'); }); @@ -32,12 +46,12 @@ context('Ethereum Wallet - verify elements on widget', function () { describe('when Connect Ethereum clicked', function () { before('', function () { - cy.get(ethWallet.connectToEthButton).click(); + cy.get(connectToEthButton).click(); }); it('should have Connect Ethereum header visible', function () { - cy.get(ethWallet.dialog).within(() => { - cy.get(ethWallet.dialogHeader) + cy.get(dialog).within(() => { + cy.get(dialogHeader) .should('be.visible') .and('have.text', 'Connect to your Ethereum wallet'); }); @@ -49,7 +63,7 @@ context('Ethereum Wallet - verify elements on widget', function () { 'MetaMask, Brave or other injected web wallet', 'WalletConnect', ]; - cy.get(ethWallet.connectorList).within(() => { + cy.get(connectorList).within(() => { cy.get('button').each(($btn, i) => { cy.wrap($btn).should('be.visible').and('have.text', connectList[i]); }); @@ -57,9 +71,9 @@ context('Ethereum Wallet - verify elements on widget', function () { }); after('close popup', function () { - cy.get(ethWallet.dialog) + cy.get(dialog) .within(() => { - cy.get(ethWallet.dialogCloseBtn).click(); + cy.get(dialogCloseBtn).click(); }) .should('not.exist'); }); @@ -71,57 +85,53 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should have ETHEREUM KEY header visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.walletHeader) + cy.get(walletContainer).within(() => { + cy.get(walletHeader) .should('be.visible') .and('have.text', 'Ethereum key'); }); }); it('should have account number visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.accountNo) + cy.get(walletContainer).within(() => { + cy.get(accountNo) .should('be.visible') .and('have.text', Cypress.env('ethWalletPublicKeyTruncated')); }); }); it('should have Associate button visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.associate) - .should('be.visible') - .and('have.text', 'Associate'); + cy.get(walletContainer).within(() => { + cy.get(associate).should('be.visible').and('have.text', 'Associate'); }); }); it('should have Disassociate button visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.disassociate) + cy.get(walletContainer).within(() => { + cy.get(disassociate) .should('be.visible') .and('have.text', 'Disassociate'); }); }); it('should have Disconnect button visible', function () { - cy.get(ethWallet.walletContainer).within(() => { - cy.get(ethWallet.disconnect) - .should('be.visible') - .and('have.text', 'Disconnect'); + cy.get(walletContainer).within(() => { + cy.get(disconnect).should('be.visible').and('have.text', 'Disconnect'); }); }); describe('VEGA IN VESTING CONTRACT', function () { it('should have currency title visible', function () { - cy.get(ethWallet.vegaInVesting).within(() => { - cy.get(ethWallet.currencyTitle) + cy.get(vegaInVesting).within(() => { + cy.get(currencyTitle) .should('be.visible') .and('have.text', 'VEGAIn vesting contract'); }); }); it('should have currency value visible', function () { - cy.get(ethWallet.vegaInVesting).within(() => { - cy.get(ethWallet.currencyValue) + cy.get(vegaInVesting).within(() => { + cy.get(currencyValue) .should('be.visible') .invoke('text') .should('match', /\d{0,3}(,\d{3})*\.\d{18}$/); @@ -129,14 +139,14 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should have progress bar visible', function () { - cy.get(ethWallet.vegaInVesting).within(() => { - cy.get(ethWallet.progressBar).should('be.visible'); + cy.get(vegaInVesting).within(() => { + cy.get(progressBar).should('be.visible'); }); }); it('should have locked currency visible', function () { - cy.get(ethWallet.vegaInVesting).within(() => { - cy.get(ethWallet.currencyLocked) + cy.get(vegaInVesting).within(() => { + cy.get(currencyLocked) .should('be.visible') .invoke('text') .should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); @@ -144,8 +154,8 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should have unlocked currency visible', function () { - cy.get(ethWallet.vegaInVesting).within(() => { - cy.get(ethWallet.currencyUnlocked) + cy.get(vegaInVesting).within(() => { + cy.get(currencyUnlocked) .should('be.visible') .invoke('text') .should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); @@ -153,19 +163,19 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should match total & locked/unlocked currency value', function () { - cy.get(ethWallet.vegaInVesting) + cy.get(vegaInVesting) .within(() => { - cy.get(ethWallet.currencyValue) + cy.get(currencyValue) .invoke('text') - .convertTokenValueToNumber() + .convert_token_value_to_number() .as('value'); - cy.get(ethWallet.currencyLocked) + cy.get(currencyLocked) .invoke('text') - .convertTokenValueToNumber() + .convert_token_value_to_number() .as('locked'); - cy.get(ethWallet.currencyUnlocked) + cy.get(currencyUnlocked) .invoke('text') - .convertTokenValueToNumber() + .convert_token_value_to_number() .as('unlocked'); }) .then(function () { @@ -176,16 +186,16 @@ context('Ethereum Wallet - verify elements on widget', function () { describe('VEGA IN WALLET', function () { it('should have currency title visible', function () { - cy.get(ethWallet.vegaInWallet).within(() => { - cy.get(ethWallet.currencyTitle) + cy.get(vegaInWallet).within(() => { + cy.get(currencyTitle) .should('be.visible') .and('have.text', 'VEGAIn Wallet'); }); }); it('should have currency value visible', function () { - cy.get(ethWallet.vegaInWallet).within(() => { - cy.get(ethWallet.currencyValue) + cy.get(vegaInWallet).within(() => { + cy.get(currencyValue) .should('be.visible') .invoke('text') .should('match', /\d{0,3}(,\d{3})*\.\d{18}$/); @@ -193,14 +203,14 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should have progress bar visible', function () { - cy.get(ethWallet.vegaInWallet).within(() => { - cy.get(ethWallet.progressBar).should('be.visible'); + cy.get(vegaInWallet).within(() => { + cy.get(progressBar).should('be.visible'); }); }); it('should have locked currency visible', function () { - cy.get(ethWallet.vegaInWallet).within(() => { - cy.get(ethWallet.currencyLocked) + cy.get(vegaInWallet).within(() => { + cy.get(currencyLocked) .should('be.visible') .invoke('text') .should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); @@ -208,8 +218,8 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should have unlocked currency visible', function () { - cy.get(ethWallet.vegaInWallet).within(() => { - cy.get(ethWallet.currencyUnlocked) + cy.get(vegaInWallet).within(() => { + cy.get(currencyUnlocked) .should('be.visible') .invoke('text') .should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); @@ -217,19 +227,19 @@ context('Ethereum Wallet - verify elements on widget', function () { }); it('should match total & locked/unlocked currency value', function () { - cy.get(ethWallet.vegaInWallet) + cy.get(vegaInWallet) .within(() => { - cy.get(ethWallet.currencyValue) + cy.get(currencyValue) .invoke('text') - .convertTokenValueToNumber() + .convert_token_value_to_number() .as('value'); - cy.get(ethWallet.currencyLocked) + cy.get(currencyLocked) .invoke('text') - .convertTokenValueToNumber() + .convert_token_value_to_number() .as('locked'); - cy.get(ethWallet.currencyUnlocked) + cy.get(currencyUnlocked) .invoke('text') - .convertTokenValueToNumber() + .convert_token_value_to_number() .as('unlocked'); }) .then(function () { diff --git a/apps/token-e2e/src/integration/withdraw.cy.js b/apps/token-e2e/src/integration/withdraw.cy.js index 0000ae619..9036b375a 100644 --- a/apps/token-e2e/src/integration/withdraw.cy.js +++ b/apps/token-e2e/src/integration/withdraw.cy.js @@ -1,36 +1,28 @@ -import navigation from '../locators/navigation.locators'; -import withdraw from '../locators/withdraw.locators'; +const connectToVegaBtn = '[data-testid="connect-to-vega-wallet-btn"]'; +const warning = '[data-testid="callout"]'; context('Withdraw Page - verify elements on page', function () { before('navigate to withdraw page', function () { - cy.visit('/') - .get(navigation.section) - .within(() => { - cy.get(navigation.withdraw).click(); - }); + cy.visit('/').navigate_to('withdraw'); }); describe('with wallets disconnected', function () { it('should have withdraw tab highlighted', function () { - cy.get(navigation.section).within(() => { - cy.get(navigation.withdraw).should('have.attr', 'aria-current'); - }); + cy.verify_tab_highlighted('withdraw'); }); it('should have WITHDRAW header visible', function () { - cy.get(withdraw.pageHeader) - .should('be.visible') - .and('have.text', 'Withdraw'); + cy.verify_page_header('Withdraw'); }); it('should have connect Vega wallet button', function () { - cy.get(withdraw.connectToVegaBtn) + cy.get(connectToVegaBtn) .should('be.visible') .and('have.text', 'Connect Vega wallet'); }); it('should have withdraw information box', function () { - cy.get(withdraw.warning).should('be.visible'); + cy.get(warning).should('be.visible'); }); }); }); diff --git a/apps/token-e2e/src/locators/common.locators.js b/apps/token-e2e/src/locators/common.locators.js deleted file mode 100644 index 77a133286..000000000 --- a/apps/token-e2e/src/locators/common.locators.js +++ /dev/null @@ -1,10 +0,0 @@ -export default { - pageHeader: 'header h1', - sectionHeader: 'h2', - link: '[data-testid="link"]', - warning: '[data-testid="callout"]', - connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]', - dialog: '[role="dialog"]', - dialogHeader: '[data-testid="dialog-title"]', - dialogCloseBtn: '[data-testid="dialog-close"]', -}; diff --git a/apps/token-e2e/src/locators/governance.locators.js b/apps/token-e2e/src/locators/governance.locators.js deleted file mode 100644 index ec3d43f05..000000000 --- a/apps/token-e2e/src/locators/governance.locators.js +++ /dev/null @@ -1,6 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, - noProposals: '[data-testid="no-proposals"]', -}; diff --git a/apps/token-e2e/src/locators/home.locators.js b/apps/token-e2e/src/locators/home.locators.js deleted file mode 100644 index 240bc3415..000000000 --- a/apps/token-e2e/src/locators/home.locators.js +++ /dev/null @@ -1,15 +0,0 @@ -export default { - tokenDetailsTable: '.token-details', - address: '[data-testid="token-address"]', - contract: '[data-testid="token-contract"]', - totalSupply: '[data-testid="total-supply"]', - circulatingSupply: '[data-testid="circulating-supply"]', - staked: '[data-testid="staked"]', - - tranchesLink: '[data-testid="tranches-link"]', - redeemBtn: '[data-testid="check-vesting-page-btn"]', - getVegaWalletLink: '[data-testid="get-vega-wallet-link"]', - associateVegaLink: '[data-testid="associate-vega-tokens-link-on-homepage"]', - stakingBtn: '[data-testid="staking-button-on-homepage"]', - governanceBtn: '[data-testid="governance-button-on-homepage"]', -}; diff --git a/apps/token-e2e/src/locators/navigation.locators.js b/apps/token-e2e/src/locators/navigation.locators.js deleted file mode 100644 index 24d414dc5..000000000 --- a/apps/token-e2e/src/locators/navigation.locators.js +++ /dev/null @@ -1,13 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, - 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/rewards.locators.js b/apps/token-e2e/src/locators/rewards.locators.js deleted file mode 100644 index 343ef2607..000000000 --- a/apps/token-e2e/src/locators/rewards.locators.js +++ /dev/null @@ -1,5 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, -}; diff --git a/apps/token-e2e/src/locators/staking.locators.js b/apps/token-e2e/src/locators/staking.locators.js deleted file mode 100644 index cfbbb3424..000000000 --- a/apps/token-e2e/src/locators/staking.locators.js +++ /dev/null @@ -1,26 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, - guideLink: '[data-testid="staking-guide-link"]', - step1: '[data-testid="staking-step-1"]', - step2: '[data-testid="staking-step-2"]', - step3: '[data-testid="staking-step-3"]', - connectToEthBtn: '[data-testid="connect-to-eth-btn"]', - connectToVegaBtn: '[data-testid="connect-to-vega-wallet-btn"]', - validatorNames: '[data-testid="node-list-item-name"]', - epochEndingText: '[data-testid="epoch-countdown"]', - addStakeRadioButton: '[data-testid="add-stake-radio"]', - removeStakeRadioButton: '[data-testid="remove-stake-radio"]', - tokenAmountInput: '[data-testid="token-amount-input"]', - tokenInputApprove: '[data-testid="token-input-approve-button"]', - tokenInputSubmit: '[data-testid="token-input-submit-button"]', - stakedAmounts: '[data-testid="staked-validator-item"]', - stakeNextEpochValue: '[data-testid="stake-next-epoch"]', - stakeThisEpochValue: '[data-testid="stake-this-epoch"]', - stakeMaximumTokens: '[data-testid="token-amount-use-maximum"]', - stakeAssociateWalletRadio: '[data-testid="associate-radio-wallet"]', - disassociateButton: '[data-testid="disassociate-tokens-btn"]', - associateMoreTokensButton: '[data-testid="associate-more-tokens-btn"]', - associateButton: '[data-testid="associate-tokens-btn"]', -}; diff --git a/apps/token-e2e/src/locators/vesting.locators.js b/apps/token-e2e/src/locators/vesting.locators.js deleted file mode 100644 index 90eb929cb..000000000 --- a/apps/token-e2e/src/locators/vesting.locators.js +++ /dev/null @@ -1,7 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, - connectPrompt: '[data-testid="eth-connect-prompt"]', - connectButton: '[data-testid="connect-to-eth-btn"]', -}; diff --git a/apps/token-e2e/src/locators/wallet-eth.locators.js b/apps/token-e2e/src/locators/wallet-eth.locators.js deleted file mode 100644 index ca15fac6b..000000000 --- a/apps/token-e2e/src/locators/wallet-eth.locators.js +++ /dev/null @@ -1,21 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, - walletContainer: '[data-testid="ethereum-wallet"]', - walletHeader: '[data-testid="wallet-header"] h1', - connectToEthButton: '[data-testid="connect-to-eth-wallet-button"]', - connectorList: '[data-testid="web3-connector-list"]', - connectorCapsule: '[data-testid="web3-connector-Unknown"]', - associate: '[href="/staking/associate"]', - disassociate: '[href="/staking/disassociate"]', - disconnect: '[data-testid="disconnect-from-eth-wallet-button"]', - accountNo: '[data-testid="ethereum-account-truncated"]', - currencyTitle: '[data-testid="currency-title"]', - currencyValue: '[data-testid="currency-value"]', - vegaInVesting: '[data-testid="vega-in-vesting-contract"]', - vegaInWallet: '[data-testid="vega-in-wallet"]', - progressBar: '[data-testid="progress-bar"]', - currencyLocked: '[data-testid="currency-locked"]', - currencyUnlocked: '[data-testid="currency-unlocked"]', -}; diff --git a/apps/token-e2e/src/locators/wallet-vega.locators.js b/apps/token-e2e/src/locators/wallet-vega.locators.js deleted file mode 100644 index 0be69d700..000000000 --- a/apps/token-e2e/src/locators/wallet-vega.locators.js +++ /dev/null @@ -1,9 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, - walletContainer: '[data-testid="vega-wallet"]', - connectRestForm: '[data-testid="rest-connector-form"]', - name: '#wallet', - passphrase: '#passphrase', -}; diff --git a/apps/token-e2e/src/locators/withdraw.locators.js b/apps/token-e2e/src/locators/withdraw.locators.js deleted file mode 100644 index 343ef2607..000000000 --- a/apps/token-e2e/src/locators/withdraw.locators.js +++ /dev/null @@ -1,5 +0,0 @@ -import common from './common.locators'; - -export default { - ...common, -}; diff --git a/apps/token-e2e/src/support/common.functions.js b/apps/token-e2e/src/support/common.functions.js index ae7d1d705..3f02096b0 100644 --- a/apps/token-e2e/src/support/common.functions.js +++ b/apps/token-e2e/src/support/common.functions.js @@ -1,7 +1,33 @@ Cypress.Commands.add( - 'convertTokenValueToNumber', + 'convert_token_value_to_number', { prevSubject: true }, (subject) => { return parseFloat(subject.replace(/,/g, '')); } ); + +const navigation = { + section: 'nav', + home: '[href="/"]', + vesting: '[href="/vesting"]', + staking: '[href="/staking"]', + rewards: '[href="/rewards"]', + withdraw: '[href="/withdraw"]', + governance: '[href="/governance"]', +}; + +Cypress.Commands.add('navigate_to', (page) => { + return cy.get(navigation.section).within(() => { + cy.get(navigation[page]).click(); + }); +}); + +Cypress.Commands.add('verify_tab_highlighted', (page) => { + return cy.get(navigation.section).within(() => { + cy.get(navigation[page]).should('have.attr', 'aria-current'); + }); +}); + +Cypress.Commands.add('verify_page_header', (text) => { + return cy.get('header h1').should('be.visible').and('have.text', text); +});