test(token): eth wallet widget validations with wallet connected (#731)
* test(token): eth wallet widget validations with wallet connected * test(token): change currency tests to be more readable Co-authored-by: Rado <rado@vegaprotocol.io>
This commit is contained in:
parent
9cfcadd39b
commit
f9a91938fb
@ -18,6 +18,7 @@ module.exports = defineConfig({
|
||||
env: {
|
||||
ethProviderUrl: 'http://localhost:8545/',
|
||||
ethWalletPublicKey: '0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F',
|
||||
ethWalletPublicKeyTruncated: '0xEe7D…d94F',
|
||||
ethStakingBridgeContractAddress:
|
||||
'0x9135f5afd6F055e731bca2348429482eE614CFfA',
|
||||
vegaWalletName: 'capsule_wallet',
|
||||
|
@ -1,15 +1,15 @@
|
||||
/// <reference types="cypress" />
|
||||
import navigation from '../../locators/navigation.locators';
|
||||
import staking from '../../locators/staking.locators';
|
||||
import wallet from '../../locators/wallet.locators';
|
||||
import vegaWallet from '../../locators/wallet-vega.locators';
|
||||
import '../../support/staking.functions';
|
||||
import '../../support/vega-wallet.functions';
|
||||
import '../../support/eth-wallet.functions';
|
||||
import '../../support/wallet-vega.functions';
|
||||
import '../../support/wallet-eth.functions';
|
||||
import '../../support/wallet-teardown.functions';
|
||||
|
||||
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
|
||||
|
||||
context('Staking Tab - 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 () {
|
||||
cy.vega_wallet_import();
|
||||
cy.visit('/');
|
||||
@ -287,7 +287,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
|
||||
cy.highlight(
|
||||
`Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}`
|
||||
);
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.contains(`${validatorName} (Next epoch)`, { timeout: 40000 })
|
||||
.siblings()
|
||||
.contains(expectedVal, { timeout: 40000 })
|
||||
@ -302,7 +302,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
|
||||
cy.highlight(
|
||||
`Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}`
|
||||
);
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.contains(`${validatorName} (This Epoch)`, { timeout: 40000 })
|
||||
.siblings()
|
||||
.contains(expectedVal, { timeout: 40000 })
|
||||
@ -314,7 +314,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
|
||||
cy.highlight(
|
||||
`Checking Validator and therefore stake removed for ${validatorName}`
|
||||
);
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.contains(`${validatorName}`, { timeout: 40000 }).should('not.exist', {
|
||||
timeout: 40000,
|
||||
});
|
||||
@ -328,7 +328,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
|
||||
cy.highlight(
|
||||
`Checking Validator Stake Value for ${validatorName} is ${expectedVal}`
|
||||
);
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.contains(`${validatorName}`, { timeout: 40000 })
|
||||
.siblings()
|
||||
.contains(expectedVal, { timeout: 40000 })
|
||||
|
@ -1,118 +1,121 @@
|
||||
/// <reference types="cypress" />
|
||||
import navigation from '../../locators/navigation.locators';
|
||||
import staking from '../../locators/staking.locators';
|
||||
import wallet from '../../locators/wallet.locators';
|
||||
import ethWallet from '../../locators/wallet-eth.locators';
|
||||
import '../../support/staking.functions';
|
||||
import '../../support/vega-wallet.functions';
|
||||
import '../../support/eth-wallet.functions';
|
||||
import '../../support/wallet-vega.functions';
|
||||
import '../../support/wallet-eth.functions';
|
||||
import '../../support/wallet-teardown.functions';
|
||||
|
||||
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
|
||||
|
||||
context('Staking Tab - with eth and vega wallets connected', function () {
|
||||
before('visit staking tab and connect vega wallet', function () {
|
||||
cy.vega_wallet_import();
|
||||
cy.visit('/');
|
||||
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
|
||||
cy.vega_wallet_connect();
|
||||
cy.vega_wallet_set_specified_approval_amount('1000');
|
||||
cy.reload();
|
||||
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
|
||||
cy.ethereum_wallet_connect();
|
||||
cy.get(navigation.staking).first().click();
|
||||
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
|
||||
cy.get(staking.validatorNames).first().invoke('text').as('validatorName');
|
||||
});
|
||||
|
||||
describe('Eth wallet - contains VEGA tokens', function () {
|
||||
beforeEach(
|
||||
'teardown wallet & drill into a specific validator',
|
||||
function () {
|
||||
cy.vega_wallet_teardown();
|
||||
cy.get(navigation.staking).first().click();
|
||||
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
|
||||
}
|
||||
);
|
||||
|
||||
it('Able to associate tokens - from staking page', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'2.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('2.0');
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
|
||||
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('/');
|
||||
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
|
||||
cy.vega_wallet_connect();
|
||||
cy.vega_wallet_set_specified_approval_amount('1000');
|
||||
cy.reload();
|
||||
cy.get(navigation.section, { timeout: 20000 }).should('be.visible');
|
||||
cy.ethereum_wallet_connect();
|
||||
cy.get(navigation.staking).first().click();
|
||||
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
|
||||
cy.get(staking.validatorNames).first().invoke('text').as('validatorName');
|
||||
});
|
||||
|
||||
it('Able to disassociate tokens - from staking page', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'2.000000000000000000'
|
||||
describe('Eth wallet - contains VEGA tokens', function () {
|
||||
beforeEach(
|
||||
'teardown wallet & drill into a specific validator',
|
||||
function () {
|
||||
cy.vega_wallet_teardown();
|
||||
cy.get(navigation.staking).first().click();
|
||||
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
|
||||
}
|
||||
);
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.get('button').contains('Select a validator to nominate').click();
|
||||
cy.staking_page_disassociate_tokens('1');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'1.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('1.0');
|
||||
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
|
||||
});
|
||||
|
||||
it('Able to access associate token form - from eth wallet', function () {
|
||||
cy.get(wallet.ethWallet).within(() =>
|
||||
cy.get(wallet.ethWalletAssociate).click()
|
||||
);
|
||||
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should(
|
||||
'be.enabled'
|
||||
);
|
||||
});
|
||||
it('Able to associate tokens - from staking page', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'2.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('2.0');
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
|
||||
});
|
||||
|
||||
it('Able to access disassociate token form - from eth wallet', function () {
|
||||
cy.get(wallet.ethWallet).within(() =>
|
||||
cy.get(wallet.ethWalletDisassociate).click()
|
||||
);
|
||||
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should(
|
||||
'be.enabled'
|
||||
);
|
||||
});
|
||||
it('Able to disassociate tokens - from staking page', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'2.000000000000000000'
|
||||
);
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.get('button').contains('Select a validator to nominate').click();
|
||||
cy.staking_page_disassociate_tokens('1');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'1.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('1.0');
|
||||
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
|
||||
});
|
||||
|
||||
it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
|
||||
cy.staking_page_associate_tokens('1001', true);
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'1,001.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('1,001.00');
|
||||
cy.vega_wallet_check_associated_value_is('1,001.000000000000000000');
|
||||
});
|
||||
it('Able to access associate token form - from eth wallet', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() =>
|
||||
cy.get(ethWallet.associate).click()
|
||||
);
|
||||
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should(
|
||||
'be.enabled'
|
||||
);
|
||||
});
|
||||
|
||||
it('Able to disassociate a partial amount of tokens currently associated', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.get('button').contains('Select a validator to nominate').click();
|
||||
cy.staking_page_disassociate_tokens('1');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'1.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('1.0');
|
||||
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
|
||||
});
|
||||
it('Able to access disassociate token form - from eth wallet', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() =>
|
||||
cy.get(ethWallet.disassociate).click()
|
||||
);
|
||||
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should(
|
||||
'be.enabled'
|
||||
);
|
||||
});
|
||||
|
||||
it('Able to disassociate all tokens', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.get('button').contains('Select a validator to nominate').click();
|
||||
cy.staking_page_disassociate_all_tokens();
|
||||
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
|
||||
vegaWalletPublicKeyShort
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('0.0');
|
||||
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
|
||||
it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
|
||||
cy.staking_page_associate_tokens('1001', true);
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'1,001.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('1,001.00');
|
||||
cy.vega_wallet_check_associated_value_is('1,001.000000000000000000');
|
||||
});
|
||||
|
||||
it('Able to disassociate a partial amount of tokens currently associated', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.get('button').contains('Select a validator to nominate').click();
|
||||
cy.staking_page_disassociate_tokens('1');
|
||||
cy.ethereum_wallet_check_associated_vega_key_value_is(
|
||||
vegaWalletPublicKeyShort,
|
||||
'1.000000000000000000'
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('1.0');
|
||||
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
|
||||
});
|
||||
|
||||
it('Able to disassociate all tokens', function () {
|
||||
cy.staking_page_associate_tokens('2');
|
||||
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
|
||||
cy.get('button').contains('Select a validator to nominate').click();
|
||||
cy.staking_page_disassociate_all_tokens();
|
||||
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
|
||||
vegaWalletPublicKeyShort
|
||||
);
|
||||
cy.ethereum_wallet_check_associated_value_is('0.0');
|
||||
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
241
apps/token-e2e/src/integration/wallet-eth.cy.js
Normal file
241
apps/token-e2e/src/integration/wallet-eth.cy.js
Normal file
@ -0,0 +1,241 @@
|
||||
import ethWallet from '../locators/wallet-eth.locators';
|
||||
import '../support/wallet-eth.functions';
|
||||
|
||||
context('Ethereum Wallet - verify elements on widget', function () {
|
||||
before('visit token home page', function () {
|
||||
cy.visit('/');
|
||||
});
|
||||
|
||||
describe('with wallets disconnected', function () {
|
||||
before('wait for widget to load', function () {
|
||||
cy.get(ethWallet.walletContainer, { timeout: 10000 }).should(
|
||||
'be.visible'
|
||||
);
|
||||
});
|
||||
|
||||
it('should have ETHEREUM KEY header visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.walletHeader)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Ethereum key');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have Connect Ethereum button visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.connectToEthButton)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Connect Ethereum wallet to associate $VEGA');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when Connect Ethereum clicked', function () {
|
||||
before('', function () {
|
||||
cy.get(ethWallet.connectToEthButton).click();
|
||||
});
|
||||
|
||||
it('should have Connect Ethereum header visible', function () {
|
||||
cy.get(ethWallet.dialog).within(() => {
|
||||
cy.get(ethWallet.dialogHeader)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Connect to your Ethereum wallet');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have connector list visible', function () {
|
||||
const connectList = [
|
||||
'Unknown',
|
||||
'MetaMask, Brave or other injected web wallet',
|
||||
'WalletConnect',
|
||||
];
|
||||
cy.get(ethWallet.connectorList).within(() => {
|
||||
cy.get('button').each(($btn, i) => {
|
||||
cy.wrap($btn).should('be.visible').and('have.text', connectList[i]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
after('close popup', function () {
|
||||
cy.get(ethWallet.dialog)
|
||||
.within(() => {
|
||||
cy.get(ethWallet.dialogCloseBtn).click();
|
||||
})
|
||||
.should('not.exist');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when Ethereum wallet connected', function () {
|
||||
before('connect to Ethereum wallet', function () {
|
||||
cy.ethereum_wallet_connect();
|
||||
});
|
||||
|
||||
it('should have ETHEREUM KEY header visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.walletHeader)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Ethereum key');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have account number visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.accountNo)
|
||||
.should('be.visible')
|
||||
.and('have.text', Cypress.env('ethWalletPublicKeyTruncated'));
|
||||
});
|
||||
});
|
||||
|
||||
it('should have Associate button visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.associate)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Associate');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have Disassociate button visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.disassociate)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Disassociate');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have Disconnect button visible', function () {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.get(ethWallet.disconnect)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'Disconnect');
|
||||
});
|
||||
});
|
||||
|
||||
describe('VEGA IN VESTING CONTRACT', function () {
|
||||
it('should have currency title visible', function () {
|
||||
cy.get(ethWallet.vegaInVesting).within(() => {
|
||||
cy.get(ethWallet.currencyTitle)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'VEGAIn vesting contract');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have currency value visible', function () {
|
||||
cy.get(ethWallet.vegaInVesting).within(() => {
|
||||
cy.get(ethWallet.currencyValue)
|
||||
.should('be.visible')
|
||||
.invoke('text')
|
||||
.should('match', /\d{0,3}(,\d{3})*\.\d{18}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have progress bar visible', function () {
|
||||
cy.get(ethWallet.vegaInVesting).within(() => {
|
||||
cy.get(ethWallet.progressBar).should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have locked currency visible', function () {
|
||||
cy.get(ethWallet.vegaInVesting).within(() => {
|
||||
cy.get(ethWallet.currencyLocked)
|
||||
.should('be.visible')
|
||||
.invoke('text')
|
||||
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have unlocked currency visible', function () {
|
||||
cy.get(ethWallet.vegaInVesting).within(() => {
|
||||
cy.get(ethWallet.currencyUnlocked)
|
||||
.should('be.visible')
|
||||
.invoke('text')
|
||||
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should match total & locked/unlocked currency value', function () {
|
||||
cy.get(ethWallet.vegaInVesting)
|
||||
.within(() => {
|
||||
cy.get(ethWallet.currencyValue)
|
||||
.invoke('text')
|
||||
.convertTokenValueToNumber()
|
||||
.as('value');
|
||||
cy.get(ethWallet.currencyLocked)
|
||||
.invoke('text')
|
||||
.convertTokenValueToNumber()
|
||||
.as('locked');
|
||||
cy.get(ethWallet.currencyUnlocked)
|
||||
.invoke('text')
|
||||
.convertTokenValueToNumber()
|
||||
.as('unlocked');
|
||||
})
|
||||
.then(function () {
|
||||
expect(this.value).to.equal(this.locked + this.unlocked);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('VEGA IN WALLET', function () {
|
||||
it('should have currency title visible', function () {
|
||||
cy.get(ethWallet.vegaInWallet).within(() => {
|
||||
cy.get(ethWallet.currencyTitle)
|
||||
.should('be.visible')
|
||||
.and('have.text', 'VEGAIn Wallet');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have currency value visible', function () {
|
||||
cy.get(ethWallet.vegaInWallet).within(() => {
|
||||
cy.get(ethWallet.currencyValue)
|
||||
.should('be.visible')
|
||||
.invoke('text')
|
||||
.should('match', /\d{0,3}(,\d{3})*\.\d{18}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have progress bar visible', function () {
|
||||
cy.get(ethWallet.vegaInWallet).within(() => {
|
||||
cy.get(ethWallet.progressBar).should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have locked currency visible', function () {
|
||||
cy.get(ethWallet.vegaInWallet).within(() => {
|
||||
cy.get(ethWallet.currencyLocked)
|
||||
.should('be.visible')
|
||||
.invoke('text')
|
||||
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have unlocked currency visible', function () {
|
||||
cy.get(ethWallet.vegaInWallet).within(() => {
|
||||
cy.get(ethWallet.currencyUnlocked)
|
||||
.should('be.visible')
|
||||
.invoke('text')
|
||||
.should('match', /\d{0,3}(,\d{3})*\.\d{2}$/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should match total & locked/unlocked currency value', function () {
|
||||
cy.get(ethWallet.vegaInWallet)
|
||||
.within(() => {
|
||||
cy.get(ethWallet.currencyValue)
|
||||
.invoke('text')
|
||||
.convertTokenValueToNumber()
|
||||
.as('value');
|
||||
cy.get(ethWallet.currencyLocked)
|
||||
.invoke('text')
|
||||
.convertTokenValueToNumber()
|
||||
.as('locked');
|
||||
cy.get(ethWallet.currencyUnlocked)
|
||||
.invoke('text')
|
||||
.convertTokenValueToNumber()
|
||||
.as('unlocked');
|
||||
})
|
||||
.then(function () {
|
||||
expect(this.value).to.equal(this.locked + this.unlocked);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -4,4 +4,7 @@ export default {
|
||||
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"]',
|
||||
};
|
||||
|
21
apps/token-e2e/src/locators/wallet-eth.locators.js
Normal file
21
apps/token-e2e/src/locators/wallet-eth.locators.js
Normal file
@ -0,0 +1,21 @@
|
||||
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"]',
|
||||
};
|
9
apps/token-e2e/src/locators/wallet-vega.locators.js
Normal file
9
apps/token-e2e/src/locators/wallet-vega.locators.js
Normal file
@ -0,0 +1,9 @@
|
||||
import common from './common.locators';
|
||||
|
||||
export default {
|
||||
...common,
|
||||
walletContainer: '[data-testid="vega-wallet"]',
|
||||
connectRestForm: '[data-testid="rest-connector-form"]',
|
||||
name: '#wallet',
|
||||
passphrase: '#passphrase',
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
import common from './common.locators';
|
||||
|
||||
export default {
|
||||
...common,
|
||||
connectRestForm: '[data-testid="rest-connector-form"]',
|
||||
name: '#wallet',
|
||||
passphrase: '#passphrase',
|
||||
vegawallet: '[data-testid="vega-wallet"]',
|
||||
ethWallet: '[data-testid="ethereum-wallet"]',
|
||||
ethWalletConnectToEth: '[data-testid="connect-to-eth-wallet-button"]',
|
||||
ethWalletConnect: '[data-testid="web3-connector-Unknown"]',
|
||||
ethWalletAssociate: '[href="/staking/associate"]',
|
||||
ethWalletDisassociate: '[href="/staking/disassociate"]',
|
||||
};
|
@ -1,15 +1,15 @@
|
||||
import wallet from '../locators/wallet.locators';
|
||||
import ethWallet from '../locators/wallet-eth.locators';
|
||||
|
||||
cy.ethereum_wallet_connect = () => {
|
||||
cy.highlight('Connecting Eth Wallet');
|
||||
cy.get(wallet.ethWalletConnectToEth).within(() => {
|
||||
cy.get(ethWallet.connectToEthButton).within(() => {
|
||||
cy.contains('Connect Ethereum wallet to associate $VEGA')
|
||||
.should('be.visible')
|
||||
.click();
|
||||
});
|
||||
cy.get(wallet.ethWalletConnect).click();
|
||||
cy.get(wallet.ethWalletConnect, { timeout: 60000 }).should('not.exist');
|
||||
cy.get(wallet.ethWallet).within(() => {
|
||||
cy.get(ethWallet.connectorCapsule).click();
|
||||
cy.get(ethWallet.connectorCapsule, { timeout: 60000 }).should('not.exist');
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
// this check is required since it ensures the wallet is fully (not partially) loaded
|
||||
cy.contains('Locked', { timeout: 15000 }).should('be.visible');
|
||||
});
|
||||
@ -17,7 +17,7 @@ cy.ethereum_wallet_connect = () => {
|
||||
|
||||
cy.ethereum_wallet_check_associated_value_is = (expectedVal) => {
|
||||
cy.highlight(`Checking Eth Wallet - Associated Value is ${expectedVal}`);
|
||||
cy.get(wallet.ethWallet).within(() => {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.contains('Associated', { timeout: 20000 })
|
||||
.parent()
|
||||
.siblings()
|
||||
@ -33,7 +33,7 @@ cy.ethereum_wallet_check_associated_vega_key_value_is = (
|
||||
cy.highlight(
|
||||
`Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}`
|
||||
);
|
||||
cy.get(wallet.ethWallet).within(() => {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.contains(vegaShortPublicKey, { timeout: 20000 })
|
||||
.parent()
|
||||
.contains(expectedVal, { timeout: 40000 })
|
||||
@ -45,7 +45,15 @@ cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing = (
|
||||
vegaShortPublicKey
|
||||
) => {
|
||||
cy.highlight('Checking Eth Wallet - Vega Key Associated is not showing');
|
||||
cy.get(wallet.ethWallet).within(() => {
|
||||
cy.get(ethWallet.walletContainer).within(() => {
|
||||
cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist');
|
||||
});
|
||||
};
|
||||
|
||||
Cypress.Commands.add(
|
||||
'convertTokenValueToNumber',
|
||||
{ prevSubject: true },
|
||||
(subject) => {
|
||||
return parseFloat(subject.replace(/,/g, ''));
|
||||
}
|
||||
);
|
@ -1,4 +1,4 @@
|
||||
import wallet from '../locators/wallet.locators';
|
||||
import vegaWallet from '../locators/wallet-vega.locators';
|
||||
|
||||
const vegaWalletName = Cypress.env('vegaWalletName');
|
||||
const vegaWalletLocation = Cypress.env('vegaWalletLocation');
|
||||
@ -18,7 +18,7 @@ cy.vega_wallet_import = () => {
|
||||
|
||||
cy.vega_wallet_connect = () => {
|
||||
cy.highlight('Connecting Vega Wallet');
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.get('button')
|
||||
.contains('Connect Vega wallet to use associated $VEGA')
|
||||
.should('be.enabled')
|
||||
@ -26,9 +26,9 @@ cy.vega_wallet_connect = () => {
|
||||
.click({ force: true });
|
||||
});
|
||||
cy.get('button').contains('rest provider').click();
|
||||
cy.get(wallet.connectRestForm).within(() => {
|
||||
cy.get(wallet.name).click().type(vegaWalletName);
|
||||
cy.get(wallet.passphrase).click().type(vegaWalletPassphrase);
|
||||
cy.get(vegaWallet.connectRestForm).within(() => {
|
||||
cy.get(vegaWallet.name).click().type(vegaWalletName);
|
||||
cy.get(vegaWallet.passphrase).click().type(vegaWalletPassphrase);
|
||||
cy.get('button').contains('Connect').click();
|
||||
});
|
||||
cy.contains(`${vegaWalletName} key`, { timeout: 20000 }).should('be.visible');
|
||||
@ -36,7 +36,7 @@ cy.vega_wallet_connect = () => {
|
||||
|
||||
cy.vega_wallet_check_unstaked_value_is = (expectedVal) => {
|
||||
cy.highlight(`Checking vega wallet - Unstaked Value is ${expectedVal}`);
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.contains('Unstaked', { timeout: 40000 })
|
||||
.siblings()
|
||||
.contains(expectedVal, { timeout: 40000 })
|
||||
@ -46,7 +46,7 @@ cy.vega_wallet_check_unstaked_value_is = (expectedVal) => {
|
||||
|
||||
cy.vega_wallet_check_associated_value_is = (expectedVal) => {
|
||||
cy.highlight(`Checking vega wallet - Associated Value is ${expectedVal}`);
|
||||
cy.get(wallet.vegawallet).within(() => {
|
||||
cy.get(vegaWallet.walletContainer).within(() => {
|
||||
cy.contains('Associated', { timeout: 40000 })
|
||||
.parent()
|
||||
.siblings()
|
@ -128,7 +128,7 @@ const ConnectedKey = () => {
|
||||
return (
|
||||
<>
|
||||
{totalVestedBalance.plus(totalLockedBalance).isEqualTo(0) ? null : (
|
||||
<>
|
||||
<section data-testid="vega-in-vesting-contract">
|
||||
<WalletCardAsset
|
||||
image={vegaVesting}
|
||||
decimals={appState.decimals}
|
||||
@ -145,7 +145,7 @@ const ConnectedKey = () => {
|
||||
rightLabel={t('Unlocked')}
|
||||
light={false}
|
||||
/>
|
||||
</>
|
||||
</section>
|
||||
)}
|
||||
{!Object.keys(appState.associationBreakdown.vestingAssociations)
|
||||
.length ? null : (
|
||||
@ -154,22 +154,24 @@ const ConnectedKey = () => {
|
||||
notAssociated={notAssociatedInContract}
|
||||
/>
|
||||
)}
|
||||
<WalletCardAsset
|
||||
image={vegaWhite}
|
||||
decimals={appState.decimals}
|
||||
name="VEGA"
|
||||
symbol="In Wallet"
|
||||
balance={walletWithAssociations}
|
||||
dark={true}
|
||||
/>
|
||||
{!Object.keys(
|
||||
appState.associationBreakdown.stakingAssociations
|
||||
) ? null : (
|
||||
<AssociatedAmounts
|
||||
associations={appState.associationBreakdown.stakingAssociations}
|
||||
notAssociated={walletBalance}
|
||||
<section data-testid="vega-in-wallet">
|
||||
<WalletCardAsset
|
||||
image={vegaWhite}
|
||||
decimals={appState.decimals}
|
||||
name="VEGA"
|
||||
symbol="In Wallet"
|
||||
balance={walletWithAssociations}
|
||||
dark={true}
|
||||
/>
|
||||
)}
|
||||
{!Object.keys(
|
||||
appState.associationBreakdown.stakingAssociations
|
||||
) ? null : (
|
||||
<AssociatedAmounts
|
||||
associations={appState.associationBreakdown.stakingAssociations}
|
||||
notAssociated={walletBalance}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
<WalletCardActions>
|
||||
<Link
|
||||
className={getButtonClasses('flex-1 mr-4', 'secondary')}
|
||||
@ -201,7 +203,12 @@ export const EthWallet = () => {
|
||||
<h1 className="text-h3 uppercase">{t('ethereumKey')}</h1>
|
||||
{account && (
|
||||
<div className="px-4 text-right">
|
||||
<div className="font-mono">{truncateMiddle(account)}</div>
|
||||
<div
|
||||
className="font-mono"
|
||||
data-testid="ethereum-account-truncated"
|
||||
>
|
||||
{truncateMiddle(account)}
|
||||
</div>
|
||||
{pendingTxs && (
|
||||
<div>
|
||||
<button
|
||||
@ -245,6 +252,7 @@ export const EthWallet = () => {
|
||||
<button
|
||||
className="mt-4 underline"
|
||||
onClick={() => connector.deactivate()}
|
||||
data-testid="disconnect-from-eth-wallet-button"
|
||||
>
|
||||
{t('disconnect')}
|
||||
</button>
|
||||
|
@ -99,6 +99,7 @@ export const LockedProgress = ({
|
||||
'border-black': light,
|
||||
'border-white': !light,
|
||||
})}
|
||||
data-testid="progress-bar"
|
||||
>
|
||||
<ProgressBar percentage={lockedPercentage} bgColor={leftColor} />
|
||||
<ProgressBar percentage={unlockedPercentage} bgColor={rightColor} />
|
||||
@ -119,8 +120,12 @@ export const LockedProgress = ({
|
||||
</ProgressContents>
|
||||
|
||||
<ProgressContents light={light}>
|
||||
<span>{formatNumber(locked, decimals)}</span>
|
||||
<span>{formatNumber(unlocked, decimals)}</span>
|
||||
<span data-testid="currency-locked">
|
||||
{formatNumber(locked, decimals)}
|
||||
</span>
|
||||
<span data-testid="currency-unlocked">
|
||||
{formatNumber(unlocked, decimals)}
|
||||
</span>
|
||||
</ProgressContents>
|
||||
</div>
|
||||
);
|
||||
|
@ -47,7 +47,10 @@ interface WalletCardHeaderProps {
|
||||
|
||||
export const WalletCardHeader = ({ children }: WalletCardHeaderProps) => {
|
||||
return (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-[auto_1fr] gap-4">
|
||||
<div
|
||||
className="grid grid-cols-1 sm:grid-cols-[auto_1fr] gap-4"
|
||||
data-testid="wallet-header"
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
@ -151,7 +154,10 @@ export const WalletCardAsset = ({
|
||||
}`}
|
||||
/>
|
||||
<div>
|
||||
<div className="flex font-medium align-center">
|
||||
<div
|
||||
className="flex font-medium align-center"
|
||||
data-testid="currency-title"
|
||||
>
|
||||
<h1
|
||||
className={`text-h5 mb-0 px-8 uppercase leading-none ${
|
||||
dark ? 'text-white' : 'text-black'
|
||||
@ -167,7 +173,10 @@ export const WalletCardAsset = ({
|
||||
{subheading || symbol}
|
||||
</h2>
|
||||
</div>
|
||||
<div className="px-8 text-h5 basis-full font-mono">
|
||||
<div
|
||||
className="px-8 text-h5 basis-full font-mono"
|
||||
data-testid="currency-value"
|
||||
>
|
||||
<span>{integers}.</span>
|
||||
<span className={dark ? 'text-white-60' : 'text-black-60'}>
|
||||
{decimalsPlaces}
|
||||
|
@ -53,6 +53,7 @@ export function Dialog({
|
||||
{title && (
|
||||
<h1
|
||||
className={`text-h5 text-black-95 dark:text-white-95 mt-0 mb-20 ${titleClassNames}`}
|
||||
data-testid="dialog-title"
|
||||
>
|
||||
{title}
|
||||
</h1>
|
||||
|
Loading…
Reference in New Issue
Block a user