diff --git a/package.json b/package.json index 69a2eb97a8..95d4a62343 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,10 @@ "prettier:format": "./node_modules/.bin/prettier --write .", "lint": "yarn workspace arb-token-bridge-ui lint", "lint:fix": "yarn workspace arb-token-bridge-ui lint:fix", - "test:e2e": "yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", - "test:e2e:cctp": "yarn test:e2e --configFile synpress.cctp.config.ts", - "test:e2e:orbit": "E2E_ORBIT=true yarn test:e2e", - "test:e2e:orbit:custom-gas-token": "E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" + "test:e2e": "E2E=true yarn workspace arb-token-bridge-ui env-cmd --silent --file .e2e.env yarn synpress run --configFile synpress.config.ts", + "test:e2e:cctp": "E2E=true yarn test:e2e --configFile synpress.cctp.config.ts", + "test:e2e:orbit": "E2E=true E2E_ORBIT=true yarn test:e2e", + "test:e2e:orbit:custom-gas-token": "E2E=true E2E_ORBIT_CUSTOM_GAS_TOKEN=true yarn test:e2e" }, "resolutions": { "**/@walletconnect/ethereum-provider": "2.13.1", diff --git a/packages/arb-token-bridge-ui/src/components/common/ProjectsListing.tsx b/packages/arb-token-bridge-ui/src/components/common/ProjectsListing.tsx index 24169687dc..f42ff7a36f 100644 --- a/packages/arb-token-bridge-ui/src/components/common/ProjectsListing.tsx +++ b/packages/arb-token-bridge-ui/src/components/common/ProjectsListing.tsx @@ -11,7 +11,7 @@ import { getBridgeUiConfigForChain } from '../../util/bridgeUiConfig' import { getChainQueryParamForChain } from '../../types/ChainQueryParam' import { trackEvent } from '../../util/AnalyticsUtils' import { useIsTestnetMode } from '../../hooks/useIsTestnetMode' -import { isTestingEnvironment } from '../../util/CommonUtils' +import { isNonProductionEnvironment } from '../../util/envUtils' const shuffleArray = (array: PortalProject[]) => { return array.sort(() => Math.random() - 0.5) @@ -54,7 +54,7 @@ const fetchProjects = async ( } if (isTestnetMode) { - return isTestingEnvironment ? generateTestnetProjects(chainId, 6) : [] // don't show any test projects in production + return isNonProductionEnvironment ? generateTestnetProjects(chainId, 6) : [] // don't show any test projects in production } try { diff --git a/packages/arb-token-bridge-ui/src/util/CommonUtils.ts b/packages/arb-token-bridge-ui/src/util/CommonUtils.ts index 987a628792..7f30ac20ec 100644 --- a/packages/arb-token-bridge-ui/src/util/CommonUtils.ts +++ b/packages/arb-token-bridge-ui/src/util/CommonUtils.ts @@ -15,6 +15,3 @@ export function shortenTxHash(txHash: string) { txHashLength )}` } - -export const isTestingEnvironment = - !!window.Cypress || process.env.NODE_ENV !== 'production' diff --git a/packages/arb-token-bridge-ui/src/util/envUtils.ts b/packages/arb-token-bridge-ui/src/util/envUtils.ts new file mode 100644 index 0000000000..2e8b6b36dd --- /dev/null +++ b/packages/arb-token-bridge-ui/src/util/envUtils.ts @@ -0,0 +1,7 @@ +export const isE2eEnvironment = + !!(typeof window !== 'undefined' && window && window.Cypress) || + process.env.E2E === 'true' + +// non-production environment can be e2e, vercel preview and local dev environment +export const isNonProductionEnvironment = + isE2eEnvironment || process.env.NODE_ENV !== 'production' diff --git a/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts b/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts index fd7bcc9f4b..93192b4756 100644 --- a/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts +++ b/packages/arb-token-bridge-ui/src/util/orbitChainsList.ts @@ -1,5 +1,6 @@ import { NativeCurrencyBase } from '../hooks/useNativeCurrency' -import { ChainWithRpcUrl } from './networks' +import { isE2eEnvironment } from './envUtils' +import { ChainWithRpcUrl, ChainId } from './networks' import orbitChainsData from './orbitChainsData.json' export type NetworkType = @@ -59,6 +60,13 @@ export function getOrbitChains( testnet: boolean } = { mainnet: true, testnet: true } ): OrbitChainConfig[] { + if (isE2eEnvironment) { + // During E2E tests, only return local chains + return Object.values(orbitChains).filter( + chain => chain.chainId === ChainId.L3Local + ) + } + const mainnetChains = mainnet ? Object.values(orbitMainnets) : [] const testnetChains = testnet ? Object.values(orbitTestnets) : [] diff --git a/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts b/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts index d32c467a51..409d05f5f4 100644 --- a/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts +++ b/packages/arb-token-bridge-ui/src/util/wagmi/setup.ts @@ -16,11 +16,11 @@ import { base, baseSepolia } from './wagmiAdditionalNetworks' -import { isTestingEnvironment } from '../CommonUtils' import { getCustomChainsFromLocalStorage, ChainId, rpcURLs } from '../networks' import { getOrbitChains } from '../orbitChainsList' import { getWagmiChain } from './getWagmiChain' import { customInfuraProvider } from '../infura' +import { isE2eEnvironment } from '../envUtils' const customChains = getCustomChainsFromLocalStorage().map(chain => getWagmiChain(chain.chainId) @@ -42,17 +42,14 @@ const defaultChains = [ holesky ] -const chainList = isTestingEnvironment +const chainList = isE2eEnvironment ? [ - ...defaultChains, - // Orbit chains - ...wagmiOrbitChains, - // add local environments during testing + // only include local + sepolia testnet during E2E's local, arbitrumLocal, l3Local, - // user-added custom chains - ...customChains + sepolia, + arbitrumSepolia ] : [...defaultChains, ...wagmiOrbitChains, ...customChains]