Skip to content

Commit

Permalink
fix: refactor e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
sahar-fehri committed Sep 24, 2024
1 parent 81cafa1 commit b101a24
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
8 changes: 8 additions & 0 deletions test/e2e/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ class FixtureBuilder {
});
}

withShowFiatTestnetEnabled() {
return this.withPreferencesController({
preferences: {
showFiatInTestnets: true,
},
});
}

withConversionRateEnabled() {
return this.withPreferencesController({
useCurrencyRateCheck: true,
Expand Down
35 changes: 8 additions & 27 deletions test/e2e/tests/settings/account-token-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const {
withFixtures,
defaultGanacheOptions,
logInWithBalanceValidation,
unlockWallet,
} = require('../../helpers');

const FixtureBuilder = require('../../fixture-builder');
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit b101a24

Please sign in to comment.