Skip to content

Commit

Permalink
fix(e2e): Fixed T1B1 recovery fail and success
Browse files Browse the repository at this point in the history
  • Loading branch information
HajekOndrej authored and mroz22 committed Oct 31, 2024
1 parent 0b3dc63 commit bef8f3c
Show file tree
Hide file tree
Showing 15 changed files with 311 additions and 112 deletions.
9 changes: 9 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/analyticsObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="cypress" />

class AnalyticsPage {
continue() {
cy.getTestElement('@analytics/continue-button').click();
}
}

export const onAnalyticsPage = new AnalyticsPage();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// <reference types="cypress" />

class ConnectDevicePrompt {
waitForConnectDevicePrompt() {
cy.getTestElement('@connect-device-prompt', { timeout: 20000 }).should('be.visible');
}
}

export const onConnectDevicePrompt = new ConnectDevicePrompt();
46 changes: 46 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/onboardingObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// <reference types="cypress" />

class OnboardingPage {
waitForConfirmationOnDevice() {
cy.getTestElement('@onboarding/confirm-on-device').should('be.visible');
}

recoverWallet() {
cy.getTestElement('@onboarding/path-recovery-button').click();
}

continueRecovery() {
cy.getTestElement('@onboarding/recovery/continue-button').click();
}

continueCoins() {
cy.getTestElement('@onboarding/coins/continue-button').click();
}

continueFirmware() {
cy.getTestElement('@firmware/continue-button').click();
}

startRecovery() {
cy.getTestElement('@onboarding/recovery/start-button').click();
}

retryRecovery() {
cy.getTestElement('@onboarding/recovery/retry-button').click();
}

skipFirmware() {
cy.getTestElement('@firmware/skip-button').click();
}

skipPin() {
cy.getTestElement('@onboarding/skip-button').click();
cy.getTestElement('@onboarding/skip-button-confirm').click();
}

checkOnboardingSuccess() {
cy.getTestElement('@onboarding/final').should('be.visible').contains('Setup complete!');
}
}

export const onOnboardingPage = new OnboardingPage();
13 changes: 13 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/recoverObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/// <reference types="cypress" />

class RecoverPage {
selectWordCount(number: number) {
cy.getTestElement(`@recover/select-count/${number}`).click();
}

selectBasicRecovery() {
cy.getTestElement('@recover/select-type/basic').click();
}
}

export const onRecoverPage = new RecoverPage();
10 changes: 10 additions & 0 deletions packages/suite-web/e2e/support/pageObjects/wordInputObject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference types="cypress" />

class WordInputPage {
inputWord(word: string) {
cy.getTestElement('@word-input-select/input').type(word);
cy.getTestElement(`@word-input-select/option/${word}`).click();
}
}

export const onWordInputPage = new WordInputPage();

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// @group_device-management
// @retry=2

import { onOnboardingPage } from '../../../support/pageObjects/onboardingObject';
import { onAnalyticsPage } from '../../../support/pageObjects/analyticsObject';
import { onRecoverPage } from '../../../support/pageObjects/recoverObject';
import { onConnectDevicePrompt } from '../../../support/pageObjects/connectDeviceObject';

describe('Onboarding - recover wallet T1B1', () => {
beforeEach(() => {
cy.task('startBridge');
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.viewport(1440, 2560).resetDb();
cy.prefixedVisit('/');
cy.disableFirmwareHashCheck();

cy.step('Go through analytics and confirm firmware', () => {
onAnalyticsPage.continue();
onAnalyticsPage.continue();
});
});

it('Device disconnected during recovery offers retry', () => {
cy.step('Start wallet recovery process and confirm on device', () => {
onOnboardingPage.continueFirmware();
onOnboardingPage.recoverWallet();
onRecoverPage.selectWordCount(24);
onRecoverPage.selectBasicRecovery();
onOnboardingPage.waitForConfirmationOnDevice();
cy.wait(1000);
cy.task('pressYes');
cy.wait(1000);
});

cy.step('Disconnect device', () => {
cy.task('stopEmu');
cy.wait(500);
onConnectDevicePrompt.waitForConnectDevicePrompt();
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: false });
});

cy.step('Check that you can retry', () => {
onOnboardingPage.retryRecovery();
onRecoverPage.selectWordCount(24);
onRecoverPage.selectBasicRecovery();
onOnboardingPage.waitForConfirmationOnDevice();
});
});
});

export {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// @group_device-management
// @retry=2

import { onOnboardingPage } from '../../../support/pageObjects/onboardingObject';
import { onWordInputPage } from '../../../support/pageObjects/wordInputObject';
import { onAnalyticsPage } from '../../../support/pageObjects/analyticsObject';
import { onRecoverPage } from '../../../support/pageObjects/recoverObject';

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',
];

describe('Onboarding - recover wallet T1B1', () => {
beforeEach(() => {
cy.task('startBridge');
cy.task('startEmu', { model: 'T1B1', version: '1-latest', wipe: true });
cy.viewport(1440, 2560).resetDb();
cy.prefixedVisit('/');
cy.disableFirmwareHashCheck();

cy.step('Go through analytics and confirm firmware', () => {
onAnalyticsPage.continue();
onAnalyticsPage.continue();
});
});

it('Successfully recovers wallet from mnemonic', () => {
cy.step('Start wallet recovery process and confirm on device', () => {
onOnboardingPage.continueFirmware();
onOnboardingPage.recoverWallet();
onRecoverPage.selectWordCount(24);
onRecoverPage.selectBasicRecovery();
onOnboardingPage.waitForConfirmationOnDevice();
cy.wait(2000);
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);
}
});

cy.step('Finalize recovery, skip pin and check success', () => {
onOnboardingPage.continueRecovery();
onOnboardingPage.skipPin();
onOnboardingPage.continueCoins();
onOnboardingPage.checkOnboardingSuccess();
});
});
});

export {};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// @group_device-management
// @retry=2

import { onNavBar } from '../../support/pageObjects/topBarObject';
import { onAnalyticsPage } from '../../../support/pageObjects/analyticsObject';
import { onConnectDevicePrompt } from '../../../support/pageObjects/connectDeviceObject';
import { onOnboardingPage } from '../../../support/pageObjects/onboardingObject';
import { onNavBar } from '../../../support/pageObjects/topBarObject';

describe('Onboarding - recover wallet T2T1', () => {
beforeEach(() => {
Expand All @@ -22,27 +25,33 @@ describe('Onboarding - recover wallet T2T1', () => {
cy.getTestElement('@device-firmware-revision/opt-out-button').click();
cy.getTestElement('@settings/menu/close').click();

// Continue with test
cy.getTestElement('@analytics/continue-button').click();
cy.getTestElement('@analytics/continue-button').click();

cy.getTestElement('@firmware/continue-button').click();

cy.getTestElement('@onboarding/path-recovery-button').click();
cy.step('Go through analytics and confirm firmware', () => {
onAnalyticsPage.continue();
onAnalyticsPage.continue();
});
});

it('Device disconnected during action', () => {
cy.getTestElement('@onboarding/confirm-on-device');
cy.task('pressYes');
cy.wait(501);
cy.task('stopEmu');
cy.getTestElement('@connect-device-prompt', { timeout: 20000 });
cy.task('startEmu', { wipe: false });
cy.log(
'If device disconnected during call, error page with retry button should appear. Also note, that unlike with T1B1, retry button initiates recoveryDevice call immediately',
);
cy.getTestElement('@onboarding/recovery/start-button', { timeout: 10000 }).click();
cy.getTestElement('@onboarding/confirm-on-device');
it('Device disconnected during recovery offers retry', () => {
cy.step('Start wallet recovery process and confirm on device', () => {
onOnboardingPage.continueFirmware();
onOnboardingPage.recoverWallet();
onOnboardingPage.startRecovery();

onOnboardingPage.waitForConfirmationOnDevice();
});

cy.step('Disconnect device', () => {
cy.wait(1000);
cy.task('stopEmu');
cy.wait(500);
onConnectDevicePrompt.waitForConnectDevicePrompt();
cy.task('startEmu', { model: 'T2T1', version: '2-main', wipe: false });
});

cy.step('Check that you can retry', () => {
onOnboardingPage.retryRecovery();
onOnboardingPage.waitForConfirmationOnDevice();
});
});
});

Expand Down
Loading

0 comments on commit bef8f3c

Please sign in to comment.