Skip to content

Commit 93950fa

Browse files
committed
test: add test for LW-13634
1 parent fbf58d8 commit 93950fa

16 files changed

+370
-26
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { expect } from 'chai';
2+
3+
import ConfigureMidnightPage from '../../elements/onboarding/ConfigureMidnightPage';
4+
import { Constants } from '../../setup/Constants';
5+
import { t } from '../../utils/translationService';
6+
7+
import OnboardingCommonAssert from './onboardingCommonAssert';
8+
9+
class ConfigureMidnightPageAssert extends OnboardingCommonAssert {
10+
async assertSeeNetworkSection() {
11+
await ConfigureMidnightPage.networkSectionLabel.waitForDisplayed();
12+
// TODO: update translation keys when LW-13474 is merged
13+
expect(await ConfigureMidnightPage.networkSectionLabel.getText()).to.equal(
14+
await t('midnight.network-config.network-label')
15+
);
16+
await ConfigureMidnightPage.networkOptionTestnet.waitForDisplayed();
17+
expect(await ConfigureMidnightPage.networkOptionTestnet.getText()).to.equal(
18+
await t('midnight.network-config.network-option.2')
19+
);
20+
await ConfigureMidnightPage.networkOptionUndeployed.waitForDisplayed();
21+
expect(await ConfigureMidnightPage.networkOptionUndeployed.getText()).to.equal(
22+
await t('midnight.network-config.network-option.0')
23+
);
24+
}
25+
26+
async assertSeeEnterWalletButton() {
27+
await ConfigureMidnightPage.enterWalletButton.waitForDisplayed();
28+
expect(await ConfigureMidnightPage.enterWalletButton.getText()).to.equal(await t('onboarding.steps.enter-wallet'));
29+
}
30+
31+
async assertSeeProofServerSection(midnightNetwork: 'testnet' | 'undeployed' = 'testnet') {
32+
await ConfigureMidnightPage.proofServerSectionLabel.waitForDisplayed();
33+
expect(await ConfigureMidnightPage.proofServerSectionLabel.getText()).to.equal(
34+
await t('midnight.network-config.proof-server-label')
35+
);
36+
37+
await ConfigureMidnightPage.proofServerOptionLocal.waitForDisplayed();
38+
const proofServerValue = await ConfigureMidnightPage.proofServerOptionLocal.getText();
39+
expect(proofServerValue).to.include(Constants.MIDNIGHT_PROOF_SERVER_ADDRESS);
40+
expect(proofServerValue).to.include(await t('midnight.network-config.proof-server-option.local'));
41+
42+
await ConfigureMidnightPage.nodeAddressInputLabel.waitForDisplayed();
43+
expect(await ConfigureMidnightPage.nodeAddressInputLabel.getText()).to.equal(
44+
await t('midnight.network-config.node-address')
45+
);
46+
await ConfigureMidnightPage.nodeAddressInput.waitForDisplayed();
47+
const expectedNodeAddress =
48+
midnightNetwork === 'undeployed' ? Constants.NODE_ADDRESS_UNDEPLOYED : Constants.NODE_ADDRESS_TESTNET;
49+
expect(await ConfigureMidnightPage.nodeAddressInput.getValue()).to.equal(expectedNodeAddress);
50+
51+
await ConfigureMidnightPage.indexerAddressInputLabel.waitForDisplayed();
52+
expect(await ConfigureMidnightPage.indexerAddressInputLabel.getText()).to.equal(
53+
await t('midnight.network-config.indexer-address')
54+
);
55+
await ConfigureMidnightPage.indexerAddressInput.waitForDisplayed();
56+
const expectedIndexerAddress =
57+
midnightNetwork === 'undeployed' ? Constants.INDEXER_ADDRESS_UNDEPLOYED : Constants.INDEXER_ADDRESS_TESTNET;
58+
expect(await ConfigureMidnightPage.indexerAddressInput.getValue()).to.equal(expectedIndexerAddress);
59+
}
60+
61+
async assertSeeConfigureMidnightPage() {
62+
await this.assertSeeTopLaceLogo();
63+
await this.assertSeeHelpAndSupportButton();
64+
await this.assertSeeStepTitle(await t('onboarding.midnight.settings.title'));
65+
await this.assertSeeStepSubtitle(await t('onboarding.midnight.settings.description'));
66+
await this.assertSeeNetworkSection();
67+
await this.assertSeeProofServerSection();
68+
await this.assertSeeBackButton();
69+
await this.assertSeeEnterWalletButton();
70+
await this.assertSeeMidnightCompatibilityInfo();
71+
await this.assertSeeLegalLinks();
72+
}
73+
}
74+
75+
export default new ConfigureMidnightPageAssert();

packages/e2e-tests/src/assert/onboarding/onboardingCommonAssert.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class OnboardingCommonAssert {
1010
this.commonOnboardingElements = new CommonOnboardingElements();
1111
}
1212

13+
async assertSeeTopLaceLogo(): Promise<void> {
14+
await this.commonOnboardingElements.laceLogo.waitForDisplayed();
15+
}
16+
1317
async assertSeeStepTitle(expectedTitle: string): Promise<void> {
1418
await this.commonOnboardingElements.stepTitle.waitForStable();
1519
expect(await this.commonOnboardingElements.stepTitle.getText()).to.equal(expectedTitle);
@@ -81,6 +85,16 @@ class OnboardingCommonAssert {
8185
}
8286
expect(await this.commonOnboardingElements.activeStepIndicator.getText()).to.equal(expectedStepTitle);
8387
}
88+
89+
async assertSeeMidnightCompatibilityInfo(): Promise<void> {
90+
await this.commonOnboardingElements.compatibilityLabel.waitForDisplayed();
91+
expect(await this.commonOnboardingElements.compatibilityLabel.getText()).to.equal(
92+
await t('onboarding.compatible-with')
93+
);
94+
await this.commonOnboardingElements.midnightSymbol.waitForDisplayed();
95+
await this.commonOnboardingElements.midnightLabel.waitForDisplayed();
96+
expect(await this.commonOnboardingElements.midnightLabel.getText()).to.equal(await t('onboarding.midnight.label'));
97+
}
8498
}
8599

86100
export default OnboardingCommonAssert;

packages/e2e-tests/src/assert/onboarding/onboardingMainPageAssert.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,22 @@ class OnboardingMainPageAssert extends OnboardingCommonAssert {
9494
await OnboardingMainPage.restoreWalletButton.waitForClickable();
9595
}
9696

97-
async assertSeeMainPage() {
97+
async assertSeeMainPage(walletType: 'Cardano' | 'Midnight' = 'Cardano') {
9898
await this.assertSeeLogo();
9999
await this.assertSeeTitle();
100100
await this.assertSeeSubtitle();
101101
await this.assertSeeCreateWalletOption();
102-
// Lack of support for hardware wallets on Firefox
103-
await this.assertSeeHardwareWalletOption(!browser.isFirefox);
102+
// Lack of support for hardware wallets on Firefox and on Midnight
103+
await this.assertSeeHardwareWalletOption(!browser.isFirefox && walletType === 'Cardano');
104104
await this.assertSeeRestoreWalletOption();
105105
await this.assertSeeLegalLinks();
106106
await this.assertSeeHelpAndSupportButton();
107107
await this.assertSeeAgreementText();
108108
await this.assertSeeTermsOfServiceLink();
109109
await this.assertSeePrivacyPolicyLink();
110+
if (walletType === 'Midnight') {
111+
await this.assertSeeMidnightCompatibilityInfo();
112+
}
110113
}
111114
}
112115

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,18 @@ class TokensPageAssert {
276276
await t('general.warnings.cannotFetchPrice')
277277
);
278278
}
279+
280+
async assertSendButtonEnabled(shouldBeEnabled: boolean): Promise<void> {
281+
await MenuHeader.sendButton.waitForEnabled({ reverse: !shouldBeEnabled });
282+
}
283+
284+
async assertSeeMidnightTokensPage() {
285+
await TokensPage.title.waitForDisplayed();
286+
expect(await TokensPage.title.getText()).to.contain(await t('app.tokens'));
287+
288+
await TokensPage.counter.waitForDisplayed();
289+
expect(await TokensPage.counter.getText()).to.to.match(TestnetPatterns.COUNTER_REGEX);
290+
}
279291
}
280292

281293
export default new TokensPageAssert();

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ class TopNavigationAssert {
8888
await t('browserView.sideMenu.links.addSharedWallet')
8989
);
9090
}
91+
// TODO: uncomment when LW-13474 is merged
92+
// await MenuHeader.menuAddMidnightWalletButton.waitForDisplayed();
93+
// expect(await MenuHeader.menuAddMidnightWalletButton.getText()).to.equal(
94+
// await t('browserView.sideMenu.links.addMidnightWallet')
95+
// );
9196
await MenuHeader.menuAddressBookButton.waitForDisplayed();
9297
expect(await MenuHeader.menuAddressBookButton.getText()).to.equal(
9398
await t('browserView.sideMenu.links.addressBook')
@@ -259,6 +264,23 @@ class TopNavigationAssert {
259264
async assertSeeAddSharedWalletOption(shouldBeDisplayed: boolean) {
260265
await MenuHeader.menuAddSharedWalletButton.waitForDisplayed({ reverse: !shouldBeDisplayed });
261266
}
267+
268+
async assertMidnightWalletIsInSyncedStatus() {
269+
await MenuHeader.midnightLogo.waitForDisplayed();
270+
await MenuHeader.midnightTitle.waitForDisplayed();
271+
await MenuHeader.midnightSyncStatus.waitForDisplayed();
272+
await this.assertMidnightSyncStatus('app.sync-status.synced');
273+
await MenuHeader.midnightResyncIcon.waitForEnabled();
274+
}
275+
276+
async assertMidnightSyncStatus(status: string) {
277+
const expectedStatus = (await t(status)) ?? status;
278+
await browser.waitUntil(async () => (await MenuHeader.getWalletSyncStatusText()) === expectedStatus, {
279+
timeout: 180_000,
280+
interval: 500,
281+
timeoutMsg: `expected sync status "${expectedStatus}" was not displayed`
282+
});
283+
}
262284
}
263285

264286
export default new TopNavigationAssert();

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class MenuHeader {
1717
private MENU_ADD_NEW_WALLET_BUTTON = '[data-testid="header-menu-new-wallet"]';
1818
private MENU_ADD_BITCOIN_WALLET_BUTTON = '[data-testid="header-menu-add-bitcoin-wallet"]';
1919
private MENU_ADD_SHARED_WALLET_BUTTON = '[data-testid="header-menu-add-shared-wallet"]';
20+
private MENU_ADD_MIDNIGHT_WALLET_BUTTON = '[data-testid="header-menu-add-midnight-wallet"]';
2021
private MENU_SETTINGS_BUTTON = '//li[@data-testid="header-menu-settings"]';
2122
private MENU_SIGN_MESSAGE_BUTTON = '//li[@data-testid="header-menu-sign-message"]';
2223
private MENU_LOCK_BUTTON = '//li[@data-testid="header-menu-lock"]';
@@ -36,6 +37,10 @@ export class MenuHeader {
3637
private readonly RECEIVE_BUTTON = 'aside [data-testid="receive-button"]';
3738
private readonly SEND_BUTTON = 'aside [data-testid="send-button"]';
3839
private readonly CO_SIGN_BUTTON = '[data-testid="co-sign-button"]';
40+
private readonly MIDNIGHT_LOGO = '[data-testid="midnight-logo"]';
41+
private readonly MIDNIGHT_TITLE = '[data-testid="midnight-title"]';
42+
private readonly MIDNIGHT_MENU_SYNC_STATUS = '[data-testid="menu-sync-status"]';
43+
private readonly MIDNIGHT_RESYNC_ICON = '[data-testid="resync-icon"]';
3944

4045
get avatarOnButton(): ChainablePromiseElement<WebdriverIO.Element> {
4146
return $(this.AVATAR_ON_BUTTON);
@@ -117,6 +122,10 @@ export class MenuHeader {
117122
return $(this.MENU_ADD_SHARED_WALLET_BUTTON);
118123
}
119124

125+
get menuAddMidnightWalletButton(): ChainablePromiseElement<WebdriverIO.Element> {
126+
return $(this.MENU_ADD_MIDNIGHT_WALLET_BUTTON);
127+
}
128+
120129
get menuSettingsButton(): ChainablePromiseElement<WebdriverIO.Element> {
121130
return $(this.MENU_SETTINGS_BUTTON);
122131
}
@@ -169,6 +178,22 @@ export class MenuHeader {
169178
return $(this.RIGHT_SIDE_PANEL_BUTTON);
170179
}
171180

181+
get midnightLogo(): ChainablePromiseElement<WebdriverIO.Element> {
182+
return $(this.MIDNIGHT_LOGO);
183+
}
184+
185+
get midnightTitle(): ChainablePromiseElement<WebdriverIO.Element> {
186+
return $(this.MIDNIGHT_TITLE);
187+
}
188+
189+
get midnightSyncStatus(): ChainablePromiseElement<WebdriverIO.Element> {
190+
return $(this.MIDNIGHT_MENU_SYNC_STATUS);
191+
}
192+
193+
get midnightResyncIcon(): ChainablePromiseElement<WebdriverIO.Element> {
194+
return $(this.MIDNIGHT_RESYNC_ICON);
195+
}
196+
172197
async clickOnExpandButton(): Promise<void> {
173198
await this.expandButton.click();
174199
}
@@ -204,6 +229,11 @@ export class MenuHeader {
204229
await this.menuAddSharedWalletButton.click();
205230
}
206231

232+
async clickOnAddMidnightWalletOption(): Promise<void> {
233+
await this.menuAddMidnightWalletButton.waitForClickable();
234+
await this.menuAddMidnightWalletButton.click();
235+
}
236+
207237
async clickMenuButton(): Promise<void> {
208238
await this.menuButton.waitForClickable({ timeout: 15_000 });
209239
await this.menuButton.click();
@@ -272,6 +302,10 @@ export class MenuHeader {
272302
async clickRightSidePanelButton(): Promise<void> {
273303
await this.rightSidePanelButton.click();
274304
}
305+
306+
async getWalletSyncStatusText(): Promise<string> {
307+
return await this.midnightSyncStatus.getText();
308+
}
275309
}
276310

277311
export default new MenuHeader();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* global WebdriverIO */
2+
import { ChainablePromiseElement } from 'webdriverio';
3+
4+
class PasswordAuthPrompt {
5+
private readonly PASSWORD_INPUT = '[data-testid="authentication-prompt-input"]';
6+
private readonly CONFIRM_BUTTON = '[data-testid="authentication-prompt-button-confirm"]';
7+
8+
get passwordInput(): ChainablePromiseElement<WebdriverIO.Element> {
9+
return $(this.PASSWORD_INPUT);
10+
}
11+
12+
get confirmButton(): ChainablePromiseElement<WebdriverIO.Element> {
13+
return $(this.CONFIRM_BUTTON);
14+
}
15+
16+
async enterPasswordAndConfirm(password: string) {
17+
await this.passwordInput.waitForDisplayed();
18+
await this.passwordInput.setValue(password);
19+
await this.confirmButton.click();
20+
}
21+
}
22+
23+
export default new PasswordAuthPrompt();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* global WebdriverIO */
2+
import CommonOnboardingElements from './commonOnboardingElements';
3+
import { ChainablePromiseElement } from 'webdriverio';
4+
5+
class ConfigureMidnightPage extends CommonOnboardingElements {
6+
private readonly NODE_ADDRESS_INPUT = '[data-testid="node-address-input"]';
7+
private readonly NODE_ADDRESS_INPUT_LAEBL = '[data-testid="node-address-input"] + label';
8+
private readonly PUB_SUB_INDEXER_ADDRESS_INPUT = '[data-testid="indexer-address-input"]';
9+
private readonly PUB_SUB_INDEXER_ADDRESS_INPUT_LABEL = '[data-testid="indexer-address-input"] + label';
10+
private readonly PROOF_SERVER_ADDRESS_OPTION_LOCAL =
11+
'[data-testid="configure-midnight-proof-server-section-option-local"] label';
12+
private readonly PROOF_SERVER_ADDRESS_LABEL = '[data-testid="configure-midnight-proof-server-section-label"]';
13+
private readonly NETWORK_LABEL = '[data-testid="configure-midnight-network-section-label"]';
14+
private readonly NETWORK_OPTION_UNDEPLOYED = '[data-testid="configure-midnight-network-section-option-0"] label';
15+
private readonly NETWORK_OPTION_TESTNET = '[data-testid="configure-midnight-network-section-option-2"] label';
16+
17+
get enterWalletButton(): ChainablePromiseElement<WebdriverIO.Element> {
18+
return this.nextButton;
19+
}
20+
21+
get nodeAddressInput(): ChainablePromiseElement<WebdriverIO.Element> {
22+
return $(this.NODE_ADDRESS_INPUT);
23+
}
24+
25+
get indexerAddressInput(): ChainablePromiseElement<WebdriverIO.Element> {
26+
return $(this.PUB_SUB_INDEXER_ADDRESS_INPUT);
27+
}
28+
29+
get proofServerOptionLocal(): ChainablePromiseElement<WebdriverIO.Element> {
30+
return $(this.PROOF_SERVER_ADDRESS_OPTION_LOCAL);
31+
}
32+
33+
get nodeAddressInputLabel(): ChainablePromiseElement<WebdriverIO.Element> {
34+
return $(this.NODE_ADDRESS_INPUT_LAEBL);
35+
}
36+
37+
get indexerAddressInputLabel(): ChainablePromiseElement<WebdriverIO.Element> {
38+
return $(this.PUB_SUB_INDEXER_ADDRESS_INPUT_LABEL);
39+
}
40+
41+
get proofServerSectionLabel(): ChainablePromiseElement<WebdriverIO.Element> {
42+
return $(this.PROOF_SERVER_ADDRESS_LABEL);
43+
}
44+
45+
get networkSectionLabel(): ChainablePromiseElement<WebdriverIO.Element> {
46+
return $(this.NETWORK_LABEL);
47+
}
48+
49+
get networkOptionUndeployed(): ChainablePromiseElement<WebdriverIO.Element> {
50+
return $(this.NETWORK_OPTION_UNDEPLOYED);
51+
}
52+
53+
get networkOptionTestnet(): ChainablePromiseElement<WebdriverIO.Element> {
54+
return $(this.NETWORK_OPTION_TESTNET);
55+
}
56+
}
57+
58+
export default new ConfigureMidnightPage();

packages/e2e-tests/src/elements/onboarding/commonOnboardingElements.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22
import { ChainablePromiseElement } from 'webdriverio';
33

44
export default class CommonOnboardingElements {
5-
private STEP_HEADER = '[data-testid="wallet-setup-step-header"]';
6-
private STEP_HEADER_TITLE = '[data-testid="wallet-setup-step-title"]';
7-
private STEP_HEADER_SUBTITLE = '[data-testid="wallet-setup-step-subtitle"]';
8-
private BACK_BUTTON = '[data-testid="wallet-setup-step-btn-back"]';
9-
private NEXT_BUTTON = '[data-testid="wallet-setup-step-btn-next"]';
10-
private HELP_AND_SUPPORT_BUTTON = '[data-testid="help-and-support-button"]';
11-
private COOKIE_POLICY_LINK = '[data-testid="cookie-policy-link"]';
12-
private PRIVACY_POLICY_LINK = '[data-testid="privacy-policy-link"]';
13-
private TERMS_OF_SERVICE_LINK = '[data-testid="terms-of-service-link"]';
14-
private ACTIVE_STEP_INDICATOR = '[data-testid="active-onboarding-step"]';
5+
private readonly LACE_LOGO = '[data-testid="lace-logo"]';
6+
private readonly STEP_HEADER = '[data-testid="wallet-setup-step-header"]';
7+
private readonly STEP_HEADER_TITLE = '[data-testid="wallet-setup-step-title"]';
8+
private readonly STEP_HEADER_SUBTITLE = '[data-testid="wallet-setup-step-subtitle"]';
9+
private readonly BACK_BUTTON = '[data-testid="wallet-setup-step-btn-back"]';
10+
private readonly NEXT_BUTTON = '[data-testid="wallet-setup-step-btn-next"]';
11+
private readonly HELP_AND_SUPPORT_BUTTON = '[data-testid="help-and-support-button"]';
12+
private readonly COOKIE_POLICY_LINK = '[data-testid="cookie-policy-link"]';
13+
private readonly PRIVACY_POLICY_LINK = '[data-testid="privacy-policy-link"]';
14+
private readonly TERMS_OF_SERVICE_LINK = '[data-testid="terms-of-service-link"]';
15+
private readonly ACTIVE_STEP_INDICATOR = '[data-testid="active-onboarding-step"]';
16+
private readonly COMPATIBILITY_LABEL = '[data-testid="compatibility-label"]';
17+
private readonly MIDNIGHT_SYMBOL = '[data-testid="midnight-symbol"]';
18+
private readonly MIDNIGHT_LABEL = '[data-testid="midnight-label"]';
19+
20+
get laceLogo(): ChainablePromiseElement<WebdriverIO.Element> {
21+
return $(this.LACE_LOGO);
22+
}
1523

1624
get stepHeader(): ChainablePromiseElement<WebdriverIO.Element> {
1725
return $(this.STEP_HEADER);
@@ -53,6 +61,18 @@ export default class CommonOnboardingElements {
5361
return $(this.ACTIVE_STEP_INDICATOR);
5462
}
5563

64+
get compatibilityLabel(): ChainablePromiseElement<WebdriverIO.Element> {
65+
return $(this.COMPATIBILITY_LABEL);
66+
}
67+
68+
get midnightSymbol(): ChainablePromiseElement<WebdriverIO.Element> {
69+
return $(this.MIDNIGHT_SYMBOL);
70+
}
71+
72+
get midnightLabel(): ChainablePromiseElement<WebdriverIO.Element> {
73+
return $(this.MIDNIGHT_LABEL);
74+
}
75+
5676
async clickOnNextButton(): Promise<void> {
5777
await this.nextButton.waitForClickable({ timeout: 12_000 });
5878
await this.nextButton.click();

0 commit comments

Comments
 (0)