From e4482c0684d06255968080d0c2640866eaf5ff07 Mon Sep 17 00:00:00 2001 From: Mark Grothe Date: Fri, 20 Dec 2024 15:09:48 -0600 Subject: [PATCH] fix: cypress init, tx errors --- cypress/e2e/3-stake-governance/stake.cy.ts | 1 + cypress/support/steps/configuration.steps.ts | 13 +++++++++++-- cypress/support/steps/stake.steps.ts | 1 - src/libs/web3-data-provider/Web3Provider.tsx | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/3-stake-governance/stake.cy.ts b/cypress/e2e/3-stake-governance/stake.cy.ts index 3338591233..f18f1b5ea5 100644 --- a/cypress/e2e/3-stake-governance/stake.cy.ts +++ b/cypress/e2e/3-stake-governance/stake.cy.ts @@ -49,6 +49,7 @@ testCases.forEach( const skipTestState = skipState(false); configEnvWithTenderlyMainnetFork({ tokens: [{ tokenAddress: testCase.asset.address }], + urlSuffix: '/staking', }); stake( { diff --git a/cypress/support/steps/configuration.steps.ts b/cypress/support/steps/configuration.steps.ts index 4b5f1a8359..40bb262db6 100644 --- a/cypress/support/steps/configuration.steps.ts +++ b/cypress/support/steps/configuration.steps.ts @@ -15,6 +15,7 @@ export const configEnvWithTenderly = ({ unpause, wallet, enableTestnet = false, + urlSuffix = '', }: { chainId: number; market: string; @@ -22,6 +23,7 @@ export const configEnvWithTenderly = ({ unpause?: boolean; wallet?: { address: string; privateKey: string }; enableTestnet?: boolean; + urlSuffix?: string; }) => { const tenderly = new TenderlyFork({ forkNetworkID: chainId }); const walletAddress: string = wallet != null ? wallet.address : DEFAULT_TEST_ACCOUNT.address; @@ -51,10 +53,15 @@ export const configEnvWithTenderly = ({ } }); before('Open main page', () => { + let url = URL as string; + if (urlSuffix) { + url = `${url}/${urlSuffix}`; + } + const rpc = tenderly.get_rpc_url(); provider = new JsonRpcProvider(rpc, 3030); signer = new Wallet(privateKey, provider); - cy.visit(URL, { + cy.visit(url, { onBeforeLoad(win) { // eslint-disable-next-line (win as any).ethereum = new CustomizedBridge(signer, provider); @@ -100,13 +107,15 @@ const createConfigWithTenderlyFork = tokens, v3, wallet, + urlSuffix, }: { market?: string; tokens?: { tokenAddress: string }[]; v3?: boolean; wallet?: { address: string; privateKey: string }; + urlSuffix?: string; }) => - configEnvWithTenderly({ chainId, market, tokens, unpause: v3, wallet }); + configEnvWithTenderly({ chainId, market, tokens, unpause: v3, wallet, urlSuffix }); export const configEnvWithTenderlyMainnetFork = createConfigWithTenderlyFork( ChainId.mainnet, diff --git a/cypress/support/steps/stake.steps.ts b/cypress/support/steps/stake.steps.ts index a01cfecdb4..93f8eaabd7 100644 --- a/cypress/support/steps/stake.steps.ts +++ b/cypress/support/steps/stake.steps.ts @@ -58,7 +58,6 @@ export const stake = ( return describe(`Stake ${_shortName}`, () => { skipSetup({ skip, updateSkipStatus }); it(`Open staking page`, () => { - cy.get('[data-cy="menuStake"]').click(); if (asset.shortName === 'GHO') cy.wait(5000); cy.get(`button[value="${tabValue}"]`).then(($clickable) => { if ($clickable.prop('disabled')) return; diff --git a/src/libs/web3-data-provider/Web3Provider.tsx b/src/libs/web3-data-provider/Web3Provider.tsx index 93738a5ae5..e62ee90674 100644 --- a/src/libs/web3-data-provider/Web3Provider.tsx +++ b/src/libs/web3-data-provider/Web3Provider.tsx @@ -131,9 +131,9 @@ export const Web3ContextProvider: React.FC<{ children: ReactElement }> = ({ chil setSwitchNetworkError(undefined); } catch (switchError) { if (switchError.code === UserRejectedRequestError.code) { - setSwitchNetworkError(undefined); - } else { setSwitchNetworkError(switchError); + } else { + setSwitchNetworkError(undefined); } } };