From f9a91938fb94fd796194b3b088422317cb18d9d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Mon, 11 Jul 2022 15:32:32 +0200 Subject: [PATCH] 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 --- apps/token-e2e/cypress.config.js | 1 + .../src/integration/flow/staking-flow.cy.js | 16 +- .../flow/token-association-flow.cy.js | 205 +++++++-------- .../src/integration/wallet-eth.cy.js | 241 ++++++++++++++++++ .../token-e2e/src/locators/common.locators.js | 3 + .../src/locators/wallet-eth.locators.js | 21 ++ .../src/locators/wallet-vega.locators.js | 9 + .../token-e2e/src/locators/wallet.locators.js | 14 - ...t.functions.js => wallet-eth.functions.js} | 24 +- ....functions.js => wallet-vega.functions.js} | 14 +- .../src/components/eth-wallet/eth-wallet.tsx | 44 ++-- .../locked-progress/locked-progress.tsx | 9 +- .../components/wallet-card/wallet-card.tsx | 15 +- .../src/components/dialog/dialog.tsx | 1 + 14 files changed, 456 insertions(+), 161 deletions(-) create mode 100644 apps/token-e2e/src/integration/wallet-eth.cy.js create mode 100644 apps/token-e2e/src/locators/wallet-eth.locators.js create mode 100644 apps/token-e2e/src/locators/wallet-vega.locators.js delete mode 100644 apps/token-e2e/src/locators/wallet.locators.js rename apps/token-e2e/src/support/{eth-wallet.functions.js => wallet-eth.functions.js} (68%) rename apps/token-e2e/src/support/{vega-wallet.functions.js => wallet-vega.functions.js} (81%) diff --git a/apps/token-e2e/cypress.config.js b/apps/token-e2e/cypress.config.js index 6cd68facd..0a2bcad52 100644 --- a/apps/token-e2e/cypress.config.js +++ b/apps/token-e2e/cypress.config.js @@ -18,6 +18,7 @@ module.exports = defineConfig({ env: { ethProviderUrl: 'http://localhost:8545/', ethWalletPublicKey: '0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F', + ethWalletPublicKeyTruncated: '0xEe7D…d94F', ethStakingBridgeContractAddress: '0x9135f5afd6F055e731bca2348429482eE614CFfA', vegaWalletName: 'capsule_wallet', diff --git a/apps/token-e2e/src/integration/flow/staking-flow.cy.js b/apps/token-e2e/src/integration/flow/staking-flow.cy.js index 87e094505..3f9cb8915 100644 --- a/apps/token-e2e/src/integration/flow/staking-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/staking-flow.cy.js @@ -1,15 +1,15 @@ /// 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 }) diff --git a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js index ece1e8aa7..a4a967be8 100644 --- a/apps/token-e2e/src/integration/flow/token-association-flow.cy.js +++ b/apps/token-e2e/src/integration/flow/token-association-flow.cy.js @@ -1,118 +1,121 @@ /// 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'); + }); }); - }); -}); + } +); diff --git a/apps/token-e2e/src/integration/wallet-eth.cy.js b/apps/token-e2e/src/integration/wallet-eth.cy.js new file mode 100644 index 000000000..a0f7e64ad --- /dev/null +++ b/apps/token-e2e/src/integration/wallet-eth.cy.js @@ -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); + }); + }); + }); + }); +}); diff --git a/apps/token-e2e/src/locators/common.locators.js b/apps/token-e2e/src/locators/common.locators.js index 11eee5f21..77a133286 100644 --- a/apps/token-e2e/src/locators/common.locators.js +++ b/apps/token-e2e/src/locators/common.locators.js @@ -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"]', }; diff --git a/apps/token-e2e/src/locators/wallet-eth.locators.js b/apps/token-e2e/src/locators/wallet-eth.locators.js new file mode 100644 index 000000000..ca15fac6b --- /dev/null +++ b/apps/token-e2e/src/locators/wallet-eth.locators.js @@ -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"]', +}; diff --git a/apps/token-e2e/src/locators/wallet-vega.locators.js b/apps/token-e2e/src/locators/wallet-vega.locators.js new file mode 100644 index 000000000..0be69d700 --- /dev/null +++ b/apps/token-e2e/src/locators/wallet-vega.locators.js @@ -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', +}; diff --git a/apps/token-e2e/src/locators/wallet.locators.js b/apps/token-e2e/src/locators/wallet.locators.js deleted file mode 100644 index 94371a8aa..000000000 --- a/apps/token-e2e/src/locators/wallet.locators.js +++ /dev/null @@ -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"]', -}; diff --git a/apps/token-e2e/src/support/eth-wallet.functions.js b/apps/token-e2e/src/support/wallet-eth.functions.js similarity index 68% rename from apps/token-e2e/src/support/eth-wallet.functions.js rename to apps/token-e2e/src/support/wallet-eth.functions.js index 451c39b1e..da6fcfb97 100644 --- a/apps/token-e2e/src/support/eth-wallet.functions.js +++ b/apps/token-e2e/src/support/wallet-eth.functions.js @@ -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, '')); + } +); diff --git a/apps/token-e2e/src/support/vega-wallet.functions.js b/apps/token-e2e/src/support/wallet-vega.functions.js similarity index 81% rename from apps/token-e2e/src/support/vega-wallet.functions.js rename to apps/token-e2e/src/support/wallet-vega.functions.js index ef350181e..684df9d66 100644 --- a/apps/token-e2e/src/support/vega-wallet.functions.js +++ b/apps/token-e2e/src/support/wallet-vega.functions.js @@ -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() diff --git a/apps/token/src/components/eth-wallet/eth-wallet.tsx b/apps/token/src/components/eth-wallet/eth-wallet.tsx index 63e97b8af..509542acc 100644 --- a/apps/token/src/components/eth-wallet/eth-wallet.tsx +++ b/apps/token/src/components/eth-wallet/eth-wallet.tsx @@ -128,7 +128,7 @@ const ConnectedKey = () => { return ( <> {totalVestedBalance.plus(totalLockedBalance).isEqualTo(0) ? null : ( - <> +
{ rightLabel={t('Unlocked')} light={false} /> - +
)} {!Object.keys(appState.associationBreakdown.vestingAssociations) .length ? null : ( @@ -154,22 +154,24 @@ const ConnectedKey = () => { notAssociated={notAssociatedInContract} /> )} - - {!Object.keys( - appState.associationBreakdown.stakingAssociations - ) ? null : ( - + - )} + {!Object.keys( + appState.associationBreakdown.stakingAssociations + ) ? null : ( + + )} + {

{t('ethereumKey')}

{account && (
-
{truncateMiddle(account)}
+
+ {truncateMiddle(account)} +
{pendingTxs && (
diff --git a/apps/token/src/components/locked-progress/locked-progress.tsx b/apps/token/src/components/locked-progress/locked-progress.tsx index 2101e48ab..37fe0c5c2 100644 --- a/apps/token/src/components/locked-progress/locked-progress.tsx +++ b/apps/token/src/components/locked-progress/locked-progress.tsx @@ -99,6 +99,7 @@ export const LockedProgress = ({ 'border-black': light, 'border-white': !light, })} + data-testid="progress-bar" > @@ -119,8 +120,12 @@ export const LockedProgress = ({ - {formatNumber(locked, decimals)} - {formatNumber(unlocked, decimals)} + + {formatNumber(locked, decimals)} + + + {formatNumber(unlocked, decimals)} +
); diff --git a/apps/token/src/components/wallet-card/wallet-card.tsx b/apps/token/src/components/wallet-card/wallet-card.tsx index 0313decd3..9ea5b6c80 100644 --- a/apps/token/src/components/wallet-card/wallet-card.tsx +++ b/apps/token/src/components/wallet-card/wallet-card.tsx @@ -47,7 +47,10 @@ interface WalletCardHeaderProps { export const WalletCardHeader = ({ children }: WalletCardHeaderProps) => { return ( -
+
{children}
); @@ -151,7 +154,10 @@ export const WalletCardAsset = ({ }`} />
-
+

-
+
{integers}. {decimalsPlaces} diff --git a/libs/ui-toolkit/src/components/dialog/dialog.tsx b/libs/ui-toolkit/src/components/dialog/dialog.tsx index e6bf068b7..09f15aa88 100644 --- a/libs/ui-toolkit/src/components/dialog/dialog.tsx +++ b/libs/ui-toolkit/src/components/dialog/dialog.tsx @@ -53,6 +53,7 @@ export function Dialog({ {title && (

{title}