-
-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): Migrated backup tests (#17150)
* feat(e2e): Migrated backup tests * fix(ci): Removed device management group from cypress tests pipeline * fix(e2e): Added missing await * fix(e2e): Fixed PR review comments
- Loading branch information
1 parent
73ba107
commit a010814
Showing
14 changed files
with
256 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/suite-desktop-core/e2e/support/pageActions/settings/deviceActions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Locator, Page } from '@playwright/test'; | ||
|
||
import { step } from '../../common'; | ||
|
||
export class DeviceActions { | ||
readonly createMultiShareBackupButton: Locator; | ||
readonly multiShareBackupGotItButton: Locator; | ||
private readonly firstInfoSubmitButton: Locator; | ||
private readonly secondInfoSubmitButton: Locator; | ||
|
||
constructor(private readonly page: Page) { | ||
this.createMultiShareBackupButton = page.getByTestId( | ||
'@settings/device/create-multi-share-backup-button', | ||
); | ||
this.multiShareBackupGotItButton = page.getByTestId( | ||
'@multi-share-backup/done/got-it-button', | ||
); | ||
this.firstInfoSubmitButton = page.getByTestId('@multi-share-backup/1st-info/submit-button'); | ||
this.secondInfoSubmitButton = page.getByTestId( | ||
'@multi-share-backup/2nd-info/submit-button', | ||
); | ||
} | ||
|
||
@step() | ||
async proceedMultiShareBackupModal(): Promise<void> { | ||
await this.page.getByTestId('@multi-share-backup/checkbox/1').click(); | ||
await this.page.getByTestId('@multi-share-backup/checkbox/2').click(); | ||
await this.firstInfoSubmitButton.click(); | ||
await this.secondInfoSubmitButton.click(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/suite-desktop-core/e2e/tests/backup/t2t1-fail.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { EventType } from '@trezor/suite-analytics'; | ||
import { ExtractByEventType } from '@trezor/suite-web/e2e/support/types'; | ||
|
||
import { expect, test } from '../../support/fixtures'; | ||
|
||
test.describe('Backup fail', { tag: ['@group=device-management'] }, () => { | ||
test.use({ | ||
emulatorStartConf: { model: 'T2T1', wipe: true }, | ||
emulatorSetupConf: { needs_backup: true }, | ||
}); | ||
|
||
test.beforeEach(async ({ onboardingPage, analytics }) => { | ||
await onboardingPage.completeOnboarding(); | ||
await analytics.interceptAnalytics(); | ||
}); | ||
|
||
test('Device disconnected during action', async ({ | ||
page, | ||
analytics, | ||
onboardingPage, | ||
dashboardPage, | ||
devicePrompt, | ||
trezorUserEnvLink, | ||
}) => { | ||
await dashboardPage.notificationNoBackupButton.click(); | ||
await onboardingPage.backup.undertandWhatSeedIsCheckbox.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(); | ||
|
||
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(); | ||
|
||
const createBackupEvent = analytics.findAnalyticsEventByType< | ||
ExtractByEventType<EventType.CreateBackup> | ||
>(EventType.CreateBackup); | ||
expect(createBackupEvent.status).toEqual('error'); | ||
expect(createBackupEvent.error).toMatch( | ||
/device\+disconnected\+during\+action|Device\+disconnected|session\+not\+found/, | ||
); | ||
}); | ||
}); |
54 changes: 54 additions & 0 deletions
54
packages/suite-desktop-core/e2e/tests/backup/t2t1-misc.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { expect, test } from '../../support/fixtures'; | ||
|
||
test.describe('Backup misc', { tag: ['@group=device-management'] }, () => { | ||
test.use({ | ||
emulatorStartConf: { model: 'T2T1', wipe: true }, | ||
emulatorSetupConf: { needs_backup: true }, | ||
}); | ||
|
||
test.beforeEach(async ({ onboardingPage, dashboardPage }) => { | ||
await onboardingPage.completeOnboarding(); | ||
await dashboardPage.discoveryShouldFinish(); | ||
}); | ||
|
||
test('Backup should reset if modal is closed', async ({ onboardingPage, dashboardPage }) => { | ||
await dashboardPage.notificationNoBackupButton.click(); | ||
await onboardingPage.backup.undertandWhatSeedIsCheckbox.click(); | ||
await onboardingPage.backup.hasEnoughTimeCheckbox.click(); | ||
await onboardingPage.backup.isInPrivateCheckbox.click(); | ||
await expect( | ||
onboardingPage.backup.undertandWhatSeedIsCheckbox.locator('input'), | ||
).toBeChecked(); | ||
await expect(onboardingPage.backup.hasEnoughTimeCheckbox.locator('input')).toBeChecked(); | ||
await expect(onboardingPage.backup.isInPrivateCheckbox.locator('input')).toBeChecked(); | ||
await onboardingPage.backup.closeButton.click(); | ||
await dashboardPage.notificationNoBackupButton.click(); | ||
|
||
//at this moment, after modal was closed and opened again, no checkbox should be checked | ||
await expect( | ||
onboardingPage.backup.undertandWhatSeedIsCheckbox.locator('input'), | ||
).not.toBeChecked(); | ||
await expect( | ||
onboardingPage.backup.hasEnoughTimeCheckbox.locator('input'), | ||
).not.toBeChecked(); | ||
await expect(onboardingPage.backup.isInPrivateCheckbox.locator('input')).not.toBeChecked(); | ||
}); | ||
|
||
test('User disconnected device that is remembered. Should not be allowed to initiate backup', async ({ | ||
page, | ||
dashboardPage, | ||
onboardingPage, | ||
trezorUserEnvLink, | ||
}) => { | ||
await expect(dashboardPage.graph).toBeVisible(); | ||
await dashboardPage.openDeviceSwitcher(); | ||
await dashboardPage.walletAtIndex(0).click(); | ||
await dashboardPage.notificationNoBackupButton.click(); | ||
await onboardingPage.backup.undertandWhatSeedIsCheckbox.click(); | ||
await onboardingPage.backup.hasEnoughTimeCheckbox.click(); | ||
await onboardingPage.backup.isInPrivateCheckbox.click(); | ||
|
||
await trezorUserEnvLink.stopEmu(); | ||
await expect(page.getByTestId('@backup/no-device')).toBeVisible(); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
packages/suite-desktop-core/e2e/tests/backup/t2t1-success.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { EventType } from '@trezor/suite-analytics'; | ||
import { ExtractByEventType } from '@trezor/suite-web/e2e/support/types'; | ||
|
||
import { expect, test } from '../../support/fixtures'; | ||
|
||
test.describe('Backup success', { tag: ['@group=device-management'] }, () => { | ||
test.use({ | ||
emulatorStartConf: { model: 'T2T1', wipe: true }, | ||
emulatorSetupConf: { needs_backup: true, mnemonic: 'mnemonic_all' }, | ||
}); | ||
|
||
test.beforeEach(async ({ onboardingPage, analytics }) => { | ||
await analytics.interceptAnalytics(); | ||
await onboardingPage.completeOnboarding(); | ||
}); | ||
|
||
test('Successful backup happy path', async ({ | ||
analytics, | ||
onboardingPage, | ||
dashboardPage, | ||
devicePrompt, | ||
trezorUserEnvLink, | ||
}) => { | ||
// access from notification | ||
await dashboardPage.notificationNoBackupButton.click(); | ||
|
||
await onboardingPage.backup.undertandWhatSeedIsCheckbox.click(); | ||
await onboardingPage.backup.hasEnoughTimeCheckbox.click(); | ||
await onboardingPage.backup.isInPrivateCheckbox.click(); | ||
|
||
// Create backup on device | ||
await onboardingPage.backup.startButton.click(); | ||
|
||
await devicePrompt.confirmOnDevicePromptIsShown(); | ||
|
||
//await trezorUserEnvLink.readAndConfirmMnemonicEmu(); should be used here, but it is flaky | ||
// TODO: https://github.com/trezor/trezor-suite/issues/17148 | ||
await trezorUserEnvLink.pressYes(); | ||
await trezorUserEnvLink.pressYes(); | ||
await trezorUserEnvLink.swipeEmu('up'); | ||
await trezorUserEnvLink.swipeEmu('up'); | ||
await trezorUserEnvLink.pressYes(); | ||
await trezorUserEnvLink.inputEmu('all'); | ||
await trezorUserEnvLink.inputEmu('all'); | ||
await trezorUserEnvLink.inputEmu('all'); | ||
await trezorUserEnvLink.pressYes(); | ||
await trezorUserEnvLink.pressYes(); | ||
|
||
// Click all after checkboxes and close backup modal | ||
await expect(onboardingPage.backup.closeButton).toBeDisabled(); | ||
await onboardingPage.backup.wroteSeedProperlyCheckbox.click(); | ||
await onboardingPage.backup.madeNoDigitalCopyCheckbox.click(); | ||
await onboardingPage.backup.willHideSeedCheckbox.click(); | ||
await expect(onboardingPage.backup.closeButton).toBeEnabled(); | ||
|
||
const createBackupEvent = analytics.findAnalyticsEventByType< | ||
ExtractByEventType<EventType.CreateBackup> | ||
>(EventType.CreateBackup); | ||
expect(createBackupEvent.status).toEqual('finished'); | ||
expect(createBackupEvent.error).toEqual(''); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
packages/suite-desktop-core/e2e/tests/backup/t3t1-create-additional-share.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { MNEMONICS } from '@trezor/trezor-user-env-link'; | ||
|
||
import { test } from '../../support/fixtures'; | ||
|
||
test.describe('Create additional share', { tag: ['@group=device-management'] }, () => { | ||
test.use({ | ||
emulatorSetupConf: { mnemonic: 'mnemonic_academic' }, | ||
}); | ||
|
||
test.beforeEach(async ({ onboardingPage }) => { | ||
await onboardingPage.completeOnboarding({ enableViewOnly: true }); | ||
}); | ||
|
||
test('Successfuly added additional share', async ({ | ||
page, | ||
settingsPage, | ||
trezorUserEnvLink, | ||
}) => { | ||
await settingsPage.navigateTo('device'); | ||
await settingsPage.device.createMultiShareBackupButton.click(); | ||
await settingsPage.device.proceedMultiShareBackupModal(); | ||
|
||
// [device screen] check your backup? | ||
await trezorUserEnvLink.pressYes(); | ||
|
||
// [device screen] select the number of words in your backup | ||
await trezorUserEnvLink.inputEmu('20'); | ||
|
||
// [device screen] backup instructions | ||
await trezorUserEnvLink.pressYes(); | ||
|
||
for (const word of MNEMONICS.mnemonic_academic.split(' ')) { | ||
// [device screen] enter next word | ||
await trezorUserEnvLink.inputEmu(word); | ||
} | ||
|
||
// [device screen] create additional backup? | ||
await page.waitForTimeout(1000); // without this timeout, backup on device simply disappears, it stinks TODO: https://github.com/trezor/trezor-suite/issues/17128 | ||
await trezorUserEnvLink.pressYes(); | ||
await trezorUserEnvLink.readAndConfirmShamirMnemonicEmu({ shares: 3, threshold: 2 }); | ||
|
||
await settingsPage.device.multiShareBackupGotItButton.click(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.