Skip to content

Commit

Permalink
tests: e2e Prerequesites tests
Browse files Browse the repository at this point in the history
(cherry picked from commit 1e57daf)
  • Loading branch information
mroz22 authored and tsusanka committed Jun 30, 2021
1 parent 2c970cb commit 290aab6
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
// @ts-ignore

import { DEVICE, Features, Device } from 'trezor-connect';
import {
getConnectDevice,
Expand All @@ -13,18 +13,17 @@ import {
* @param features
*/

export const connectDevice = (device?: Partial<Device>, features?: Partial<Features>) => {
return cy
export const connectDevice = (device?: Partial<Device>, features?: Partial<Features>) =>
cy
.window()
.its('store')
.invoke('dispatch', {
type: DEVICE.CONNECT,
payload: getConnectDevice(device, getDeviceFeatures(features)),
});
};

export const connectBootloaderDevice = (path: string) => {
return cy
export const connectBootloaderDevice = (path: string) =>
cy
.window()
.its('store')
.invoke('dispatch', {
Expand Down Expand Up @@ -74,7 +73,6 @@ export const connectBootloaderDevice = (path: string) => {
useEmptyPassphrase: true,
},
});
};
/**
* Helper method to dispatch DEVICE.CHANGED action.
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @group:onboarding
// @retry=2

describe('Onboarding - packaging security', () => {
beforeEach(() => {
cy.task('startBridge');
cy.viewport(1024, 768).resetDb();
cy.prefixedVisit('/');
});

it('Device without firmware is expected to come fresh out of package', () => {
cy.connectDevice({ mode: 'initialize', firmware: 'none' });
cy.getTestElement('@onboarding/continue-button').click();
cy.getTestElement('@onboarding/exit-app-button');
cy.matchImageSnapshot('security-check');
});
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Onboarding - recover wallet T1', () => {
);
cy.wait(501);
cy.task('stopEmu');
cy.getTestElement('@onboarding/connect-device', { timeout: 20000 });
cy.getTestElement('@connect-device-prompt', { timeout: 20000 });
cy.task('startEmu', { version: '1.9.0' });

cy.getTestElement('@onboarding/recovery/retry-button').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Onboarding - recover wallet T2', () => {
cy.task('pressYes');
cy.wait(501);
cy.task('stopEmu');
cy.getTestElement('@onboarding/connect-device', { timeout: 20000 });
cy.getTestElement('@connect-device-prompt', { timeout: 20000 });
cy.task('startEmu', { version: '2.1.4', wipe: false });
cy.log(
'If device disconnected during call, error page with retry button should appear. Also note, that unlike with T1, retry button initiates recoveryDevice call immediately',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('Onboarding - T2 in recovery mode', () => {

// disconnect device, reload application
cy.task('stopEmu');
cy.getTestElement('@onboarding/connect-device', { timeout: 20000 });
cy.getTestElement('@connect-device-prompt', { timeout: 20000 });
cy.wait(501);
cy.resetDb();
cy.reload();
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('Onboarding - T2 in recovery mode', () => {
cy.wait(501);
cy.task('stopEmu');
cy.wait(1000);
cy.getTestElement('@onboarding/connect-device', { timeout: 30000 });
cy.getTestElement('@connect-device-prompt', { timeout: 30000 });
cy.task('startEmu', { version: '2.3.1', wipe: false });
cy.getTestElement('@onboarding/confirm-on-device');
cy.wait(1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Recovery - dry run', () => {
cy.wait(501);
cy.task('stopEmu');
cy.getTestElement('@recovery/close-button', { timeout: 30000 }).click();
cy.getTestElement('@modal/connect-device');
cy.getTestElement('@connect-device-prompt');
cy.task('startEmu', { wipe: false, version: '2.3.1' });
cy.getTestElement('@suite/modal/confirm-action-on-device', { timeout: 20000 });
cy.task('pressYes');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ describe('Bridge page', () => {
// user may exit bridge page and use webusb
cy.getTestElement('@bridge/goto/wallet-index').click();

// connect device modal with webusb enabled appears
cy.getTestElement('@modal/connect-device');
// connect device prompt with webusb enabled appears
cy.getTestElement('@connect-device-prompt');

// linux platforms show udev rules link also
cy.getTestElement('@modal/connect-device/goto/suite-udev').click();
// todo: rename @onboarding/expand-troubleshooting-tips as it is in suite now
cy.getTestElement('@onboarding/expand-troubleshooting-tips').click();
cy.getTestElement('@goto/udev').click();
cy.getTestElement('@modal/udev').matchImageSnapshot('udev rules modal');

// udev rules modal is closable via close button
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { PrerequisiteType } from "@suite/types/suite";

type Fixture = {
desc: PrerequisiteType;
mockDevice: any;
}

describe('prerequisites = test various types of devices connecting to the application', () => {
beforeEach(() => {

cy.viewport(1024, 768).resetDb();
cy.prefixedVisit('/');

cy.getTestElement('@connect-device-prompt');
});

// todo: add transport related prerequisites
const fixtures: Fixture[] = [
{
desc: 'device-seedless',
mockDevice: () => cy.connectDevice({ mode: 'seedless' }),
}, {
desc: 'device-unacquired',
mockDevice: () => cy.connectDevice({ type: 'unacquired' }),
}, {
desc: 'device-unreadable',
mockDevice: () => cy.connectDevice({ type: 'unreadable' }),
}, {
desc: 'device-unknown',
mockDevice: () => cy.connectDevice({ features: undefined })
}, {
desc: 'device-disconnected',
mockDevice: () => { },
},
{
desc: 'device-bootloader',
mockDevice: () => cy.connectBootloaderDevice('1'),
}
];

fixtures.forEach(f => {
it(f.desc, () => {
f.mockDevice();
cy.getTestElement('@onboarding/expand-troubleshooting-tips').click();
cy.matchImageSnapshot(f.desc);
})
})

describe('should redirect to onboarding', () => {
it('to welcome step', () => {
cy.connectDevice({ mode: 'initialize' });
cy.getTestElement('@onboarding/welcome');
});

// device-recover-mode is tested elsewhere with full-fledged emulator
})
})
Loading

0 comments on commit 290aab6

Please sign in to comment.