From 53f0ca9b7ea74c8e7c06feff16e259c3238785d8 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:54:24 -0700 Subject: [PATCH] fix: disable UniswapX opt-out in e2e tests (#7423) --- cypress/e2e/swap/uniswapx.test.ts | 17 +++++++++++++---- cypress/e2e/wallet-dropdown.test.ts | 8 ++++---- cypress/support/commands.ts | 7 +++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/swap/uniswapx.test.ts b/cypress/e2e/swap/uniswapx.test.ts index 371f0a946a..d42981047f 100644 --- a/cypress/e2e/swap/uniswapx.test.ts +++ b/cypress/e2e/swap/uniswapx.test.ts @@ -1,4 +1,5 @@ import { ChainId, CurrencyAmount } from '@uniswap/sdk-core' +import { FeatureFlag } from 'featureFlags' import { DAI, nativeOnChain, USDC_MAINNET } from '../../../src/constants/tokens' import { getTestSelector } from '../../utils' @@ -26,7 +27,9 @@ function stubSwapTxReceipt() { describe('UniswapX Toggle', () => { beforeEach(() => { cy.intercept(QuoteEndpoint, { fixture: QuoteWhereUniswapXIsBetter }) - cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`) + cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`, { + featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: false }], + }) }) it('only displays uniswapx ui when setting is on', () => { @@ -76,7 +79,9 @@ describe('UniswapX Orders', () => { stubSwapTxReceipt() cy.hardhat().then((hardhat) => hardhat.fund(hardhat.wallet, CurrencyAmount.fromRawAmount(USDC_MAINNET, 3e8))) - cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`) + cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`, { + featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: false }], + }) }) it('can swap exact-in trades using uniswapX', () => { @@ -164,7 +169,9 @@ describe('UniswapX Eth Input', () => { stubSwapTxReceipt() - cy.visit(`/swap/?inputCurrency=ETH&outputCurrency=${DAI.address}`) + cy.visit(`/swap/?inputCurrency=ETH&outputCurrency=${DAI.address}`, { + featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: false }], + }) }) it('can swap using uniswapX with ETH as input', () => { @@ -249,7 +256,9 @@ describe('UniswapX activity history', () => { cy.hardhat().then(async (hardhat) => { await hardhat.fund(hardhat.wallet, CurrencyAmount.fromRawAmount(USDC_MAINNET, 3e8)) }) - cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`) + cy.visit(`/swap/?inputCurrency=${USDC_MAINNET.address}&outputCurrency=${DAI.address}`, { + featureFlags: [{ name: FeatureFlag.uniswapXDefaultEnabled, value: false }], + }) }) it('can view UniswapX order status progress in activity', () => { diff --git a/cypress/e2e/wallet-dropdown.test.ts b/cypress/e2e/wallet-dropdown.test.ts index 3e88e8c715..67856c775e 100644 --- a/cypress/e2e/wallet-dropdown.test.ts +++ b/cypress/e2e/wallet-dropdown.test.ts @@ -53,7 +53,7 @@ describe('Wallet Dropdown', () => { describe('should change locale with feature flag', () => { beforeEach(() => { - cy.visit('/', { featureFlags: [FeatureFlag.currencyConversion] }) + cy.visit('/', { featureFlags: [{ name: FeatureFlag.currencyConversion, value: true }] }) cy.get(getTestSelector('web3-status-connected')).click() cy.get(getTestSelector('wallet-settings')).click() }) @@ -147,19 +147,19 @@ describe('Wallet Dropdown', () => { describe('local currency', () => { it('loads local currency from the query param', () => { - cy.visit('/', { featureFlags: [FeatureFlag.currencyConversion] }) + cy.visit('/', { featureFlags: [{ name: FeatureFlag.currencyConversion, value: true }] }) cy.get(getTestSelector('web3-status-connected')).click() cy.get(getTestSelector('wallet-settings')).click() cy.contains('USD') - cy.visit('/?cur=AUD', { featureFlags: [FeatureFlag.currencyConversion] }) + cy.visit('/?cur=AUD', { featureFlags: [{ name: FeatureFlag.currencyConversion, value: true }] }) cy.get(getTestSelector('web3-status-connected')).click() cy.get(getTestSelector('wallet-settings')).click() cy.contains('AUD') }) it('loads local currency from menu', () => { - cy.visit('/', { featureFlags: [FeatureFlag.currencyConversion] }) + cy.visit('/', { featureFlags: [{ name: FeatureFlag.currencyConversion, value: true }] }) cy.get(getTestSelector('web3-status-connected')).click() cy.get(getTestSelector('wallet-settings')).click() cy.contains('USD') diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index acd5bfc04f..3c7659f279 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -24,7 +24,7 @@ declare global { } interface VisitOptions { serviceWorker?: true - featureFlags?: Array + featureFlags?: Array<{ name: FeatureFlag; value: boolean }> /** * Initial user state. * @default {@type import('../utils/user-state').CONNECTED_WALLET_USER_STATE} @@ -59,7 +59,10 @@ Cypress.Commands.overwrite( // Set feature flags, if configured. if (options?.featureFlags) { - const featureFlags = options.featureFlags.reduce((flags, flag) => ({ ...flags, [flag]: 'enabled' }), {}) + const featureFlags = options.featureFlags.reduce( + (flags, flag) => ({ ...flags, [flag.name]: flag.value ? 'enabled' : 'control' }), + {} + ) win.localStorage.setItem('featureFlags', JSON.stringify(featureFlags)) }