Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): add btc e2e tests #25663

Merged
merged 92 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
54db504
refactor: better typing for handleSnapRequest
ccharly Jun 4, 2024
448b28e
feat(btc): add CreateBtcAccount component
ccharly Jun 4, 2024
ab68a06
feat(btc): add [email protected] as a preinstalled snap
ccharly Jul 2, 2024
11edb03
refactor(btc): only add btc account menu entry for flask
ccharly Jul 2, 2024
9216114
chore: ignore prettier for app/scripts/snaps/*.json
ccharly Jul 2, 2024
2ab28e7
chore: lint
ccharly Jul 2, 2024
f73c467
fix(storybook): fix title for Create{Btc,Eth}Account
ccharly Jul 2, 2024
afc2d35
refactor: use new addAccount value everywhere
ccharly Jul 2, 2024
c8ca2a7
fix(btc): call onActionComplete after account has been created + renamed
ccharly Jul 2, 2024
ac85ac7
test(btc): fix CreateBtcAccount tests
ccharly Jul 2, 2024
f2ffffe
chore: lint
ccharly Jul 2, 2024
af7b143
Merge branch 'develop' into feature/create-btc-account-without-snap-flow
ccharly Jul 2, 2024
7b0b10b
fix(btc): fix initial account BTC creation
ccharly Jul 2, 2024
93d5ee5
test(btc): add missing mock for forceUpdateMetamaskState
ccharly Jul 2, 2024
8c0a432
Merge branch 'develop' into feature/create-btc-account-without-snap-flow
ccharly Jul 2, 2024
34a1e15
chore(btc): use bitcoin-manager-snap as a dependency
ccharly Jul 2, 2024
a970e3d
Merge branch 'develop' into feature/create-btc-account-without-snap-flow
ccharly Jul 2, 2024
28c9474
Revert "chore(btc): use bitcoin-manager-snap as a dependency"
ccharly Jul 2, 2024
f471e36
refactor(btc): remove shared/constants/bitcoin-manager-snap.ts
ccharly Jul 3, 2024
8189a42
Merge branch 'develop' into feature/create-btc-account-without-snap-flow
ccharly Jul 3, 2024
397e05b
chore: add copy
gantunesr Jul 4, 2024
266dbbd
feat: add experimental BTC toggle
gantunesr Jul 4, 2024
4d034c1
chore(deps): use [email protected] as a dependency
ccharly Jul 4, 2024
b6a3627
refactor: update experiment-tab component to TS
gantunesr Jul 4, 2024
2567660
refactor: update experiment-tab container to TS
gantunesr Jul 4, 2024
261e55c
chore: update messages file
gantunesr Jul 4, 2024
8fcde18
fix: prettier
gantunesr Jul 4, 2024
a114e6f
chore: update to use code fence
gantunesr Jul 4, 2024
9c7e0a3
fix: lint errors
gantunesr Jul 4, 2024
1a5b731
refactor: update data types
gantunesr Jul 4, 2024
bfbe6aa
test: add tests and update mocks
gantunesr Jul 4, 2024
7b9b133
Merge branch 'develop' into feat/btc-toggle
gantunesr Jul 5, 2024
5f8f30b
Merge branch 'develop' into feat/btc-toggle
gantunesr Jul 5, 2024
ad1d0f5
chore: solve CI issues
gantunesr Jul 5, 2024
c0c76ee
Merge branch 'feat/btc-toggle' of https://github.com/MetaMask/metamas…
gantunesr Jul 5, 2024
2e37b0b
fix: code fenced logic
gantunesr Jul 5, 2024
7190ee1
fix: lint issues
gantunesr Jul 5, 2024
d3cebc7
chore: update test ids
gantunesr Jul 5, 2024
d61b1c3
Merge branch 'develop' into feat/btc-toggle
gantunesr Jul 5, 2024
31010e9
chore: update snapshots
gantunesr Jul 5, 2024
8c6306d
test: add unit test to setBitcoinSupportEnabled
gantunesr Jul 5, 2024
b4821c7
chore: update snapshots
gantunesr Jul 5, 2024
a0b03be
fix: e2e test for request queue
gantunesr Jul 5, 2024
2ed11b1
test: update test name
gantunesr Jul 5, 2024
d5fd4b9
fix: e2e test for json-rpc/switchEthereumChain
gantunesr Jul 5, 2024
bb7059f
chore: add metric event
gantunesr Jul 9, 2024
2d3a750
fix: lint
gantunesr Jul 9, 2024
d1a94e5
feat: add account / remove account e2e test
montelaidev Jul 3, 2024
473efba
feat: overview e2e test
montelaidev Jul 3, 2024
287c03f
feat: add restore srp test
montelaidev Jul 3, 2024
c52b66e
fix: address assertion
montelaidev Jul 3, 2024
564de73
fix: only test
montelaidev Jul 3, 2024
7823f32
fix: check for flask if its btc test
montelaidev Jul 9, 2024
1f35b1d
fix: lint
montelaidev Jul 9, 2024
482e102
Merge remote-tracking branch 'origin/feat/btc-toggle' into feat/btc-e…
montelaidev Jul 9, 2024
4b4e452
refactor: move btc test to flask
montelaidev Jul 9, 2024
66f21f4
feat: add connection and experimental settings
montelaidev Jul 9, 2024
48c87b5
fix: fence
montelaidev Jul 9, 2024
dd63e4d
fix: add fence for isBtcEnabled
montelaidev Jul 9, 2024
07d9583
fix: lint
montelaidev Jul 9, 2024
324b955
chore: update commentary for setBitcoinSupportEnabled
gantunesr Jul 9, 2024
573a5b5
test: update toggle test ID
gantunesr Jul 9, 2024
f39d57f
chore: update event variable name
gantunesr Jul 9, 2024
20e356b
chore: update copy variable names
gantunesr Jul 9, 2024
736dc39
refactor: remove redundant code
gantunesr Jul 9, 2024
737b269
chore: rename metrics variable
gantunesr Jul 9, 2024
2b33044
Merge branch 'develop' into feat/btc-toggle
ccharly Jul 10, 2024
e99ef83
chore: update metrics event
gantunesr Jul 10, 2024
f789263
chore: update metrics event
gantunesr Jul 10, 2024
163511b
chore: update copy
gantunesr Jul 10, 2024
81f3c4b
Merge remote-tracking branch 'origin/develop' into feat/btc-e2e-tests
montelaidev Jul 10, 2024
d923f8d
Merge branch 'develop' into feat/btc-toggle
montelaidev Jul 10, 2024
a88a3bb
chore: update copy
gantunesr Jul 10, 2024
e330b9d
Merge branch 'feat/btc-toggle' of https://github.com/MetaMask/metamas…
gantunesr Jul 10, 2024
58cccfe
chore: hide add account behind feature flag
gantunesr Jul 10, 2024
9e04ff7
Merge remote-tracking branch 'origin/feat/btc-toggle' into feat/btc-e…
montelaidev Jul 10, 2024
8a97a37
fix:lint
montelaidev Jul 10, 2024
dc1c1cf
Merge branch 'develop' into feat/btc-e2e-tests
montelaidev Jul 10, 2024
024fc7e
fix: remove unused dep
montelaidev Jul 10, 2024
b710377
Merge remote-tracking branch 'origin/develop' into feat/btc-e2e-tests
montelaidev Jul 10, 2024
98f0760
fix: remove unneeded changes
montelaidev Jul 10, 2024
1632170
fix: test
montelaidev Jul 11, 2024
3d31330
Update test/e2e/accounts/common.ts
montelaidev Jul 11, 2024
5902636
fix: cannot create multiple BTC account test
montelaidev Jul 11, 2024
89a85b6
fix: empty lines
montelaidev Jul 11, 2024
11451d8
Apply suggestions from code review
montelaidev Jul 12, 2024
1998540
Update test/e2e/flask/btc/create-btc-account.spec.ts
montelaidev Jul 12, 2024
d6b78db
Merge branch 'develop' into feat/btc-e2e-tests
montelaidev Jul 12, 2024
eb37113
fix: test
montelaidev Jul 12, 2024
4d81c47
Apply suggestions from code review
montelaidev Jul 15, 2024
fb351b2
fix: lint
montelaidev Jul 15, 2024
4a97a6f
fix: import path
montelaidev Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions privacy-snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
"acl.execution.metamask.io",
"api.blockchair.com",
"api.lens.dev",
"api.segment.io",
"api.web3modal.com",
Expand Down
12 changes: 12 additions & 0 deletions test/e2e/accounts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,15 @@ export async function signData(
});
}
}

export async function createBtcAccount(driver: Driver) {
await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
await driver.clickElement({
text: 'Add a new Bitcoin account',
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
tag: 'button',
});
await driver.clickElement({ text: 'Create', tag: 'button' });
}
1 change: 1 addition & 0 deletions test/e2e/accounts/create-snap-account.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Suite } from 'mocha';

import FixtureBuilder from '../fixture-builder';
import {
WINDOW_TITLES,
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/fixture-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ class FixtureBuilder {
});
}

withPreferencesControllerAndFeatureFlag(flags) {
merge(this.fixture.data.PreferencesController, flags);
return this;
}

withAccountsController(data) {
merge(this.fixture.data.AccountsController, data);
return this;
Expand Down
63 changes: 63 additions & 0 deletions test/e2e/flask/btc/btc-account-overview.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { strict as assert } from 'assert';
import { Suite } from 'mocha';
import {
withFixtures,
defaultGanacheOptions,
unlockWallet,
} from '../../helpers';
import { Driver } from '../../webdriver/driver';
import FixtureBuilder from '../../fixture-builder';
import { createBtcAccount } from '../../accounts/common';

describe('BTC Account - Overview', function (this: Suite) {
it('has buy/sell and portfolio button enabled for BTC accounts', async function () {
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
await withFixtures(
{
fixtures: new FixtureBuilder()
.withPreferencesControllerAndFeatureFlag({
bitcoinSupportEnabled: true,
})
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
await unlockWallet(driver);
await createBtcAccount(driver);
await driver.findElement({
css: '[data-testid="account-menu-icon"]',
text: 'Bitcoin Account',
});

await driver.waitForSelector({
text: 'Send',
tag: 'button',
css: '[disabled]',
});

await driver.waitForSelector({
text: 'Swap',
tag: 'button',
css: '[disabled]',
});

await driver.waitForSelector({
text: 'Bridge',
tag: 'button',
css: '[disabled]',
});

const buySellButton = await driver.waitForSelector(
'[data-testid="coin-overview-buy"]',
);
assert.equal(await buySellButton.isEnabled(), true);

const portfolioButton = await driver.waitForSelector(
'[data-testid="coin-overview-portfolio"]',
);

montelaidev marked this conversation as resolved.
Show resolved Hide resolved
assert.equal(await portfolioButton.isEnabled(), true);
},
);
});
});
47 changes: 47 additions & 0 deletions test/e2e/flask/btc/btc-dapp-connection.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { strict as assert } from 'assert';
import { Suite } from 'mocha';
import {
withFixtures,
defaultGanacheOptions,
unlockWallet,
openDapp,
WINDOW_TITLES,
} from '../../helpers';
import { Driver } from '../../webdriver/driver';
import FixtureBuilder from '../../fixture-builder';
import { createBtcAccount } from '../../accounts/common';

describe('BTC Account - Dapp Connection', function (this: Suite) {
it('cannot connect to dapps', async function () {
await withFixtures(
{
dapp: true,
fixtures: new FixtureBuilder()
.withPreferencesControllerAndFeatureFlag({
bitcoinSupportEnabled: true,
})
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
await unlockWallet(driver);
await createBtcAccount(driver);
await openDapp(driver);
await driver.clickElement('#connectButton');
await driver.waitUntilXWindowHandles(3);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);

const account2 = await driver.waitForSelector(
'[data-testid="choose-account-list-1"]',
);
assert((await account2.getText()).includes('Bitcoin Ac...'));
await account2.click();
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
const nextButton = await driver.waitForSelector(
'[data-testid="page-container-footer-next"]',
);
assert.equal(await nextButton.isEnabled(), false);
},
);
});
});
47 changes: 47 additions & 0 deletions test/e2e/flask/btc/btc-experimental-settings.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Suite } from 'mocha';

import FixtureBuilder from '../../fixture-builder';
import {
defaultGanacheOptions,
unlockWallet,
withFixtures,
} from '../../helpers';
import { Driver } from '../../webdriver/driver';

describe('BTC Experimental Settings', function (this: Suite) {
it('will show `Add new BTC account` option when setting is enabled', async function () {
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
await withFixtures(
{
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({ driver }: { driver: Driver }) => {
await unlockWallet(driver);
await driver.clickElement(
'[data-testid="account-options-menu-button"]',
);
await driver.clickElement({ text: 'Settings', tag: 'div' });
await driver.clickElement({ text: 'Experimental', tag: 'div' });

await driver.waitForSelector({
text: 'Enable "Add a new Bitcoin account (Beta)"',
tag: 'span',
});

await driver.clickElement('[data-testid="bitcoin-support-toggle-div"]');

await driver.clickElement('button[aria-label="Close"]');

await driver.clickElement('[data-testid="account-menu-icon"]');
await driver.clickElement(
'[data-testid="multichain-account-menu-popover-action-button"]',
);
await driver.waitForSelector({
text: 'Add a new Bitcoin account',
montelaidev marked this conversation as resolved.
Show resolved Hide resolved
tag: 'button',
});
},
);
});
});
Loading