Skip to content

Commit

Permalink
test(trezor-user-env-link): share common mnemonics in e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz authored and mroz22 committed Sep 18, 2024
1 parent 72ea3fa commit 6557168
Show file tree
Hide file tree
Showing 39 changed files with 50 additions and 88 deletions.
1 change: 0 additions & 1 deletion packages/connect-popup/e2e/tests/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ test('reporting', async ({ page }) => {
});

await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: true,
label: 'My Trevor',
Expand Down
1 change: 0 additions & 1 deletion packages/connect-popup/e2e/tests/passphrase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ test.beforeEach(async ({ page }) => {
});
log('beforeEach', 'setupEmu');
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: true,
label: 'My Trevor',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ test.beforeEach(async ({ page }) => {
wipe: true,
});
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: false,
label: 'My Trevor',
Expand Down
1 change: 0 additions & 1 deletion packages/connect-popup/e2e/tests/popup-close.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const setup = async ({ page, context }: { page: Page; context?: BrowserContext }
});
log('beforeEach', 'setupEmu');
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: false,
label: 'My Trevor',
Expand Down
2 changes: 0 additions & 2 deletions packages/connect-popup/e2e/tests/popup-pages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ test('popup should display error page when device disconnected and debug mode',
wipe: true,
});
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: false,
label: 'My Trevor',
Expand Down Expand Up @@ -113,7 +112,6 @@ test('log page should contain logs from shared worker', async ({ page, context }
wipe: true,
});
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: false,
label: 'My Trevor',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ test.beforeEach(async () => {
wipe: true,
});
await TrezorUserEnvLink.setupEmu({
mnemonic: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
pin: '',
passphrase_protection: false,
label: 'My Trevor',
Expand Down
14 changes: 2 additions & 12 deletions packages/connect/e2e/common.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,10 @@ import {
TrezorUserEnvLink,
type TrezorUserEnvLinkClass,
StartEmu,
MNEMONICS,
} from '@trezor/trezor-user-env-link';
import { ApplySettings } from '@trezor/protobuf/src/messages-schema';

const MNEMONICS = {
mnemonic_all: 'all all all all all all all all all all all all',
mnemonic_12: 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
mnemonic_abandon:
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
};

const emulatorStartOpts =
(process.env.emulatorStartOpts as StartEmu) || global.emulatorStartOpts || {};

Expand Down Expand Up @@ -60,11 +54,7 @@ export const setup = async (

await TrezorUserEnvLink.startEmu(emulatorStartOpts);

const mnemonic =
typeof options.mnemonic === 'string' && options.mnemonic.indexOf(' ') > 0
? options.mnemonic
: // @ts-expect-error
MNEMONICS[options.mnemonic] || MNEMONICS.mnemonic_all;
const mnemonic = options.mnemonic || MNEMONICS.mnemonic_all;

await TrezorUserEnvLink.setupEmu({
...options,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test as testPlaywright, ElectronApplication, Page } from '@playwright/test';

import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link/src';
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link';

import { launchSuite } from '../../support/common';
import { onDashboardPage } from '../../support/pageActions/dashboardActions';
Expand All @@ -13,7 +13,7 @@ testPlaywright.beforeAll(async () => {
await TrezorUserEnvLink.startEmu({ wipe: true });
await TrezorUserEnvLink.setupEmu({
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
});
({ electronApp, window } = await launchSuite());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ testPlaywright.describe.serial('Suite works with Electrum server', () => {
await TrezorUserEnvLink.startEmu({ wipe: true });
await TrezorUserEnvLink.setupEmu({
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
});
({ electronApp, window } = await launchSuite());
});
Expand Down
2 changes: 0 additions & 2 deletions packages/suite-web/e2e/tests/analytics/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describe('Analytics Events', () => {
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.6.0' });
cy.task('setupEmu', {
needs_backup: false,
mnemonic: 'all all all all all all all all all all all all',
passphrase_protection: true,
});

Expand Down Expand Up @@ -89,7 +88,6 @@ describe('Analytics Events', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
needs_backup: false,
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('startBridge');

Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/backup/t2t1-success.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Backup success', () => {
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.8.1' });
cy.task('setupEmu', {
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
});
cy.task('startBridge');

Expand Down
1 change: 0 additions & 1 deletion packages/suite-web/e2e/tests/dashboard/assets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('Assets', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('startBridge');

Expand Down
1 change: 0 additions & 1 deletion packages/suite-web/e2e/tests/dashboard/dashboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ describe('Dashboard', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('startBridge');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Hovering over fields that may be labeled shows "add label" button upon which is
it(provider, () => {
// prepare test
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task(`metadataStartProvider`, provider);

cy.prefixedVisit('/', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ describe('Metadata - address labeling', () => {
it(provider, () => {
// prepare test
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', provider);
cy.prefixedVisit('/', {
Expand Down
12 changes: 3 additions & 9 deletions packages/suite-web/e2e/tests/metadata/dropbox-api-errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ describe('Dropbox api errors', () => {

it('Malformed token', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', 'dropbox');
// prepare some initial files
Expand Down Expand Up @@ -72,9 +70,7 @@ describe('Dropbox api errors', () => {

it('Success after retrying GET request', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', 'dropbox');
// prepare some initial files
Expand Down Expand Up @@ -148,9 +144,7 @@ describe('Dropbox api errors', () => {

it('Incomplete data returned from provider', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', 'dropbox');
// prepare some initial files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ describe('Google api errors', () => {
beforeEach(() => {
cy.viewport(1440, 2560).resetDb();
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', provider);
cy.prefixedVisit('/', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ describe('Metadata - suite is watching cloud provider and syncs periodically', (
it(`${f.provider}-${f.desc}`, () => {
// prepare test
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', f.provider);
cy.clock();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// @group_metadata
// @retry=2

const mnemonic = 'all all all all all all all all all all all all';

describe('Metadata - cancel metadata on device', () => {
beforeEach(() => {
cy.viewport('macbook-15').resetDb();
Expand All @@ -12,7 +10,7 @@ describe('Metadata - cancel metadata on device', () => {
// prepare test
cy.task('startEmu', { wipe: true, model: 'T2T1', version: '2.7.0' });
cy.task('setupEmu', {
mnemonic,
mnemonic: 'mnemonic_all',
passphrase_protection: true,
});
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ describe('Metadata - Output labeling', () => {
'@metadata/outputLabel/1d7a8556bb5bda4895596c52017b98c9af29eda10770865e845d3848aa222d1c-0/add-label-button';
// prepare test
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', provider);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ describe(
// prepare test
cy.task('stopBridge');
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task('metadataStartProvider', f.provider);
cy.task('metadataSetFileContent', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ describe(`Metadata - switching between cloud providers`, () => {
it('Start with one and switch to another', () => {
// prepare test
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.task(`metadataStartProvider`, 'dropbox');
cy.task(`metadataStartProvider`, 'google');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { rerouteMetadataToMockProvider, stubOpen } from '../../stubs/metadata';
const firmwares = ['2.3.0', '2-main'] as const;
const provider = 'dropbox';

const mnemonic = 'all all all all all all all all all all all all';
// state corresponding to all seed
const standardWalletState = 'mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q@355C817510C0EABF2F147145:1';
// state corresponding to "wallet for drugs"
Expand All @@ -23,7 +22,7 @@ describe.skip('Metadata - wallet labeling', () => {
// prepare test
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic,
mnemonic: 'mnemonic_all',
passphrase_protection: true,
});
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
describe('Recovery - dry run', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
});
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/suite/bug-report-form.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { onSuiteGuide } from '../../support/pageObjects/suiteGuideObject';
describe('Stories of bug report forms', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', { mnemonic: 'all all all all all all all all all all all all' });
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });

cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('Database migration', () => {
cy.viewport(1440, 2560);
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
passphrase_protection: true,
});
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Passphrase cancel', () => {
it(version.model + '_' + version.version, () => {
cy.task('startEmu', { wipe: true, ...version });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
passphrase_protection: true,
});
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Passphrase with cardano', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
passphrase_protection: true,
});
cy.task('startBridge');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Passphrase', () => {
// note that versions before 2.3.1 don't have passphrase caching, this means that returning
// back to passphrase that was used before in the session would require to type the passphrase again
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', { mnemonic: 'all all all all all all all all all all all all' });
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');

cy.viewport(1440, 2560).resetDb();
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/suite/passphrase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Passphrase', () => {
// back to passphrase that was used before in the session would require to type the passphrase again
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
passphrase_protection: true,
});
cy.task('startBridge');
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/suite/tooltip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export {};
describe.skip('Test tooltip conditional rendering', () => {
beforeEach(() => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', { mnemonic: 'all all all all all all all all all all all all' });
cy.task('setupEmu', { mnemonic: 'mnemonic_all' });
cy.task('startBridge');
cy.viewport(1440, 2560).resetDb();
cy.prefixedVisit('/');
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-web/e2e/tests/wallet/coin-balance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Dashboard with regtest', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
});
cy.task('startBridge');
cy.task('sendToAddressAndMineBlock', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Custom-blockbook-discovery', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
needs_backup: true,
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
});
cy.task('startBridge');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Overview and transactions check', () => {
cy.task('startEmu', { wipe: true });
cy.task('setupEmu', {
needs_backup: false,
mnemonic: 'all all all all all all all all all all all all',
mnemonic: 'mnemonic_all',
});
cy.task('startBridge');

Expand Down
Loading

0 comments on commit 6557168

Please sign in to comment.