From dd58323672670448c3ff047056713695aec83f0e Mon Sep 17 00:00:00 2001 From: Danica Shen Date: Sat, 15 Jun 2024 07:08:42 +0100 Subject: [PATCH] fix: fix lint issues --- test/e2e/accounts/account-custom-name.spec.ts | 9 ++++++++- test/e2e/helpers.js | 2 +- test/e2e/tests/metrics/dapp-viewed.spec.js | 20 +++++++++++-------- test/e2e/tests/metrics/unlock-wallet.spec.js | 2 +- .../tests/multichain/connection-page.spec.js | 1 - .../tests/multichain/permission-page.spec.js | 4 +++- .../tests/swap-send/swap-send-erc20.spec.ts | 5 ++--- test/e2e/tests/tokens/nft/import-nft.spec.js | 14 ++++++------- 8 files changed, 33 insertions(+), 24 deletions(-) diff --git a/test/e2e/accounts/account-custom-name.spec.ts b/test/e2e/accounts/account-custom-name.spec.ts index f4516427a827..62547f6433e2 100644 --- a/test/e2e/accounts/account-custom-name.spec.ts +++ b/test/e2e/accounts/account-custom-name.spec.ts @@ -7,6 +7,7 @@ import { } from '../helpers'; import FixtureBuilder from '../fixture-builder'; import { Driver } from '../webdriver/driver'; +import { Ganache } from '../seeder/ganache'; const newAccountLabel = 'Custom name'; const anotherAccountLabel = '2nd custom name'; @@ -18,7 +19,13 @@ describe('Account Custom Name Persistence', function (this: Suite) { fixtures: new FixtureBuilder().build(), title: this.test?.fullTitle(), }, - async ({ driver }: { driver: Driver, ganacheServer }) => { + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer: Ganache; + }) => { await unlockWallet(driver); // Change account label for existing account diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index 636f42738dbc..cc292e76f3fd 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -859,7 +859,7 @@ const TEST_SEED_PHRASE = const TEST_SEED_PHRASE_TWO = 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'; -// Usually happens when onboarded to make sure the state is retrieved from metamaskState properly, or a success login, or after txn is made +// Usually happens when onboarded to make sure the state is retrieved from metamaskState properly, or after txn is made const locateAccountBalanceDOM = async (driver, ganacheServer) => { const balance = await ganacheServer.getBalance(); diff --git a/test/e2e/tests/metrics/dapp-viewed.spec.js b/test/e2e/tests/metrics/dapp-viewed.spec.js index 25ee982c4228..f88d7b754bf5 100644 --- a/test/e2e/tests/metrics/dapp-viewed.spec.js +++ b/test/e2e/tests/metrics/dapp-viewed.spec.js @@ -6,8 +6,8 @@ const { getEventPayloads, openDapp, logInWithBalanceValidation, - locateAccountBalanceDOM, WINDOW_TITLES, + defaultGanacheOptions, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); const { @@ -40,8 +40,7 @@ async function mockPermissionApprovedEndpoint(mockServer) { }); } -async function createTwoAccounts(driver, ganacheServer) { - await locateAccountBalanceDOM(driver, ganacheServer); +async function createTwoAccounts(driver) { await driver.clickElement('[data-testid="account-menu-icon"]'); await driver.clickElement( '[data-testid="multichain-account-menu-popover-action-button"]', @@ -108,10 +107,10 @@ describe('Dapp viewed Event @no-mmi', function () { .build(), title: this.test.fullTitle(), testSpecificMock: mockSegment, + ganacheOptions: defaultGanacheOptions, }, - async ({ driver, mockedEndpoint: mockedEndpoints }) => { - await unlockWallet(driver); - + async ({ driver, mockedEndpoint: mockedEndpoints, ganacheServer }) => { + await logInWithBalanceValidation(driver, ganacheServer); await connectToDapp(driver); await waitForDappConnected(driver); const events = await getEventPayloads(driver, mockedEndpoints); @@ -143,6 +142,7 @@ describe('Dapp viewed Event @no-mmi', function () { .build(), title: this.test.fullTitle(), testSpecificMock: mockSegment, + ganacheOptions: defaultGanacheOptions, }, async ({ driver, mockedEndpoint: mockedEndpoints, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); @@ -180,6 +180,7 @@ describe('Dapp viewed Event @no-mmi', function () { .build(), title: this.test.fullTitle(), testSpecificMock: mockSegment, + ganacheOptions: defaultGanacheOptions, }, async ({ driver, mockedEndpoint: mockedEndpoints, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); @@ -222,6 +223,7 @@ describe('Dapp viewed Event @no-mmi', function () { .build(), title: this.test.fullTitle(), testSpecificMock: mockSegment, + ganacheOptions: defaultGanacheOptions, }, async ({ driver, mockedEndpoint: mockedEndpoints, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); @@ -257,12 +259,13 @@ describe('Dapp viewed Event @no-mmi', function () { }) .build(), title: this.test.fullTitle(), + ganacheOptions: defaultGanacheOptions, testSpecificMock: mockSegment, }, async ({ driver, mockedEndpoint: mockedEndpoints, ganacheServer }) => { - await unlockWallet(driver); + await logInWithBalanceValidation(driver, ganacheServer); // create 2nd account - await createTwoAccounts(driver, ganacheServer); + await createTwoAccounts(driver); // Connect to dapp with two accounts await openDapp(driver); await driver.clickElement({ @@ -312,6 +315,7 @@ describe('Dapp viewed Event @no-mmi', function () { .build(), title: this.test.fullTitle(), testSpecificMock: mockSegment, + ganacheOptions: defaultGanacheOptions, }, async ({ driver, mockedEndpoint: mockedEndpoints, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); diff --git a/test/e2e/tests/metrics/unlock-wallet.spec.js b/test/e2e/tests/metrics/unlock-wallet.spec.js index 6de676756cf5..9d6adf6a7275 100644 --- a/test/e2e/tests/metrics/unlock-wallet.spec.js +++ b/test/e2e/tests/metrics/unlock-wallet.spec.js @@ -35,7 +35,7 @@ describe('Unlock wallet', function () { title: this.test.fullTitle(), testSpecificMock: mockSegment, }, - async ({ driver, mockedEndpoint, ganacheServer}) => { + async ({ driver, mockedEndpoint, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); const events = await getEventPayloads(driver, mockedEndpoint); assert.equal(events.length, 3); diff --git a/test/e2e/tests/multichain/connection-page.spec.js b/test/e2e/tests/multichain/connection-page.spec.js index 353bc881fcdc..5de9271bf747 100644 --- a/test/e2e/tests/multichain/connection-page.spec.js +++ b/test/e2e/tests/multichain/connection-page.spec.js @@ -1,7 +1,6 @@ const { strict: assert } = require('assert'); const { withFixtures, - unlockWallet, WINDOW_TITLES, connectToDapp, logInWithBalanceValidation, diff --git a/test/e2e/tests/multichain/permission-page.spec.js b/test/e2e/tests/multichain/permission-page.spec.js index 3198d719f293..5ae3f71b6046 100644 --- a/test/e2e/tests/multichain/permission-page.spec.js +++ b/test/e2e/tests/multichain/permission-page.spec.js @@ -1,10 +1,10 @@ const { strict: assert } = require('assert'); const { withFixtures, - unlockWallet, WINDOW_TITLES, connectToDapp, logInWithBalanceValidation, + defaultGanacheOptions, } = require('../../helpers'); const FixtureBuilder = require('../../fixture-builder'); @@ -15,6 +15,7 @@ describe('Permissions Page', function () { dapp: true, fixtures: new FixtureBuilder().build(), title: this.test.fullTitle(), + ganacheOptions: defaultGanacheOptions, }, async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); @@ -50,6 +51,7 @@ describe('Permissions Page', function () { dapp: true, fixtures: new FixtureBuilder().build(), title: this.test.fullTitle(), + ganacheOptions: defaultGanacheOptions, }, async ({ driver, ganacheServer }) => { await logInWithBalanceValidation(driver, ganacheServer); diff --git a/test/e2e/tests/swap-send/swap-send-erc20.spec.ts b/test/e2e/tests/swap-send/swap-send-erc20.spec.ts index 10b18592f42b..e8b416b9604e 100644 --- a/test/e2e/tests/swap-send/swap-send-erc20.spec.ts +++ b/test/e2e/tests/swap-send/swap-send-erc20.spec.ts @@ -4,6 +4,7 @@ import { openActionMenuAndStartSendFlow, logInWithBalanceValidation, } from '../../helpers'; +import { Driver } from '../../webdriver/driver'; import type { Ganache } from '../../seeder/ganache'; import { NATIVE_TOKEN_SYMBOL, @@ -27,9 +28,7 @@ describe('Swap-Send ERC20', function () { driver, ganacheServer, }: { - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - driver: any; + driver: Driver; ganacheServer: Ganache; }) => { const swapSendPage = new SwapSendPage(driver); diff --git a/test/e2e/tests/tokens/nft/import-nft.spec.js b/test/e2e/tests/tokens/nft/import-nft.spec.js index cbb5295c9433..9710afc3910f 100644 --- a/test/e2e/tests/tokens/nft/import-nft.spec.js +++ b/test/e2e/tests/tokens/nft/import-nft.spec.js @@ -59,7 +59,7 @@ describe('Import NFT', function () { ); }); - it('should continue to display an imported NFT after importing, adding a new account, and switching back', async function () { + it.only('should continue to display an imported NFT after importing, adding a new account, and switching back', async function () { await withFixtures( { dapp: true, @@ -109,24 +109,22 @@ describe('Import NFT', function () { ); await driver.clickElement({ text: 'Add a new account', tag: 'button' }); - // set account name - await driver.fill('[placeholder="Account 2"]', '2nd account'); - await driver.delay(400); + // By clicking creating button without filling in the account name + // the default name would be set as Account 2 await driver.clickElement({ text: 'Create', tag: 'button' }); await driver.isElementPresent({ tag: 'span', - text: '2nd account', + text: 'Account 2', }); - const accountOneSelector = await findAnotherAccountFromAccountList( driver, 1, 'Account 1', ); - await locateAccountBalanceDOM(driver, ganacheServer); - await driver.clickElement(accountOneSelector); + await driver.clickElement(accountOneSelector); + await locateAccountBalanceDOM(driver, ganacheServer); const nftIsStillDisplayed = await driver.isElementPresentAndVisible({ css: 'h5', text: 'TestDappNFTs',