From abcc3c0afdc13b5dd8324fd5fa230d749bc61fff Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Thu, 21 Nov 2024 11:34:09 -0800 Subject: [PATCH] fix: Flaky add-hide-token.spec file by programatically closing flashing modal --- test/e2e/tests/tokens/add-hide-token.spec.js | 16 +++++++++++++++- .../ui/new-network-info/new-network-info.js | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test/e2e/tests/tokens/add-hide-token.spec.js b/test/e2e/tests/tokens/add-hide-token.spec.js index c9a1f26ad9eb..9774ef03d5f2 100644 --- a/test/e2e/tests/tokens/add-hide-token.spec.js +++ b/test/e2e/tests/tokens/add-hide-token.spec.js @@ -104,7 +104,8 @@ describe('Add existing token using search', function () { }), ]; } - it('renders the balance for the chosen token', async function () { + + it.only('renders the balance for the chosen token', async function () { await withFixtures( { fixtures: new FixtureBuilder({ inputChainId: CHAIN_IDS.BSC }) @@ -129,6 +130,19 @@ describe('Add existing token using search', function () { async ({ driver }) => { await unlockWallet(driver); + // there is a race condition where "You are now using" new network modal temporarily flashes + // this modal obscures the elements beneath it, including the import tokens button + // this check mitigates this flakiness. However, the modal itself maybe isn't super useful to have at all + const closeButton = await driver.findElement( + '[data-testid="new-network-info-popup-close-button"]', + ); + + if (closeButton) { + await driver.clickElement( + '[data-testid="new-network-info-popup-close-button"]', + ); + } + await driver.clickElement(`[data-testid="import-token-button"]`); await driver.clickElement(`[data-testid="importTokens"]`); await driver.fill('input[placeholder="Search tokens"]', 'BAT'); diff --git a/ui/components/ui/new-network-info/new-network-info.js b/ui/components/ui/new-network-info/new-network-info.js index 51b96bdc5b36..66544dd9cd3b 100644 --- a/ui/components/ui/new-network-info/new-network-info.js +++ b/ui/components/ui/new-network-info/new-network-info.js @@ -103,6 +103,7 @@ export default function NewNetworkInfo() {