chore(token): get rid of locators files (#749)

* chore(token): get rid of locators files

* chore(token): refactor some functions and locators

Co-authored-by: Rado <rado@vegaprotocol.io>
This commit is contained in:
Radosław Szpiech 2022-07-13 17:23:51 +02:00 committed by GitHub
parent 07abc2b1eb
commit 359414f353
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 321 additions and 429 deletions

View File

@ -1,4 +1,3 @@
const stakingPageLink = '[href="/staking"]';
const pageSpinner = 'splash-loader'; const pageSpinner = 'splash-loader';
const menuBar = 'nav'; const menuBar = 'nav';
const validatorList = '[data-testid="node-list-item-name"]'; 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 tokenAmountInputBox = '[data-testid="token-amount-input"]';
const tokenSubmitButton = '[data-testid="token-input-submit-button"]'; const tokenSubmitButton = '[data-testid="token-input-submit-button"]';
const stakeNextEpochValue = '[data-testid="stake-next-epoch"]'; const stakeNextEpochValue = '[data-testid="stake-next-epoch"]';
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
const vegaWalletContainer = '[data-testid="vega-wallet"]'; const vegaWalletContainer = '[data-testid="vega-wallet"]';
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
context('Staking Flow - with eth and vega wallets connected', function () { context('Staking Flow - with eth and vega wallets connected', function () {
before('visit staking tab and connect vega wallet', function () { before('visit staking tab and connect vega wallet', function () {
cy.vega_wallet_import(); cy.vega_wallet_import();
@ -19,7 +19,7 @@ context('Staking Flow - with eth and vega wallets connected', function () {
cy.reload(); cy.reload();
cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.get(menuBar, { timeout: 20000 }).should('be.visible');
cy.ethereum_wallet_connect(); cy.ethereum_wallet_connect();
cy.get(stakingPageLink).first().click(); cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.get(pageSpinner, { timeout: 20000 }).should('not.exist');
cy.get(validatorList).first().invoke('text').as('validatorName'); cy.get(validatorList).first().invoke('text').as('validatorName');
cy.get(validatorList).last().invoke('text').as('otherValidatorName'); 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', 'teardown wallet & drill into a specific validator',
function () { function () {
cy.vega_wallet_teardown(); 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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); 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, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('1.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, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.staking_validator_page_check_stake_next_epoch_value('2.0'); 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_this_epoch_value('2.0');
}); });
it('Able to stake against mulitple validators', function () { 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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_validator_staked_value_is( vega_wallet_check_validator_staked_value_is(
this.validatorName, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.get(stakingPageLink).first().click(); cy.navigate_to('staking');
cy.get(validatorList).contains(this.otherValidatorName).click(); cy.get(validatorList).contains(this.otherValidatorName).click();
cy.staking_validator_page_add_stake('1'); cy.staking_validator_page_add_stake('1');
cy.vega_wallet_check_validator_staked_value_is( vega_wallet_check_validator_staked_value_is(
this.otherValidatorName, this.otherValidatorName,
'1.000000000000000000' '1.000000000000000000'
); );
@ -89,34 +89,34 @@ context('Staking Flow - with eth and vega wallets connected', function () {
cy.get(validatorList).contains(this.validatorName).click(); cy.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('3'); cy.staking_validator_page_add_stake('3');
cy.staking_validator_page_check_stake_next_epoch_value('3.0'); staking_validator_page_check_stake_next_epoch_value('3.0');
cy.vega_wallet_check_validator_stake_next_epoch_value_is( vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, this.validatorName,
'3.000000000000000000' '3.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('1.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(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_removeStake('1'); cy.staking_validator_page_removeStake('1');
cy.staking_validator_page_check_stake_next_epoch_value('2.0'); staking_validator_page_check_stake_next_epoch_value('2.0');
cy.staking_validator_page_check_stake_this_epoch_value('3.0'); staking_validator_page_check_stake_this_epoch_value('3.0');
cy.vega_wallet_check_validator_stake_next_epoch_value_is( vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.vega_wallet_check_validator_stake_this_epoch_value_is( vega_wallet_check_validator_stake_this_epoch_value_is(
this.validatorName, this.validatorName,
'3.000000000000000000' '3.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('2.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, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.staking_validator_page_check_stake_next_epoch_value('2.0'); 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_this_epoch_value('2.0');
}); });
it('Able to remove a full stake against a validator', function () { 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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('1'); 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, this.validatorName,
'1.000000000000000000' '1.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('2.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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_removeStake('1'); 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, this.validatorName,
'1.000000000000000000' '1.000000000000000000'
); );
cy.vega_wallet_check_validator_stake_next_epoch_value_is( vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, this.validatorName,
'0.000000000000000000' '0.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000'); cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.staking_validator_page_check_stake_next_epoch_value('0.0'); staking_validator_page_check_stake_next_epoch_value('0.0');
cy.staking_validator_page_check_stake_this_epoch_value('0.0'); staking_validator_page_check_stake_this_epoch_value('0.0');
cy.vega_wallet_check_validator_no_longer_showing(this.validatorName); vega_wallet_check_validator_no_longer_showing(this.validatorName);
}); });
it.skip('Unable to remove a stake with a negative value for a validator', function () { 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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
cy.staking_validator_page_check_stake_next_epoch_value('2.0'); staking_validator_page_check_stake_next_epoch_value('2.0');
cy.vega_wallet_check_validator_stake_next_epoch_value_is( vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('1.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(validatorList).contains(this.validatorName).click();
cy.get(removeStakeRadioButton).click({ force: true }); cy.get(removeStakeRadioButton).click({ force: true });
cy.get(tokenAmountInputBox).type('-0.1'); 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.get(validatorList).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2'); cy.staking_validator_page_add_stake('2');
cy.staking_validator_page_check_stake_next_epoch_value('2.0'); staking_validator_page_check_stake_next_epoch_value('2.0');
cy.vega_wallet_check_validator_stake_next_epoch_value_is( vega_wallet_check_validator_stake_next_epoch_value_is(
this.validatorName, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.vega_wallet_check_unstaked_value_is('1.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(validatorList).contains(this.validatorName).click();
cy.get(removeStakeRadioButton).click({ force: true }); cy.get(removeStakeRadioButton).click({ force: true });
cy.get(tokenAmountInputBox).type(4); 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.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.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, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.get(stakingPageLink).first().click(); cy.navigate_to('staking');
cy.staking_page_disassociate_all_tokens(); cy.staking_page_disassociate_all_tokens();
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing( cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
vegaWalletPublicKeyShort vegaWalletPublicKeyShort
); );
cy.ethereum_wallet_check_associated_value_is('0.0'); cy.ethereum_wallet_check_associated_value_is('0.0');
cy.vega_wallet_check_associated_value_is('0.000000000000000000'); 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 () { 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.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.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, this.validatorName,
'2.000000000000000000' '2.000000000000000000'
); );
cy.get(stakingPageLink).first().click(); cy.navigate_to('staking');
cy.staking_page_disassociate_tokens('1'); cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_value_is('2.0'); cy.ethereum_wallet_check_associated_value_is('2.0');
cy.vega_wallet_check_associated_value_is('2.000000000000000000'); 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, this.validatorName,
'2.000000000000000000' '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');
});
}

View File

@ -1,7 +1,7 @@
const stakingPageLink = '[href="/staking"]';
const pageSpinner = 'splash-loader'; const pageSpinner = 'splash-loader';
const menuBar = 'nav'; const menuBar = 'nav';
const validatorList = '[data-testid="node-list-item-name"]'; const validatorList = '[data-testid="node-list-item-name"]';
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
context( context(
@ -16,7 +16,7 @@ context(
cy.reload(); cy.reload();
cy.get(menuBar, { timeout: 20000 }).should('be.visible'); cy.get(menuBar, { timeout: 20000 }).should('be.visible');
cy.ethereum_wallet_connect(); cy.ethereum_wallet_connect();
cy.get(stakingPageLink).first().click(); cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.get(pageSpinner, { timeout: 20000 }).should('not.exist');
cy.get(validatorList).first().invoke('text').as('validatorName'); cy.get(validatorList).first().invoke('text').as('validatorName');
}); });
@ -26,7 +26,7 @@ context(
'teardown wallet & drill into a specific validator', 'teardown wallet & drill into a specific validator',
function () { function () {
cy.vega_wallet_teardown(); cy.vega_wallet_teardown();
cy.get(stakingPageLink).first().click(); cy.navigate_to('staking');
cy.get(pageSpinner, { timeout: 20000 }).should('not.exist'); cy.get(pageSpinner, { timeout: 20000 }).should('not.exist');
} }
); );

View File

@ -1,30 +1,21 @@
import navigation from '../locators/navigation.locators'; const noProposals = '[data-testid="no-proposals"]';
import governance from '../locators/governance.locators';
context('Governance Page - verify elements on page', function () { context('Governance Page - verify elements on page', function () {
before('navigate to governance page', function () { before('navigate to governance page', function () {
cy.visit('/') cy.visit('/').navigate_to('governance');
.get(navigation.section)
.within(() => {
cy.get(navigation.governance).click();
});
}); });
describe('with no network change proposals', function () { describe('with no network change proposals', function () {
it('should have governance tab highlighted', function () { it('should have governance tab highlighted', function () {
cy.get(navigation.section).within(() => { cy.verify_tab_highlighted('governance');
cy.get(navigation.governance).should('have.attr', 'aria-current');
});
}); });
it('should have GOVERNANCE header visible', function () { it('should have GOVERNANCE header visible', function () {
cy.get(governance.pageHeader) cy.verify_page_header('Governance');
.should('be.visible')
.and('have.text', 'Governance');
}); });
it('should have information box visible', function () { it('should have information box visible', function () {
cy.get(governance.noProposals) cy.get(noProposals)
.should('be.visible') .should('be.visible')
.and('have.text', 'There are no active network change proposals'); .and('have.text', 'There are no active network change proposals');
}); });

View File

@ -1,5 +1,24 @@
import navigation from '../locators/navigation.locators'; const navSection = 'nav';
import home from '../locators/home.locators'; 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 vegaTokenAddress = Cypress.env('vegaTokenAddress');
const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress'); const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress');
@ -11,111 +30,111 @@ context('Home Page - verify elements on page', function () {
describe('with wallets disconnected', function () { describe('with wallets disconnected', function () {
before('wait for page to load', 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 () { describe('Navigation tabs', function () {
it('should have HOME tab', function () { it('should have HOME tab', function () {
cy.get(navigation.section).within(() => { cy.get(navSection).within(() => {
cy.get(navigation.home).should('be.visible'); cy.get(navHome).should('be.visible');
}); });
}); });
it('should have VESTING tab', function () { it('should have VESTING tab', function () {
cy.get(navigation.section).within(() => { cy.get(navSection).within(() => {
cy.get(navigation.vesting).should('be.visible'); cy.get(navVesting).should('be.visible');
}); });
}); });
it('should have STAKING tab', function () { it('should have STAKING tab', function () {
cy.get(navigation.section).within(() => { cy.get(navSection).within(() => {
cy.get(navigation.staking).should('be.visible'); cy.get(navStaking).should('be.visible');
}); });
}); });
it('should have REWARDS tab', function () { it('should have REWARDS tab', function () {
cy.get(navigation.section).within(() => { cy.get(navSection).within(() => {
cy.get(navigation.rewards).should('be.visible'); cy.get(navRewards).should('be.visible');
}); });
}); });
it('should have WITHDRAW tab', function () { it('should have WITHDRAW tab', function () {
cy.get(navigation.section).within(() => { cy.get(navSection).within(() => {
cy.get(navigation.withdraw).should('be.visible'); cy.get(navWithdraw).should('be.visible');
}); });
}); });
it('should have GOVERNANCE tab', function () { it('should have GOVERNANCE tab', function () {
cy.get(navigation.section).within(() => { cy.get(navSection).within(() => {
cy.get(navigation.governance).should('be.visible'); cy.get(navGovernance).should('be.visible');
}); });
}); });
}); });
describe('THE $VEGA TOKEN table', function () { describe('THE $VEGA TOKEN table', function () {
it('should have TOKEN ADDRESS', function () { it('should have TOKEN ADDRESS', function () {
cy.get(home.tokenDetailsTable).within(() => { cy.get(tokenDetailsTable).within(() => {
cy.get(home.address) cy.get(address)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('be.equal', vegaTokenAddress); .should('be.equal', vegaTokenAddress);
}); });
}); });
it('should have VESTING CONTRACT', function () { it('should have VESTING CONTRACT', function () {
cy.get(home.tokenDetailsTable).within(() => { cy.get(tokenDetailsTable).within(() => {
cy.get(home.contract) cy.get(contract)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('be.equal', vegaTokenContractAddress); .should('be.equal', vegaTokenContractAddress);
}); });
}); });
it('should have TOTAL SUPPLY', function () { it('should have TOTAL SUPPLY', function () {
cy.get(home.tokenDetailsTable).within(() => { cy.get(tokenDetailsTable).within(() => {
cy.get(home.totalSupply).should('be.visible'); cy.get(totalSupply).should('be.visible');
}); });
}); });
it('should have CIRCULATING SUPPLY', function () { it('should have CIRCULATING SUPPLY', function () {
cy.get(home.tokenDetailsTable).within(() => { cy.get(tokenDetailsTable).within(() => {
cy.get(home.circulatingSupply).should('be.visible'); cy.get(circulatingSupply).should('be.visible');
}); });
}); });
it('should have STAKED $VEGA', function () { it('should have STAKED $VEGA', function () {
cy.get(home.tokenDetailsTable).within(() => { cy.get(tokenDetailsTable).within(() => {
cy.get(home.staked).should('be.visible'); cy.get(staked).should('be.visible');
}); });
}); });
}); });
describe('links and buttons', function () { describe('links and buttons', function () {
it('should have TRANCHES link', function () { it('should have TRANCHES link', function () {
cy.get(home.tranchesLink) cy.get(tranchesLink)
.should('be.visible') .should('be.visible')
.and('have.attr', 'href') .and('have.attr', 'href')
.and('equal', '/tranches'); .and('equal', '/tranches');
}); });
it('should have REDEEM button', function () { it('should have REDEEM button', function () {
cy.get(home.redeemBtn) cy.get(redeemBtn)
.should('be.visible') .should('be.visible')
.parent() .parent()
.should('have.attr', 'href') .should('have.attr', 'href')
.and('equal', '/vesting'); .and('equal', '/vesting');
}); });
it('should have GET VEGA WALLET link', function () { it('should have GET VEGA WALLET link', function () {
cy.get(home.getVegaWalletLink) cy.get(getVegaWalletLink)
.should('be.visible') .should('be.visible')
.and('have.attr', 'href') .and('have.attr', 'href')
.and('equal', 'https://vega.xyz/wallet'); .and('equal', 'https://vega.xyz/wallet');
}); });
it('should have ASSOCIATE VEGA TOKENS link', function () { it('should have ASSOCIATE VEGA TOKENS link', function () {
cy.get(home.associateVegaLink) cy.get(associateVegaLink)
.should('be.visible') .should('be.visible')
.and('have.attr', 'href') .and('have.attr', 'href')
.and('equal', '/staking/associate'); .and('equal', '/staking/associate');
}); });
it('should have STAKING button', function () { it('should have STAKING button', function () {
cy.get(home.stakingBtn) cy.get(stakingBtn)
.should('be.visible') .should('be.visible')
.parent() .parent()
.should('have.attr', 'href') .should('have.attr', 'href')
.and('equal', '/staking'); .and('equal', '/staking');
}); });
it('should have GOVERNANCE button', function () { it('should have GOVERNANCE button', function () {
cy.get(home.governanceBtn) cy.get(governanceBtn)
.should('be.visible') .should('be.visible')
.parent() .parent()
.should('have.attr', 'href') .should('have.attr', 'href')

View File

@ -1,30 +1,22 @@
import navigation from '../locators/navigation.locators'; const connectToVegaBtn = '[data-testid="connect-to-vega-wallet-btn"]';
import rewards from '../locators/rewards.locators'; const warning = '[data-testid="callout"]';
context('Rewards Page - verify elements on page', function () { context('Rewards Page - verify elements on page', function () {
before('navigate to rewards page', function () { before('navigate to rewards page', function () {
cy.visit('/') cy.visit('/').navigate_to('rewards');
.get(navigation.section)
.within(() => {
cy.get(navigation.rewards).click();
});
}); });
describe('with wallets disconnected', function () { describe('with wallets disconnected', function () {
it('should have REWARDS tab highlighted', function () { it('should have REWARDS tab highlighted', function () {
cy.get(navigation.section).within(() => { cy.verify_tab_highlighted('rewards');
cy.get(navigation.rewards).should('have.attr', 'aria-current');
});
}); });
it('should have rewards header visible', function () { it('should have rewards header visible', function () {
cy.get(rewards.pageHeader) cy.verify_page_header('Rewards');
.should('be.visible')
.and('have.text', 'Rewards');
}); });
it('should have epoch warning', function () { it('should have epoch warning', function () {
cy.get(rewards.warning) cy.get(warning)
.should('be.visible') .should('be.visible')
.and( .and(
'have.text', 'have.text',
@ -33,7 +25,7 @@ context('Rewards Page - verify elements on page', function () {
}); });
it('should have connect Vega wallet button', function () { it('should have connect Vega wallet button', function () {
cy.get(rewards.connectToVegaBtn) cy.get(connectToVegaBtn)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Vega wallet'); .and('have.text', 'Connect Vega wallet');
}); });

View File

@ -1,31 +1,30 @@
import navigation from '../locators/navigation.locators'; const guideLink = '[data-testid="staking-guide-link"]';
import staking from '../locators/staking.locators'; 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 () { context('Staking Page - verify elements on page', function () {
before('navigate to staking page', function () { before('navigate to staking page', function () {
cy.visit('/') cy.visit('/').navigate_to('staking');
.get(navigation.section)
.within(() => {
cy.get(navigation.staking).click();
});
}); });
describe('with wallets disconnected', function () { describe('with wallets disconnected', function () {
describe('description section', function () { describe('description section', function () {
it('should have staking tab highlighted', function () { it('should have staking tab highlighted', function () {
cy.get(navigation.section).within(() => { cy.verify_tab_highlighted('staking');
cy.get(navigation.staking).should('have.attr', 'aria-current');
});
}); });
it('should have STAKING ON VEGA header visible', function () { it('should have STAKING ON VEGA header visible', function () {
cy.get(staking.pageHeader) cy.verify_page_header('Staking on Vega');
.should('be.visible')
.and('have.text', 'Staking on Vega');
}); });
it('should have Staking Guide link visible', function () { it('should have Staking Guide link visible', function () {
cy.get(staking.guideLink) cy.get(guideLink)
.should('be.visible') .should('be.visible')
.and('have.text', 'Read more about staking on Vega') .and('have.text', 'Read more about staking on Vega')
.and( .and(
@ -38,16 +37,16 @@ context('Staking Page - verify elements on page', function () {
describe('step 1 section', function () { describe('step 1 section', function () {
it('should have header visible', function () { it('should have header visible', function () {
cy.get(staking.step1).within(() => { cy.get(step1).within(() => {
cy.get(staking.sectionHeader) cy.get(sectionHeader)
.should('be.visible') .should('be.visible')
.and('have.text', 'Step 1. Connect to a Vega Wallet'); .and('have.text', 'Step 1. Connect to a Vega Wallet');
}); });
}); });
it('should have text visible', function () { it('should have text visible', function () {
cy.get(staking.step1).within(() => { cy.get(step1).within(() => {
cy.get(staking.link) cy.get(link)
.should('be.visible') .should('be.visible')
.and('have.text', 'Vega Wallet') .and('have.text', 'Vega Wallet')
.and('have.attr', 'href', 'https://vega.xyz/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 () { it('should have connect to eth button visible', function () {
cy.get(staking.step1).within(() => { cy.get(step1).within(() => {
cy.get(staking.connectToEthBtn) cy.get(connectToEthBtn)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Ethereum wallet'); .and('have.text', 'Connect Ethereum wallet');
}); });
}); });
it('should have connect to vega button visible', function () { it('should have connect to vega button visible', function () {
cy.get(staking.step1).within(() => { cy.get(step1).within(() => {
cy.get(staking.connectToVegaBtn) cy.get(connectToVegaBtn)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Vega wallet'); .and('have.text', 'Connect Vega wallet');
}); });
@ -73,16 +72,16 @@ context('Staking Page - verify elements on page', function () {
describe('step 2 section', function () { describe('step 2 section', function () {
it('should have header visible', function () { it('should have header visible', function () {
cy.get(staking.step2).within(() => { cy.get(step2).within(() => {
cy.get(staking.sectionHeader) cy.get(sectionHeader)
.should('be.visible') .should('be.visible')
.and('have.text', 'Step 2. Associate tokens with a Vega Wallet'); .and('have.text', 'Step 2. Associate tokens with a Vega Wallet');
}); });
}); });
it('should have warning visible', function () { it('should have warning visible', function () {
cy.get(staking.step2).within(() => { cy.get(step2).within(() => {
cy.get(staking.warning) cy.get(warning)
.should('be.visible') .should('be.visible')
.and( .and(
'have.text', 'have.text',
@ -94,8 +93,8 @@ context('Staking Page - verify elements on page', function () {
describe('step 3 section', function () { describe('step 3 section', function () {
it('should have header visible', function () { it('should have header visible', function () {
cy.get(staking.step3).within(() => { cy.get(step3).within(() => {
cy.get(staking.sectionHeader) cy.get(sectionHeader)
.should('be.visible') .should('be.visible')
.and( .and(
'have.text', 'have.text',

View File

@ -1,34 +1,26 @@
import navigation from '../locators/navigation.locators'; const connectPrompt = '[data-testid="eth-connect-prompt"]';
import vesting from '../locators/vesting.locators'; const connectButton = '[data-testid="connect-to-eth-btn"]';
context('Vesting Page - verify elements on page', function () { context('Vesting Page - verify elements on page', function () {
before('navigate to vesting page', function () { before('navigate to vesting page', function () {
cy.visit('/') cy.visit('/').navigate_to('vesting');
.get(navigation.section)
.within(() => {
cy.get(navigation.vesting).click();
});
}); });
describe('with wallets disconnected', function () { describe('with wallets disconnected', function () {
it('should have vesting tab highlighted', function () { it('should have vesting tab highlighted', function () {
cy.get(navigation.section).within(() => { cy.verify_tab_highlighted('vesting');
cy.get(navigation.vesting).should('have.attr', 'aria-current');
});
}); });
it('should have VESTING header visible', function () { it('should have VESTING header visible', function () {
cy.get(vesting.pageHeader) cy.verify_page_header('Vesting');
.should('be.visible')
.and('have.text', 'Vesting');
}); });
it('should have connect Eth wallet info', function () { 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 () { it('should have connect Eth wallet button', function () {
cy.get(vesting.connectButton) cy.get(connectButton)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Ethereum wallet'); .and('have.text', 'Connect Ethereum wallet');
}); });

View File

@ -1,5 +1,21 @@
import ethWallet from '../locators/wallet-eth.locators'; const walletContainer = '[data-testid="ethereum-wallet"]';
import '../support/wallet-eth.functions'; 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 () { context('Ethereum Wallet - verify elements on widget', function () {
before('visit token home page', function () { before('visit token home page', function () {
@ -8,22 +24,20 @@ context('Ethereum Wallet - verify elements on widget', function () {
describe('with wallets disconnected', function () { describe('with wallets disconnected', function () {
before('wait for widget to load', function () { before('wait for widget to load', function () {
cy.get(ethWallet.walletContainer, { timeout: 10000 }).should( cy.get(walletContainer, { timeout: 10000 }).should('be.visible');
'be.visible'
);
}); });
it('should have ETHEREUM KEY header visible', function () { it('should have ETHEREUM KEY header visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.walletHeader) cy.get(walletHeader)
.should('be.visible') .should('be.visible')
.and('have.text', 'Ethereum key'); .and('have.text', 'Ethereum key');
}); });
}); });
it('should have Connect Ethereum button visible', function () { it('should have Connect Ethereum button visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.connectToEthButton) cy.get(connectToEthButton)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Ethereum wallet to associate $VEGA'); .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 () { describe('when Connect Ethereum clicked', function () {
before('', function () { before('', function () {
cy.get(ethWallet.connectToEthButton).click(); cy.get(connectToEthButton).click();
}); });
it('should have Connect Ethereum header visible', function () { it('should have Connect Ethereum header visible', function () {
cy.get(ethWallet.dialog).within(() => { cy.get(dialog).within(() => {
cy.get(ethWallet.dialogHeader) cy.get(dialogHeader)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect to your Ethereum wallet'); .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', 'MetaMask, Brave or other injected web wallet',
'WalletConnect', 'WalletConnect',
]; ];
cy.get(ethWallet.connectorList).within(() => { cy.get(connectorList).within(() => {
cy.get('button').each(($btn, i) => { cy.get('button').each(($btn, i) => {
cy.wrap($btn).should('be.visible').and('have.text', connectList[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 () { after('close popup', function () {
cy.get(ethWallet.dialog) cy.get(dialog)
.within(() => { .within(() => {
cy.get(ethWallet.dialogCloseBtn).click(); cy.get(dialogCloseBtn).click();
}) })
.should('not.exist'); .should('not.exist');
}); });
@ -71,57 +85,53 @@ context('Ethereum Wallet - verify elements on widget', function () {
}); });
it('should have ETHEREUM KEY header visible', function () { it('should have ETHEREUM KEY header visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.walletHeader) cy.get(walletHeader)
.should('be.visible') .should('be.visible')
.and('have.text', 'Ethereum key'); .and('have.text', 'Ethereum key');
}); });
}); });
it('should have account number visible', function () { it('should have account number visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.accountNo) cy.get(accountNo)
.should('be.visible') .should('be.visible')
.and('have.text', Cypress.env('ethWalletPublicKeyTruncated')); .and('have.text', Cypress.env('ethWalletPublicKeyTruncated'));
}); });
}); });
it('should have Associate button visible', function () { it('should have Associate button visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.associate) cy.get(associate).should('be.visible').and('have.text', 'Associate');
.should('be.visible')
.and('have.text', 'Associate');
}); });
}); });
it('should have Disassociate button visible', function () { it('should have Disassociate button visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.disassociate) cy.get(disassociate)
.should('be.visible') .should('be.visible')
.and('have.text', 'Disassociate'); .and('have.text', 'Disassociate');
}); });
}); });
it('should have Disconnect button visible', function () { it('should have Disconnect button visible', function () {
cy.get(ethWallet.walletContainer).within(() => { cy.get(walletContainer).within(() => {
cy.get(ethWallet.disconnect) cy.get(disconnect).should('be.visible').and('have.text', 'Disconnect');
.should('be.visible')
.and('have.text', 'Disconnect');
}); });
}); });
describe('VEGA IN VESTING CONTRACT', function () { describe('VEGA IN VESTING CONTRACT', function () {
it('should have currency title visible', function () { it('should have currency title visible', function () {
cy.get(ethWallet.vegaInVesting).within(() => { cy.get(vegaInVesting).within(() => {
cy.get(ethWallet.currencyTitle) cy.get(currencyTitle)
.should('be.visible') .should('be.visible')
.and('have.text', 'VEGAIn vesting contract'); .and('have.text', 'VEGAIn vesting contract');
}); });
}); });
it('should have currency value visible', function () { it('should have currency value visible', function () {
cy.get(ethWallet.vegaInVesting).within(() => { cy.get(vegaInVesting).within(() => {
cy.get(ethWallet.currencyValue) cy.get(currencyValue)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('match', /\d{0,3}(,\d{3})*\.\d{18}$/); .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 () { it('should have progress bar visible', function () {
cy.get(ethWallet.vegaInVesting).within(() => { cy.get(vegaInVesting).within(() => {
cy.get(ethWallet.progressBar).should('be.visible'); cy.get(progressBar).should('be.visible');
}); });
}); });
it('should have locked currency visible', function () { it('should have locked currency visible', function () {
cy.get(ethWallet.vegaInVesting).within(() => { cy.get(vegaInVesting).within(() => {
cy.get(ethWallet.currencyLocked) cy.get(currencyLocked)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); .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 () { it('should have unlocked currency visible', function () {
cy.get(ethWallet.vegaInVesting).within(() => { cy.get(vegaInVesting).within(() => {
cy.get(ethWallet.currencyUnlocked) cy.get(currencyUnlocked)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); .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 () { it('should match total & locked/unlocked currency value', function () {
cy.get(ethWallet.vegaInVesting) cy.get(vegaInVesting)
.within(() => { .within(() => {
cy.get(ethWallet.currencyValue) cy.get(currencyValue)
.invoke('text') .invoke('text')
.convertTokenValueToNumber() .convert_token_value_to_number()
.as('value'); .as('value');
cy.get(ethWallet.currencyLocked) cy.get(currencyLocked)
.invoke('text') .invoke('text')
.convertTokenValueToNumber() .convert_token_value_to_number()
.as('locked'); .as('locked');
cy.get(ethWallet.currencyUnlocked) cy.get(currencyUnlocked)
.invoke('text') .invoke('text')
.convertTokenValueToNumber() .convert_token_value_to_number()
.as('unlocked'); .as('unlocked');
}) })
.then(function () { .then(function () {
@ -176,16 +186,16 @@ context('Ethereum Wallet - verify elements on widget', function () {
describe('VEGA IN WALLET', function () { describe('VEGA IN WALLET', function () {
it('should have currency title visible', function () { it('should have currency title visible', function () {
cy.get(ethWallet.vegaInWallet).within(() => { cy.get(vegaInWallet).within(() => {
cy.get(ethWallet.currencyTitle) cy.get(currencyTitle)
.should('be.visible') .should('be.visible')
.and('have.text', 'VEGAIn Wallet'); .and('have.text', 'VEGAIn Wallet');
}); });
}); });
it('should have currency value visible', function () { it('should have currency value visible', function () {
cy.get(ethWallet.vegaInWallet).within(() => { cy.get(vegaInWallet).within(() => {
cy.get(ethWallet.currencyValue) cy.get(currencyValue)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('match', /\d{0,3}(,\d{3})*\.\d{18}$/); .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 () { it('should have progress bar visible', function () {
cy.get(ethWallet.vegaInWallet).within(() => { cy.get(vegaInWallet).within(() => {
cy.get(ethWallet.progressBar).should('be.visible'); cy.get(progressBar).should('be.visible');
}); });
}); });
it('should have locked currency visible', function () { it('should have locked currency visible', function () {
cy.get(ethWallet.vegaInWallet).within(() => { cy.get(vegaInWallet).within(() => {
cy.get(ethWallet.currencyLocked) cy.get(currencyLocked)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); .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 () { it('should have unlocked currency visible', function () {
cy.get(ethWallet.vegaInWallet).within(() => { cy.get(vegaInWallet).within(() => {
cy.get(ethWallet.currencyUnlocked) cy.get(currencyUnlocked)
.should('be.visible') .should('be.visible')
.invoke('text') .invoke('text')
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/); .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 () { it('should match total & locked/unlocked currency value', function () {
cy.get(ethWallet.vegaInWallet) cy.get(vegaInWallet)
.within(() => { .within(() => {
cy.get(ethWallet.currencyValue) cy.get(currencyValue)
.invoke('text') .invoke('text')
.convertTokenValueToNumber() .convert_token_value_to_number()
.as('value'); .as('value');
cy.get(ethWallet.currencyLocked) cy.get(currencyLocked)
.invoke('text') .invoke('text')
.convertTokenValueToNumber() .convert_token_value_to_number()
.as('locked'); .as('locked');
cy.get(ethWallet.currencyUnlocked) cy.get(currencyUnlocked)
.invoke('text') .invoke('text')
.convertTokenValueToNumber() .convert_token_value_to_number()
.as('unlocked'); .as('unlocked');
}) })
.then(function () { .then(function () {

View File

@ -1,36 +1,28 @@
import navigation from '../locators/navigation.locators'; const connectToVegaBtn = '[data-testid="connect-to-vega-wallet-btn"]';
import withdraw from '../locators/withdraw.locators'; const warning = '[data-testid="callout"]';
context('Withdraw Page - verify elements on page', function () { context('Withdraw Page - verify elements on page', function () {
before('navigate to withdraw page', function () { before('navigate to withdraw page', function () {
cy.visit('/') cy.visit('/').navigate_to('withdraw');
.get(navigation.section)
.within(() => {
cy.get(navigation.withdraw).click();
});
}); });
describe('with wallets disconnected', function () { describe('with wallets disconnected', function () {
it('should have withdraw tab highlighted', function () { it('should have withdraw tab highlighted', function () {
cy.get(navigation.section).within(() => { cy.verify_tab_highlighted('withdraw');
cy.get(navigation.withdraw).should('have.attr', 'aria-current');
});
}); });
it('should have WITHDRAW header visible', function () { it('should have WITHDRAW header visible', function () {
cy.get(withdraw.pageHeader) cy.verify_page_header('Withdraw');
.should('be.visible')
.and('have.text', 'Withdraw');
}); });
it('should have connect Vega wallet button', function () { it('should have connect Vega wallet button', function () {
cy.get(withdraw.connectToVegaBtn) cy.get(connectToVegaBtn)
.should('be.visible') .should('be.visible')
.and('have.text', 'Connect Vega wallet'); .and('have.text', 'Connect Vega wallet');
}); });
it('should have withdraw information box', function () { it('should have withdraw information box', function () {
cy.get(withdraw.warning).should('be.visible'); cy.get(warning).should('be.visible');
}); });
}); });
}); });

View File

@ -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"]',
};

View File

@ -1,6 +0,0 @@
import common from './common.locators';
export default {
...common,
noProposals: '[data-testid="no-proposals"]',
};

View File

@ -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"]',
};

View File

@ -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',
};

View File

@ -1,5 +0,0 @@
import common from './common.locators';
export default {
...common,
};

View File

@ -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"]',
};

View File

@ -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"]',
};

View File

@ -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"]',
};

View File

@ -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',
};

View File

@ -1,5 +0,0 @@
import common from './common.locators';
export default {
...common,
};

View File

@ -1,7 +1,33 @@
Cypress.Commands.add( Cypress.Commands.add(
'convertTokenValueToNumber', 'convert_token_value_to_number',
{ prevSubject: true }, { prevSubject: true },
(subject) => { (subject) => {
return parseFloat(subject.replace(/,/g, '')); 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);
});