Test/884 token e2e adjust staking flow tests to new implementation of validators table (#990)

* test: flake fixes since ui revamp

* test: lint

* test: fix broken locator since locator revamp

* test: unrelated flake preventing PR - fix
This commit is contained in:
AndyWhiteVega 2022-08-11 08:34:29 +01:00 committed by GitHub
parent 416805c2a2
commit db3aa7c17b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 18 deletions

View File

@ -71,7 +71,7 @@ context('Node switcher', function () {
});
afterEach('Close node switcher', function () {
cy.getByTestId(closeDialogBtn).should('be.visible').click();
cy.getByTestId(closeDialogBtn).should('be.enabled').click();
});
function validateNodeError(errortype, errorMsg) {

View File

@ -1,7 +1,7 @@
/// <reference types="cypress" />
const stakeValidatorListTotalStake = '[col-id="totalStakeThisEpoch"]';
const stakeValidatorListTotalShare = '[col-id="share"]';
const stakeValdatorListValidatorStake = '[col-id="validatorStake"]';
const stakeValidatorListValidatorStake = '[col-id="validatorStake"]';
const stakeRemoveStakeRadioButton = '[data-testid="remove-stake-radio"]';
const stakeTokenAmountInputBox = '[data-testid="token-amount-input"]';
const stakeTokenSubmitButton = '[data-testid="token-input-submit-button"]';
@ -50,6 +50,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
function () {
cy.vega_wallet_teardown();
cy.navigate_to('staking');
cy.wait_for_spinner();
}
);
@ -153,15 +154,30 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.navigate_to('staking');
cy.get(`[row-id="${0}"]`).within(() => {
cy.get(stakeValidatorListTotalStake).should('have.text', '3.00');
cy.get(stakeValidatorListTotalShare).should('have.text', '66.67%');
cy.get(stakeValdatorListValidatorStake).should('have.text', '2.00');
cy.get(stakeValidatorListTotalStake)
.should('have.text', '2.00')
.and('be.visible');
cy.get(stakeValidatorListTotalShare)
.should('have.text', '66.67%')
.and('be.visible');
cy.get(stakeValidatorListValidatorStake)
.scrollIntoView()
.should('have.text', '2.00')
.and('be.visible');
});
cy.get(`[row-id="${1}"]`).within(() => {
cy.get(stakeValidatorListTotalStake).should('have.text', '3.00');
cy.get(stakeValidatorListTotalShare).should('have.text', '33.33%');
cy.get(stakeValdatorListValidatorStake).should('have.text', '1.00');
cy.get(stakeValidatorListTotalStake)
.scrollIntoView()
.should('have.text', '1.00')
.and('be.visible');
cy.get(stakeValidatorListTotalShare)
.should('have.text', '33.33%')
.and('be.visible');
cy.get(stakeValidatorListValidatorStake)
.scrollIntoView()
.should('have.text', '1.00')
.and('be.visible');
});
});

View File

@ -14,7 +14,7 @@ const navigation = {
rewards: '[href="/rewards"]',
withdraw: '[href="/withdraw"]',
governance: '[href="/governance"]',
pageSpinner: 'splash-loader',
pageSpinner: '[data-testid="splash-loader"]',
};
Cypress.Commands.add('navigate_to', (page) => {

View File

@ -22,7 +22,7 @@ Cypress.Commands.add('wait_for_begining_of_epoch', () => {
Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {
cy.highlight(`Adding a stake of ${stake}`);
cy.get(addStakeRadioButton).click({ force: true });
cy.get(addStakeRadioButton, { timeout: 8000 }).click({ force: true });
cy.get(tokenAmountInputBox).type(stake);
cy.wait_for_begining_of_epoch();
cy.get(tokenSubmitButton, { timeout: 8000 })
@ -34,7 +34,7 @@ Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {
Cypress.Commands.add('staking_validator_page_remove_stake', (stake) => {
cy.highlight(`Removing a stake of ${stake}`);
cy.get(removeStakeRadioButton).click();
cy.get(removeStakeRadioButton, { timeout: 8000 }).click();
cy.get(tokenAmountInputBox).type(stake);
cy.wait_for_begining_of_epoch();
cy.get(tokenSubmitButton)
@ -94,6 +94,8 @@ Cypress.Commands.add(
'click_on_validator_from_list',
(validatorNumber, validatorName = null) => {
cy.contains('Waiting for next epoch to start').should('not.exist');
// below is to ensure validator list is shown
cy.get(stakeValidatorListName, { timeout: 10000 }).should('exist');
cy.get(stakeValidatorListPendingStake, txTimeout).should(
'not.contain',
'2,000,000,000,000,000,000.00' // number due to bug #936

View File

@ -5,6 +5,7 @@ import {
} from '@vegaprotocol/smart-contracts';
import { ethers, Wallet } from 'ethers';
const vegaWalletContainer = '[data-testid="vega-wallet"]';
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic');
const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey');
@ -40,14 +41,24 @@ before('Vega wallet teardown prep', function () {
});
Cypress.Commands.add('vega_wallet_teardown', function () {
cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
cy.vega_wallet_teardown_vesting(this.vestingContract);
cy.get(vegaWalletContainer).within(() => {
cy.get(vegaWalletAssociatedBalance)
.invoke('text')
.then((balance) => {
if (balance != '0.000000000000000000') {
cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
cy.vega_wallet_teardown_vesting(this.vestingContract);
}
});
});
cy.get(vegaWalletAssociatedBalance, { timeout: transactionTimeout }).should(
'contain',
'0.000000000000000000',
{ timeout: transactionTimeout }
);
cy.get(vegaWalletContainer).within(() => {
cy.get(vegaWalletAssociatedBalance, { timeout: transactionTimeout }).should(
'contain',
'0.000000000000000000',
{ timeout: transactionTimeout }
);
});
});
Cypress.Commands.add(