Skip to content

Commit

Permalink
Feat convert cy pw suite settings t1b1 (#15928)
Browse files Browse the repository at this point in the history
* feat(e2e): Convert suite t1b1-device-settings to playwright

* fix(e2e): Resolve two notification problem
  • Loading branch information
Vere-Grey authored Dec 12, 2024
1 parent 4701fbf commit 7d69f3f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const backgroundImages = {
path: 'static/images/homescreens/BW_64x128/circleweb.png',
locator: '@modal/gallery/bw_64x128/circleweb',
},
nyancat: {
path: 'static/images/homescreens/BW_64x128/nyancat.png',
locator: '@modal/gallery/bw_64x128/nyancat',
},
};

export class SettingsActions {
Expand All @@ -51,6 +55,8 @@ export class SettingsActions {
readonly deviceLabelSubmit: Locator;
readonly confirmOnDevicePrompt: Locator;
readonly homescreenGalleryButton: Locator;
readonly notificationSuccessToast: Locator;
readonly pinSubmitButton: Locator;
//coin Advance settings
readonly networkButton = (symbol: NetworkSymbol) =>
this.window.getByTestId(`@settings/wallet/network/${symbol}`);
Expand All @@ -67,6 +73,7 @@ export class SettingsActions {
readonly languageInput: Locator;
readonly languageInputOption = (language: Language) =>
this.window.getByTestId(`@settings/language-select/option/${language}`);
readonly pinInput = (index: number) => this.window.getByTestId(`@pin/input/${index}`);

constructor(window: Page, apiURL: string) {
this.window = window;
Expand All @@ -93,14 +100,15 @@ export class SettingsActions {
this.homescreenGalleryButton = this.window.getByTestId(
'@settings/device/homescreen-gallery',
);
//coin Advance settings
this.notificationSuccessToast = this.window.getByTestId('@toast/settings-applied').first();
this.coinBackendSelector = this.window.getByTestId('@settings/advance/select-type/input');
this.coinAddressInput = this.window.getByTestId('@settings/advance/url');
this.coinAdvanceSettingSaveButton = this.window.getByTestId(
'@settings/advance/button/save',
);
this.themeInput = this.window.getByTestId('@theme/color-scheme-select/input');
this.languageInput = this.window.getByTestId('@settings/language-select/input');
this.pinSubmitButton = this.window.getByTestId('@pin/submit-button');
}

async navigateTo() {
Expand Down Expand Up @@ -191,6 +199,7 @@ export class SettingsActions {
await expect(this.confirmOnDevicePrompt).toBeVisible();
await TrezorUserEnvLink.pressYes();
await this.confirmOnDevicePrompt.waitFor({ state: 'detached' });
await expect(this.notificationSuccessToast).toBeVisible();
}

async changeDeviceBackground(image: keyof typeof backgroundImages) {
Expand All @@ -205,6 +214,16 @@ export class SettingsActions {
await expect(this.confirmOnDevicePrompt).toBeVisible();
await TrezorUserEnvLink.pressYes();
await this.confirmOnDevicePrompt.waitFor({ state: 'detached' });
await expect(this.notificationSuccessToast).toBeVisible();
});
}

async enterPinOnBlindMatrix(pinEntryNumber: string) {
await test.step('Find number on blind matrix and click it', async () => {
const state = await TrezorUserEnvLink.getDebugState();
const index = state.matrix.indexOf(pinEntryNumber) + 1;
await this.pinInput(index).click();
await this.pinSubmitButton.click();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { test, expect } from '../../support/fixtures';

test.describe('T1B1 - Device settings', { tag: ['@group=settings'] }, () => {
test.use({ emulatorStartConf: { model: 'T1B1', version: '1-main', wipe: true } });
test.beforeEach(async ({ onboardingPage, settingsPage, dashboardPage }) => {
await onboardingPage.completeOnboarding();
// Initiating pin change is not stable when discovery is not yet finished
await dashboardPage.discoveryShouldFinish();
await settingsPage.navigateTo();
await settingsPage.deviceTabButton.click();
});

test('enable pin', async ({ window: page, trezorUserEnvLink, settingsPage }) => {
await page.getByTestId('@settings/device/pin-switch').click();
await expect(page.getByTestId('@prompts/confirm-on-device')).toBeVisible();
await trezorUserEnvLink.pressYes();

const pinEntryNumber = '1';
await settingsPage.enterPinOnBlindMatrix(pinEntryNumber);
await expect(page.getByTestId('@pin/input/1')).toBeVisible();
await settingsPage.enterPinOnBlindMatrix(pinEntryNumber);
await expect(page.getByTestId('@toast/pin-changed')).toBeVisible();
});

test('pin mismatch', async ({ window: page, trezorUserEnvLink }) => {
await page.getByTestId('@settings/device/pin-switch').click();
await expect(page.getByTestId('@prompts/confirm-on-device')).toBeVisible();
await trezorUserEnvLink.pressYes();

await test.step('First input with one number', async () => {
await page.getByTestId('@pin/input/1').click();
await page.getByTestId('@pin/submit-button').click();
});
await test.step('Second input with two numbers', async () => {
await page.getByTestId('@pin/input/1').click();
await page.getByTestId('@pin/input/1').click();
await page.getByTestId('@pin/submit-button').click();
});
await expect(page.getByTestId('@pin-mismatch')).toBeVisible();
await page.getByTestId('@pin-mismatch/try-again-button').click();
await expect(page.getByTestId('@prompts/confirm-on-device')).toBeVisible();
await trezorUserEnvLink.pressYes();
});

test('Change homescreen', async ({ settingsPage }) => {
await settingsPage.changeDeviceBackground('nyancat');
});

// TODO: pin caching immediately after it is set
// TODO: keyboard handling
// TODO: set auto-lock (needs pin)
});
95 changes: 0 additions & 95 deletions packages/suite-web/e2e/tests/settings/t1b1-device-settings.test.ts

This file was deleted.

0 comments on commit 7d69f3f

Please sign in to comment.