Test/token association fixes (#1216)

* test: fixes

* test: lint
This commit is contained in:
AndyWhiteVega 2022-09-01 12:25:11 +01:00 committed by GitHub
parent c79f3b08b4
commit e66e5af6a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 48 deletions

View File

@ -23,7 +23,7 @@ module.exports = defineConfig({
chromeWebSecurity: false,
viewportWidth: 1440,
viewportHeight: 900,
numTestsKeptInMemory: 4,
numTestsKeptInMemory: 5,
},
env: {
ethProviderUrl: 'http://localhost:8545/',

View File

@ -25,6 +25,7 @@ const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]';
const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
const ethWalletContainer = '[data-testid="ethereum-wallet"]';
const vegaWallet = '[data-testid="vega-wallet"]';
const partValidatorId = '…';
const txTimeout = Cypress.env('txTimeout');
const epochTimeout = Cypress.env('epochTimeout');
@ -550,11 +551,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.contains('0.0', txTimeout)
.should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'0.000000000000000000',
txTimeout
'0.000000000000000000'
);
});
cy.get(vegaWalletStakedBalances, txTimeout).should(
'not.exist',
@ -603,11 +605,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.contains('0.0', txTimeout)
.should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'0.000000000000000000',
txTimeout
'0.000000000000000000'
);
});
cy.get(vegaWalletStakedBalances, txTimeout).should(
'not.exist',
@ -650,11 +653,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.contains('2.0', txTimeout)
.should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'2.000000000000000000',
txTimeout
'2.000000000000000000'
);
});
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, txTimeout)
@ -804,11 +808,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.staking_page_associate_tokens('6');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'12.000000000000000000',
txTimeout
'12.000000000000000000'
);
});
cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', '4.0', txTimeout)

View File

@ -1,4 +1,3 @@
const validatorsGrid = '[data-testid="validators-grid"]';
const ethWalletContainer = '[data-testid="ethereum-wallet"]';
const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]';
@ -6,7 +5,7 @@ const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]';
const txTimeout = { timeout: 40000 };
const txTimeout = Cypress.env('txTimeout');
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
const ethWalletAssociateButton = '[href="/staking/associate"]';
const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]';
@ -18,6 +17,7 @@ const vegaInWalletSection = '[data-testid="vega-in-wallet"]';
const associatedKey = '[data-test-id="associated-key"]';
const associatedAmount = '[data-test-id="associated-amount"]';
const disassocitiationWarning = '[data-testid="disassociation-warning"]';
const vegaWallet = '[data-testid="vega-wallet"]';
context(
'Token association flow - with eth and vega wallets connected',
@ -33,7 +33,7 @@ context(
cy.ethereum_wallet_connect();
cy.navigate_to('staking');
cy.wait_for_spinner();
cy.get(validatorsGrid).should('be.visible');
cy.wait_for_begining_of_epoch();
});
describe('Eth wallet - contains VEGA tokens', function () {
@ -46,7 +46,7 @@ context(
}
);
it('Able to associate tokens', function () {
it('Able to associate tokens - from wallet', function () {
//1000-ASSO-0008
//1000-ASSO-0009
//1000-ASSO-0030
@ -66,12 +66,14 @@ context(
.contains('2.0', txTimeout)
.should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0);
});
it('Able to disassociate tokens', function () {
it('Able to disassociate all associated tokens - manually', function () {
// 1000-ASSO-0025
// 1000-ASSO-0027
// 1000-ASSO-0028
@ -90,15 +92,12 @@ context(
cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_tokens('1');
cy.staking_page_disassociate_tokens('2');
cy.get(ethWalletAssociatedBalances, txTimeout)
.contains(vegaWalletPublicKeyShort)
.parent(txTimeout)
.should('contain', 1.0);
cy.get(ethWalletAssociatedBalances, txTimeout).should('not.exist');
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('1.0', txTimeout)
.contains('0.00', txTimeout)
.should('be.visible');
});
@ -115,16 +114,20 @@ context(
.contains('1,001.00', txTimeout)
.should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain',
'1,001.000000000000000000'
);
});
});
it('Able to disassociate a partial amount of tokens currently associated', function () {
cy.staking_page_associate_tokens('2');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get('button').contains('Select a validator to nominate').click();
@ -140,17 +143,21 @@ context(
.parent(txTimeout)
.should('contain', 1.0);
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 1.0);
});
});
it('Able to disassociate all tokens', function () {
it('Able to disassociate all tokens - using max', function () {
// 1000-ASSO-0026
const warningText =
'Warning: Any tokens that have been nominated to a node will sacrifice rewards they are due for the current epoch. If you do not wish to sacrifice these, you should remove stake from a node at the end of an epoch before disassociation.';
cy.staking_page_associate_tokens('2');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get('button').contains('Select a validator to nominate').click();
@ -171,8 +178,10 @@ context(
);
});
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 0.0);
});
});
it('Able to associate and disassociate vesting contract tokens', function () {
// 1000-ASSO-0006
@ -190,7 +199,9 @@ context(
.contains('2.0', txTimeout)
.should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0);
cy.staking_page_disassociate_tokens('1', { type: 'contract' });
@ -231,22 +242,30 @@ context(
cy.get(associatedAmount, txTimeout).should('contain', 21);
});
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 58);
});
cy.staking_page_disassociate_tokens('6', { type: 'contract' });
cy.get(vestingContractSection).within(() => {
cy.get(associatedAmount, txTimeout).should('contain', 31);
});
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 52);
cy.get('[href="/staking"]').first().click();
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 52);
});
cy.navigate_to('staking');
cy.staking_page_disassociate_tokens('9', { type: 'wallet' });
cy.get(vegaInWalletSection).within(() => {
cy.get(associatedAmount, txTimeout).should('contain', 12);
});
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 43);
});
});
it('Not able to associate more tokens than owned', function () {
// 1000-ASSO-0010

View File

@ -24,7 +24,9 @@ Cypress.Commands.add('wait_for_begining_of_epoch', () => {
cy.contains('Waiting for next epoch to start', epochTimeout).should(
'not.exist'
);
cy.contains('Waiting for next epoch to start', epochTimeout);
cy.contains('Waiting for next epoch to start', epochTimeout).should(
'be.visible'
);
});
Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {