Skip to content

Commit a811f65

Browse files
authored
test(extension): maintenance 24 June 2025 (#1918)
* test(extension): fix LW-4071 * test(extension): clean up methods within settingsExtendedPageObject.ts - part 1 * test(extension): clean up methods within settingsExtendedPageObject.ts - part 2
1 parent ead6ea7 commit a811f65

File tree

13 files changed

+265
-243
lines changed

13 files changed

+265
-243
lines changed

packages/e2e-tests/src/assert/topNavigationAssert.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { t } from '../utils/translationService';
44
import { expect } from 'chai';
55
import { ParsedCSSValue } from 'webdriverio';
66
import extensionUtils from '../utils/utils';
7-
import settingsExtendedPageObject from '../pageobject/settingsExtendedPageObject';
87
import { browser } from '@wdio/globals';
98
import WalletOption from '../elements/WalletOption';
109
import CrashScreen from '../elements/CrashScreen';
10+
import { waitUntilHdWalletSynced } from '../utils/networkUtils';
1111

1212
class TopNavigationAssert {
1313
private readonly CSS_COLOR = 'color';
@@ -137,7 +137,7 @@ class TopNavigationAssert {
137137
if (await CrashScreen.reloadExtensionButton.isDisplayed()) {
138138
throw new Error('Crash screen occurred!');
139139
}
140-
await settingsExtendedPageObject.waitUntilHdWalletSynced();
140+
await waitUntilHdWalletSynced();
141141
await this.assertLogoPresent();
142142
await MenuHeader.menuButton.waitForClickable({ timeout: 10_000 });
143143
await MenuHeader.menuButton.click();

packages/e2e-tests/src/elements/PrivacyPolicyUpdateBanner.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ class PrivacyPolicyUpdateBanner {
1717
await this.agreeButton.waitForClickable();
1818
await this.agreeButton.click();
1919
}
20+
21+
async closePrivacyPolicyUpdateBanner(): Promise<void> {
22+
if (await this.container.isDisplayed()) {
23+
await this.clickOnAgreeButton();
24+
}
25+
}
2026
}
2127

2228
export default new PrivacyPolicyUpdateBanner();

packages/e2e-tests/src/elements/modal.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint-disable no-undef */
22
import { ChainablePromiseElement } from 'webdriverio';
33
import { browser } from '@wdio/globals';
4+
import { expect } from 'chai';
5+
import { t } from '../utils/translationService';
46

57
class Modal {
68
private CONTAINER_FIREFOX = '.ant-modal-root .ant-modal-content';
@@ -50,6 +52,23 @@ class Modal {
5052
timeoutMsg: 'failed while waiting for the modal to disappear'
5153
});
5254
}
55+
56+
async confirmMultiAddressModal() {
57+
if (await this.container.isDisplayed()) {
58+
expect(await this.confirmButton.getText()).to.equal(await t('modals.beta.button'));
59+
await this.confirmButton.click();
60+
}
61+
}
62+
63+
async waitUntilSyncingModalDisappears(): Promise<void> {
64+
await browser.pause(500);
65+
if (
66+
(await this.container.isDisplayed()) &&
67+
(await this.title.getText()) === (await t('addressesDiscovery.overlay.title'))
68+
) {
69+
await this.title.waitForDisplayed({ reverse: true, timeout: 220_000 });
70+
}
71+
}
5372
}
5473

5574
export default new Modal();
Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,69 @@
1+
/* global WebdriverIO */
12
import CommonDrawerElements from '../CommonDrawerElements';
3+
import type { ChainablePromiseElement } from 'webdriverio';
4+
import type { NetworkType } from '../../types/network';
25

36
class NetworkDrawer extends CommonDrawerElements {
7+
private MAINNET_RADIO_BUTTON_INPUT = '//input[@data-testid="network-mainnet-radio-button"]';
48
private MAINNET_RADIO_BUTTON = '//label[span/input[@data-testid="network-mainnet-radio-button"]]';
9+
private PREPROD_RADIO_BUTTON_INPUT = '//input[@data-testid="network-preprod-radio-button"]';
510
private PREPROD_RADIO_BUTTON = '//label[span/input[@data-testid="network-preprod-radio-button"]]';
11+
private PREVIEW_RADIO_BUTTON_INPUT = '//input[@data-testid="network-preview-radio-button"]';
612
private PREVIEW_RADIO_BUTTON = '//label[span/input[@data-testid="network-preview-radio-button"]]';
713

8-
get mainnetRadioButton() {
14+
get mainnetRadioButton(): ChainablePromiseElement<WebdriverIO.Element> {
915
return $(this.MAINNET_RADIO_BUTTON);
1016
}
1117

12-
get preprodRadioButton() {
18+
get mainnetRadioButtonInput(): ChainablePromiseElement<WebdriverIO.Element> {
19+
return $(this.MAINNET_RADIO_BUTTON_INPUT);
20+
}
21+
22+
get preprodRadioButton(): ChainablePromiseElement<WebdriverIO.Element> {
1323
return $(this.PREPROD_RADIO_BUTTON);
1424
}
1525

16-
get previewRadioButton() {
26+
get preprodRadioButtonInput(): ChainablePromiseElement<WebdriverIO.Element> {
27+
return $(this.PREPROD_RADIO_BUTTON_INPUT);
28+
}
29+
30+
get previewRadioButton(): ChainablePromiseElement<WebdriverIO.Element> {
1731
return $(this.PREVIEW_RADIO_BUTTON);
1832
}
33+
34+
get previewRadioButtonInput(): ChainablePromiseElement<WebdriverIO.Element> {
35+
return $(this.PREVIEW_RADIO_BUTTON_INPUT);
36+
}
37+
38+
clickOnNetworkRadioButton = async (network: NetworkType) => {
39+
switch (network) {
40+
case 'Mainnet':
41+
await this.mainnetRadioButton.waitForClickable();
42+
await this.mainnetRadioButton.click();
43+
break;
44+
case 'Preprod':
45+
await this.preprodRadioButton.waitForClickable();
46+
await this.preprodRadioButton.click();
47+
break;
48+
case 'Preview':
49+
await this.previewRadioButton.waitForClickable();
50+
await this.previewRadioButton.click();
51+
break;
52+
}
53+
};
54+
55+
isNetworkSelected = async (network: NetworkType) => {
56+
switch (network) {
57+
case 'Mainnet':
58+
return await this.mainnetRadioButtonInput.isSelected();
59+
case 'Preprod':
60+
return await this.preprodRadioButtonInput.isSelected();
61+
case 'Preview':
62+
return await this.previewRadioButtonInput.isSelected();
63+
default:
64+
return false;
65+
}
66+
};
1967
}
2068

2169
export default new NetworkDrawer();

packages/e2e-tests/src/elements/settings/SettingsPage.ts

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ import { SettingsLink } from './SettingsLink';
55
import CommonDrawerElements from '../CommonDrawerElements';
66
import { ChainablePromiseArray } from 'webdriverio/build/types';
77

8+
export type SettingsElementName =
9+
| 'About'
10+
| 'Your keys'
11+
| 'Network'
12+
| 'Authorized DApps'
13+
| 'Show recovery phrase'
14+
| 'Passphrase verification'
15+
| 'FAQs'
16+
| 'Help'
17+
| 'Terms and conditions'
18+
| 'Privacy policy'
19+
| 'Collateral'
20+
| 'Cookie policy'
21+
| 'Custom Submit API'
22+
| 'Generate paper wallet';
23+
824
class SettingsPage extends CommonDrawerElements {
925
private readonly WALLET_HEADER = '[data-testid="wallet-settings-heading"]';
1026
private readonly SECURITY_HEADER = '[data-testid="security-settings-heading"]';
@@ -187,6 +203,92 @@ class SettingsPage extends CommonDrawerElements {
187203
await this.betaProgramSwitch.waitForClickable();
188204
await this.betaProgramSwitch.click();
189205
}
206+
207+
async setExtensionTheme(mode: 'light' | 'dark'): Promise<void> {
208+
if (mode !== ((await this.themeSwitch.getAttribute('aria-checked')) === 'true' ? 'light' : 'dark')) {
209+
await this.themeSwitch.waitForClickable();
210+
await this.themeSwitch.click();
211+
}
212+
}
213+
214+
async clickOnRemoveWallet(): Promise<void> {
215+
await this.removeWalletButton.waitForStable();
216+
await this.removeWalletButton.click();
217+
}
218+
219+
async toggleDebugging(isEnabled: boolean): Promise<void> {
220+
(await this.debuggingSwitch.getAttribute('aria-checked')) !== String(isEnabled) &&
221+
(await this.debuggingSwitch.click());
222+
}
223+
224+
private readonly elementActions: Record<SettingsElementName, () => Promise<void>> = {
225+
About: async () => {
226+
await this.aboutLink.element.waitForClickable();
227+
await this.aboutLink.element.click();
228+
},
229+
'Your keys': async () => {
230+
await this.yourKeysLink.element.waitForClickable();
231+
await this.yourKeysLink.element.click();
232+
},
233+
Network: async () => {
234+
await this.networkLink.element.waitForClickable();
235+
await this.networkLink.element.click();
236+
},
237+
'Authorized DApps': async () => {
238+
await this.authorizedDAppsLink.element.waitForClickable();
239+
await this.authorizedDAppsLink.element.click();
240+
},
241+
'Show recovery phrase': async () => {
242+
await this.showRecoveryPhraseLink.element.waitForClickable();
243+
await this.showRecoveryPhraseLink.element.click();
244+
},
245+
'Passphrase verification': async () => {
246+
await this.passphraseVerificationLink.element.waitForClickable();
247+
await this.passphraseVerificationLink.element.click();
248+
},
249+
FAQs: async () => {
250+
await this.faqsLink.element.waitForClickable();
251+
await this.faqsLink.element.click();
252+
},
253+
Help: async () => {
254+
await this.helpLink.element.waitForClickable();
255+
await this.helpLink.element.click();
256+
},
257+
'Terms and conditions': async () => {
258+
await this.tncLink.element.waitForClickable();
259+
await this.tncLink.element.click();
260+
},
261+
'Privacy policy': async () => {
262+
await this.privacyPolicyLink.element.waitForClickable();
263+
await this.privacyPolicyLink.element.click();
264+
},
265+
Collateral: async () => {
266+
await this.collateralLink.element.waitForClickable();
267+
await this.collateralLink.element.click();
268+
},
269+
'Cookie policy': async () => {
270+
await this.cookiePolicy.element.waitForClickable();
271+
await this.cookiePolicy.element.click();
272+
},
273+
'Custom Submit API': async () => {
274+
await this.customSubmitAPILink.element.waitForClickable();
275+
await this.customSubmitAPILink.element.click();
276+
},
277+
'Generate paper wallet': async () => {
278+
await this.generatePaperWallet.element.waitForClickable();
279+
await this.generatePaperWallet.element.click();
280+
}
281+
};
282+
283+
clickSettingsItem = async (elementName: SettingsElementName): Promise<void> => {
284+
const action = this.elementActions[elementName];
285+
if (!action) {
286+
const supportedElements = Object.keys(this.elementActions).join(', ');
287+
throw new Error(`Unsupported element: "${elementName}". Supported elements: ${supportedElements}`);
288+
}
289+
290+
await action();
291+
};
190292
}
191293

192294
export default new SettingsPage();

packages/e2e-tests/src/elements/settings/YourKeysDrawer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ class YourKeysDrawer extends CommonDrawerElements {
88
get showPublicKeyButton(): ChainablePromiseElement<WebdriverIO.Element> {
99
return $(this.SHOW_PUBLIC_KEY_BUTTON);
1010
}
11+
12+
async clickOnShowPublicKey(): Promise<void> {
13+
await this.showPublicKeyButton.waitForStable();
14+
await this.showPublicKeyButton.click();
15+
}
1116
}
1217

1318
export default new YourKeysDrawer();

packages/e2e-tests/src/elements/toastMessage.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable no-undef */
22
import { ChainablePromiseElement } from 'webdriverio';
3+
import { t } from '../utils/translationService';
4+
import { Logger } from '../support/logger';
35

46
class ToastMessage {
57
private CONTAINER = '[data-testid="toast-content-wrapper"]';
@@ -32,6 +34,17 @@ class ToastMessage {
3234
await this.closeButton.waitForClickable();
3335
await this.closeButton.click();
3436
}
37+
38+
async closeWalletSyncedToast(): Promise<void> {
39+
if (await this.container.isDisplayed()) {
40+
const toastMessage = await (await this.messageText).getText();
41+
if (toastMessage === (await t('addressesDiscovery.toast.successText')).toString()) {
42+
await this.clickCloseButton();
43+
} else {
44+
Logger.warn('Wallet synced toast is not displayed, you might want to remove this step');
45+
}
46+
}
47+
}
3548
}
3649

3750
export default new ToastMessage();

0 commit comments

Comments
 (0)