From b101a242238ee0a867425ebe93653e4e9982e0b9 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Wed, 25 Sep 2024 01:22:02 +0200 Subject: [PATCH] fix: refactor e2e --- test/e2e/fixture-builder.js | 8 +++++ .../tests/settings/account-token-list.spec.js | 35 +++++-------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 61b4b7c829b4..592e98c96596 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -186,6 +186,14 @@ class FixtureBuilder { }); } + withShowFiatTestnetEnabled() { + return this.withPreferencesController({ + preferences: { + showFiatInTestnets: true, + }, + }); + } + withConversionRateEnabled() { return this.withPreferencesController({ useCurrencyRateCheck: true, diff --git a/test/e2e/tests/settings/account-token-list.spec.js b/test/e2e/tests/settings/account-token-list.spec.js index 925d5d0694a7..a301dfdf2dd1 100644 --- a/test/e2e/tests/settings/account-token-list.spec.js +++ b/test/e2e/tests/settings/account-token-list.spec.js @@ -3,6 +3,7 @@ const { withFixtures, defaultGanacheOptions, logInWithBalanceValidation, + unlockWallet, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -41,36 +42,16 @@ describe('Settings', function () { it('Should match the value of token list item and account list item for fiat conversion', async function () { await withFixtures( { - fixtures: new FixtureBuilder().withConversionRateEnabled().build(), + fixtures: new FixtureBuilder() + .withConversionRateEnabled() + .withShowFiatTestnetEnabled() + .withPreferencesControllerShowNativeTokenAsMainBalanceDisabled() + .build(), ganacheOptions: defaultGanacheOptions, title: this.test.fullTitle(), }, - async ({ driver, ganacheServer }) => { - await logInWithBalanceValidation(driver, ganacheServer); - - await driver.clickElement( - '[data-testid="account-options-menu-button"]', - ); - await driver.clickElement({ text: 'Settings', tag: 'div' }); - await driver.clickElement({ - text: 'General', - tag: 'div', - }); - await driver.clickElement('.show-native-token-as-main-balance'); - // We now need to enable "Show fiat on testnet" if we are using testnets (and since our custom - // network during test is using a testnet chain ID, it will be considered as a test network) - await driver.clickElement({ - text: 'Advanced', - tag: 'div', - }); - await driver.clickElement('.show-fiat-on-testnets-toggle'); - // Looks like when enabling the "Show fiat on testnet" it takes some time to re-update the - // overview screen, so just wait a bit here: - await driver.delay(1000); - - await driver.clickElement( - '.settings-page__header__title-container__close-button', - ); + async ({ driver }) => { + await unlockWallet(driver); await driver.clickElement('[data-testid="popover-close"]'); await driver.clickElement(