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, chromeWebSecurity: false,
viewportWidth: 1440, viewportWidth: 1440,
viewportHeight: 900, viewportHeight: 900,
numTestsKeptInMemory: 4, numTestsKeptInMemory: 5,
}, },
env: { env: {
ethProviderUrl: 'http://localhost:8545/', ethProviderUrl: 'http://localhost:8545/',

View File

@ -25,6 +25,7 @@ const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]'; '[data-testid="eth-wallet-associated-balances"]';
const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]'; const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
const ethWalletContainer = '[data-testid="ethereum-wallet"]'; const ethWalletContainer = '[data-testid="ethereum-wallet"]';
const vegaWallet = '[data-testid="vega-wallet"]';
const partValidatorId = '…'; const partValidatorId = '…';
const txTimeout = Cypress.env('txTimeout'); const txTimeout = Cypress.env('txTimeout');
const epochTimeout = Cypress.env('epochTimeout'); const epochTimeout = Cypress.env('epochTimeout');
@ -550,11 +551,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.contains('0.0', txTimeout) .contains('0.0', txTimeout)
.should('be.visible'); .should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should( cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'0.000000000000000000', '0.000000000000000000'
txTimeout
); );
});
cy.get(vegaWalletStakedBalances, txTimeout).should( cy.get(vegaWalletStakedBalances, txTimeout).should(
'not.exist', 'not.exist',
@ -603,11 +605,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.contains('0.0', txTimeout) .contains('0.0', txTimeout)
.should('be.visible'); .should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should( cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'0.000000000000000000', '0.000000000000000000'
txTimeout
); );
});
cy.get(vegaWalletStakedBalances, txTimeout).should( cy.get(vegaWalletStakedBalances, txTimeout).should(
'not.exist', 'not.exist',
@ -650,11 +653,12 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.contains('2.0', txTimeout) .contains('2.0', txTimeout)
.should('be.visible'); .should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should( cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'2.000000000000000000', '2.000000000000000000'
txTimeout
); );
});
cy.get(vegaWalletStakedBalances, txTimeout) cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', 2.0, 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.staking_page_associate_tokens('6');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should( cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'12.000000000000000000', '12.000000000000000000'
txTimeout
); );
});
cy.get(vegaWalletStakedBalances, txTimeout) cy.get(vegaWalletStakedBalances, txTimeout)
.should('contain', '4.0', 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 ethWalletContainer = '[data-testid="ethereum-wallet"]';
const ethWalletAssociatedBalances = const ethWalletAssociatedBalances =
'[data-testid="eth-wallet-associated-balances"]'; '[data-testid="eth-wallet-associated-balances"]';
@ -6,7 +5,7 @@ const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]'; const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
const vegaWalletUnstakedBalance = const vegaWalletUnstakedBalance =
'[data-testid="vega-wallet-balance-unstaked"]'; '[data-testid="vega-wallet-balance-unstaked"]';
const txTimeout = { timeout: 40000 }; const txTimeout = Cypress.env('txTimeout');
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort'); const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
const ethWalletAssociateButton = '[href="/staking/associate"]'; const ethWalletAssociateButton = '[href="/staking/associate"]';
const associateWalletRadioButton = '[data-testid="associate-radio-wallet"]'; 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 associatedKey = '[data-test-id="associated-key"]';
const associatedAmount = '[data-test-id="associated-amount"]'; const associatedAmount = '[data-test-id="associated-amount"]';
const disassocitiationWarning = '[data-testid="disassociation-warning"]'; const disassocitiationWarning = '[data-testid="disassociation-warning"]';
const vegaWallet = '[data-testid="vega-wallet"]';
context( context(
'Token association flow - with eth and vega wallets connected', 'Token association flow - with eth and vega wallets connected',
@ -33,7 +33,7 @@ context(
cy.ethereum_wallet_connect(); cy.ethereum_wallet_connect();
cy.navigate_to('staking'); cy.navigate_to('staking');
cy.wait_for_spinner(); cy.wait_for_spinner();
cy.get(validatorsGrid).should('be.visible'); cy.wait_for_begining_of_epoch();
}); });
describe('Eth wallet - contains VEGA tokens', function () { 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-0008
//1000-ASSO-0009 //1000-ASSO-0009
//1000-ASSO-0030 //1000-ASSO-0030
@ -66,12 +66,14 @@ context(
.contains('2.0', txTimeout) .contains('2.0', txTimeout)
.should('be.visible'); .should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get(vegaWalletUnstakedBalance, 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-0025
// 1000-ASSO-0027 // 1000-ASSO-0027
// 1000-ASSO-0028 // 1000-ASSO-0028
@ -90,15 +92,12 @@ context(
cy.get('button').contains('Select a validator to nominate').click(); 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) cy.get(ethWalletAssociatedBalances, txTimeout).should('not.exist');
.contains(vegaWalletPublicKeyShort)
.parent(txTimeout)
.should('contain', 1.0);
cy.get(ethWalletTotalAssociatedBalance, txTimeout) cy.get(ethWalletTotalAssociatedBalance, txTimeout)
.contains('1.0', txTimeout) .contains('0.00', txTimeout)
.should('be.visible'); .should('be.visible');
}); });
@ -115,16 +114,20 @@ context(
.contains('1,001.00', txTimeout) .contains('1,001.00', txTimeout)
.should('be.visible'); .should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should( cy.get(vegaWalletAssociatedBalance, txTimeout).should(
'contain', 'contain',
'1,001.000000000000000000' '1,001.000000000000000000'
); );
}); });
});
it('Able to disassociate a partial amount of tokens currently associated', function () { it('Able to disassociate a partial amount of tokens currently associated', function () {
cy.staking_page_associate_tokens('2'); cy.staking_page_associate_tokens('2');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get('button').contains('Select a validator to nominate').click(); cy.get('button').contains('Select a validator to nominate').click();
@ -140,17 +143,21 @@ context(
.parent(txTimeout) .parent(txTimeout)
.should('contain', 1.0); .should('contain', 1.0);
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 1.0); 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 // 1000-ASSO-0026
const warningText = 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.'; '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.staking_page_associate_tokens('2');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get('button').contains('Select a validator to nominate').click(); 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); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 0.0);
}); });
});
it('Able to associate and disassociate vesting contract tokens', function () { it('Able to associate and disassociate vesting contract tokens', function () {
// 1000-ASSO-0006 // 1000-ASSO-0006
@ -190,7 +199,9 @@ context(
.contains('2.0', txTimeout) .contains('2.0', txTimeout)
.should('be.visible'); .should('be.visible');
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
});
cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0); cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0);
cy.staking_page_disassociate_tokens('1', { type: 'contract' }); cy.staking_page_disassociate_tokens('1', { type: 'contract' });
@ -231,22 +242,30 @@ context(
cy.get(associatedAmount, txTimeout).should('contain', 21); cy.get(associatedAmount, txTimeout).should('contain', 21);
}); });
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 58); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 58);
});
cy.staking_page_disassociate_tokens('6', { type: 'contract' }); cy.staking_page_disassociate_tokens('6', { type: 'contract' });
cy.get(vestingContractSection).within(() => { cy.get(vestingContractSection).within(() => {
cy.get(associatedAmount, txTimeout).should('contain', 31); 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.staking_page_disassociate_tokens('9', { type: 'wallet' });
cy.get(vegaInWalletSection).within(() => { cy.get(vegaInWalletSection).within(() => {
cy.get(associatedAmount, txTimeout).should('contain', 12); cy.get(associatedAmount, txTimeout).should('contain', 12);
}); });
cy.get(vegaWallet).within(() => {
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 43); cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 43);
}); });
});
it('Not able to associate more tokens than owned', function () { it('Not able to associate more tokens than owned', function () {
// 1000-ASSO-0010 // 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( cy.contains('Waiting for next epoch to start', epochTimeout).should(
'not.exist' '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) => { Cypress.Commands.add('staking_validator_page_add_stake', (stake) => {