Skip to content

Commit

Permalink
feat(e2e): Migrated suite tests (#16934)
Browse files Browse the repository at this point in the history
  • Loading branch information
HajekOndrej authored Feb 11, 2025
1 parent 246db18 commit 1516375
Show file tree
Hide file tree
Showing 15 changed files with 223 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { step } from '../common';
export class AnalyticsActions {
readonly heading: Locator;
readonly continueButton: Locator;
readonly toggleSwitch: Locator;

constructor(page: Page) {
this.continueButton = page.getByTestId('@analytics/continue-button');
this.heading = page.getByTestId('@analytics/consent/heading');
this.toggleSwitch = page.getByTestId('@analytics/toggle-switch');
}

@step()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class SettingsActions {
readonly checkSeedButton: Locator;
readonly metadataSwitch: Locator;
readonly analyticsSwitch: Locator;
readonly showLogButton: Locator;

constructor(
private readonly page: Page,
Expand Down Expand Up @@ -100,6 +101,7 @@ export class SettingsActions {
this.checkSeedButton = this.page.getByTestId('@settings/device/check-seed-button');
this.metadataSwitch = this.page.getByTestId('@settings/metadata-switch');
this.analyticsSwitch = this.page.getByTestId('@analytics/toggle-switch');
this.showLogButton = this.page.getByTestId('@settings/show-log-button');
}

@step()
Expand Down Expand Up @@ -200,4 +202,14 @@ export class SettingsActions {
await expect(this.notificationSuccessToast).toBeVisible();
});
}

@step()
async changeSafetyChecksLevel(level: 'strict' | 'prompt') {
await this.navigateTo('device');
await this.page.getByTestId('@settings/device/safety-checks-button').click();
await this.page.getByTestId(`@radio-button-${level}`).click();
await this.page.getByTestId('@safety-checks-apply').click();
await expect(this.confirmOnDevicePrompt).toBeVisible();
await TrezorUserEnvLinkProxy.pressYes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export class SuiteGuide {
readonly toastNotifications: Locator;
readonly feedbackSuccessToast: Locator;
readonly articleHeader: Locator;
readonly guideNodes: Locator;
readonly guideLabel: Locator;
readonly searchNoResults: Locator;

constructor(private readonly page: Page) {
this.guideButton = this.page.getByTestId('@guide/button-open');
Expand All @@ -46,6 +49,9 @@ export class SuiteGuide {
this.toastNotifications = this.page.locator('[data-testid-alt="@toast"]');
this.feedbackSuccessToast = this.page.getByTestId('@toast/user-feedback-send-success');
this.articleHeader = this.page.getByTestId('@guide/article').locator('h1');
this.guideNodes = this.page.getByTestId('@guide/nodes');
this.guideLabel = this.page.getByTestId('@guide/label');
this.searchNoResults = this.page.getByTestId('@guide/search/no-results');
}

@step()
Expand Down
19 changes: 19 additions & 0 deletions packages/suite-desktop-core/e2e/tests/suite/bridge.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect, test } from '../../support/fixtures';

test.describe('Bridge page', { tag: ['@group=suite', '@webOnly'] }, () => {
test.beforeEach(async ({ trezorUserEnvLink }) => {
await trezorUserEnvLink.stopEmu();
await trezorUserEnvLink.stopBridge();
});

test.use({ startEmulator: false });
test('can use webusb', async ({ url, page }) => {
await page.goto(url + 'bridge');

// user may exit bridge page and use webusb
await page.getByTestId('@bridge/goto/wallet-index').click();

// connect device prompt with webusb enabled appears
await expect(page.getByTestId('@connect-device-prompt')).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FeedbackCategory } from '@suite-common/suite-types';

import { expect, test } from '../../support/fixtures';

test.describe('Bug report forms', { tag: ['@group=suite'] }, () => {
test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } });
test('Send a bug report', async ({ page, suiteGuidePage }) => {
const testData = {
location: 'account' as FeedbackCategory,
report: 'Henlo this is testy test writing hangry test user report',
};

await suiteGuidePage.openPanel();
await suiteGuidePage.supportAndFeedbackButton.click();

await suiteGuidePage.sendBugReport(testData);

await expect(page.getByTestId('@toast/user-feedback-send-success')).toBeVisible();
});
});
63 changes: 63 additions & 0 deletions packages/suite-desktop-core/e2e/tests/suite/guide.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { expect, test } from '../../support/fixtures';

test.describe('Guide without device', { tag: ['@group=suite', '@webOnly'] }, () => {
test.beforeEach(async ({ trezorUserEnvLink }) => {
await trezorUserEnvLink.stopEmu();
await trezorUserEnvLink.stopBridge();
});
test.use({ startEmulator: false });
test('open / close guide', async ({ page, suiteGuidePage, settingsPage }) => {
// Open guide
await suiteGuidePage.openPanel();
const firstNode = suiteGuidePage.guideNodes.first().locator('> *').first();
const text = await firstNode.innerText();
await firstNode.click();
await expect(suiteGuidePage.guideLabel).toHaveText(text);
await firstNode.click();
await suiteGuidePage.closeGuide();
await expect(suiteGuidePage.guideButton).toBeVisible();

// Feedback form
await suiteGuidePage.openPanel();
await suiteGuidePage.supportAndFeedbackButton.click();
await suiteGuidePage.feedbackFormButton.click();
await page.getByTestId('@guide/feedback/suggestion/5').click();
await suiteGuidePage.bugInputTextField.fill('Hello!');
await suiteGuidePage.submitButton.click();
await expect(suiteGuidePage.feedbackSuccessToast).toBeVisible();

// Guide over modal
await settingsPage.navigateTo('application');
await settingsPage.showLogButton.click();
await suiteGuidePage.closeGuide();
await suiteGuidePage.openPanel();
await expect(suiteGuidePage.guidePanel).toBeVisible();

// Search input
await suiteGuidePage.searchInput.fill('trezor');
await expect
.poll(async () => (await suiteGuidePage.searchResults.all()).length)
.toBeGreaterThan(0);
await suiteGuidePage.searchInput.fill('meow-wuf-nonsense');
await expect(suiteGuidePage.searchNoResults).toBeVisible();
});
});

test.describe('Guide with device', { tag: ['@group=suite'] }, () => {
test('onboarding with device', async ({
page,
analyticsPage,
onboardingPage,
suiteGuidePage,
}) => {
await onboardingPage.disableFirmwareHashCheck();
await onboardingPage.optionallyDismissFwHashCheckError();
await analyticsPage.continueButton.click();

await suiteGuidePage.openPanel();
await expect(page.getByTestId('@guide/panel')).toBeVisible();
await page.getByTestId('@guide/button-feedback').click();
await expect(suiteGuidePage.bugFormButton).toBeVisible();
await expect(suiteGuidePage.feedbackFormButton).toBeVisible();
});
});
33 changes: 33 additions & 0 deletions packages/suite-desktop-core/e2e/tests/suite/initial-run.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect, test } from '../../support/fixtures';

test.describe('Suite initial run', { tag: ['@group=suite'] }, () => {
test.beforeEach(async ({ onboardingPage }) => {
await onboardingPage.disableFirmwareHashCheck();
});

test('Until user passed through initial run, it will be there after reload', async ({
page,
analyticsPage,
onboardingPage,
}) => {
await expect(analyticsPage.toggleSwitch).toBeVisible();
await page.reload();
// analytics screen is there until user confirms his choice
await expect(analyticsPage.toggleSwitch).toBeVisible();
await analyticsPage.continueButton.click();
await page.reload();
await expect(analyticsPage.toggleSwitch).not.toBeVisible();
await expect(onboardingPage.onboardingContinueButton).toBeVisible();
});

test('Once user passed trough, skips initial run and shows connect-device modal', async ({
page,
dashboardPage,
onboardingPage,
}) => {
await onboardingPage.completeOnboarding({ enableViewOnly: true });
await dashboardPage.discoveryShouldFinish();
await page.reload();
await expect(dashboardPage.deviceSwitchingOpenButton).toContainText('Connected');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { expect, test } from '../../support/fixtures';

test.describe('safety_checks Warnings', { tag: ['@group=suite'] }, () => {
test.beforeEach(async ({ onboardingPage, dashboardPage, settingsPage }) => {
await onboardingPage.completeOnboarding();
await dashboardPage.discoveryShouldFinish();
await settingsPage.changeSafetyChecksLevel('prompt');
});

test('Dismissible warning appears when safety_checks to prompt', async ({ page }) => {
await expect(page.getByTestId('@banner/safety-checks/button')).toBeVisible();
await expect(page.getByTestId('@banner/safety-checks/dismiss')).toBeVisible();
});

test('CTA button opens device settings when safety_checks to prompt', async ({
page,
settingsPage,
}) => {
await page.getByTestId('@banner/safety-checks/button').click();
await expect(settingsPage.settingsHeader).toBeVisible();
});

test('Dismiss button hides the warning when safety_checks to prompt', async ({ page }) => {
await page.getByTestId('@banner/safety-checks/dismiss').click();
await expect(page.getByTestId('@banner/safety-checks/button')).not.toBeVisible();
});

test('Warning disappears when safety_checks are set to strict from prompt', async ({
page,
settingsPage,
}) => {
await settingsPage.changeSafetyChecksLevel('strict');

await expect(page.getByTestId('@banner/safety-checks/button')).not.toBeVisible();
});

test('Dismissed warning re-appears when safety_checks are set to strict and then to Prompt again', async ({
page,
settingsPage,
}) => {
await settingsPage.changeSafetyChecksLevel('strict');

await expect(page.getByTestId('@banner/safety-checks/button')).not.toBeVisible();
// Set safety_checks back to PromptTemporarily
await settingsPage.changeSafetyChecksLevel('prompt');

// Assert the warning appears again.
await expect(page.getByTestId('@banner/safety-checks/button')).toBeVisible();
});
});
18 changes: 18 additions & 0 deletions packages/suite-desktop-core/e2e/tests/suite/version-page.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getSuiteVersion } from '@trezor/env-utils';

import { expect, test } from '../../support/fixtures';

test.describe('Hidden version page', { tag: ['@group=suite', '@webOnly'] }, () => {
test.beforeEach(async ({ trezorUserEnvLink }) => {
await trezorUserEnvLink.stopEmu();
await trezorUserEnvLink.stopBridge();
});
test.use({ startEmulator: false });

test('is accessible via route', async ({ url, page }) => {
const suiteVersion = getSuiteVersion();
await page.goto(url + 'version');
await expect(page.getByTestId('@version/number')).toContainText(suiteVersion);
await page.getByTestId('@modal/version').screenshot({ path: 'version-modal.png' });
});
});
22 changes: 0 additions & 22 deletions packages/suite-web/e2e/tests/suite/bridge.test.ts

This file was deleted.

49 changes: 0 additions & 49 deletions packages/suite-web/e2e/tests/suite/bug-report-form.test.ts

This file was deleted.

Loading

0 comments on commit 1516375

Please sign in to comment.