Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(e2e): stabilize t2t1 backup fail test #17590

Merged
merged 2 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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',
);
Expand Down Expand Up @@ -133,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 },
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down
46 changes: 25 additions & 21 deletions packages/suite-desktop-core/e2e/tests/backup/t2t1-fail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,38 @@ 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,
dashboardPage,
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<EventType.CreateBackup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down