diff --git a/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts b/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts index d24d4e800cf..55877e9d06f 100644 --- a/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts +++ b/packages/suite-desktop-core/e2e/support/pageActions/settingsActions.ts @@ -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 { @@ -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 coinNetworkButton = (coin: NetworkSymbol) => this.window.getByTestId(`@settings/wallet/network/${coin}`); @@ -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; @@ -93,7 +100,7 @@ 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( @@ -101,6 +108,7 @@ export class SettingsActions { ); 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() { @@ -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) { @@ -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(); }); } } diff --git a/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts b/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts new file mode 100644 index 00000000000..05bb0fcb936 --- /dev/null +++ b/packages/suite-desktop-core/e2e/tests/settings/t1b1-device-settings.test.ts @@ -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) +}); diff --git a/packages/suite-web/e2e/tests/settings/t1b1-device-settings.test.ts b/packages/suite-web/e2e/tests/settings/t1b1-device-settings.test.ts deleted file mode 100644 index 03d23ef6b22..00000000000 --- a/packages/suite-web/e2e/tests/settings/t1b1-device-settings.test.ts +++ /dev/null @@ -1,95 +0,0 @@ -// @group_settings -// @retry=2 - -import { onSettingsDevicePage } from '../../support/pageObjects/settings/settingsDeviceObject'; -import { onSettingsMenu } from '../../support/pageObjects/settings/settingsMenuObject'; -import { onNavBar } from '../../support/pageObjects/topBarObject'; - -// TODO: t1 tests are flaky in CI. I suspect it is something in bridge/udp layer. So next step is implementing -// udp transport in suite and trying to enable this test again. -describe('T1B1 - Device settings', () => { - beforeEach(() => { - cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true }); - cy.task('setupEmu', { needs_backup: false }); - cy.task('startBridge'); - cy.viewport('macbook-13').resetDb(); - cy.prefixedVisit('/'); - cy.passThroughInitialRun(); - }); - afterEach(() => { - cy.task('stopEmu'); - }); - - it('enable pin', () => { - onNavBar.openSettings(); - onSettingsMenu.openDeviceSettings(); - onSettingsDevicePage.togglePinSwitch(); - - cy.getTestElement('@prompts/confirm-on-device'); - cy.task('pressYes'); - - cy.enterPinOnBlindMatrix('1'); - - cy.getTestElement('@pin/input/1'); - - cy.enterPinOnBlindMatrix('1'); - - cy.getTestElement('@toast/pin-changed'); - }); - - it('pin mismatch', () => { - onNavBar.openSettings(); - onSettingsMenu.openDeviceSettings(); - onSettingsDevicePage.togglePinSwitch(); - - cy.getTestElement('@prompts/confirm-on-device'); - cy.task('pressYes'); - cy.getTestElement('@pin/input/1').click(); - - cy.getTestElement('@pin/submit-button').click(); - cy.log('enter 2 digits instead of 1 in the first entry. This way pin is always wrong'); - cy.getTestElement('@pin/input/1').click(); - cy.getTestElement('@pin/input/1').click(); - - cy.getTestElement('@pin/submit-button').click(); - cy.getTestElement('@pin-mismatch').matchImageSnapshot('pin-mismatch'); - cy.getTestElement('@pin-mismatch/try-again-button').click(); - cy.getTestElement('@prompts/confirm-on-device'); - cy.task('pressYes'); - }); - - /* - * 1. navigate to settings/device screen and wait for it to load - * 2. Select & click Choose from gallery in Customization section - * 3. Select Doge homescreen - * 4. Confirm on device - * 5. Wait for success notification Settings applied - */ - it.skip('change homescreen', () => { - // - // Test preparation - // - - cy.viewport('macbook-13').resetDb(); - cy.visit('/'); - cy.passThroughInitialRun(); - cy.discoveryShouldFinish(); - - cy.getTestElement('@settings/device/homescreen').scrollIntoView(); - cy.getTestElement('@settings/device/homescreen-gallery').click(); - cy.get('#doge').click(); - cy.getTestElement('@prompts/confirm-on-device'); - cy.wait(2000); - cy.task('pressYes'); - cy.wait(2000); - - // - // Assert - // - cy.getTestElement('@toast/settings-applied').should('be.visible'); - }); - - // TODO: pin caching immediately after it is set - // TODO: keyboard handling - // TODO: set auto-lock (needs pin) -});