Skip to content

Commit

Permalink
fix: cypress init, tx errors
Browse files Browse the repository at this point in the history
  • Loading branch information
grothem committed Dec 20, 2024
1 parent 9c12f5c commit e4482c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions cypress/e2e/3-stake-governance/stake.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ testCases.forEach(
const skipTestState = skipState(false);
configEnvWithTenderlyMainnetFork({
tokens: [{ tokenAddress: testCase.asset.address }],
urlSuffix: '/staking',
});
stake(
{
Expand Down
13 changes: 11 additions & 2 deletions cypress/support/steps/configuration.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export const configEnvWithTenderly = ({
unpause,
wallet,
enableTestnet = false,
urlSuffix = '',
}: {
chainId: number;
market: string;
tokens?: { tokenAddress: string; donorAddress?: string; tokenCount?: string }[];
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion cypress/support/steps/stake.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/web3-data-provider/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};
Expand Down

0 comments on commit e4482c0

Please sign in to comment.