Skip to content

Commit

Permalink
test(suite-web): add a test for t3t1 multishare backup
Browse files Browse the repository at this point in the history
  • Loading branch information
mroz22 authored and tomasklim committed Oct 15, 2024
1 parent bf7ef93 commit 39c0c63
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 3 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
@@ -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 {};
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps)
),
bottomBarComponents: (
<>
<Button onClick={goToStepNextStep}>
<Button
onClick={goToStepNextStep}
data-testid="@multi-share-backup/1st-info/submit-button"
>
<Translation id="TR_CREATE_MULTI_SHARE_BACKUP" />
</Button>
<LearnMoreButton
Expand Down Expand Up @@ -142,7 +145,10 @@ export const MultiShareBackupModal = ({ onCancel }: MultiShareBackupModalProps)
children: <MultiShareBackupStep2SecondInfo />,
bottomBarComponents: (
<>
<Button onClick={enterBackup}>
<Button
onClick={enterBackup}
data-testid="@multi-share-backup/2nd-info/submit-button"
>
<Translation id="TR_ENTER_EXISTING_BACKUP" />
</Button>
<LearnMoreButton url={TREZOR_SUPPORT_RECOVERY_ISSUES_URL} size="medium">
Expand Down Expand Up @@ -179,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
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ export const MultiShareBackupStep1FirstInfo = ({
isChecked={isChecked1}
onClick={toggleCheckbox1}
variant={checkboxVariant1}
data-testid={`@multi-share-backup/checkbox/1`}
>
<Translation id="TR_MULTI_SHARE_BACKUP_CHECKBOX_1" />
</Checkbox>
<Checkbox
isChecked={isChecked2}
onClick={toggleCheckbox2}
variant={checkboxVariant2}
data-testid={`@multi-share-backup/checkbox/2`}
>
<Translation id="TR_MULTI_SHARE_BACKUP_CHECKBOX_2" />
</Checkbox>
Expand Down

0 comments on commit 39c0c63

Please sign in to comment.