Skip to content

Commit 37a8859

Browse files
authored
test(extension): add tests for Settings - Generate paper wallet (#1436)
1 parent df7d00b commit 37a8859

File tree

14 files changed

+427
-3
lines changed

14 files changed

+427
-3
lines changed

apps/browser-extension-wallet/src/views/browser-view/features/settings/components/PaperWalletSettingsDrawer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const PaperWalletSettingsDrawer = ({ isOpen, onClose, popupView = false }
141141
setStage('passphrase');
142142
}}
143143
w="$fill"
144+
data-testid="next-button"
144145
/>
145146
);
146147
}
@@ -151,6 +152,7 @@ export const PaperWalletSettingsDrawer = ({ isOpen, onClose, popupView = false }
151152
disabled={!password}
152153
label={i18n.t('browserView.settings.generatePaperWallet.title')}
153154
onClick={handleVerifyPass}
155+
data-testid="generate-paper-wallet-button"
154156
/>
155157
);
156158
}
@@ -172,6 +174,7 @@ export const PaperWalletSettingsDrawer = ({ isOpen, onClose, popupView = false }
172174
w="$fill"
173175
label={i18n.t('paperWallet.savePaperWallet.downloadBtnLabel')}
174176
icon={<DownloadIcon />}
177+
data-testid="download-button"
175178
/>
176179
</a>
177180
<Button.Secondary
@@ -184,6 +187,7 @@ export const PaperWalletSettingsDrawer = ({ isOpen, onClose, popupView = false }
184187
disabled={pdfInstance.loading || !!pdfInstance.error}
185188
icon={<PrinterIcon />}
186189
label={i18n.t('paperWallet.savePaperWallet.printBtnLabel')}
190+
data-testid="print-button"
187191
/>
188192
</Flex>
189193
);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { expect } from 'chai';
2+
import { t } from '../../utils/translationService';
3+
import EnterYourPasswordDrawer from '../../elements/settings/EnterYourPasswordDrawer';
4+
5+
class EnterYourPasswordDrawerAssert {
6+
async assertSeeSecureYourPaperWalletDrawer() {
7+
await EnterYourPasswordDrawer.drawerHeaderCloseButton.waitForClickable();
8+
await EnterYourPasswordDrawer.drawerNavigationTitle.waitForDisplayed();
9+
expect(await EnterYourPasswordDrawer.drawerNavigationTitle.getText()).to.equal(
10+
await t('browserView.settings.heading')
11+
);
12+
await EnterYourPasswordDrawer.drawerHeaderTitle.waitForDisplayed();
13+
expect(await EnterYourPasswordDrawer.drawerHeaderTitle.getText()).to.equal(
14+
await t('paperWallet.SettingsDrawer.passphraseStage.title')
15+
);
16+
await EnterYourPasswordDrawer.drawerHeaderSubtitle.waitForDisplayed();
17+
expect(await EnterYourPasswordDrawer.drawerHeaderSubtitle.getText()).to.equal(
18+
await t('paperWallet.SettingsDrawer.passphraseStage.subtitle')
19+
);
20+
21+
await EnterYourPasswordDrawer.passwordInput.container.waitForEnabled();
22+
23+
await EnterYourPasswordDrawer.bannerIcon.waitForDisplayed();
24+
await EnterYourPasswordDrawer.bannerDescription.waitForDisplayed();
25+
expect(await EnterYourPasswordDrawer.bannerDescription.getText()).to.equal(
26+
await t('browserView.settings.security.showPassphraseDrawer.warning')
27+
);
28+
29+
await EnterYourPasswordDrawer.generatePaperWalletButton.waitForEnabled();
30+
expect(await EnterYourPasswordDrawer.generatePaperWalletButton.getText()).to.equal(
31+
await t('browserView.settings.generatePaperWallet.title')
32+
);
33+
}
34+
35+
async assertGeneratePaperWalletButtonEnabled(shouldBeEnabled: boolean): Promise<void> {
36+
await EnterYourPasswordDrawer.generatePaperWalletButton.waitForEnabled({ reverse: !shouldBeEnabled });
37+
}
38+
}
39+
40+
export default new EnterYourPasswordDrawerAssert();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { t } from '../../utils/translationService';
2+
import { expect } from 'chai';
3+
import SaveYourPaperWalletDrawer from '../../elements/settings/SaveYourPaperWalletDrawer';
4+
5+
class SaveYourPaperWalletDrawerAssert {
6+
async assertSeeSaveYourPaperWalletPage(expectedPaperWalletName: string) {
7+
await SaveYourPaperWalletDrawer.drawerHeaderCloseButton.waitForClickable();
8+
await SaveYourPaperWalletDrawer.drawerNavigationTitle.waitForDisplayed();
9+
expect(await SaveYourPaperWalletDrawer.drawerNavigationTitle.getText()).to.equal(
10+
await t('browserView.settings.heading')
11+
);
12+
await SaveYourPaperWalletDrawer.drawerHeaderTitle.waitForDisplayed();
13+
expect(await SaveYourPaperWalletDrawer.drawerHeaderTitle.getText()).to.equal(
14+
await t('paperWallet.savePaperWallet.title')
15+
);
16+
await SaveYourPaperWalletDrawer.drawerHeaderSubtitle.waitForDisplayed();
17+
expect(await SaveYourPaperWalletDrawer.drawerHeaderSubtitle.getText()).to.equal(
18+
await t('paperWallet.savePaperWallet.description')
19+
);
20+
21+
await SaveYourPaperWalletDrawer.paperWalletName.waitForDisplayed();
22+
expect(await SaveYourPaperWalletDrawer.paperWalletName.getText()).to.equal(expectedPaperWalletName);
23+
await SaveYourPaperWalletDrawer.containsLabel.waitForDisplayed();
24+
25+
expect(await SaveYourPaperWalletDrawer.containsLabel.getText()).to.equal(
26+
await t('core.paperWallet.savePaperWallet.contains')
27+
);
28+
await SaveYourPaperWalletDrawer.privateQrCodeIcon.waitForDisplayed();
29+
await SaveYourPaperWalletDrawer.privateQrCodeTitle.waitForDisplayed();
30+
expect(await SaveYourPaperWalletDrawer.privateQrCodeTitle.getText()).to.equal(
31+
await t('core.paperWallet.savePaperWallet.privateQrTitle')
32+
);
33+
await SaveYourPaperWalletDrawer.privateQrCodeDescription.waitForDisplayed();
34+
expect(await SaveYourPaperWalletDrawer.privateQrCodeDescription.getText()).to.equal(
35+
await t('core.paperWallet.savePaperWallet.privateQrDescription')
36+
);
37+
await SaveYourPaperWalletDrawer.publicQrCodeIcon.waitForDisplayed();
38+
await SaveYourPaperWalletDrawer.publicQrCodeTitle.waitForDisplayed();
39+
expect(await SaveYourPaperWalletDrawer.publicQrCodeTitle.getText()).to.equal(
40+
await t('core.paperWallet.savePaperWallet.publicQrTitle')
41+
);
42+
await SaveYourPaperWalletDrawer.publicQrCodeDescription.waitForDisplayed();
43+
expect(await SaveYourPaperWalletDrawer.publicQrCodeDescription.getText()).to.equal(
44+
await t('core.paperWallet.savePaperWallet.publicQrDescription')
45+
);
46+
47+
await SaveYourPaperWalletDrawer.downloadButton.waitForClickable();
48+
expect(await SaveYourPaperWalletDrawer.downloadButton.getText()).to.equal(
49+
await t('paperWallet.savePaperWallet.downloadBtnLabel')
50+
);
51+
await SaveYourPaperWalletDrawer.printButton.waitForClickable();
52+
expect(await SaveYourPaperWalletDrawer.printButton.getText()).to.equal(
53+
await t('paperWallet.savePaperWallet.printBtnLabel')
54+
);
55+
}
56+
}
57+
58+
export default new SaveYourPaperWalletDrawerAssert();
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import SecureYourPaperWalletDrawer from '../../elements/settings/SecureYourPaperWalletDrawer';
2+
import { expect } from 'chai';
3+
import { t } from '../../utils/translationService';
4+
5+
class SecureYourPaperWalletDrawerAssert {
6+
async assertSeeSecureYourPaperWalletDrawer() {
7+
await SecureYourPaperWalletDrawer.drawerHeaderCloseButton.waitForClickable();
8+
await SecureYourPaperWalletDrawer.drawerNavigationTitle.waitForDisplayed();
9+
expect(await SecureYourPaperWalletDrawer.drawerNavigationTitle.getText()).to.equal(
10+
await t('browserView.settings.heading')
11+
);
12+
await SecureYourPaperWalletDrawer.drawerHeaderTitle.waitForDisplayed();
13+
expect(await SecureYourPaperWalletDrawer.drawerHeaderTitle.getText()).to.equal(
14+
await t('paperWallet.securePaperWallet.title')
15+
);
16+
await SecureYourPaperWalletDrawer.drawerHeaderSubtitle.waitForDisplayed();
17+
expect(await SecureYourPaperWalletDrawer.drawerHeaderSubtitle.getText()).to.equal(
18+
await t('paperWallet.securePaperWallet.description')
19+
);
20+
21+
await SecureYourPaperWalletDrawer.pgpKeyNameInputLabel.waitForDisplayed();
22+
expect(await SecureYourPaperWalletDrawer.pgpKeyNameInputLabel.getText()).to.equal(
23+
await t('core.paperWallet.securePaperWallet.pgpPublicKeyReference')
24+
);
25+
await SecureYourPaperWalletDrawer.pgpKeyNameInput.waitForDisplayed();
26+
await SecureYourPaperWalletDrawer.yourPublicPgpKeyBlockInputLabel.waitForDisplayed();
27+
expect(await SecureYourPaperWalletDrawer.yourPublicPgpKeyBlockInputLabel.getText()).to.equal(
28+
await t('core.paperWallet.securePaperWallet.pgpPublicKeyLabel')
29+
);
30+
await SecureYourPaperWalletDrawer.yourPublicPgpKeyBlockInput.waitForDisplayed();
31+
32+
await SecureYourPaperWalletDrawer.nextButton.waitForDisplayed();
33+
expect(await SecureYourPaperWalletDrawer.nextButton.getText()).to.equal(await t('send.form.next'));
34+
}
35+
36+
async assertNextButtonEnabled(shouldBeEnabled: boolean): Promise<void> {
37+
await SecureYourPaperWalletDrawer.nextButton.waitForEnabled({ reverse: !shouldBeEnabled });
38+
}
39+
}
40+
41+
export default new SecureYourPaperWalletDrawerAssert();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class SecureYourPaperWalletPage extends CommonOnboardingElements {
4545
}
4646

4747
async enterPgpKeyName(name: string): Promise<void> {
48+
await this.pgpKeyNameInput.waitForClickable();
4849
await this.pgpKeyNameInput.setValue(name);
4950
}
5051

@@ -68,6 +69,7 @@ class SecureYourPaperWalletPage extends CommonOnboardingElements {
6869
}
6970

7071
await clipboard.write(key);
72+
await this.yourPublicPgpKeyBlockInput.waitForClickable();
7173
await this.yourPublicPgpKeyBlockInput.click();
7274
await browser.keys([Key.Ctrl, 'v']);
7375
testContext.save('publicPgpKey', key);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-disable no-undef */
2+
import CommonDrawerElements from '../CommonDrawerElements';
3+
import type { ChainablePromiseElement } from 'webdriverio';
4+
import PasswordInput from '../passwordInput';
5+
6+
class EnterYourPasswordDrawer extends CommonDrawerElements {
7+
private BANNER_ICON = '[data-testid="banner-icon"]';
8+
private BANNER_DESCRIPTION = '[data-testid="banner-description"]';
9+
private GENERATE_PAPER_WALLET_BUTTON = '[data-testid="generate-paper-wallet-button"]';
10+
11+
get bannerIcon(): ChainablePromiseElement<WebdriverIO.Element> {
12+
return $(this.BANNER_ICON);
13+
}
14+
15+
get bannerDescription(): ChainablePromiseElement<WebdriverIO.Element> {
16+
return $(this.BANNER_DESCRIPTION);
17+
}
18+
19+
get passwordInput(): typeof PasswordInput {
20+
return PasswordInput;
21+
}
22+
23+
get generatePaperWalletButton(): ChainablePromiseElement<WebdriverIO.Element> {
24+
return $(this.GENERATE_PAPER_WALLET_BUTTON);
25+
}
26+
27+
async clickGeneratePaperWalletButton(): Promise<void> {
28+
await this.generatePaperWalletButton.waitForClickable();
29+
await this.generatePaperWalletButton.click();
30+
}
31+
}
32+
33+
export default new EnterYourPasswordDrawer();
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* eslint-disable no-undef */
2+
import type { ChainablePromiseElement } from 'webdriverio';
3+
import CommonDrawerElements from '../CommonDrawerElements';
4+
5+
class SaveYourPaperWalletDrawer extends CommonDrawerElements {
6+
private PAPER_WALLET_NAME = '[data-testid="paper-wallet-name"]';
7+
private CONTAINS_LABEL = '[data-testid="contains-label"]';
8+
private PRIVATE_QR_CODE_ICON = '[data-testid="private-qr-code-icon"]';
9+
private PRIVATE_QR_CODE_TITLE = '[data-testid="private-qr-code-title"]';
10+
private PRIVATE_QR_CODE_DESCRIPTION = '[data-testid="private-qr-code-description"]';
11+
private PUBLIC_QR_CODE_ICON = '[data-testid="public-qr-code-icon"]';
12+
private PUBLIC_QR_CODE_TITLE = '[data-testid="public-qr-code-title"]';
13+
private PUBLIC_QR_CODE_DESCRIPTION = '[data-testid="public-qr-code-description"]';
14+
private DOWNLOAD_BUTTON = '[data-testid="download-button"]';
15+
private PRINT_BUTTON = '[data-testid="print-button"]';
16+
17+
get paperWalletName(): ChainablePromiseElement<WebdriverIO.Element> {
18+
return $(this.PAPER_WALLET_NAME);
19+
}
20+
21+
get containsLabel(): ChainablePromiseElement<WebdriverIO.Element> {
22+
return $(this.CONTAINS_LABEL);
23+
}
24+
25+
get privateQrCodeIcon(): ChainablePromiseElement<WebdriverIO.Element> {
26+
return $(this.PRIVATE_QR_CODE_ICON);
27+
}
28+
29+
get privateQrCodeTitle(): ChainablePromiseElement<WebdriverIO.Element> {
30+
return $(this.PRIVATE_QR_CODE_TITLE);
31+
}
32+
33+
get privateQrCodeDescription(): ChainablePromiseElement<WebdriverIO.Element> {
34+
return $(this.PRIVATE_QR_CODE_DESCRIPTION);
35+
}
36+
37+
get publicQrCodeIcon(): ChainablePromiseElement<WebdriverIO.Element> {
38+
return $(this.PUBLIC_QR_CODE_ICON);
39+
}
40+
41+
get publicQrCodeTitle(): ChainablePromiseElement<WebdriverIO.Element> {
42+
return $(this.PUBLIC_QR_CODE_TITLE);
43+
}
44+
45+
get publicQrCodeDescription(): ChainablePromiseElement<WebdriverIO.Element> {
46+
return $(this.PUBLIC_QR_CODE_DESCRIPTION);
47+
}
48+
49+
get downloadButton(): ChainablePromiseElement<WebdriverIO.Element> {
50+
return $(this.DOWNLOAD_BUTTON);
51+
}
52+
53+
get printButton(): ChainablePromiseElement<WebdriverIO.Element> {
54+
return $(this.PRINT_BUTTON);
55+
}
56+
}
57+
58+
export default new SaveYourPaperWalletDrawer();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* eslint-disable no-undef */
2+
import CommonDrawerElements from '../CommonDrawerElements';
3+
import type { ChainablePromiseElement } from 'webdriverio';
4+
5+
class SecureYourPaperWalletDrawer extends CommonDrawerElements {
6+
// TODO: update selectors when new lace-ui-toolkit package is released
7+
private PGP_KEY_NAME_INPUT = '[data-testid="pgp-public-key-reference"]';
8+
private PGP_KEY_NAME_INPUT_LABEL = '//form//label';
9+
private YOUR_PUBLIC_PGP_KEY_BLOCK_INPUT = '[data-testid="pgp-public-key-block"]';
10+
private YOUR_PUBLIC_PGP_KEY_BLOCK_INPUT_LABEL = '//span[contains(@class, "text-area-label")]';
11+
private NEXT_BUTTON = '[data-testid="next-button"]';
12+
13+
get pgpKeyNameInput(): ChainablePromiseElement<WebdriverIO.Element> {
14+
return $(this.PGP_KEY_NAME_INPUT);
15+
}
16+
17+
get pgpKeyNameInputLabel(): ChainablePromiseElement<WebdriverIO.Element> {
18+
return $(this.PGP_KEY_NAME_INPUT_LABEL);
19+
}
20+
21+
get yourPublicPgpKeyBlockInput(): ChainablePromiseElement<WebdriverIO.Element> {
22+
return $(this.YOUR_PUBLIC_PGP_KEY_BLOCK_INPUT);
23+
}
24+
25+
get yourPublicPgpKeyBlockInputLabel(): ChainablePromiseElement<WebdriverIO.Element> {
26+
return $(this.YOUR_PUBLIC_PGP_KEY_BLOCK_INPUT_LABEL);
27+
}
28+
29+
get nextButton(): ChainablePromiseElement<WebdriverIO.Element> {
30+
return $(this.NEXT_BUTTON);
31+
}
32+
33+
async clickNextButton(): Promise<void> {
34+
await this.nextButton.waitForClickable();
35+
await this.nextButton.click();
36+
}
37+
}
38+
39+
export default new SecureYourPaperWalletDrawer();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SettingsPage extends CommonDrawerElements {
2626
private readonly CUSTOM_SUBMIT_API_LINK_TEST_ID = 'settings-wallet-custom-submit-api-link';
2727
private readonly THEME_SWITCH_TEST_ID = '[data-testid="switch"]';
2828
private readonly SHOW_RECOVERY_PHRASE_LINK_TEST_ID = 'settings-show-recovery-phrase-link';
29+
private readonly GENERATE_PAPER_WALLET_LINK_TEST_ID = 'settings-generate-paperwallet-link';
2930
private readonly PASSPHRASE_VERIFICATION_LINK_TEST_ID = 'settings-passphrase-verification-link';
3031
private readonly ANALYTICS_LINK_TEST_ID = 'settings-analytics-section';
3132
private readonly FAQS_LINK_TEST_ID = 'settings-support-faqs-link';
@@ -103,6 +104,10 @@ class SettingsPage extends CommonDrawerElements {
103104
return new SettingsLink(this.SHOW_RECOVERY_PHRASE_LINK_TEST_ID);
104105
}
105106

107+
get generatePaperWallet() {
108+
return new SettingsLink(this.GENERATE_PAPER_WALLET_LINK_TEST_ID);
109+
}
110+
106111
get analyticsLink() {
107112
return new SettingsLink(this.ANALYTICS_LINK_TEST_ID);
108113
}

0 commit comments

Comments
 (0)