From 39c0c639f5dbf486b21f556e0aa6408287126f84 Mon Sep 17 00:00:00 2001 From: Martin Varmuza Date: Wed, 11 Sep 2024 09:43:38 +0200 Subject: [PATCH] test(suite-web): add a test for t3t1 multishare backup --- .../pageObjects/multiShareBackupObject.ts | 16 +++++ .../pageObjects/settingsDeviceObject.ts | 12 ++++ .../support/pageObjects/settingsMenuObject.ts | 9 +++ .../t3t1-create-addtional-share.test.ts | 67 +++++++++++++++++++ .../MultiShareBackupModal.tsx | 15 ++++- .../MultiShareBackupStep1FirstInfo.tsx | 2 + 6 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 packages/suite-web/e2e/support/pageObjects/multiShareBackupObject.ts create mode 100644 packages/suite-web/e2e/support/pageObjects/settingsDeviceObject.ts create mode 100644 packages/suite-web/e2e/support/pageObjects/settingsMenuObject.ts create mode 100644 packages/suite-web/e2e/tests/backup/t3t1-create-addtional-share.test.ts diff --git a/packages/suite-web/e2e/support/pageObjects/multiShareBackupObject.ts b/packages/suite-web/e2e/support/pageObjects/multiShareBackupObject.ts new file mode 100644 index 00000000000..821974d3ad5 --- /dev/null +++ b/packages/suite-web/e2e/support/pageObjects/multiShareBackupObject.ts @@ -0,0 +1,16 @@ +/// + +class MultiShareBackupModal { + createMultiShareBackup(): void { + cy.getTestElement('@multi-share-backup/checkbox/1').click(); + cy.getTestElement('@multi-share-backup/checkbox/2').click(); + cy.getTestElement('@multi-share-backup/1st-info/submit-button').click(); + cy.getTestElement('@multi-share-backup/2nd-info/submit-button').click(); + } + + finalizeMultiShareBackup(): void { + cy.getTestElement('@multi-share-backup/done/got-it-button').should('be.visible').click(); + } +} + +export const onMultiShareBackupModal = new MultiShareBackupModal(); diff --git a/packages/suite-web/e2e/support/pageObjects/settingsDeviceObject.ts b/packages/suite-web/e2e/support/pageObjects/settingsDeviceObject.ts new file mode 100644 index 00000000000..af47f1fd6c5 --- /dev/null +++ b/packages/suite-web/e2e/support/pageObjects/settingsDeviceObject.ts @@ -0,0 +1,12 @@ +/// + +class SettingsDevicePage { + openCreateMultiShareBackup(): void { + cy.getTestElement('@settings/device/create-multi-share-backup-button') + .should('be.visible') + .click(); + cy.getTestElement('@multi-share-backup/1st-info/submit-button').should('be.visible'); + } +} + +export const onSettingsDevicePage = new SettingsDevicePage(); diff --git a/packages/suite-web/e2e/support/pageObjects/settingsMenuObject.ts b/packages/suite-web/e2e/support/pageObjects/settingsMenuObject.ts new file mode 100644 index 00000000000..bb0b4b8d900 --- /dev/null +++ b/packages/suite-web/e2e/support/pageObjects/settingsMenuObject.ts @@ -0,0 +1,9 @@ +/// + +class SettingsMenu { + openDeviceSettings(): void { + cy.getTestElement('@settings/menu/device').should('be.visible').click(); + } +} + +export const onSettingsMenu = new SettingsMenu(); diff --git a/packages/suite-web/e2e/tests/backup/t3t1-create-addtional-share.test.ts b/packages/suite-web/e2e/tests/backup/t3t1-create-addtional-share.test.ts new file mode 100644 index 00000000000..16d1b518b2f --- /dev/null +++ b/packages/suite-web/e2e/tests/backup/t3t1-create-addtional-share.test.ts @@ -0,0 +1,67 @@ +// @group_device-management +// @retry=2 + +import { onNavBar } from '../../support/pageObjects/topBarObject'; +import { onSettingsMenu } from '../../support/pageObjects/settingsMenuObject'; +import { onSettingsDevicePage } from '../../support/pageObjects/settingsDeviceObject'; +import { onMultiShareBackupModal } from '../../support/pageObjects/multiShareBackupObject'; + +const mnemonic = + 'academic again academic academic academic academic academic academic academic academic academic academic academic academic academic academic academic pecan provide remember'; +describe('Backup success', () => { + beforeEach(() => { + cy.task('startEmu', { wipe: true, model: 'T3T1', version: '2.8.1' }); + cy.task('setupEmu', { + needs_backup: false, + mnemonic, + }); + cy.task('startBridge'); + + cy.viewport('macbook-15').resetDb(); + cy.prefixedVisit('/'); + }); + + it('Successful backup happy path', () => { + // Arrange + cy.getTestElement('@analytics/continue-button', { timeout: 40000 }) + .click() + .getTestElement('@onboarding/exit-app-button') + .click(); + cy.passThroughAuthenticityCheck(); + cy.getTestElement('@onboarding/viewOnly/enable').click(); + cy.getTestElement('@viewOnlyTooltip/gotIt', { timeout: 15000 }) + .should('be.visible') + .click(); + + // Act + // navigate to device settings page + onNavBar.openSettings(); + onSettingsMenu.openDeviceSettings(); + onSettingsDevicePage.openCreateMultiShareBackup(); + onMultiShareBackupModal.createMultiShareBackup(); + + // [device screen] check your backup? + cy.task('swipeEmu', 'up'); + + // [device screen] select the number of words in your backup + cy.task('inputEmu', '20'); + + // [device screen] backup instructions + cy.task('swipeEmu', 'up'); + for (const word of mnemonic.split(' ')) { + // [device screen] enter next word + cy.task('inputEmu', word); + } + + // [device screen] create additional backup? + cy.wait(1000); // without this timeout, backup on device simply disappears, it stinks + cy.task('swipeEmu', 'up'); + + cy.task('readAndConfirmShamirMnemonicEmu', { shares: 3, threshold: 2 }); + + // Assert + onMultiShareBackupModal.finalizeMultiShareBackup(); + }); +}); + +export {}; diff --git a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx index e8d1f4f6af6..3f0b1011a6d 100644 --- a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx +++ b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupModal.tsx @@ -91,7 +91,10 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps) ), bottomBarComponents: ( <> - , bottomBarComponents: ( <> - @@ -179,7 +185,10 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps) children: , bottomBarComponents: ( <> - diff --git a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupStep1FirstInfo.tsx b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupStep1FirstInfo.tsx index f9c98970b43..8239fcc18b6 100644 --- a/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupStep1FirstInfo.tsx +++ b/packages/suite/src/components/suite/modals/ReduxModal/UserContextModal/MultiShareBackupModal/MultiShareBackupStep1FirstInfo.tsx @@ -60,6 +60,7 @@ export const MultiShareBackupStep1FirstInfo = ({ isChecked={isChecked1} onClick={toggleCheckbox1} variant={checkboxVariant1} + data-testid={`@multi-share-backup/checkbox/1`} > @@ -67,6 +68,7 @@ export const MultiShareBackupStep1FirstInfo = ({ isChecked={isChecked2} onClick={toggleCheckbox2} variant={checkboxVariant2} + data-testid={`@multi-share-backup/checkbox/2`} >