From a4642d80b411842175194d5fc6abc05aa132ddbc Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Wed, 17 Nov 2021 13:12:27 +0000 Subject: [PATCH 1/2] Fix tests --- cypress-custom/integration/swap.test.ts | 31 ++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/cypress-custom/integration/swap.test.ts b/cypress-custom/integration/swap.test.ts index 024dbf4f5..86ac07f2c 100644 --- a/cypress-custom/integration/swap.test.ts +++ b/cypress-custom/integration/swap.test.ts @@ -3,17 +3,20 @@ // GP doesn't use ETH, so we need to test for this describe('Swap (custom)', () => { - beforeEach(() => { - cy.visit('/swap') - }) - // uses WETH instead of ETH // it('can swap ETH for DAI', () => { it('can swap WETH for DAI', () => { // select DAI - cy.get('#swap-currency-output .open-currency-select-button').click() - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) + // TODO: Define our command, so it search by name and select the input + // cy.get('#swap-currency-output .open-currency-select-button').click() + + // cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') + // cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) + + cy.visit( + '/swap?inputCurrency=0xc778417E063141139Fce010982780140Aa0cD5Ab&outputCurrency=0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa' + ) + // input amounts cy.get('#swap-currency-input .token-amount-input').should('be.visible') cy.get('#swap-currency-input .token-amount-input').type('0.5', { force: true, delay: 200 }) @@ -24,14 +27,16 @@ describe('Swap (custom)', () => { // ETH should be tradable but show Switch to Weth it('Swap ETH for DAI - shows Switch to WETH ', () => { + cy.visit('/swap?inputCurrency=ETH&outputCurrency=0x5592EC0cfb4dbc12D3aB100b257153436a1f0FEa') + // select ETH - cy.get('#swap-currency-input .open-currency-select-button').click() - cy.get('.token-item-ETHER').should('be.visible') - cy.get('.token-item-ETHER').click({ force: true }) + // cy.get('#swap-currency-input .open-currency-select-button').click() + // cy.get('.token-item-ETHER').should('be.visible') + // cy.get('.token-item-ETHER').click({ force: true }) // select DAI - cy.get('#swap-currency-output .open-currency-select-button').click() - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') - cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) + // cy.get('#swap-currency-output .open-currency-select-button').click() + // cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').should('be.visible') + // cy.get('.token-item-0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735').click({ force: true }) // input amounts cy.get('#swap-currency-input .token-amount-input').should('be.visible') cy.get('#swap-currency-input .token-amount-input').type('0.001', { force: true, delay: 400 }) From 65f2b68a7436433936c6a7308d865d0da2a813b1 Mon Sep 17 00:00:00 2001 From: Anxo Rodriguez Date: Wed, 17 Nov 2021 13:12:37 +0000 Subject: [PATCH 2/2] Fix auto-connect for tests --- src/custom/hooks/web3.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/custom/hooks/web3.ts b/src/custom/hooks/web3.ts index 4e3636f5e..cddc7f19c 100644 --- a/src/custom/hooks/web3.ts +++ b/src/custom/hooks/web3.ts @@ -30,11 +30,12 @@ export function useEagerConnect() { // if there is no last saved provider set tried state to true if (!latestProvider) { - setTried(true) - } - - // check if the last saved provider is Metamask - if (latestProvider === WalletProvider.INJECTED) { + // Try to auto-connect to the injected wallet + activate(injected, undefined, true).catch(() => { + setTried(true) + }) + } else if (latestProvider === WalletProvider.INJECTED) { + // check if the last saved provider is Metamask // check if the our application is authorized/connected with Metamask injected.isAuthorized().then((isAuthorized) => { if (isAuthorized) {