Skip to content

Commit

Permalink
refactor(e2e): Switching to true chromium headless
Browse files Browse the repository at this point in the history
modifies browser tests
updates snapshots
removes unnecessary steps
  • Loading branch information
Vere-Grey committed Jan 19, 2025
1 parent 067a472 commit 5f7568f
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 21 deletions.
16 changes: 11 additions & 5 deletions docs/tests/e2e-playwright-suite.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,21 @@ Steps:

#### Troubleshooting

1. **To run just one test file** you can do: `yarn workspace @trezor/suite-desktop-core test:e2e:web general/wallet-discovery.test.ts`
1. **To run both Web and Desktop at same time** you can do: `yarn workspace @trezor/suite-desktop-core test:e2e`

1. **To run just one test** you can do: `yarn workspace @trezor/suite-desktop-core test:e2e:web -g "Basic cardano walkthrough"`
1. **To run tests headed (showing UI)** you can add: `--headed`

1. **To run one group** you can do: `yarn workspace @trezor/suite-desktop-core test:e2e:web --grep @group=wallet`
1. **To run just one test file** you can do: `yarn workspace @trezor/suite-desktop-core test:e2e general/wallet-discovery.test.ts`

1. **To check for flakiness** you can specify test/suite and how many time it should run: `yarn workspace @trezor/suite-desktop-core test:e2e:web general/wallet-discovery.test.ts --repeat-each=10`
1. **To run just one test** you can add: `-g "Basic cardano walkthrough"`

1. **To debug test** add `await window.pause();` to place where you want test to stop. Debugger window will open.
1. **To run one group** you can add: `--grep @group=wallet`

1. **To open advance debug ui** you can add: `--ui`

1. **To check for flakiness** you can specify test/suite and how many time it should run: `--repeat-each=10`

1. **To debug test** add `await window.pause();` to place where you want test to stop. Debugger window will open. This works only in `--headed` run.

1. **To enable Debug Tools in the browser** press `Ctrl+Shift+I`

Expand Down
4 changes: 3 additions & 1 deletion packages/suite-desktop-core/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';

export enum PlaywrightProjects {
Web = 'web',
Expand All @@ -13,7 +14,8 @@ const config: PlaywrightTestConfig = {
{
name: PlaywrightProjects.Web,
use: {
browserName: 'chromium',
...devices['Desktop Chrome'],
channel: 'chromium',
baseURL: process.env.BASE_URL || 'http://localhost:8000/',
},
grepInvert: /@desktopOnly/,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ export class OnboardingActions {
.then(dismissFwHashCheckButton => dismissFwHashCheckButton?.click());
}

@step()
async continueToSuiteFromBrowserWarning() {
if (await this.continueAtYourOwnRiskButton.isVisible()) {
await this.page.getByTestId('@continue-to-suite').click();
}
}

@step()
async completeOnboarding({ enableViewOnly = false } = {}) {
await this.disableFirmwareHashCheck();
Expand All @@ -116,8 +109,6 @@ export class OnboardingActions {

@step()
async disableFirmwareHashCheck() {
//TODO: Rework
await this.continueToSuiteFromBrowserWarning();
// Desktop starts with already disabled firmware hash check. Web needs to disable it.
if (!isWebProject(this.testInfo)) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { devices } from '@playwright/test';

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

test.use({ startEmulator: false, browserName: 'firefox' });
test.use({ startEmulator: false, ...devices['Desktop Firefox'], channel: 'firefox' });
test.describe('Firefox', { tag: ['@group=other', '@webOnly'] }, () => {
test('Suite does support Firefox', async ({ page, onboardingPage }) => {
await expect(onboardingPage.welcomeTitle).toBeVisible({ timeout: 20_000 });
Expand Down
4 changes: 3 additions & 1 deletion packages/suite-desktop-core/e2e/tests/browser/safari.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { devices } from '@playwright/test';

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

const safariAria = `
Expand All @@ -13,7 +15,7 @@ const safariAria = `
- paragraph: Continue at my own risk
`;

test.use({ startEmulator: false, browserName: 'webkit' });
test.use({ startEmulator: false, ...devices['Desktop Safari'], channel: 'webkit' });
test.describe('Safari', { tag: ['@group=other', '@webOnly', '@snapshot'] }, () => {
test('Suite does not support Safari', async ({ page, onboardingPage }) => {
await expect(page.locator('body')).toMatchAriaSnapshot(safariAria);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { test, expect } from '../../support/fixtures';

test.describe('Suite Guide', { tag: '@group=suite' }, () => {
test.use({ startEmulator: false });
test.beforeEach(async ({ onboardingPage }) => {
await onboardingPage.continueToSuiteFromBrowserWarning();
});
/**
* Test case:
* 1. Go to Bug section in Suite Guide
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ testCases.forEach(({ testName, userPreferences, text, textColor, bodyBackgroundC
test.describe.serial('Language and theme detection', { tag: ['@group=settings'] }, () => {
test.use(userPreferences);
test(testName, async ({ onboardingPage, analyticsPage }) => {
await onboardingPage.continueToSuiteFromBrowserWarning();
await onboardingPage.optionallyDismissFwHashCheckError();
await expect(analyticsPage.heading).toHaveText(text);
await expect(analyticsPage.heading).toHaveCSS('color', textColor);
Expand Down

0 comments on commit 5f7568f

Please sign in to comment.