Skip to content

Commit 39792b1

Browse files
authored
test(extension): [LW-8420] trezor emulator automation (#551)
* test(extension): [LW-6869] test automation for trezor * test(extension): integrate trezor tc with docker implementation * test(extension): change step name * test(extension): add connecting trezor step and description * test(extension): remove old images * test(extension): remove web security disabling * test(extension): apply comment changes
1 parent 485af7d commit 39792b1

17 files changed

+189
-7
lines changed

packages/core/src/ui/components/WalletSetup/WalletSetupConnectHardwareWalletStep.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const WalletSetupConnectHardwareWalletStep = ({
7171
[styles.hdWallet]: true,
7272
[styles.hdWalletActive]: isButtonActive(wallet)
7373
})}
74-
data-testid="connect-hardware-wallet-button-ledger"
74+
data-testid={`connect-hardware-wallet-button-${wallet.toLowerCase()}`}
7575
>
7676
{wallet in logoMap ? (
7777
<Icon className={styles.logo} component={logoMap[wallet as keyof typeof logoMap]} />

packages/core/src/ui/components/WalletSetup/WalletSetupWalletNameStep.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const WalletSetupWalletNameStep = ({
5555
>
5656
<p className={styles.subtitle}>{translations.chooseName}</p>
5757
<Input
58+
dataTestId="wallet-setup-register-name-input"
5859
className={styles.inputName}
5960
label={translations.walletName}
6061
value={walletName}

packages/e2e-tests/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,10 @@ UI-mapped gherkin tests for the Lace browser extension
6868
- make necessary updates in `packages/e2e-tests/src/support/walletConfiguration.ts`
6969
- encrypt `walletConfiguration.ts` by running `./encrypt_secret.sh` (from the `packages/e2e-tests` directory)
7070
- delete `packages/e2e-tests/src/support/walletConfiguration.ts`
71+
72+
## Trezor test automation precondition (local run)
73+
74+
- run docker image locally <https://github.com/input-output-hk/lace-hw-testing-toolkit.git>
75+
- After starting docker image (info should be displayed - `⚡️ Trezor Device Manipulation API is running at http://localhost:8000`)
76+
Tests need to be triggered in 60 sec because emulator shuts down device if there is no action
77+
(will be improved in follow-up tickets by starting emulator trough API)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,14 @@ export default class CommonOnboardingElements {
4747
get termsOfServiceLink(): ChainablePromiseElement<WebdriverIO.Element> {
4848
return $(this.TERMS_OF_SERVICE_LINK);
4949
}
50+
51+
async clickOnNextButton(): Promise<void> {
52+
await this.nextButton.waitForClickable({ timeout: 12_000 });
53+
await this.nextButton.click();
54+
}
55+
56+
async clickOnBackButton(): Promise<void> {
57+
await this.backButton.waitForClickable();
58+
await this.backButton.click();
59+
}
5060
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export class OnboardingConnectHardwareWalletPage extends CommonOnboardingElement
66
private SUBTITLE_TEXT = '[data-testid="connect-hardware-wallet-subtitle"]';
77
private SUPPORTED_DEVICES_TEXT = '[data-testid="connect-hardware-wallet-supported-devices-text"]';
88
private LEDGER_BUTTON = '[data-testid="connect-hardware-wallet-button-ledger"]';
9+
private TREZOR_BUTTON = '[data-testid="connect-hardware-wallet-button-trezor"]';
10+
911
private CONNECT_DEVICE_TEXT = '[data-testid="connect-hardware-wallet-connect-device-text"]';
1012

1113
get subTitle(): ChainablePromiseElement<WebdriverIO.Element> {
@@ -20,6 +22,10 @@ export class OnboardingConnectHardwareWalletPage extends CommonOnboardingElement
2022
return $(this.LEDGER_BUTTON);
2123
}
2224

25+
get trezorButton(): ChainablePromiseElement<WebdriverIO.Element> {
26+
return $(this.TREZOR_BUTTON);
27+
}
28+
2329
get connectDevice(): ChainablePromiseElement<WebdriverIO.Element> {
2430
return $(this.CONNECT_DEVICE_TEXT);
2531
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import CommonOnboardingElements from './commonOnboardingElements';
2+
3+
class SelectAccountPage extends CommonOnboardingElements {
4+
private ACCOUNT_RADIO_BUTTONS = '.ant-radio-input';
5+
6+
get accountRadioButtons() {
7+
return $$(this.ACCOUNT_RADIO_BUTTONS);
8+
}
9+
}
10+
export default new SelectAccountPage();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class TrezorConnectPage {
2+
private CONFIRM_BUTTON = '[data-test="@permissions/confirm-button"]';
3+
private EXPORT_BUTTON = '[id="container"] .confirm';
4+
private ANALYTICS_CONFIRM_BUTTON = '[data-test="@analytics/continue-button"]';
5+
private ANALYTICS_TOGGLE_BUTTON = '[data-test="@analytics/toggle-switch"]';
6+
private SHADOW_ROOT = '#react';
7+
8+
get confirmButton() {
9+
return $(this.CONFIRM_BUTTON);
10+
}
11+
12+
get analyticsConfirmButton() {
13+
return $(this.SHADOW_ROOT).shadow$(this.ANALYTICS_CONFIRM_BUTTON);
14+
}
15+
16+
get analyticsToggleButton() {
17+
return $(this.SHADOW_ROOT).shadow$(this.ANALYTICS_TOGGLE_BUTTON);
18+
}
19+
20+
get exportButton() {
21+
return $(this.EXPORT_BUTTON);
22+
}
23+
24+
async clickOnConfirmButton(): Promise<void> {
25+
await this.confirmButton.waitForClickable();
26+
await this.confirmButton.click();
27+
}
28+
29+
async clickOnAnalyticsConfirmButton(): Promise<void> {
30+
await this.analyticsConfirmButton.waitForClickable();
31+
await this.analyticsConfirmButton.click();
32+
}
33+
34+
async clickOnAnalyticsToggleButton(): Promise<void> {
35+
await this.analyticsToggleButton.waitForClickable();
36+
await this.analyticsToggleButton.click();
37+
}
38+
39+
async clickOnExportButton(): Promise<void> {
40+
await this.exportButton.waitForClickable();
41+
await this.exportButton.click();
42+
}
43+
}
44+
export default new TrezorConnectPage();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@TrezorOnboarding @Trezor @Pending
2+
Feature: Trezor Onboarding
3+
4+
Scenario: Onboarding Trezor wallet
5+
And I connect, unlock and enter correct pin on Trezor emulator
6+
Given I click "Connect" button on wallet setup page
7+
And I click "OK" button on "Limited support for DApp" modal
8+
And I am on "Lace terms of use" page and accept terms
9+
And I am on "Help us improve your experience" page
10+
When I click "Agree" button on Analytics page
11+
And I click Trezor wallet icon
12+
And I click "Next" button during wallet setup
13+
And I select 1 account on Select Account page
14+
When I click "Next" button during wallet setup
15+
When I enter wallet name with size of: 10 characters
16+
When I click "Next" button during wallet setup
17+
And I switch to window with title: TrezorConnect
18+
And I reject analytics and click "Allow once for this session" on Trezor Connect page
19+
And I click "Export" on Trezor Connect page
20+
And I confirm exporting public key on Trezor emulator
21+
And I switch to window with Lace
22+
Then "All done" page is displayed
23+
When I click "Go to my wallet" button on "All done" page
24+
Then I see LW homepage

packages/e2e-tests/src/hooks/beforeTagHooks.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const popupViewWalletInitialization = async (walletName = TestWalletName.TestAut
2020
};
2121

2222
Before(
23-
{ tags: '@OnboardingCreateWallet or @Staking-initial-E2E or @OnboardingRestoreWallet or @OnboardingHardwareWallet' },
23+
{
24+
tags: '@OnboardingCreateWallet or @Staking-initial-E2E or @OnboardingRestoreWallet or @OnboardingHardwareWallet or @TrezorOnboarding'
25+
},
2426
async () => await extendedView.visit()
2527
);
2628

packages/e2e-tests/src/steps/commonSteps.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import BackgroundStorageAssert from '../assert/backgroundStorageAssert';
1818
import topNavigationAssert from '../assert/topNavigationAssert';
1919
import testContext from '../utils/testContext';
2020
import MenuHeader from '../elements/menuHeader';
21-
import { closeAllTabsExceptActiveOne, switchToLastWindow, switchToWindowWithLace } from '../utils/window';
21+
import {
22+
closeAllTabsExceptActiveOne,
23+
switchToLastWindow,
24+
switchToWindowWithLace,
25+
switchToWindowWithRetry
26+
} from '../utils/window';
2227
import { Given } from '@wdio/cucumber-framework';
2328
import tokensPageObject from '../pageobject/tokensPageObject';
2429
import menuMainAssert from '../assert/menuMainAssert';
@@ -196,6 +201,10 @@ Then(/^I switch to last window$/, async () => {
196201
await switchToLastWindow();
197202
});
198203

204+
Then(/^I switch to window with title: ([^"]*)$/, async (url: string) => {
205+
await switchToWindowWithRetry(url);
206+
});
207+
199208
Then(/^I see a different wallet address than in my initial wallet$/, async () => {
200209
await menuMainAssert.assertAddressIsNotEqual();
201210
});

0 commit comments

Comments
 (0)