From 72d9e560215f259a28bc831ad29bff0d35ecf561 Mon Sep 17 00:00:00 2001 From: Florian Date: Wed, 22 May 2024 19:11:07 +0200 Subject: [PATCH] Extract Cypress (#368) * Update Cypress * Fix cypress tests * Cleanup the delete account flow * Cleanup the hooks flow * Cleanup the networks flow * Cleanup the NFTs flow * Cleanup the offers flow * Cleanup the payments flow * Cleanup the receive flow * Cleanup the send token flow * Cleanup the set account flow * Cleanup the set regular key flow * Cleanup the sign transaction flow * Cleanup the submit raw transaction flow * Cleanup the submit transaction flow * Cleanup the submit transaction bulk flow * Cleanup the trustlines flow * Cleanup the xahau flow * Rename variable for local storage wallets * Update gitignore * Update naming for the environment variables * Update the pipeline --- .github/workflows/integration.yml | 8 + packages/extension/.gitignore | 4 + packages/extension/cypress/e2e/NFT.cy.ts | 26 ++-- .../cypress/e2e/delete_account.cy.ts | 50 ++---- packages/extension/cypress/e2e/hooks.cy.ts | 13 +- packages/extension/cypress/e2e/networks.cy.ts | 37 +---- packages/extension/cypress/e2e/offers.cy.ts | 31 ++-- packages/extension/cypress/e2e/payments.cy.ts | 63 ++++---- packages/extension/cypress/e2e/receive.cy.ts | 46 +----- .../extension/cypress/e2e/send_token.cy.ts | 69 +++------ .../extension/cypress/e2e/set_account.cy.ts | 10 +- .../cypress/e2e/set_regular_key.cy.ts | 9 +- .../cypress/e2e/sign_transaction.cy.ts | 19 ++- .../cypress/e2e/submit_raw_json_tx.cy.ts | 12 +- .../cypress/e2e/submit_transaction.cy.ts | 23 ++- .../e2e/submit_transactions_bulk.cy.ts | 23 ++- .../extension/cypress/e2e/trustlines.cy.ts | 47 +++--- .../cypress/e2e/wallet_management.cy.ts | 143 ++++-------------- packages/extension/cypress/e2e/xahau.cy.ts | 9 +- .../extension/cypress/utils/navigation.ts | 16 +- packages/extension/package.json | 2 +- yarn.lock | 16 +- 22 files changed, 233 insertions(+), 443 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index e545ec8e7..90c991f2c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -70,3 +70,11 @@ jobs: browser: chrome config-file: cypress.config.ts working-directory: packages/extension + env: + CYPRESS_DEFAULT_WALLET_ADDRESS: ${{vars.CYPRESS_DEFAULT_WALLET_ADDRESS}} + CYPRESS_ISSUER_ETH_ADDRESS: ${{vars.CYPRESS_ISSUER_ETH_ADDRESS}} + CYPRESS_ISSUER_SOLO_ADDRESS: ${{vars.CYPRESS_ISSUER_SOLO_ADDRESS}} + CYPRESS_LOCAL_STORAGE_WALLETS: ${{vars.CYPRESS_LOCAL_STORAGE_WALLETS}} + CYPRESS_MNEMONIC: ${{vars.CYPRESS_MNEMONIC}} + CYPRESS_PASSWORD: ${{vars.CYPRESS_PASSWORD}} + CYPRESS_SEED: ${{vars.CYPRESS_SEED}} diff --git a/packages/extension/.gitignore b/packages/extension/.gitignore index 41f27973e..15c5e1814 100644 --- a/packages/extension/.gitignore +++ b/packages/extension/.gitignore @@ -30,3 +30,7 @@ dist-ssr .env.development.local .env.test.local .env.production.local + + +# Cypress +cypress.env.json diff --git a/packages/extension/cypress/e2e/NFT.cy.ts b/packages/extension/cypress/e2e/NFT.cy.ts index 2e8da32aa..68a13042b 100644 --- a/packages/extension/cypress/e2e/NFT.cy.ts +++ b/packages/extension/cypress/e2e/NFT.cy.ts @@ -4,8 +4,9 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); const STORAGE_KEY = '1693425372955.3833'; describe('Mint', () => { @@ -33,10 +34,7 @@ describe('Mint', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -164,7 +162,7 @@ describe('Mint', () => { const params = { amount: { currency: 'SOLO', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_ADDRESS, value: '0.4' }, fee: '199', @@ -189,7 +187,7 @@ describe('Mint', () => { cy.contains('p', 'NFT').next().should('have.text', this.NFTokenID); cy.contains('Amount').next().should('have.text', '0.4 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_ADDRESS); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Offer type: Sell offer'); @@ -214,7 +212,7 @@ describe('Mint', () => { const params = { amount: { currency: '534F4C4F00000000000000000000000000000000', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_ADDRESS, value: '0.4' }, fee: '199', @@ -239,7 +237,7 @@ describe('Mint', () => { cy.contains('p', 'NFT').next().should('have.text', this.NFTokenID); cy.contains('Amount').next().should('have.text', '0.4 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_ADDRESS); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Offer type: Sell offer'); @@ -334,7 +332,7 @@ describe('Mint', () => { ], NFTokenBrokerFee: { currency: 'SOLO', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_ADDRESS, value: '0.1' } }; @@ -347,7 +345,7 @@ describe('Mint', () => { cy.contains('Sell Offer').next().should('have.text', this.OfferID); cy.contains('Broker Fee').next().should('have.text', '0.1 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_ADDRESS); // Confirm cy.contains('button', 'Submit').click(); @@ -375,7 +373,7 @@ describe('Mint', () => { ], NFTokenBrokerFee: { currency: '534F4C4F00000000000000000000000000000000', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_ADDRESS, value: '0.1' } }; @@ -388,7 +386,7 @@ describe('Mint', () => { cy.contains('Sell Offer').next().should('have.text', this.OfferID); cy.contains('Broker Fee').next().should('have.text', '0.1 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_ADDRESS); // Confirm cy.contains('button', 'Submit').click(); diff --git a/packages/extension/cypress/e2e/delete_account.cy.ts b/packages/extension/cypress/e2e/delete_account.cy.ts index 3d0051667..c5f4ddc59 100644 --- a/packages/extension/cypress/e2e/delete_account.cy.ts +++ b/packages/extension/cypress/e2e/delete_account.cy.ts @@ -1,18 +1,18 @@ /// import { Chain, XRPLNetwork } from '@gemwallet/constants'; +import { navigate } from '../utils/navigation'; -describe('Delete account', () => { - // deepcode ignore NoHardcodedPasswords: - const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const DEFAULT_WALLET_ADDRESS = Cypress.env('DEFAULT_WALLET_ADDRESS'); +const VALID_ADDRESS = 'rNvFCZXpDtGeQ3bVas95wGLN6N2stGmA9o'; +describe('Delete account', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX18AlCMtFj8wFHFphXwjUK7eE88VPubDBdA0p2PPWShzgCETsCScUwibFZBToMQ4k3pAJj1bwvo0IRlIr0eGnGizk3/Ga309btSK5igom3OSYbqT5SA3JHjCCdTgsM/+tSauA6kdb/A6O3GpNXdXihKa4V/SiuwxOUV9iTP/5zrgvGyGPkv6onJb' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -63,7 +63,7 @@ describe('Delete account', () => { // Enter the same address as the current wallet cy.get('input[name="destination-address"]').clear(); - cy.get('input[name="destination-address"]').type('rJD2jq9TboEoQgNtuRYBRWqJCJupoq9uVr'); + cy.get('input[name="destination-address"]').type(DEFAULT_WALLET_ADDRESS); cy.get('input[name="destination-address"]').blur(); cy.get('#destination-address-helper-text').should( 'have.text', @@ -73,7 +73,7 @@ describe('Delete account', () => { // Enter valid address cy.get('input[name="destination-address"]').clear(); - cy.get('input[name="destination-address"]').type('rNvFCZXpDtGeQ3bVas95wGLN6N2stGmA9o'); + cy.get('input[name="destination-address"]').type(VALID_ADDRESS); cy.contains('button', 'Continue').should('not.be.disabled'); cy.contains('button', 'Continue').click(); @@ -82,11 +82,9 @@ describe('Delete account', () => { cy.contains('You are about to permanently delete the following account from the XRPL:') .next() - .should('have.text', 'rJD2jq9TboEoQgNtuRYBRWqJCJupoq9uVr'); + .should('have.text', DEFAULT_WALLET_ADDRESS); - cy.contains('and transfer your XRP funds to:') - .next() - .should('have.text', 'rNvFCZXpDtGeQ3bVas95wGLN6N2stGmA9o'); + cy.contains('and transfer your XRP funds to:').next().should('have.text', VALID_ADDRESS); // We are not going to actually delete the account, so we just click on the cancel button cy.contains('button', 'Cancel').click(); @@ -95,29 +93,3 @@ describe('Delete account', () => { cy.contains('Settings').should('exist'); }); }); - -const navigate = (url: string, password: string) => { - cy.visit(url, { - onBeforeLoad(win) { - win['chrome'] = win['chrome'] || {}; - win['chrome'].runtime = { - sendMessage() {} - }; - - win['chrome'].storage = { - local: { - get() {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub(win['chrome'].runtime, 'sendMessage').resolves({}); - } - }); - - // Login - cy.get('input[name="password"]').type(password); - cy.contains('button', 'Unlock').click(); -}; diff --git a/packages/extension/cypress/e2e/hooks.cy.ts b/packages/extension/cypress/e2e/hooks.cy.ts index 7a5a52a60..b32ce5d8a 100644 --- a/packages/extension/cypress/e2e/hooks.cy.ts +++ b/packages/extension/cypress/e2e/hooks.cy.ts @@ -2,14 +2,15 @@ import { Chain, XahauNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const STORAGE_KEY = '1693425372955.3833'; + describe('Hooks', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -20,10 +21,6 @@ describe('Hooks', () => { }); }); - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; - const STORAGE_KEY = '1693425372955.3833'; - it('Set Hook through API', () => { const url = `http://localhost:3000/set-hook?storageKey=${STORAGE_KEY}&id=210401976&requestMessage=undefined&transaction=setHook`; diff --git a/packages/extension/cypress/e2e/networks.cy.ts b/packages/extension/cypress/e2e/networks.cy.ts index 576eb3500..98644f759 100644 --- a/packages/extension/cypress/e2e/networks.cy.ts +++ b/packages/extension/cypress/e2e/networks.cy.ts @@ -1,20 +1,18 @@ /// import { XRPLNetwork } from '@gemwallet/constants'; +import { navigate } from '../utils/navigation'; -describe('Switch networks', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +describe('Switch networks', () => { let networkLocalStorage = undefined; let customNetworkLocalStorage = undefined; beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX18AlCMtFj8wFHFphXwjUK7eE88VPubDBdA0p2PPWShzgCETsCScUwibFZBToMQ4k3pAJj1bwvo0IRlIr0eGnGizk3/Ga309btSK5igom3OSYbqT5SA3JHjCCdTgsM/+tSauA6kdb/A6O3GpNXdXihKa4V/SiuwxOUV9iTP/5zrgvGyGPkv6onJb' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); if (networkLocalStorage) { win.localStorage.setItem('network', networkLocalStorage); } @@ -22,31 +20,8 @@ describe('Switch networks', () => { win.localStorage.setItem('customNetworks', customNetworkLocalStorage); } }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } - }); - - cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); - // Login - cy.get('input[name="password"]').type(PASSWORD); - cy.contains('button', 'Unlock').click(); + navigate('http://localhost:3000/', PASSWORD); }); it('Switch from Mainnet (default network) to Testnet', () => { diff --git a/packages/extension/cypress/e2e/offers.cy.ts b/packages/extension/cypress/e2e/offers.cy.ts index e274338cf..ea0edd350 100644 --- a/packages/extension/cypress/e2e/offers.cy.ts +++ b/packages/extension/cypress/e2e/offers.cy.ts @@ -2,18 +2,17 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_ETH_ADDRESS = Cypress.env('ISSUER_ETH_ADDRESS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); const STORAGE_KEY = '1693425372955.3833'; describe('Offers', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -31,7 +30,7 @@ describe('Offers', () => { takerGets: '10000000', takerPays: { currency: 'ETH', - issuer: 'rnm76Qgz4G9G4gZBJVuXVvkbt7gVD7szey', + issuer: ISSUER_ETH_ADDRESS, value: '0.1' }, flags: { @@ -54,7 +53,7 @@ describe('Offers', () => { cy.contains('Taker Gets').next().should('have.text', '10 XRP'); cy.contains('Taker Pays').next().should('have.text', '0.1 ETH'); - cy.contains('Trustline').next().should('have.text', 'rnm76Qgz4G9G4gZBJVuXVvkbt7gVD7szey'); + cy.contains('Trustline').next().should('have.text', ISSUER_ETH_ADDRESS); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Passive'); @@ -81,7 +80,7 @@ describe('Offers', () => { takerGets: '10000000', takerPays: { currency: 'SOLO', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, value: '0.1' }, flags: { @@ -104,7 +103,7 @@ describe('Offers', () => { cy.contains('Taker Gets').next().should('have.text', '10 XRP'); cy.contains('Taker Pays').next().should('have.text', '0.1 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Passive'); @@ -131,7 +130,7 @@ describe('Offers', () => { takerPays: '10000000', takerGets: { currency: 'SOLO', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, value: '0.1' }, flags: { @@ -154,7 +153,7 @@ describe('Offers', () => { cy.contains('Taker Pays').next().should('have.text', '10 XRP'); cy.contains('Taker Gets').next().should('have.text', '0.1 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Passive'); @@ -181,7 +180,7 @@ describe('Offers', () => { takerGets: '10000000', takerPays: { currency: 'SOLO', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, value: '0.1' }, flags: { @@ -204,7 +203,7 @@ describe('Offers', () => { cy.contains('Taker Gets').next().should('have.text', '10 XRP'); cy.contains('Taker Pays').next().should('have.text', '0.1 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Passive'); @@ -231,7 +230,7 @@ describe('Offers', () => { takerPays: '10000000', takerGets: { currency: 'SOLO', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, value: '0.1' }, flags: { @@ -254,7 +253,7 @@ describe('Offers', () => { cy.contains('Taker Pays').next().should('have.text', '10 XRP'); cy.contains('Taker Gets').next().should('have.text', '0.1 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Flags').next().should('have.text', 'Passive'); diff --git a/packages/extension/cypress/e2e/payments.cy.ts b/packages/extension/cypress/e2e/payments.cy.ts index 08772fadc..8e4dc627e 100644 --- a/packages/extension/cypress/e2e/payments.cy.ts +++ b/packages/extension/cypress/e2e/payments.cy.ts @@ -6,19 +6,17 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_ETH_ADDRESS = Cypress.env('ISSUER_ETH_ADDRESS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); const STORAGE_KEY = '1693425372955.3833'; const URL = `http://localhost:3000/transaction?storageKey=${STORAGE_KEY}&id=210405959&requestMessage=REQUEST_SEND_PAYMENT%2FV3&transaction=payment`; -const DESTINATION_ADDRESS = 'rNvFCZXpDtGeQ3bVas95wGLN6N2stGmA9o'; beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -33,13 +31,13 @@ describe('Make payment - XRP', () => { const AMOUNT = '0.01'; const params = { amount: xrpToDrops(AMOUNT), - destination: DESTINATION_ADDRESS + destination: ISSUER_SOLO_ADDRESS }; it('Confirm the payment', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -47,7 +45,7 @@ describe('Make payment - XRP', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Send Payment'); // Should have the proper information - cy.contains('Destination').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Destination').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Amount').next().should('have.text', `${AMOUNT} XRP`); // Confirm the payment @@ -68,7 +66,7 @@ describe('Make payment - XRP', () => { it('Reject the payment', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -76,7 +74,7 @@ describe('Make payment - XRP', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Send Payment'); // Should have the proper information - cy.contains('Destination').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Destination').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Amount').next().should('have.text', `${AMOUNT} XRP`); // Reject the payment @@ -92,22 +90,21 @@ describe('Make payment - XRP', () => { describe('Make payment - ETH', () => { const TOKEN = 'ETH'; const VALUE = '0.01'; - const DESTINATION_ADDRESS = 'rnm76Qgz4G9G4gZBJVuXVvkbt7gVD7szey'; const AMOUNT = JSON.stringify({ currency: TOKEN, value: VALUE, - issuer: DESTINATION_ADDRESS + issuer: ISSUER_ETH_ADDRESS }); const params = { amount: AMOUNT, - destination: DESTINATION_ADDRESS + destination: ISSUER_SOLO_ADDRESS }; it('Confirm the payment', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -115,9 +112,9 @@ describe('Make payment - ETH', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Send Payment'); // Should have the proper information - cy.contains('Destination').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Destination').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Amount').next().should('have.text', `${VALUE} ${TOKEN}`); - cy.contains('Trustline').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Trustline').next().should('have.text', ISSUER_ETH_ADDRESS); // Confirm the payment cy.contains('button', 'Submit').click(); @@ -137,7 +134,7 @@ describe('Make payment - ETH', () => { it('Reject the payment', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -145,9 +142,9 @@ describe('Make payment - ETH', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Send Payment'); // Should have the proper information - cy.contains('Destination').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Destination').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Amount').next().should('have.text', `${VALUE} ${TOKEN}`); - cy.contains('Trustline').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Trustline').next().should('have.text', ISSUER_ETH_ADDRESS); // Reject the payment cy.contains('button', 'Reject').click(); @@ -163,21 +160,20 @@ describe('Make payment - SOLO', () => { it('Check the payment information (non hex)', () => { const TOKEN = 'SOLO'; const VALUE = '0.01'; - const DESTINATION_ADDRESS = 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'; const AMOUNT = JSON.stringify({ currency: TOKEN, value: VALUE, - issuer: DESTINATION_ADDRESS + issuer: ISSUER_SOLO_ADDRESS }); const params = { amount: AMOUNT, - destination: DESTINATION_ADDRESS + destination: ISSUER_SOLO_ADDRESS }; navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -185,29 +181,28 @@ describe('Make payment - SOLO', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Send Payment'); // Should have the proper information - cy.contains('Destination').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Destination').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Amount').next().should('have.text', `${VALUE} ${TOKEN}`); - cy.contains('Trustline').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); }); it('Check the payment information (hex)', () => { const TOKEN = '534F4C4F00000000000000000000000000000000'; const VALUE = '0.01'; - const DESTINATION_ADDRESS = 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'; const AMOUNT = JSON.stringify({ currency: TOKEN, value: VALUE, - issuer: DESTINATION_ADDRESS + issuer: ISSUER_SOLO_ADDRESS }); const params = { amount: AMOUNT, - destination: DESTINATION_ADDRESS + destination: ISSUER_SOLO_ADDRESS }; navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -215,9 +210,9 @@ describe('Make payment - SOLO', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Send Payment'); // Should have the proper information - cy.contains('Destination').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Destination').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Amount').next().should('have.text', `${VALUE} SOLO`); - cy.contains('Trustline').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); }); }); @@ -228,7 +223,7 @@ describe('Make payment from the UI', () => { cy.contains('button', 'Send').click(); // Input recipient's address - cy.get('#recipient-address').type(DESTINATION_ADDRESS); + cy.get('#recipient-address').type(ISSUER_SOLO_ADDRESS); // Input wrong amount cy.get('#amount').type('0.0000001'); diff --git a/packages/extension/cypress/e2e/receive.cy.ts b/packages/extension/cypress/e2e/receive.cy.ts index f2fb5081b..5ef12bfb4 100644 --- a/packages/extension/cypress/e2e/receive.cy.ts +++ b/packages/extension/cypress/e2e/receive.cy.ts @@ -1,16 +1,14 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; +import { navigate } from '../utils/navigation'; + +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); describe('ReceivePayment View', () => { beforeEach(() => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; - // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX1/JAHkPXi6ZonxQukDVxSlHcveDl30pBLB/Y9tPmrtAIi0ulBoj+mgxv/qj29Odgw8pRm0QzwGpT5zKmTRyf4QHmjpl5UcSNfRw95l/ZxPMgOpy/qrOJgWQHKNVK1TUpQHuV/c+ULBmpyOeMsI60paKXKvBEddTfHggacZV9ABvmCZZbIMM4h3tRn0HtVQY8kFvp9yJuUxq8T6BMgHzCys7hzUjtwdZ81YVEfdUShzEkleuqLsx4STqNvibUmf6HnwCgMCCPTzjulr3XvZK+yfreBb3RPsivSCsl5dwSz0ORtNwg04zjLiTvR+1btv91kifEBrMo3dh/Q==' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -19,37 +17,7 @@ describe('ReceivePayment View', () => { }) ); }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - }, - session: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } - }); - - cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); - - // Login - cy.get('input[name="password"]').type(PASSWORD); - cy.contains('button', 'Unlock').click(); + navigate('http://localhost:3000/', PASSWORD); // Go to the receive page cy.contains('button', 'Receive').click(); @@ -58,6 +26,6 @@ describe('ReceivePayment View', () => { it('should display the QRCode and wallet address', () => { cy.get('canvas').should('be.visible'); - cy.get('[data-testid="receive-payment-address"]').should('have.text', 'rB3J...7HQu'); + cy.get('[data-testid="receive-payment-address"]').should('have.text', 'rpeV...7gHu'); }); }); diff --git a/packages/extension/cypress/e2e/send_token.cy.ts b/packages/extension/cypress/e2e/send_token.cy.ts index bb9f1ad0e..88fa26a47 100644 --- a/packages/extension/cypress/e2e/send_token.cy.ts +++ b/packages/extension/cypress/e2e/send_token.cy.ts @@ -1,21 +1,18 @@ /// import { Chain, XRPLNetwork } from '@gemwallet/constants'; +import { navigate } from '../utils/navigation'; -const SRC_ADDRESS = 'rB3JmRd5m292YjCsCr65tc8dwZz2WN7HQu'; -const DEST_ADDRESS = 'rhikRdkFw28csKw9z7fVoBjWncz1HSoQij'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const SENDER_ADDRESS = Cypress.env('DEFAULT_WALLET_ADDRESS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); describe('Send Token', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; - beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX1/JAHkPXi6ZonxQukDVxSlHcveDl30pBLB/Y9tPmrtAIi0ulBoj+mgxv/qj29Odgw8pRm0QzwGpT5zKmTRyf4QHmjpl5UcSNfRw95l/ZxPMgOpy/qrOJgWQHKNVK1TUpQHuV/c+ULBmpyOeMsI60paKXKvBEddTfHggacZV9ABvmCZZbIMM4h3tRn0HtVQY8kFvp9yJuUxq8T6BMgHzCys7hzUjtwdZ81YVEfdUShzEkleuqLsx4STqNvibUmf6HnwCgMCCPTzjulr3XvZK+yfreBb3RPsivSCsl5dwSz0ORtNwg04zjLiTvR+1btv91kifEBrMo3dh/Q==' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -24,37 +21,7 @@ describe('Send Token', () => { }) ); }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - }, - session: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } - }); - - cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); - - // Login - cy.get('input[name="password"]').type(PASSWORD); - cy.contains('button', 'Unlock').click(); + navigate('http://localhost:3000/', PASSWORD); // Go to the send page cy.contains('button', 'Send').click(); @@ -101,17 +68,17 @@ describe('Send Token', () => { sendXRP(undefined, '123456789'); }); - it('Send USD', () => { - sendUSD(); + it('Send ETH', () => { + sendETH(); }); - it('Send USD with memo and destination tag', () => { - sendUSD('This is another memo', '12'); + it('Send ETH with memo and destination tag', () => { + sendETH('This is another memo', '12'); }); it('Reject Send XRP', () => { // Add receipient address as the sender address - cy.get('input[name="recipient-address"]').type(SRC_ADDRESS); + cy.get('input[name="recipient-address"]').type(SENDER_ADDRESS); // Blur the input to trigger the validation cy.get('input[name="recipient-address"]').blur(); @@ -180,7 +147,7 @@ describe('Send Token', () => { ); //Add a valid amount, a valid receipient address and a valid memo - cy.get('input[name="recipient-address"]').clear().type(DEST_ADDRESS); + cy.get('input[name="recipient-address"]').clear().type(ISSUER_SOLO_ADDRESS); cy.get('input[name="amount"]').clear().type('0.001'); cy.get('input[name="memo"]').clear().type('This is a memo'); cy.get('input[name="destination-tag"]').clear().type('123456789'); @@ -202,18 +169,18 @@ describe('Send Token', () => { const sendXRP = (memo?: string, destinationTag?: string) => { // Add receipient address - cy.get('input[name="recipient-address"]').type(DEST_ADDRESS); + cy.get('input[name="recipient-address"]').type(ISSUER_SOLO_ADDRESS); handleTransaction(memo, destinationTag); }; -const sendUSD = (memo?: string, destinationTag?: string) => { +const sendETH = (memo?: string, destinationTag?: string) => { // Add receipient address - cy.get('input[name="recipient-address"]').type(DEST_ADDRESS); + cy.get('input[name="recipient-address"]').type(ISSUER_SOLO_ADDRESS); - // Select USD token + // Select ETH token cy.get('#token-select').click(); - cy.contains('li', 'USD').click(); + cy.contains('li', 'ETH').click(); handleTransaction(memo, destinationTag); }; diff --git a/packages/extension/cypress/e2e/set_account.cy.ts b/packages/extension/cypress/e2e/set_account.cy.ts index 35f2d51dd..8ac3d708c 100644 --- a/packages/extension/cypress/e2e/set_account.cy.ts +++ b/packages/extension/cypress/e2e/set_account.cy.ts @@ -2,19 +2,17 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); + describe('Set Account', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; const STORAGE_KEY = '1693425372955.3833'; const URL = `http://localhost:3000/set-account?storageKey=${STORAGE_KEY}&id=210406324&requestMessage=undefined&transaction=setAccount`; beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ diff --git a/packages/extension/cypress/e2e/set_regular_key.cy.ts b/packages/extension/cypress/e2e/set_regular_key.cy.ts index a6ef97867..e2326fe87 100644 --- a/packages/extension/cypress/e2e/set_regular_key.cy.ts +++ b/packages/extension/cypress/e2e/set_regular_key.cy.ts @@ -2,18 +2,15 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); const STORAGE_KEY = '1693425372955.3833'; describe('Set Regular Key', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ diff --git a/packages/extension/cypress/e2e/sign_transaction.cy.ts b/packages/extension/cypress/e2e/sign_transaction.cy.ts index c15fe3923..7201d2d17 100644 --- a/packages/extension/cypress/e2e/sign_transaction.cy.ts +++ b/packages/extension/cypress/e2e/sign_transaction.cy.ts @@ -5,17 +5,16 @@ import { navigate } from '../utils/navigation'; const URL = 'http://localhost:3000/sign-transaction?storageKey=1693425372955.3833&id=210401828&requestMessage=undefined&sign=transaction'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); +const DEFAULT_WALLET_ADDRESS = Cypress.env('DEFAULT_WALLET_ADDRESS'); describe('Sign Transaction', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -38,7 +37,7 @@ describe('Sign Transaction', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Sign Transaction'); cy.contains( - '{"TransactionType":"Payment""Destination":"rhikRdkFw28csKw9z7fVoBjWncz1HSoQij""Amount":"100000""Account":"rB3JmRd5m292YjCsCr65tc8dwZz2WN7HQu"}' + `{"TransactionType":"Payment""Destination":"rhikRdkFw28csKw9z7fVoBjWncz1HSoQij""Amount":"100000""Account":"${DEFAULT_WALLET_ADDRESS}"}` ); // Confirm @@ -55,7 +54,7 @@ describe('Sign Transaction', () => { TransactionType: 'TrustSet', LimitAmount: { currency: '534F4C4F00000000000000000000000000000000', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, value: '10000000' }, Memos: [ @@ -73,12 +72,12 @@ describe('Sign Transaction', () => { cy.get('h1[data-testid="page-title"]').should('have.text', 'Sign Transaction'); cy.contains( - '{"TransactionType":"TrustSet""LimitAmount":{"currency":"534F4C4F00000000000000000000000000000000""issuer":"rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN""value":"10000000"}"Memos":[0:{"Memo":{"MemoType":"4465736372697074696f6e""MemoData":"54657374206d656d6f"}}]"Fee":"199""Account":"rB3JmRd5m292YjCsCr65tc8dwZz2WN7HQu"}' + `{"TransactionType":"TrustSet""LimitAmount":{"currency":"534F4C4F00000000000000000000000000000000""issuer":"${ISSUER_SOLO_ADDRESS}""value":"10000000"}"Memos":[0:{"Memo":{"MemoType":"4465736372697074696f6e""MemoData":"54657374206d656d6f"}}]"Fee":"199""Account":"${DEFAULT_WALLET_ADDRESS}"}` ); cy.contains('Transaction Type').next().should('have.text', 'TrustSet'); cy.contains('Limit Amount').next().should('have.text', '10,000,000 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); diff --git a/packages/extension/cypress/e2e/submit_raw_json_tx.cy.ts b/packages/extension/cypress/e2e/submit_raw_json_tx.cy.ts index d638be677..56ba93b77 100644 --- a/packages/extension/cypress/e2e/submit_raw_json_tx.cy.ts +++ b/packages/extension/cypress/e2e/submit_raw_json_tx.cy.ts @@ -3,16 +3,14 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; const SUBMIT_RAW_TRANSACTION_PATH = 'http://localhost:3000/build-transaction?transaction=buildRaw'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -75,7 +73,7 @@ describe('JSON Transaction', () => { const rawTx = `{ "TransactionType": "Payment", - "Destination": "rhikRdkFw28csKw9z7fVoBjWncz1HSoQij", + "Destination": "${ISSUER_SOLO_ADDRESS}", "Amount": "100000", "Memos": [ { diff --git a/packages/extension/cypress/e2e/submit_transaction.cy.ts b/packages/extension/cypress/e2e/submit_transaction.cy.ts index 569959997..4ca1a4d8f 100644 --- a/packages/extension/cypress/e2e/submit_transaction.cy.ts +++ b/packages/extension/cypress/e2e/submit_transaction.cy.ts @@ -5,17 +5,16 @@ import { navigate } from '../utils/navigation'; const URL = 'http://localhost:3000/submit-transaction?storageKey=1693425372955.3833&id=210401828&requestMessage=undefined&submit=transaction'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); +const DEFAULT_WALLET_ADDRESS = Cypress.env('DEFAULT_WALLET_ADDRESS'); describe('Submit Transaction', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -29,8 +28,8 @@ describe('Submit Transaction', () => { it('Submit Transaction', () => { const transaction = { TransactionType: 'Payment', - Destination: 'rhikRdkFw28csKw9z7fVoBjWncz1HSoQij', - Amount: '100000' + Destination: ISSUER_SOLO_ADDRESS, + Amount: '1000' }; navigate(URL, PASSWORD, '1693425372955.3833', { transaction }); @@ -42,7 +41,7 @@ describe('Submit Transaction', () => { }); cy.contains( - '{"TransactionType":"Payment""Destination":"rhikRdkFw28csKw9z7fVoBjWncz1HSoQij""Amount":"100000""Account":"rB3JmRd5m292YjCsCr65tc8dwZz2WN7HQu"}' + `{"TransactionType":"Payment""Destination":"${ISSUER_SOLO_ADDRESS}""Amount":"1000""Account":"${DEFAULT_WALLET_ADDRESS}"}` ); // Confirm @@ -65,7 +64,7 @@ describe('Submit Transaction', () => { TransactionType: 'TrustSet', LimitAmount: { currency: '534F4C4F00000000000000000000000000000000', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, value: '10000000' }, Memos: [ @@ -87,12 +86,12 @@ describe('Submit Transaction', () => { }); cy.contains( - '{"TransactionType":"TrustSet""LimitAmount":{"currency":"534F4C4F00000000000000000000000000000000""issuer":"rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN""value":"10000000"}"Memos":[0:{"Memo":{"MemoType":"4465736372697074696f6e""MemoData":"54657374206d656d6f"}}]"Fee":"199""Account":"rB3JmRd5m292YjCsCr65tc8dwZz2WN7HQu"}' + `{"TransactionType":"TrustSet""LimitAmount":{"currency":"534F4C4F00000000000000000000000000000000""issuer":"${ISSUER_SOLO_ADDRESS}""value":"10000000"}"Memos":[0:{"Memo":{"MemoType":"4465736372697074696f6e""MemoData":"54657374206d656d6f"}}]"Fee":"199""Account":"${DEFAULT_WALLET_ADDRESS}"}` ); cy.contains('Transaction Type').next().should('have.text', 'TrustSet'); cy.contains('Limit Amount').next().should('have.text', '10,000,000 SOLO'); - cy.contains('Trustline').next().should('have.text', 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN'); + cy.contains('Trustline').next().should('have.text', ISSUER_SOLO_ADDRESS); cy.contains('Memo').next().should('have.text', 'Test memo'); cy.contains('Network fees').next().should('have.text', '0.000199 XRP (MANUAL)'); diff --git a/packages/extension/cypress/e2e/submit_transactions_bulk.cy.ts b/packages/extension/cypress/e2e/submit_transactions_bulk.cy.ts index 402039b6a..eafc70387 100644 --- a/packages/extension/cypress/e2e/submit_transactions_bulk.cy.ts +++ b/packages/extension/cypress/e2e/submit_transactions_bulk.cy.ts @@ -3,14 +3,16 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; describe('Submit Transactions (Bulk)', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; + const PASSWORD = Cypress.env('PASSWORD'); + const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); + const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); + const ISSUER_ETH_ADDRESS = Cypress.env('ISSUER_ETH_ADDRESS'); const transactions = [ { ID: '001', TransactionType: 'Payment', - Destination: 'rhikRdkFw28csKw9z7fVoBjWncz1HSoQij', + Destination: ISSUER_SOLO_ADDRESS, Amount: '100000', Memos: [ { @@ -26,7 +28,7 @@ describe('Submit Transactions (Bulk)', () => { TransactionType: 'TrustSet', LimitAmount: { currency: 'ETH', - issuer: 'rnm76Qgz4G9G4gZBJVuXVvkbt7gVD7szey', + issuer: ISSUER_ETH_ADDRESS, value: '10000000' }, Memos: [ @@ -42,8 +44,8 @@ describe('Submit Transactions (Bulk)', () => { { ID: '003', TransactionType: 'Payment', - Destination: 'rhikRdkFw28csKw9z7fVoBjWncz1HSoQij', - Amount: '100000', + Destination: ISSUER_SOLO_ADDRESS, + Amount: '1000', Memos: [ { Memo: { @@ -56,8 +58,8 @@ describe('Submit Transactions (Bulk)', () => { { ID: '004', TransactionType: 'Payment', - Destination: 'rhikRdkFw28csKw9z7fVoBjWncz1HSoQij', - Amount: '100000', + Destination: ISSUER_SOLO_ADDRESS, + Amount: '1000', Memos: [ { Memo: { @@ -77,10 +79,7 @@ describe('Submit Transactions (Bulk)', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ diff --git a/packages/extension/cypress/e2e/trustlines.cy.ts b/packages/extension/cypress/e2e/trustlines.cy.ts index 05a29b26e..642349155 100644 --- a/packages/extension/cypress/e2e/trustlines.cy.ts +++ b/packages/extension/cypress/e2e/trustlines.cy.ts @@ -4,13 +4,15 @@ import { Chain, XRPLNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); +const ISSUER_SOLO_ADDRESS = Cypress.env('ISSUER_SOLO_ADDRESS'); +const ISSUER_ETH_ADDRESS = Cypress.env('ISSUER_ETH_ADDRESS'); + beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ @@ -21,19 +23,16 @@ beforeEach(() => { }); }); -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; const STORAGE_KEY = '1693425372955.3833'; const URL = `http://localhost:3000/add-new-trustline?storageKey=${STORAGE_KEY}&id=210405959&requestMessage=undefined&transaction=trustSet`; describe('Trustline', () => { - const CURRENCY = 'USD'; - const DESTINATION_ADDRESS = 'rwtDvu9QDfCskWuyE2TSEt3s56RbiWUKJN'; + const CURRENCY = 'ETH'; const VALUE = '10000000'; const AMOUNT = JSON.stringify({ currency: CURRENCY, value: VALUE, - issuer: DESTINATION_ADDRESS + issuer: ISSUER_ETH_ADDRESS }); const FLAGS = JSON.stringify({ tfSetNoRipple: true @@ -48,7 +47,7 @@ describe('Trustline', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -75,17 +74,17 @@ describe('Trustline', () => { it('Confirm the trustline', () => { navigate(URL, PASSWORD); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); - validateTrustlineTx(DESTINATION_ADDRESS, CURRENCY, '10,000,000'); + validateTrustlineTx(ISSUER_ETH_ADDRESS, CURRENCY, '10,000,000'); }); it('Reject the trustline', () => { navigate(URL, PASSWORD); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); @@ -109,7 +108,7 @@ describe('Trustline', () => { // Should have the proper information cy.contains('Limit Amount').next().should('have.text', `10,000,000 ${CURRENCY}`); - cy.contains('p', 'Trustline').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('p', 'Trustline').next().should('have.text', ISSUER_ETH_ADDRESS); // Confirm the trustline cy.contains('button', 'Reject').click(); @@ -125,7 +124,7 @@ describe('Trustline', () => { const amount = JSON.stringify({ currency: 'SOLO', value: '10000000', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN' + issuer: ISSUER_SOLO_ADDRESS }); const params = { @@ -136,18 +135,18 @@ describe('Trustline', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); - validateTrustlineTx('rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', 'SOLO', '10,000,000'); + validateTrustlineTx(ISSUER_SOLO_ADDRESS, 'SOLO', '10,000,000'); }); it('Confirm SOLO (hex)', () => { const amount = JSON.stringify({ currency: '534F4C4F00000000000000000000000000000000', value: '10000000', - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN' + issuer: ISSUER_SOLO_ADDRESS }); const params = { @@ -158,22 +157,22 @@ describe('Trustline', () => { navigate(URL, PASSWORD, STORAGE_KEY, params); - cy.on('uncaught:exception', (err, runnable) => { + cy.on('uncaught:exception', () => { // Continue with the test return false; }); - validateTrustlineTx('rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', 'SOLO', '10,000,000'); + validateTrustlineTx(ISSUER_SOLO_ADDRESS, 'SOLO', '10,000,000'); }); const testCases = [ { - issuer: 'rwtDvu9QDfCskWuyE2TSEt3s56RbiWUKJN', - token: 'USD', + issuer: ISSUER_ETH_ADDRESS, + token: 'ETH', limit: '10000000', formattedLimit: '10,000,000' }, { - issuer: 'rHZwvHEs56GCmHupwjA4RY7oPA3EoAJWuN', + issuer: ISSUER_SOLO_ADDRESS, token: 'SOLO', limit: '100000000', formattedLimit: '100,000,000' @@ -238,7 +237,7 @@ describe('Trustline', () => { // Check values in the confirmation page cy.contains('Limit Amount').next().should('have.text', `${newLimit} ${CURRENCY}`); - cy.contains('p', 'Trustline').next().should('have.text', DESTINATION_ADDRESS); + cy.contains('p', 'Trustline').next().should('have.text', ISSUER_ETH_ADDRESS); cy.contains('button', 'Submit').click(); diff --git a/packages/extension/cypress/e2e/wallet_management.cy.ts b/packages/extension/cypress/e2e/wallet_management.cy.ts index 9d3feb8f0..d5f2dc85d 100644 --- a/packages/extension/cypress/e2e/wallet_management.cy.ts +++ b/packages/extension/cypress/e2e/wallet_management.cy.ts @@ -1,32 +1,30 @@ /// -describe('Setup the initial wallet (no previous wallet)', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; - const SEED = 'sEdSPaf6j72fpTWbufHtN8yBTtm4QSK'; - const MNEMONIC = - 'frozen voyage arrest venture question deny print brother genuine hip tooth rigid life output bitter raccoon kidney wine urban rookie allow envelope pitch marriage'; - const ERROR_MNEMONIC = 'You need 6 digits'; +const PASSWORD = Cypress.env('PASSWORD'); +const SEED = Cypress.env('SEED'); +const MNEMONIC = Cypress.env('MNEMONIC'); +const ERROR_MNEMONIC = 'You need 6 digits'; +const URL_WALLET = 'http://localhost:3000/'; + +const setupChromeMocks = (win) => { + win['chrome'] = win['chrome'] || {}; + win['chrome'].runtime = { + sendMessage: cy.stub().resolves({}) + }; + win['chrome'].storage = { + local: { + get() {}, + set(obj, cb) { + if (cb) cb(); + } + } + }; +}; +describe('Setup the initial wallet (no previous wallet)', () => { beforeEach(() => { - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } + cy.visit(URL_WALLET, { + onBeforeLoad: setupChromeMocks }); cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); @@ -225,12 +223,6 @@ describe('Setup the initial wallet (no previous wallet)', () => { }); describe('Add an additional wallet (with previous wallet)', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; - const SEED = 'sEdSPaf6j72fpTWbufHtN8yBTtm4QSK'; - const MNEMONIC = - 'frozen voyage arrest venture question deny print brother genuine hip tooth rigid life output bitter raccoon kidney wine urban rookie allow envelope pitch marriage'; - const ERROR_MNEMONIC = 'You need 6 digits'; let walletLocalStorage = 'U2FsdGVkX18AlCMtFj8wFHFphXwjUK7eE88VPubDBdA0p2PPWShzgCETsCScUwibFZBToMQ4k3pAJj1bwvo0IRlIr0eGnGizk3/Ga309btSK5igom3OSYbqT5SA3JHjCCdTgsM/+tSauA6kdb/A6O3GpNXdXihKa4V/SiuwxOUV9iTP/5zrgvGyGPkv6onJb'; @@ -239,24 +231,8 @@ describe('Add an additional wallet (with previous wallet)', () => { cy.window().then((win) => { win.localStorage.setItem('wallets', walletLocalStorage); }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } + cy.visit(URL_WALLET, { + onBeforeLoad: setupChromeMocks }); cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); @@ -394,11 +370,6 @@ describe('Add an additional wallet (with previous wallet)', () => { }); describe('Edit wallet', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; - const MNEMONIC = - 'frozen voyage arrest venture question deny print brother genuine hip tooth rigid life output bitter raccoon kidney wine urban rookie allow envelope pitch marriage'; - beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { @@ -407,24 +378,8 @@ describe('Edit wallet', () => { 'U2FsdGVkX18lhnWbAn5EJDspfPXAVOsREMhg5+2NHl2IH8nrDClBsmNH75PutpB4AO0ddYhMYmNk8fsfx2ym2HW3VJGn8x+ZQreGATWF7beHhhx2vPJDsnODdOXWdcF2eqmeEp7P3pQZfZnGggvXiwqvn/NPg4mbzx5GjPcx1TfuFjBLM/YbyxXskVeOKs+fL4fGvCBj4s1/8x0Ok9fRYFdN2i9ODEJDNuJRrAZygsiqVaFPEBHHg7FfZYLuECwIOA2MukcjESPOAPRg2JMLbjWblI6rcLVx4zblkjMsfWOYujuq7zDWWt6hNCncs6DnHpBr4joQIayx6bNqpXUBQ0sEA1gpSeAvKuDf7eWpHzEJtpCUYEXYa8zW25XeABiUU8Hht7dK0r6L2V7mWpPNbQTTFA7yaXrhTQI2JNCt31ZEIWCWd2w5vgTGvPTJcs8xKPmUtXk+fJDbG9zHzwSrMDMLh5TtxzCGmTFUGNAc2NCZJKNjj6SUJGW2AgLqt3NYPpG91Ec6V0baina40VAZ/5pgCgzUWgkcxFU8J1htMaD2cMnAs6MeqVCeJOPpOVjIVD70RsJRsR8782K2pJezwV5TdzEYKkfpzEYMEl6aKfJSGzbGcActM1LDpi8fJBuqUia3YhqhAMevSFWpuw9anA==' ); }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } + cy.visit(URL_WALLET, { + onBeforeLoad: setupChromeMocks }); cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); @@ -513,7 +468,7 @@ describe('Edit wallet', () => { // Show seed cy.get('input[name="password"]').clear().type(PASSWORD); cy.contains('button', 'Show').click(); - cy.contains('sEdSPaf6j72fpTWbufHtN8yBTtm4QSK').should('be.visible'); + cy.contains(SEED).should('be.visible'); }); it('Show Mnemonic', () => { @@ -545,8 +500,6 @@ describe('Edit wallet', () => { }); describe('Switch wallet', () => { - // deepcode ignore NoHardcodedPasswords: password used for testing purposes - const PASSWORD = 'SECRET_PASSWORD'; beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { @@ -555,24 +508,8 @@ describe('Switch wallet', () => { 'U2FsdGVkX18lhnWbAn5EJDspfPXAVOsREMhg5+2NHl2IH8nrDClBsmNH75PutpB4AO0ddYhMYmNk8fsfx2ym2HW3VJGn8x+ZQreGATWF7beHhhx2vPJDsnODdOXWdcF2eqmeEp7P3pQZfZnGggvXiwqvn/NPg4mbzx5GjPcx1TfuFjBLM/YbyxXskVeOKs+fL4fGvCBj4s1/8x0Ok9fRYFdN2i9ODEJDNuJRrAZygsiqVaFPEBHHg7FfZYLuECwIOA2MukcjESPOAPRg2JMLbjWblI6rcLVx4zblkjMsfWOYujuq7zDWWt6hNCncs6DnHpBr4joQIayx6bNqpXUBQ0sEA1gpSeAvKuDf7eWpHzEJtpCUYEXYa8zW25XeABiUU8Hht7dK0r6L2V7mWpPNbQTTFA7yaXrhTQI2JNCt31ZEIWCWd2w5vgTGvPTJcs8xKPmUtXk+fJDbG9zHzwSrMDMLh5TtxzCGmTFUGNAc2NCZJKNjj6SUJGW2AgLqt3NYPpG91Ec6V0baina40VAZ/5pgCgzUWgkcxFU8J1htMaD2cMnAs6MeqVCeJOPpOVjIVD70RsJRsR8782K2pJezwV5TdzEYKkfpzEYMEl6aKfJSGzbGcActM1LDpi8fJBuqUia3YhqhAMevSFWpuw9anA==' ); }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } + cy.visit(URL_WALLET, { + onBeforeLoad: setupChromeMocks }); cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); @@ -620,24 +557,8 @@ describe('Reset password', () => { 'U2FsdGVkX18lhnWbAn5EJDspfPXAVOsREMhg5+2NHl2IH8nrDClBsmNH75PutpB4AO0ddYhMYmNk8fsfx2ym2HW3VJGn8x+ZQreGATWF7beHhhx2vPJDsnODdOXWdcF2eqmeEp7P3pQZfZnGggvXiwqvn/NPg4mbzx5GjPcx1TfuFjBLM/YbyxXskVeOKs+fL4fGvCBj4s1/8x0Ok9fRYFdN2i9ODEJDNuJRrAZygsiqVaFPEBHHg7FfZYLuECwIOA2MukcjESPOAPRg2JMLbjWblI6rcLVx4zblkjMsfWOYujuq7zDWWt6hNCncs6DnHpBr4joQIayx6bNqpXUBQ0sEA1gpSeAvKuDf7eWpHzEJtpCUYEXYa8zW25XeABiUU8Hht7dK0r6L2V7mWpPNbQTTFA7yaXrhTQI2JNCt31ZEIWCWd2w5vgTGvPTJcs8xKPmUtXk+fJDbG9zHzwSrMDMLh5TtxzCGmTFUGNAc2NCZJKNjj6SUJGW2AgLqt3NYPpG91Ec6V0baina40VAZ/5pgCgzUWgkcxFU8J1htMaD2cMnAs6MeqVCeJOPpOVjIVD70RsJRsR8782K2pJezwV5TdzEYKkfpzEYMEl6aKfJSGzbGcActM1LDpi8fJBuqUia3YhqhAMevSFWpuw9anA==' ); }); - cy.visit('http://localhost:3000/', { - onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} - }; - - (win as any).chrome.storage = { - local: { - get(key, cb) {}, - set(obj, cb) { - if (cb) cb(); - } - } - }; - - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); - } + cy.visit(URL_WALLET, { + onBeforeLoad: setupChromeMocks }); cy.get('.MuiCircularProgress-root', { timeout: 20000 }).should('not.exist'); diff --git a/packages/extension/cypress/e2e/xahau.cy.ts b/packages/extension/cypress/e2e/xahau.cy.ts index 618de07c3..53e0bce6a 100644 --- a/packages/extension/cypress/e2e/xahau.cy.ts +++ b/packages/extension/cypress/e2e/xahau.cy.ts @@ -2,18 +2,15 @@ import { Chain, XahauNetwork } from '@gemwallet/constants'; import { navigate } from '../utils/navigation'; -// deepcode ignore NoHardcodedPasswords: password used for testing purposes -const PASSWORD = 'SECRET_PASSWORD'; +const PASSWORD = Cypress.env('PASSWORD'); +const LOCAL_STORAGE_WALLETS = Cypress.env('LOCAL_STORAGE_WALLETS'); const STORAGE_KEY = '1693425372955.3833'; describe('Xahau transactions', () => { beforeEach(() => { // Mock the localStorage with a wallet already loaded cy.window().then((win) => { - win.localStorage.setItem( - 'wallets', - 'U2FsdGVkX19VA07d7tVhAAtUbt+YVbw0xQY7OZMykOW4YI4nRZK9iZ7LT3+xHvrj4kwlPKEcRg0S1GjbIWSFaMzg3Mw8fklZrZLL9QZvnbF821SeDB5lBBj/F9PBg8A07uZhYz1p4sTDsWAOFvrnKJjmlWIqXzN5MFFbWBb3os2xGtAGTslFVUXuTp6eM9X9' - ); + win.localStorage.setItem('wallets', LOCAL_STORAGE_WALLETS); win.localStorage.setItem( 'network', JSON.stringify({ diff --git a/packages/extension/cypress/utils/navigation.ts b/packages/extension/cypress/utils/navigation.ts index 2827d0eb3..c2ae104b3 100644 --- a/packages/extension/cypress/utils/navigation.ts +++ b/packages/extension/cypress/utils/navigation.ts @@ -3,14 +3,14 @@ const mockSessionStorage = {}; export const navigate = (url: string, password: string, storageKey?: string, data?) => { cy.visit(url, { onBeforeLoad(win) { - (win as any).chrome = (win as any).chrome || {}; - (win as any).chrome.runtime = { - sendMessage(message, cb) {} + win['chrome'] = win['chrome'] || {}; + win['chrome'].runtime = { + sendMessage() {} }; - (win as any).chrome.storage = { + win['chrome'].storage = { local: { - get(key, cb) {}, + get() {}, set(obj, cb) { if (cb) cb(); } @@ -31,14 +31,14 @@ export const navigate = (url: string, password: string, storageKey?: string, dat }; if (storageKey && data) { - (win as any).chrome.storage.session.set({ + win['chrome'].storage.session.set({ [storageKey]: JSON.stringify(data) }); } - (win as any).chrome.runtime.lastError = null; + win['chrome'].runtime.lastError = null; - cy.stub((win as any).chrome.runtime, 'sendMessage').resolves({}); + cy.stub(win['chrome'].runtime, 'sendMessage').resolves({}); } }); diff --git a/packages/extension/package.json b/packages/extension/package.json index 454656cb7..c01697e97 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -58,7 +58,7 @@ "@typescript-eslint/eslint-plugin": "^6.14.0", "@typescript-eslint/parser": "^6.14.0", "@vitejs/plugin-react": "^4.2.1", - "cypress": "^13.6.3", + "cypress": "13.8.1", "eslint": "^8.55.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.5", diff --git a/yarn.lock b/yarn.lock index ba1e8231c..d364272f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2927,7 +2927,7 @@ buffer@6.0.3: base64-js "^1.3.1" ieee754 "^1.2.1" -buffer@^5.6.0, buffer@^5.7.1: +buffer@^5.7.1: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== @@ -3504,10 +3504,10 @@ csstype@^3.0.2, csstype@^3.1.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== -cypress@^13.6.3: - version "13.6.3" - resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.6.3.tgz#54f03ca07ee56b2bc18211e7bd32abd2533982ba" - integrity sha512-d/pZvgwjAyZsoyJ3FOsJT5lDsqnxQ/clMqnNc++rkHjbkkiF2h9s0JsZSyyH4QXhVFW3zPFg82jD25roFLOdZA== +cypress@13.8.1: + version "13.8.1" + resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.8.1.tgz#f558e51b770a409e2360031bbd36c3f4fb3f2db4" + integrity sha512-Uk6ovhRbTg6FmXjeZW/TkbRM07KPtvM5gah1BIMp4Y2s+i/NMxgaLw0+PbYTOdw1+egE0FP3mWRiGcRkjjmhzA== dependencies: "@cypress/request" "^3.0.0" "@cypress/xvfb" "^1.2.4" @@ -3516,7 +3516,7 @@ cypress@^13.6.3: arch "^2.2.0" blob-util "^2.0.2" bluebird "^3.7.2" - buffer "^5.6.0" + buffer "^5.7.1" cachedir "^2.3.0" chalk "^4.1.0" check-more-types "^2.24.0" @@ -3534,7 +3534,7 @@ cypress@^13.6.3: figures "^3.2.0" fs-extra "^9.1.0" getos "^3.2.1" - is-ci "^3.0.0" + is-ci "^3.0.1" is-installed-globally "~0.4.0" lazy-ass "^1.6.0" listr2 "^3.8.3" @@ -5322,7 +5322,7 @@ is-callable@^1.1.3: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== -is-ci@^3.0.0: +is-ci@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867" integrity sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==