Skip to content

Commit

Permalink
fixup! test(suite-web): add a test for t3t1 multishare backup
Browse files Browse the repository at this point in the history
  • Loading branch information
HajekOndrej committed Oct 11, 2024
1 parent d0683e0 commit 56f9431
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference types="cypress" />

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();
12 changes: 12 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/settingsDeviceObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types="cypress" />

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();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="cypress" />

class SettingsMenu {
openDeviceSettings(): void {
cy.getTestElement('@settings/menu/device').should('be.visible').click();
}
}

export const onSettingsMenu = new SettingsMenu();
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// @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', () => {
Expand All @@ -14,6 +19,10 @@ describe('Backup success', () => {

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')
Expand All @@ -23,60 +32,35 @@ describe('Backup success', () => {
cy.getTestElement('@viewOnlyTooltip/gotIt', { timeout: 15000 })
.should('be.visible')
.click();
// navigate to device settings page
cy.getTestElement('@suite/menu/settings').click();
cy.getTestElement('@settings/menu/device').click();

cy.getTestElement('@settings/device/create-multi-share-backup-button').click();
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();
// Act
// navigate to device settings page
onNavBar.openSettings();
onSettingsMenu.openDeviceSettings();
onSettingsDevicePage.openCreateMultiShareBackup();
onMultiShareBackupModal.createMultiShareBackup();

// cy.pause();
// [device screen] check your backup?
cy.task('swipeEmu', 'up');
// cy.pause();

// [device screen] select the number of words in your backup
cy.task('inputEmu', '20');
// cy.pause();

// [device screen] backup instructions
cy.task('swipeEmu', 'up');
for (const m of mnemonic.split(' ')) {
// [device screen] enter next word
cy.task('inputEmu', m);
}

// [device screen] create additional backup?
cy.wait(1000); // without this timeout, backup on device simply disappears, it stinks
cy.task('swipeEmu', 'up');
// [device screen] your wallet backup contains multiple lists of words in a specific order (shares)
cy.task('swipeEmu', 'up');
// [device screen] multi share backup steps overview
cy.task('swipeEmu', 'up');
// [device screen] set number of shares
cy.task('swipeEmu', 'up');
// [device screen] multi share backup steps overview (2. set threshold)
cy.task('swipeEmu', 'up');
// [device screen] set threshold
cy.task('swipeEmu', 'up');
// [device screen] multi share backup steps overview (write down and check)
cy.task('swipeEmu', 'up');
// [device screen] never put your digital backup anywhere digital!
cy.task('swipeEmu', 'up');
// [device screen] instructions - start with share 1
cy.task('swipeEmu', 'up');
cy.wait(500);

// TODO: uf, readAndConfirmMnemonicEmu doesn't work as expected. I could do it using getDebugState
// but it would be reinventing the wheel. Lets wait for Jiri to help with it.
cy.task('getDebugState', _event => {});
});
cy.task('readAndConfirmShamirMnemonicEmu', { shares: 3, threshold: 2 });

it('Successful backup happy path', () => {
// access from notification
// cy.pause();
// Assert
onMultiShareBackupModal.finalizeMultiShareBackup();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps)
children: <MultiShareBackupStep5Done />,
bottomBarComponents: (
<>
<Button onClick={handleCancel}>
<Button
onClick={handleCancel}
data-testid="@multi-share-backup/done/got-it-button"
>
<Translation id="TR_GOT_IT_BUTTON" />
</Button>
<LearnMoreButton url={HELP_CENTER_KEEPING_SEED_SAFE_URL} size="medium">
Expand Down

0 comments on commit 56f9431

Please sign in to comment.