From 773c5b9d6afc97bd21277e718f39a0e9bc104a17 Mon Sep 17 00:00:00 2001 From: Arthur Geron <3487334+arthurgeron@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:17:29 -0300 Subject: [PATCH] fix: e2e failing when crx name is set to Fuel Wallet (#1509) - Fixed e2e flakiness due to the use of wrong connector/VITE_CRX_NAME pair - Adds errors warning when required env var is not set --- .changeset/long-squids-tap.md | 5 +++++ packages/app/playwright/e2e.ts | 25 +++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .changeset/long-squids-tap.md diff --git a/.changeset/long-squids-tap.md b/.changeset/long-squids-tap.md new file mode 100644 index 000000000..01e0134b7 --- /dev/null +++ b/.changeset/long-squids-tap.md @@ -0,0 +1,5 @@ +--- +"fuels-wallet": patch +--- + +Fixed e2e flakiness due to the use of wrong connector/VITE_CRX_NAME pair diff --git a/packages/app/playwright/e2e.ts b/packages/app/playwright/e2e.ts index 38f3e8bfa..c89b93adb 100644 --- a/packages/app/playwright/e2e.ts +++ b/packages/app/playwright/e2e.ts @@ -1,10 +1,27 @@ -import { FuelWalletDevelopmentConnector } from '@fuels/connectors'; -import { Address, Fuel, Provider } from 'fuels'; +import { + FuelWalletConnector, + FuelWalletDevelopmentConnector, +} from '@fuels/connectors'; +import { Address, Fuel } from 'fuels'; +import { VITE_CRX_NAME } from '../src/config'; localStorage.clear(); +const connectors = []; + +// Do not change this. This fixes e2e flakyness triggered by different env variables. +switch (VITE_CRX_NAME) { + case 'Fuel Wallet Development': + connectors.push(new FuelWalletDevelopmentConnector()); + break; + case 'Fuel Wallet': + connectors.push(new FuelWalletConnector()); + break; + default: + throw new Error('VITE_CRX_NAME is not set to a valid value'); +} + window.fuel = new Fuel({ - connectors: [new FuelWalletDevelopmentConnector()], + connectors, }); - window.createAddress = (address: string) => Address.fromString(address);