From 7cbca7b848f951773ced27ae3ec5f37c16838bda Mon Sep 17 00:00:00 2001 From: Martin Vere Cihlar Date: Wed, 12 Mar 2025 08:51:34 +0100 Subject: [PATCH 1/2] fix(e2e): stabilize t2t1 backup fail test --- .../e2e/support/pageObjects/dashboardPage.ts | 2 + .../pageObjects/onboarding/backupSection.ts | 4 ++ .../e2e/tests/backup/t2t1-fail.test.ts | 46 ++++++++++--------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts b/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts index 1a3bc93d977..59ee469a135 100644 --- a/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts +++ b/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts @@ -35,6 +35,7 @@ export class DashboardPage { readonly passphraseShowButton: Locator; readonly loading: Locator; readonly notificationNoBackupButton: Locator; + readonly notificationFailedBackup: Locator; readonly openUnusedWalletButton1: Locator; readonly openUnusedWalletButton2: Locator; @@ -66,6 +67,7 @@ export class DashboardPage { this.passphraseShowButton = this.page.getByTestId('@passphrase/show-toggle'); this.loading = this.page.getByTestId('@dashboard/loading'); this.notificationNoBackupButton = this.page.getByTestId('@notification/no-backup/button'); + this.notificationFailedBackup = this.page.getByTestId('@notification/failed-backup/cta'); this.openUnusedWalletButton1 = this.page.getByTestId( '@passphrase-confirmation/step1-open-unused-wallet-button', ); diff --git a/packages/suite-desktop-core/e2e/support/pageObjects/onboarding/backupSection.ts b/packages/suite-desktop-core/e2e/support/pageObjects/onboarding/backupSection.ts index 0cd00df5ca7..940a5d8fef2 100644 --- a/packages/suite-desktop-core/e2e/support/pageObjects/onboarding/backupSection.ts +++ b/packages/suite-desktop-core/e2e/support/pageObjects/onboarding/backupSection.ts @@ -12,6 +12,8 @@ export class BackupSection { readonly madeNoDigitalCopyCheckbox: Locator; readonly willHideSeedCheckbox: Locator; readonly closeButton: Locator; + readonly noDeviceModal: Locator; + readonly errorModal: Locator; constructor( private page: Page, @@ -29,6 +31,8 @@ export class BackupSection { ); this.willHideSeedCheckbox = page.getByTestId('@backup/check-item/will-hide-seed'); this.closeButton = page.getByTestId('@backup/close-button'); + this.noDeviceModal = page.getByTestId('@backup/no-device'); + this.errorModal = page.getByTestId('@backup/error-message'); } @step() diff --git a/packages/suite-desktop-core/e2e/tests/backup/t2t1-fail.test.ts b/packages/suite-desktop-core/e2e/tests/backup/t2t1-fail.test.ts index 281d1b91b2d..2f3da76c694 100644 --- a/packages/suite-desktop-core/e2e/tests/backup/t2t1-fail.test.ts +++ b/packages/suite-desktop-core/e2e/tests/backup/t2t1-fail.test.ts @@ -14,8 +14,7 @@ test.describe('Backup fail', { tag: ['@group=device-management'] }, () => { await analytics.interceptAnalytics(); }); - //TEST: #17241 Fix unstable test - test.skip('Device disconnected during action', async ({ + test('Device disconnected during action', async ({ page, analytics, onboardingPage, @@ -23,25 +22,30 @@ test.describe('Backup fail', { tag: ['@group=device-management'] }, () => { devicePrompt, trezorUserEnvLink, }) => { - await dashboardPage.notificationNoBackupButton.click(); - await onboardingPage.backup.understandWhatSeedIsCheckbox.click(); - await onboardingPage.backup.hasEnoughTimeCheckbox.click(); - await onboardingPage.backup.isInPrivateCheckbox.click(); - await onboardingPage.backup.startButton.click(); - await devicePrompt.confirmOnDevicePromptIsShown(); - await trezorUserEnvLink.pressYes(); - await trezorUserEnvLink.stopEmu(); - - // This screen is not always visible. Sometimes it goes directly to '@backup/error-message' - // await expect(page.getByTestId('@backup/no-device')).toBeVisible(); - - await trezorUserEnvLink.startEmu(); - - await expect(page.getByTestId('@backup/error-message')).toBeVisible({ timeout: 30000 }); - - // Now go to dashboard and see if security card and notification reflects backup failed state correctly - await onboardingPage.backup.closeButton.click(); - await expect(page.getByTestId('@notification/failed-backup/cta')).toBeVisible(); + await test.step('Start backup', async () => { + await dashboardPage.notificationNoBackupButton.click(); + await onboardingPage.backup.understandWhatSeedIsCheckbox.click(); + await onboardingPage.backup.hasEnoughTimeCheckbox.click(); + await onboardingPage.backup.isInPrivateCheckbox.click(); + await onboardingPage.backup.startButton.click(); + await devicePrompt.waitForPromptAndConfirm(); + }); + + await test.step('Simulate disconnect', async () => { + await trezorUserEnvLink.stopEmu(); + await expect(onboardingPage.backup.noDeviceModal).toBeVisible({ timeout: 30_000 }); + }); + + await test.step('Simulate reconnect and check errors', async () => { + await trezorUserEnvLink.startEmu(); + await expect(page.getByTestId('@toast/backup-failed')).toBeVisible({ timeout: 30_000 }); + await expect(onboardingPage.backup.errorModal).toBeVisible({ timeout: 30_000 }); + }); + + await test.step('Check dashboard notification error banner', async () => { + await onboardingPage.backup.closeButton.click(); + await expect(dashboardPage.notificationFailedBackup).toBeVisible(); + }); const createBackupEvent = analytics.findAnalyticsEventByType< ExtractByEventType From 6878cd3c0827ee18117ad200c4f2d90440641a5b Mon Sep 17 00:00:00 2001 From: Martin Vere Cihlar Date: Wed, 12 Mar 2025 09:46:10 +0100 Subject: [PATCH 2/2] fix(e2e): One more case of unstable passphare tests --- .../suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts | 2 +- .../suite-desktop-core/e2e/tests/passphrase/passphrase.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts b/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts index 59ee469a135..9270e7851a6 100644 --- a/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts +++ b/packages/suite-desktop-core/e2e/support/pageObjects/dashboardPage.ts @@ -135,7 +135,7 @@ export class DashboardPage { async addUnusedHiddenWallet( passphrase: string, // We are not waiting for discovery by expecting discovery bar to be visible for unused wallet - // Because sometime the suite is to fast and the discovery bar is not shown at all + // Because sometimes the pressYes action takes 5,5s and suite in meantime can finish discovery // This would cause failure of the test even tho the flow completed successfully options: { skipDiscovery?: boolean } = { skipDiscovery: true }, ) { diff --git a/packages/suite-desktop-core/e2e/tests/passphrase/passphrase.test.ts b/packages/suite-desktop-core/e2e/tests/passphrase/passphrase.test.ts index c6a40c01088..31a6b0c357f 100644 --- a/packages/suite-desktop-core/e2e/tests/passphrase/passphrase.test.ts +++ b/packages/suite-desktop-core/e2e/tests/passphrase/passphrase.test.ts @@ -106,7 +106,7 @@ test.describe('Passphrase', { tag: ['@group=passphrase'] }, () => { test('Fail to confirm passphrase and retry', async ({ page, dashboardPage, devicePrompt }) => { // add 1st hidden wallet await dashboardPage.openDeviceSwitcher(); - await dashboardPage.addHiddenWallet('abc'); + await dashboardPage.addHiddenWallet('abc', { skipDiscovery: true }); await page.getByTestId('@passphrase-confirmation/step1-open-unused-wallet-button').click(); await page.getByTestId('@passphrase-confirmation/step2-button').click();