Skip to content

Commit b118f49

Browse files
authored
test(e2e): Add E2E test for Snaps WASM (MetaMask#17932)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This adds an E2E test for WASM in Snaps. ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Closes MetaMask/snaps#3494. ## **Manual testing steps** n/a ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent ae3e614 commit b118f49

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

e2e/selectors/Browser/TestSnaps.selectors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const TestSnapViewSelectorWebIDS = {
1515
connectNetworkAccessButton: 'connectnetwork-access',
1616
connectEthereumProviderButton: 'connectethereum-provider',
1717
connectStateButton: 'connectstate',
18+
connectWasmButton: 'connectwasm',
1819
getPreferencesButton: 'getPreferences',
1920
getPublicKeyBip44Button: 'sendBip44Test',
2021
signMessageBip44Button: 'signBip44Message',
@@ -39,6 +40,7 @@ export const TestSnapViewSelectorWebIDS = {
3940
getChainIdButton: 'sendEthprovider',
4041
getAccountsButton: 'sendEthproviderAccounts',
4142
personalSignButton: 'signPersonalSignMessage',
43+
sendWasmMessageButton: 'sendWasmMessage',
4244
signTypedDataButton: 'signTypedDataButton',
4345
};
4446

@@ -59,6 +61,7 @@ export const TestSnapInputSelectorWebIDS = {
5961
webSocketUrlInput: 'webSocketUrl',
6062
personalSignMessageInput: 'personalSignMessage',
6163
signTypedDataMessageInput: 'signTypedData',
64+
wasmInput: 'wasmInput',
6265
};
6366

6467
export const EntropyDropDownSelectorWebIDS = {
@@ -94,6 +97,7 @@ export const TestSnapResultSelectorWebIDS = {
9497
sendUnencryptedManageStateResultSpan: 'sendUnencryptedManageStateResult',
9598
signTypedDataResultSpan: 'signTypedDataResult',
9699
unencryptedStateResultSpan: 'unencryptedStateResult',
100+
wasmResultSpan: 'wasmResult',
97101
};
98102

99103
export const TestSnapBottomSheetSelectorWebIDS = {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { FlaskBuildTests } from '../../tags';
2+
import { loginToApp } from '../../viewHelper';
3+
import FixtureBuilder from '../../framework/fixtures/FixtureBuilder';
4+
import { withFixtures } from '../../framework/fixtures/FixtureHelper';
5+
import TabBarComponent from '../../pages/wallet/TabBarComponent';
6+
import TestSnaps from '../../pages/Browser/TestSnaps';
7+
8+
jest.setTimeout(150_000);
9+
10+
describe(FlaskBuildTests('WASM Snap Tests'), () => {
11+
it('can connect to the WASM Snap', async () => {
12+
await withFixtures(
13+
{
14+
fixture: new FixtureBuilder().build(),
15+
restartDevice: true,
16+
},
17+
async () => {
18+
await loginToApp();
19+
await TabBarComponent.tapBrowser();
20+
await TestSnaps.navigateToTestSnap();
21+
22+
await TestSnaps.installSnap('connectWasmButton');
23+
},
24+
);
25+
});
26+
27+
it('return a response for the given number', async () => {
28+
await withFixtures(
29+
{
30+
fixture: new FixtureBuilder().build(),
31+
},
32+
async () => {
33+
await TestSnaps.fillMessage('wasmInput', '23');
34+
await TestSnaps.tapButton('sendWasmMessageButton');
35+
await TestSnaps.checkResultSpan('wasmResultSpan', '28657');
36+
},
37+
);
38+
});
39+
});

0 commit comments

Comments
 (0)