diff --git a/cypress/e2e/smoke/balances.cy.js b/cypress/e2e/smoke/balances.cy.js index 5321f3ffb0..3702e55663 100644 --- a/cypress/e2e/smoke/balances.cy.js +++ b/cypress/e2e/smoke/balances.cy.js @@ -3,7 +3,7 @@ const balanceSingleRow = '[aria-labelledby="tableTitle"] > tbody tr' const TEST_SAFE = 'gor:0x97d314157727D517A706B5D08507A1f9B44AaaE9' const PAGINATION_TEST_SAFE = 'gor:0x850493a15914aAC05a821A3FAb973b4598889A7b' -const ASSETS_LENGTH = 7 +const ASSETS_LENGTH = 8 const ASSET_NAME_COLUMN = 0 const TOKEN_AMOUNT_COLUMN = 1 const FIAT_AMOUNT_COLUMN = 2 @@ -13,6 +13,8 @@ describe('Assets > Coins', () => { const fiatRegex = new RegExp(`([0-9]{1,3},)*[0-9]{1,3}.[0-9]{2}`) before(() => { + cy.disableProdCGW() + // Open the Safe used for testing cy.visit(`/balances?safe=${TEST_SAFE}`) cy.contains('button', 'Accept selection').click() @@ -20,21 +22,15 @@ describe('Assets > Coins', () => { cy.contains('Görli Ether') cy.contains('button', 'Got it').click() + + cy.get(balanceSingleRow).should('have.length.lessThan', ASSETS_LENGTH) + cy.contains('div', 'Default tokens').click() + cy.wait(100) + cy.contains('div', 'All tokens').click() + cy.get(balanceSingleRow).should('have.length', ASSETS_LENGTH) }) describe('should have different tokens', () => { - it(`should have ${ASSETS_LENGTH} entries in the table`, () => { - // "Spam" tokens filtered - cy.get(balanceSingleRow).should('have.length', 3) - - // Enable all tokens - cy.contains('div', 'Default tokens').click() - cy.wait(100) - cy.contains('div', 'All tokens').click() - - cy.get(balanceSingleRow).should('have.length', ASSETS_LENGTH) - }) - it('should have Dai', () => { // Row should have an image with alt text "Dai" cy.contains('Dai') @@ -215,7 +211,7 @@ describe('Assets > Coins', () => { it('should allow changing rows per page and navigate to next and previous page', () => { // Table should have 25 rows inittially cy.contains('Rows per page:').next().contains('25') - cy.contains('1–25 of 27') + cy.contains('1–25 of') cy.get(balanceSingleRow).should('have.length', 25) // Change to 10 rows per page @@ -225,22 +221,22 @@ describe('Assets > Coins', () => { // Table should have 10 rows cy.contains('Rows per page:').next().contains('10') - cy.contains('1–10 of 27') + cy.contains('1–10 of') cy.get(balanceSingleRow).should('have.length', 10) // Click on the next page button cy.get('button[aria-label="Go to next page"]').click({ force: true }) cy.get('button[aria-label="Go to next page"]').click({ force: true }) - // Table should have 7 rows - cy.contains('21–27 of 27') - cy.get(balanceSingleRow).should('have.length', 7) + // Table should have N rows + cy.contains('21–28 of') + cy.get(balanceSingleRow).should('have.length', ASSETS_LENGTH) // Click on the previous page button cy.get('button[aria-label="Go to previous page"]').click({ force: true }) // Table should have 10 rows - cy.contains('11–20 of 27') + cy.contains('11–20 of') cy.get(balanceSingleRow).should('have.length', 10) }) }) diff --git a/cypress/e2e/smoke/create_tx.cy.js b/cypress/e2e/smoke/create_tx.cy.js index 0355ba022b..ee09b6b43f 100644 --- a/cypress/e2e/smoke/create_tx.cy.js +++ b/cypress/e2e/smoke/create_tx.cy.js @@ -9,6 +9,7 @@ const currentNonce = 3 describe('Queue a transaction on 1/N', () => { before(() => { cy.connectE2EWallet() + cy.useProdCGW() cy.visit(`/home?safe=${SAFE}`) @@ -167,7 +168,7 @@ describe('Queue a transaction on 1/N', () => { // Click on the notification cy.contains('View transaction').click() - cy.contains('Queue').click() + //cy.contains('Queue').click() // Single Tx page cy.contains('h3', 'Transaction details').should('be.visible') diff --git a/cypress/e2e/smoke/dashboard.cy.js b/cypress/e2e/smoke/dashboard.cy.js index 86f2fddbb2..4442841459 100644 --- a/cypress/e2e/smoke/dashboard.cy.js +++ b/cypress/e2e/smoke/dashboard.cy.js @@ -2,8 +2,11 @@ const SAFE = encodeURIComponent('gor:0xCD4FddB8FfA90012DFE11eD4bf258861204FeEAE' describe('Dashboard', () => { before(() => { + cy.useProdCGW() + // Go to the test Safe home page cy.visit(`/home?safe=${SAFE}`) + cy.contains('button', 'Accept selection').click() // Wait for dashboard to initialize @@ -19,7 +22,8 @@ describe('Dashboard', () => { cy.contains('0xCD4FddB8FfA90012DFE11eD4bf258861204FeEAE').should('exist') cy.contains('2/3') cy.get(`a[href="/balances?safe=${SAFE}"]`).contains('View assets') - cy.contains('p', 'Tokens').next().contains('1') + // Text next to Tokens contains a number greater than 0 + cy.contains('p', 'Tokens').next().contains('3') cy.contains('p', 'NFTs').next().contains('0') }) }) diff --git a/cypress/e2e/smoke/pending_actions.cy.js b/cypress/e2e/smoke/pending_actions.cy.js index f89cf91a1e..e381212f6d 100644 --- a/cypress/e2e/smoke/pending_actions.cy.js +++ b/cypress/e2e/smoke/pending_actions.cy.js @@ -3,10 +3,10 @@ const SAFE = 'gor:0xCD4FddB8FfA90012DFE11eD4bf258861204FeEAE' describe('Pending actions', () => { before(() => { cy.connectE2EWallet() + cy.useProdCGW() cy.visit(`/welcome`) cy.contains('button', 'Accept selection').click() - cy.contains('E2E Wallet @ Görli') }) beforeEach(() => { @@ -42,8 +42,8 @@ describe('Pending actions', () => { cy.get('li').within(() => { cy.contains('0xCD4F...eEAE').should('exist') - cy.get('img[alt="E2E Wallet logo"]').next().contains('3').should('exist') - cy.get('[data-testid=CheckIcon]').next().contains('3').should('exist') + cy.get('img[alt="E2E Wallet logo"]').next().contains('2').should('exist') + cy.get('[data-testid=CheckIcon]').next().contains('2').should('exist') // click on the pending actions cy.get('[data-testid=CheckIcon]').next().click() @@ -55,12 +55,12 @@ describe('Pending actions', () => { cy.contains('h3', 'Transactions').should('be.visible') // contains 3 queued transactions - cy.get('span:contains("1 out of 2")').should('have.length', 3) + cy.get('span:contains("1 out of 2")').should('have.length', 2) // Ensure wallet is connected - cy.contains('E2E Wallet @ Görli') + cy.contains('E2E Wallet @ Goerli') // contains 3 signable transactions - cy.get('span:contains("Needs your confirmation")').should('have.length', 3) + cy.get('span:contains("Needs your confirmation")').should('have.length', 2) }) }) diff --git a/cypress/e2e/smoke/tx_history.cy.js b/cypress/e2e/smoke/tx_history.cy.js index f67179c432..f5da4642ab 100644 --- a/cypress/e2e/smoke/tx_history.cy.js +++ b/cypress/e2e/smoke/tx_history.cy.js @@ -6,6 +6,8 @@ const CONTRACT_INTERACTION = 'Contract interaction' describe('Transaction history', () => { before(() => { + cy.useProdCGW() + // Go to the test Safe transaction history cy.visit(`/transactions/history?safe=${SAFE}`) cy.contains('button', 'Accept selection').click() diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 5393ef0a01..75eae8fba5 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -5,6 +5,18 @@ Cypress.Commands.add('connectE2EWallet', () => { }) }) +Cypress.Commands.add('useProdCGW', () => { + cy.on('window:before:load', (window) => { + window.localStorage.setItem('SAFE_v2__debugProdCgw', JSON.stringify(true)) + }) +}) + +Cypress.Commands.add('disableProdCGW', () => { + cy.on('window:before:load', (window) => { + window.localStorage.setItem('SAFE_v2__debugProdCgw', JSON.stringify(false)) + }) +}) + let LOCAL_STORAGE_MEMORY = {} Cypress.Commands.add('saveLocalStorageCache', () => { diff --git a/src/hooks/wallets/useOnboard.ts b/src/hooks/wallets/useOnboard.ts index d85f4d55a6..627fb3cde4 100644 --- a/src/hooks/wallets/useOnboard.ts +++ b/src/hooks/wallets/useOnboard.ts @@ -197,12 +197,10 @@ export const useInitOnboard = () => { onboard.state.actions.setWalletModules(supportedWallets) } - enableWallets() - }, [chain, onboard]) + // Connect to the last connected wallet + enableWallets().then(() => { + if (onboard.state.get().wallets.length > 0) return - // Connect to the last connected wallet - useEffect(() => { - if (onboard && onboard.state.get().wallets.length === 0) { const label = lastWalletStorage.get() if (!label) return @@ -212,8 +210,8 @@ export const useInitOnboard = () => { autoSelect: { label, disableModals: true }, }) }) - } - }, [onboard]) + }) + }, [chain, onboard]) } export default useStore