Skip to content

Commit

Permalink
fix: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DDDDDanica committed Jun 20, 2024
1 parent af4d328 commit 008851b
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 40 deletions.
5 changes: 2 additions & 3 deletions test/e2e/accounts/account-custom-name.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ describe('Account Custom Name Persistence', function (this: Suite) {
fixtures: new FixtureBuilder().build(),
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver, ganacheServer }) => {
async ({ driver }: { driver: Driver }) => {
await unlockWallet(driver);

// Change account label for existing account
await driver.clickElement(
'[data-testid="account-options-menu-button"]',
Expand All @@ -47,7 +46,7 @@ describe('Account Custom Name Persistence', function (this: Suite) {
);
await driver.fill('[placeholder="Account 2"]', anotherAccountLabel);
await driver.clickElement({ text: 'Create', tag: 'button' });
await locateAccountBalanceDOM(driver, ganacheServer);
await locateAccountBalanceDOM(driver);

// Verify initial custom account label after freshly added account was active
const accountOneSelector = await findAnotherAccountFromAccountList(
Expand Down
18 changes: 11 additions & 7 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,14 +859,18 @@ 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();

await driver.waitForSelector({
css: '[data-testid="eth-overview__primary-currency"]',
text: `${balance} ETH`,
});
const balanceSelector = '[data-testid="eth-overview__primary-currency"]';
if (ganacheServer) {
const balance = await ganacheServer.getBalance();
await driver.waitForSelector({
css: balanceSelector,
text: `${balance} ETH`,
});
} else {
await driver.findElement(balanceSelector);
}
};

const WALLET_PASSWORD = 'correct horse battery staple';
Expand Down
17 changes: 9 additions & 8 deletions test/e2e/tests/account/add-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
sendTransaction,
findAnotherAccountFromAccountList,
locateAccountBalanceDOM,
logInWithBalanceValidation,
regularDelayMs,
unlockWallet,
WALLET_PASSWORD,
Expand Down Expand Up @@ -67,7 +68,7 @@ describe('Add account', function () {
WALLET_PASSWORD,
);

// Check address of 1st account
// Check address of 1st accoun
await locateAccountBalanceDOM(driver, ganacheServer);
await driver.findElement('[data-testid="app-header-copy-button"]');

Expand All @@ -83,7 +84,7 @@ describe('Add account', function () {
await driver.clickElement({ text: 'Create', tag: 'button' });

// Check address of 2nd account
await locateAccountBalanceDOM(driver, ganacheServer);
await locateAccountBalanceDOM(driver);
await driver.findElement('[data-testid="app-header-copy-button"]');

// Log into the account with balance(account 1)
Expand All @@ -94,7 +95,7 @@ describe('Add account', function () {
1,
'Account 1',
);
await locateAccountBalanceDOM(driver, ganacheServer);
await locateAccountBalanceDOM(driver);
await driver.clickElement(accountOneSelector);
await sendTransaction(driver, secondAccount, '2.8');

Expand Down Expand Up @@ -127,7 +128,7 @@ describe('Add account', function () {

// Land in 1st account home page
await driver.findElement('.home__main-view');
await locateAccountBalanceDOM(driver, ganacheServer);
await locateAccountBalanceDOM(driver);

// Check address of 1st account
await driver.findElement('[data-testid="app-header-copy-button"]');
Expand All @@ -154,8 +155,8 @@ describe('Add account', function () {
ganacheOptions,
title: this.test.fullTitle(),
},
async ({ driver, ganacheServer }) => {
await unlockWallet(driver);
async ({ driver }) => {
await logInWithBalanceValidation(driver);

await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement(
Expand All @@ -168,7 +169,7 @@ describe('Add account', function () {
await driver.clickElement({ text: 'Create', tag: 'button' });

// Wait for 2nd account to be created
await locateAccountBalanceDOM(driver, ganacheServer);
await locateAccountBalanceDOM(driver);
await driver.findElement({
css: '[data-testid="account-menu-icon"]',
text: '2nd account',
Expand Down Expand Up @@ -201,7 +202,7 @@ describe('Add account', function () {
);

// Wait for 3rd account to be created
await locateAccountBalanceDOM(driver, ganacheServer);
await locateAccountBalanceDOM(driver);
await driver.findElement({
css: '[data-testid="account-menu-icon"]',
text: 'Account 3',
Expand Down
20 changes: 12 additions & 8 deletions test/e2e/tests/metrics/dapp-viewed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const {
getEventPayloads,
openDapp,
logInWithBalanceValidation,
locateAccountBalanceDOM,
WINDOW_TITLES,
defaultGanacheOptions,
} = require('../../helpers');
const FixtureBuilder = require('../../fixture-builder');
const {
Expand Down Expand Up @@ -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"]',
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/metrics/unlock-wallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
const sortedEvents = sortEventsByTime(events);
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/tests/multichain/connection-page.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { strict: assert } = require('assert');
const {
withFixtures,
unlockWallet,
WINDOW_TITLES,
connectToDapp,
logInWithBalanceValidation,
locateAccountBalanceDOM,
defaultGanacheOptions,
} = require('../../helpers');
const FixtureBuilder = require('../../fixture-builder');

Expand All @@ -18,6 +19,7 @@ describe('Connections page', function () {
dapp: true,
fixtures: new FixtureBuilder().build(),
title: this.test.fullTitle(),
ganacheOptions: defaultGanacheOptions,
},
async ({ driver, ganacheServer }) => {
await logInWithBalanceValidation(driver, ganacheServer);
Expand Down Expand Up @@ -90,12 +92,14 @@ describe('Connections page', function () {
},
);
});

it('should connect more accounts when already connected to a dapp', async function () {
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder().build(),
title: this.test.fullTitle(),
ganacheOptions: defaultGanacheOptions,
},
async ({ driver, ganacheServer }) => {
await logInWithBalanceValidation(driver, ganacheServer);
Expand Down Expand Up @@ -133,7 +137,7 @@ describe('Connections page', function () {
);
await driver.fill('[placeholder="Account 3"]', accountLabel3);
await driver.clickElement({ text: 'Create', tag: 'button' });
await logInWithBalanceValidation(driver, ganacheServer);
await locateAccountBalanceDOM(driver);
await driver.clickElement(
'[data-testid ="account-options-menu-button"]',
);
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/tests/multichain/permission-page.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { strict: assert } = require('assert');
const {
withFixtures,
unlockWallet,
WINDOW_TITLES,
connectToDapp,
logInWithBalanceValidation,
defaultGanacheOptions,
} = require('../../helpers');
const FixtureBuilder = require('../../fixture-builder');

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/tests/swap-send/swap-send-erc20.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
openActionMenuAndStartSendFlow,
logInWithBalanceValidation,
} from '../../helpers';
import { Driver } from '../../webdriver/driver';
import type { Ganache } from '../../seeder/ganache';
import {
NATIVE_TOKEN_SYMBOL,
Expand All @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions test/e2e/tests/tokens/nft/import-nft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 008851b

Please sign in to comment.