2022-07-27 12:46:02 +00:00
|
|
|
const validatorsGrid = '[data-testid="validators-grid"]';
|
2022-07-14 14:21:51 +00:00
|
|
|
const ethWalletContainer = '[data-testid="ethereum-wallet"]';
|
|
|
|
const ethWalletAssociatedBalances =
|
|
|
|
'[data-testid="eth-wallet-associated-balances"]';
|
|
|
|
const ethWalletTotalAssociatedBalance = '[data-testid="currency-locked"]';
|
|
|
|
const vegaWalletAssociatedBalance = '[data-testid="currency-value"]';
|
|
|
|
const vegaWalletUnstakedBalance =
|
|
|
|
'[data-testid="vega-wallet-balance-unstaked"]';
|
|
|
|
const txTimeout = { timeout: 40000 };
|
2022-07-08 10:48:51 +00:00
|
|
|
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
|
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
context(
|
|
|
|
'Token association flow - with eth and vega wallets connected',
|
|
|
|
function () {
|
|
|
|
before('visit staking tab and connect vega wallet', function () {
|
|
|
|
cy.vega_wallet_import();
|
|
|
|
cy.visit('/');
|
2022-07-14 14:21:51 +00:00
|
|
|
cy.verify_page_header('The $VEGA token');
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.vega_wallet_connect();
|
|
|
|
cy.vega_wallet_set_specified_approval_amount('1000');
|
|
|
|
cy.reload();
|
2022-07-14 14:21:51 +00:00
|
|
|
cy.verify_page_header('The $VEGA token');
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.ethereum_wallet_connect();
|
2022-07-13 15:23:51 +00:00
|
|
|
cy.navigate_to('staking');
|
2022-07-14 14:21:51 +00:00
|
|
|
cy.wait_for_spinner();
|
2022-07-27 12:46:02 +00:00
|
|
|
cy.get(validatorsGrid).should('be.visible');
|
2022-07-08 10:48:51 +00:00
|
|
|
});
|
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
describe('Eth wallet - contains VEGA tokens', function () {
|
|
|
|
beforeEach(
|
|
|
|
'teardown wallet & drill into a specific validator',
|
|
|
|
function () {
|
|
|
|
cy.vega_wallet_teardown();
|
2022-07-13 15:23:51 +00:00
|
|
|
cy.navigate_to('staking');
|
2022-07-14 14:21:51 +00:00
|
|
|
cy.wait_for_spinner();
|
2022-07-11 13:32:32 +00:00
|
|
|
}
|
2022-07-08 10:48:51 +00:00
|
|
|
);
|
|
|
|
|
2022-07-12 13:43:04 +00:00
|
|
|
it('Able to associate tokens', function () {
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.staking_page_associate_tokens('2');
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletAssociatedBalances, txTimeout)
|
|
|
|
.contains(vegaWalletPublicKeyShort)
|
2022-08-18 10:10:30 +00:00
|
|
|
.parent(txTimeout)
|
|
|
|
.should('contain', 2.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
|
|
|
|
.contains('2.0', txTimeout)
|
|
|
|
.should('be.visible');
|
|
|
|
|
2022-08-18 10:10:30 +00:00
|
|
|
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-08-18 10:10:30 +00:00
|
|
|
cy.get(vegaWalletUnstakedBalance, txTimeout).should('contain', 2.0);
|
2022-07-11 13:32:32 +00:00
|
|
|
});
|
2022-07-08 10:48:51 +00:00
|
|
|
|
2022-07-12 13:43:04 +00:00
|
|
|
it('Able to disassociate tokens', function () {
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.staking_page_associate_tokens('2');
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletAssociatedBalances, txTimeout)
|
|
|
|
.contains(vegaWalletPublicKeyShort)
|
2022-08-18 10:10:30 +00:00
|
|
|
.parent(txTimeout)
|
|
|
|
.should('contain', 2.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
|
|
|
|
.contains('2.0', txTimeout)
|
|
|
|
.should('be.visible');
|
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.get('button').contains('Select a validator to nominate').click();
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.staking_page_disassociate_tokens('1');
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletAssociatedBalances, txTimeout)
|
|
|
|
.contains(vegaWalletPublicKeyShort)
|
2022-08-18 10:10:30 +00:00
|
|
|
.parent(txTimeout)
|
|
|
|
.should('contain', 1.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
|
|
|
|
.contains('1.0', txTimeout)
|
|
|
|
.should('be.visible');
|
2022-07-11 13:32:32 +00:00
|
|
|
});
|
2022-07-08 10:48:51 +00:00
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
|
|
|
|
cy.staking_page_associate_tokens('1001', true);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletAssociatedBalances, txTimeout)
|
|
|
|
.contains(vegaWalletPublicKeyShort)
|
|
|
|
.parent()
|
|
|
|
.should('contain', '1,001.000000000000000000', txTimeout);
|
|
|
|
|
|
|
|
cy.get(ethWalletTotalAssociatedBalance, txTimeout)
|
|
|
|
.contains('1,001.00', txTimeout)
|
|
|
|
.should('be.visible');
|
|
|
|
|
|
|
|
cy.get(vegaWalletAssociatedBalance, txTimeout).should(
|
|
|
|
'contain',
|
2022-08-18 10:10:30 +00:00
|
|
|
'1,001.000000000000000000'
|
2022-07-11 13:32:32 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Able to disassociate a partial amount of tokens currently associated', function () {
|
|
|
|
cy.staking_page_associate_tokens('2');
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-08-18 10:10:30 +00:00
|
|
|
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.get('button').contains('Select a validator to nominate').click();
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.staking_page_disassociate_tokens('1');
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletAssociatedBalances, txTimeout)
|
|
|
|
.contains(vegaWalletPublicKeyShort)
|
2022-08-18 10:10:30 +00:00
|
|
|
.parent(txTimeout)
|
|
|
|
.should('contain', 1.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletAssociatedBalances, txTimeout)
|
|
|
|
.contains(vegaWalletPublicKeyShort)
|
2022-08-18 10:10:30 +00:00
|
|
|
.parent(txTimeout)
|
|
|
|
.should('contain', 1.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-08-18 10:10:30 +00:00
|
|
|
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 1.0);
|
2022-07-11 13:32:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Able to disassociate all tokens', function () {
|
|
|
|
cy.staking_page_associate_tokens('2');
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-08-18 10:10:30 +00:00
|
|
|
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 2.0);
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.get('button').contains('Select a validator to nominate').click();
|
2022-07-14 14:21:51 +00:00
|
|
|
|
2022-07-11 13:32:32 +00:00
|
|
|
cy.staking_page_disassociate_all_tokens();
|
2022-07-14 14:21:51 +00:00
|
|
|
|
|
|
|
cy.get(ethWalletContainer).within(() => {
|
|
|
|
cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should(
|
|
|
|
'not.exist'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
cy.get(ethWalletContainer).within(() => {
|
|
|
|
cy.contains(vegaWalletPublicKeyShort, { timeout: 20000 }).should(
|
|
|
|
'not.exist'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2022-08-18 10:10:30 +00:00
|
|
|
cy.get(vegaWalletAssociatedBalance, txTimeout).should('contain', 0.0);
|
2022-07-11 13:32:32 +00:00
|
|
|
});
|
2022-07-08 10:48:51 +00:00
|
|
|
});
|
2022-07-11 13:32:32 +00:00
|
|
|
}
|
|
|
|
);
|