Skip to content

Commit baf9b08

Browse files
authored
test: snap-bip-32 test scenario migration to pom (#30175)
<!-- 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** PR to migrate snap-bip32 test scenario to POM PR to migrate snap-bip44 test scenario to POM <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/30175?quickstart=1) ## **Related issues** Fixes: #29894 #30179 ## **Manual testing steps** yarn build:test:flask yarn test:e2e:single test/e2e/snaps/test-snap-bip-32.spec.ts --browser=chrome --leave-running yarn test:e2e:single test/e2e/snaps/test-snap-bip-44.spec.ts --browser=chrome --leave-running ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/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 28f8d74 commit baf9b08

7 files changed

+429
-273
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Driver } from '../../../webdriver/driver';
2+
3+
class SnapInstallWarning {
4+
private driver: Driver;
5+
6+
private readonly checkBoxPermission = '.mm-checkbox__input';
7+
8+
private readonly buttonConfirm =
9+
'[data-testid="snap-install-warning-modal-confirm"]';
10+
11+
private readonly permissionConnect = '.permissions-connect';
12+
13+
constructor(driver: Driver) {
14+
this.driver = driver;
15+
}
16+
17+
async check_pageIsLoaded(): Promise<void> {
18+
try {
19+
await this.driver.waitForMultipleSelectors([
20+
this.checkBoxPermission,
21+
this.permissionConnect,
22+
]);
23+
} catch (e) {
24+
console.log(
25+
'Timeout while waiting for snap install warning dialog to be loaded',
26+
e,
27+
);
28+
throw e;
29+
}
30+
console.log('Snap install warning dialog is loaded');
31+
}
32+
33+
async clickCheckboxPermission() {
34+
console.log('Click checkbox permission');
35+
await this.driver.clickElement(this.checkBoxPermission);
36+
}
37+
38+
async clickConfirmButton() {
39+
console.log('Click confirm button');
40+
await this.driver.clickElement(this.buttonConfirm);
41+
}
42+
}
43+
44+
export default SnapInstallWarning;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { Driver } from '../../../webdriver/driver';
2+
3+
class SnapInstall {
4+
private driver: Driver;
5+
6+
private readonly nextPageButton =
7+
'[data-testid="page-container-footer-next"]';
8+
9+
private readonly pageFooter = '.page-container__footer';
10+
11+
private readonly permissionConnect = '.permissions-connect';
12+
13+
private readonly scrollSnapInstall = '[data-testid="snap-install-scroll"]';
14+
15+
private readonly approveButton = '[data-testid="confirmation-submit-button"]';
16+
17+
constructor(driver: Driver) {
18+
this.driver = driver;
19+
}
20+
21+
async check_pageIsLoaded(): Promise<void> {
22+
try {
23+
await this.driver.waitForMultipleSelectors([
24+
this.pageFooter,
25+
this.permissionConnect,
26+
]);
27+
} catch (e) {
28+
console.log(
29+
'Timeout while waiting for Snap install dialog to be loaded',
30+
e,
31+
);
32+
throw e;
33+
}
34+
console.log('Snap install dialog is loaded');
35+
}
36+
37+
async clickNextButton() {
38+
console.log('Click Confirm/Ok button');
39+
await this.driver.clickElement(this.nextPageButton);
40+
}
41+
42+
async clickConfirmButton() {
43+
console.log('Scroll and click confirm button');
44+
await this.driver.clickElementSafe(this.scrollSnapInstall);
45+
await this.driver.clickElement(this.nextPageButton);
46+
}
47+
48+
async clickApproveButton() {
49+
console.log('Click approve button');
50+
await this.driver.clickElement(this.approveButton);
51+
}
52+
}
53+
54+
export default SnapInstall;

test/e2e/page-objects/pages/test-snaps.ts

+127
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,48 @@ export class TestSnaps {
3232

3333
private readonly connectHomePage = '#connecthomepage';
3434

35+
private readonly connectBip32 = '#connectbip32';
36+
37+
private readonly connectBip44 = '#connectbip44';
38+
39+
private readonly reconnectButton = {
40+
css: '#connectbip32',
41+
text: 'Reconnect to BIP-32 Snap',
42+
};
43+
44+
private readonly reconnectBip44Button = {
45+
css: '#connectbip44',
46+
text: 'Reconnect to BIP-44 Snap',
47+
};
48+
49+
private readonly getPublicKeyButton = {
50+
css: '#bip32GetPublic',
51+
text: 'Get Public Key',
52+
};
53+
54+
private readonly getCompressedKeyButton = {
55+
css: '#bip32GetCompressedPublic',
56+
text: 'Get Compressed Public Key',
57+
};
58+
59+
private readonly publicKeyBip44Button = '#sendBip44Test';
60+
61+
private readonly inputMessageEd25519 = '#bip32Message-ed25519';
62+
63+
private readonly inputMessageEd25519Bip32 = '#bip32Message-ed25519Bip32';
64+
65+
private readonly inputMessageSecp256k1 = '#bip32Message-secp256k1';
66+
67+
private readonly buttonMessageSecp256k1 = '#sendBip32-secp256k1';
68+
69+
private readonly buttonSignEd25519Message = '#sendBip32-ed25519';
70+
71+
private readonly inputMessageBip44 = '#bip44Message';
72+
73+
private readonly buttonSignBip44Message = '#signBip44Message';
74+
75+
private readonly buttonSignEd25519Bip32Message = '#sendBip32-ed25519Bip32';
76+
3577
constructor(driver: Driver) {
3678
this.driver = driver;
3779
}
@@ -53,6 +95,44 @@ export class TestSnaps {
5395
await this.driver.clickElement(this.dialogsSnapConfirmationButton);
5496
}
5597

98+
async clickConnectBip32() {
99+
console.log('Wait, scroll and click connect button');
100+
await this.driver.scrollToElement(
101+
this.driver.findClickableElement(this.connectBip32),
102+
);
103+
await this.driver.delay(largeDelayMs);
104+
await this.driver.waitForSelector(this.connectBip32);
105+
await this.driver.clickElement(this.connectBip32);
106+
}
107+
108+
async clickConnectBip44() {
109+
console.log('Wait, scroll and click connect button');
110+
await this.driver.scrollToElement(
111+
this.driver.findClickableElement(this.connectBip44),
112+
);
113+
await this.driver.delay(largeDelayMs);
114+
await this.driver.waitForSelector(this.connectBip44);
115+
await this.driver.clickElement(this.connectBip44);
116+
}
117+
118+
async clickGetPublicKeyButton() {
119+
console.log('Wait and click get public key button');
120+
await this.driver.waitForSelector(this.getPublicKeyButton);
121+
await this.driver.clickElement(this.getPublicKeyButton);
122+
}
123+
124+
async clickPublicKeyBip44Button() {
125+
console.log('Wait and click get public key button');
126+
await this.driver.waitForSelector(this.publicKeyBip44Button);
127+
await this.driver.clickElement(this.publicKeyBip44Button);
128+
}
129+
130+
async clickGetCompressedPublicKeyButton() {
131+
console.log('Wait and click get compressed public key button');
132+
await this.driver.waitForSelector(this.getCompressedKeyButton);
133+
await this.driver.clickElement(this.getCompressedKeyButton);
134+
}
135+
56136
async completeSnapInstallConfirmation() {
57137
await this.driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
58138

@@ -85,4 +165,51 @@ export class TestSnaps {
85165
await this.driver.waitForSelector(this.connectHomePage);
86166
await this.driver.clickElement(this.connectHomePage);
87167
}
168+
169+
async fillMessageSecp256k1(message: string) {
170+
console.log('Wait and fill message in secp256k1');
171+
await this.driver.fill(this.inputMessageSecp256k1, message);
172+
await this.driver.clickElement(this.buttonMessageSecp256k1);
173+
}
174+
175+
async fillMessageEd25519(message: string) {
176+
console.log('Wait and fill message in ed25519');
177+
await this.driver.waitForSelector(this.inputMessageEd25519);
178+
await this.driver.fill(this.inputMessageEd25519, message);
179+
await this.driver.clickElement(this.buttonSignEd25519Message);
180+
}
181+
182+
async fillMessageEd25519Bip32(message: string) {
183+
console.log('Wait and fill message in ed25519 bip32');
184+
await this.driver.waitForSelector(this.inputMessageEd25519Bip32);
185+
await this.driver.fill(this.inputMessageEd25519Bip32, message);
186+
await this.driver.clickElement(this.buttonSignEd25519Bip32Message);
187+
}
188+
189+
async fillBip44MessageAndSign(message: string) {
190+
console.log('Wait and enter bip44 message ');
191+
await this.driver.pasteIntoField(this.inputMessageBip44, message);
192+
const buttonSignBip44 = await this.driver.findElement(
193+
this.buttonSignBip44Message,
194+
);
195+
await this.driver.scrollToElement(buttonSignBip44);
196+
await this.driver.waitForSelector(this.buttonSignBip44Message);
197+
await this.driver.clickElement(this.buttonSignBip44Message);
198+
}
199+
200+
async scrollToSendEd25519() {
201+
console.log('Scroll to send ed25519');
202+
const sendEd25519 = await this.driver.findElement(this.inputMessageEd25519);
203+
await this.driver.scrollToElement(sendEd25519);
204+
}
205+
206+
async waitForReconnectButton() {
207+
console.log('Wait for reconnect button');
208+
await this.driver.waitForSelector(this.reconnectButton);
209+
}
210+
211+
async waitForReconnectBip44Button() {
212+
console.log('Wait for reconnect button');
213+
await this.driver.waitForSelector(this.reconnectBip44Button);
214+
}
88215
}

0 commit comments

Comments
 (0)