Skip to content

Commit

Permalink
fix(e2e): Fixed and updated t1b1 seed check test
Browse files Browse the repository at this point in the history
  • Loading branch information
HajekOndrej authored and mroz22 committed Nov 15, 2024
1 parent b45a147 commit 84bd8f5
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 24 deletions.
4 changes: 4 additions & 0 deletions packages/suite-web/e2e/support/enums/seedCheckType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum SeedCheckType {
Advanced = 'advanced',
Standard = 'basic',
}
18 changes: 18 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/checkSeedObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference types="cypress" />

import { SeedCheckType } from '../enums/seedCheckType';

class CheckSeedPage {
initCheck(type: SeedCheckType, numOfWords: 12 | 24): void {
cy.getTestElement('@recovery/user-understands-checkbox').click();
cy.getTestElement('@recovery/start-button').click();
cy.getTestElement(`@recover/select-count/${numOfWords}`).click();
cy.getTestElement(`@recover/select-type/${type}`).click();
}

verifyCheckSuccessful(): void {
cy.getTestElement('@recovery/success-title').should('be.visible');
}
}

export const onCheckSeedPage = new CheckSeedPage();
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/// <reference types="cypress" />

class SettingsDevicePage {
openSeedCheck(): void {
cy.getTestElement('@settings/device/check-seed-button').click();
}

openCreateMultiShareBackup(): void {
cy.getTestElement('@settings/device/create-multi-share-backup-button')
.should('be.visible')
Expand Down
14 changes: 14 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/wordInputObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ class WordInputPage {
cy.getTestElement('@word-input-select/input').type(word);
cy.getTestElement(`@word-input-select/option/${word}`).click();
}

inputMnemonicT1B1(mnemonic: string[]) {
cy.step('Input mnemonic', () => {
for (let i = 0; i < 24; i++) {
cy.task('getDebugState').then(state => {
// @ts-expect-error
const position = state.recovery_word_pos - 1;
this.inputWord(mnemonic[position]);
});

cy.wait(500);
}
});
}
}

export const onWordInputPage = new WordInputPage();
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,7 @@ describe('Onboarding - recover wallet T1B1', () => {
cy.task('pressYes');
});

cy.step('Input mnemonic', () => {
for (let i = 0; i < 24; i++) {
cy.task('getDebugState').then(state => {
// @ts-expect-error
const position = state.recovery_word_pos - 1;
onWordInputPage.inputWord(mnemonic[position]);
});

cy.wait(500);
}
});
onWordInputPage.inputMnemonicT1B1(mnemonic);

cy.step('Finalize recovery, skip pin and check success', () => {
onOnboardingPage.continueRecovery();
Expand Down
63 changes: 50 additions & 13 deletions packages/suite-web/e2e/tests/recovery/t1b1-dry-run.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
// @group_device-management

describe.skip('Recovery - dry run', () => {
import { SeedCheckType } from '../../support/enums/seedCheckType';
import { onCheckSeedPage } from '../../support/pageObjects/checkSeedObject';
import { onSettingsDevicePage } from '../../support/pageObjects/settings/settingsDeviceObject';
import { onSettingsMenu } from '../../support/pageObjects/settings/settingsMenuObject';
import { onNavBar } from '../../support/pageObjects/topBarObject';
import { onWordInputPage } from '../../support/pageObjects/wordInputObject';

const mnemonic = [
'nasty',
'answer',
'gentle',
'inform',
'unaware',
'abandon',
'regret',
'supreme',
'dragon',
'gravity',
'behind',
'lava',
'dose',
'pilot',
'garden',
'into',
'dynamic',
'outer',
'hard',
'speed',
'luxury',
'run',
'truly',
'armed',
];

function confirmSuccessOnDevice(): void {
cy.task('pressYes');
}

describe('Recovery T1B1 - dry run', () => {
beforeEach(() => {
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.wait(2000);
cy.task('setupEmu', { needs_backup: false });
cy.task('setupEmu', { needs_backup: false, mnemonic: mnemonic.join(' ') });
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.prefixedVisit('/settings/device');
cy.viewport('macbook-13').resetDb();
cy.prefixedVisit('/');
cy.passThroughInitialRun();
onNavBar.openSettings();
onSettingsMenu.openDeviceSettings();
});

it('Dry run with T1B1', () => {
cy.getTestElement('@settings/device/check-seed-button').click();
cy.getTestElement('@recovery/user-understands-checkbox').click();
cy.getTestElement('@recovery/start-button').click();
it('Standard dry run', () => {
onSettingsDevicePage.openSeedCheck();
onCheckSeedPage.initCheck(SeedCheckType.Standard, 24);
onWordInputPage.inputMnemonicT1B1(mnemonic);

cy.getTestElement('@recover/select-count/24').click();
cy.getTestElement('@recover/select-type/advanced').click();
cy.task('pressYes');
cy.getTestElement('@recovery/word-input-advanced/1');
confirmSuccessOnDevice();

// todo: elaborate more, seems like finally T1B1 tests are stable so it would make finally sense to finish this
onCheckSeedPage.verifyCheckSuccessful();
});
});

0 comments on commit 84bd8f5

Please sign in to comment.