Skip to content

Commit

Permalink
simpler playwright test definitions for special pages (#996)
Browse files Browse the repository at this point in the history
* simpler playwright test definitions for special pages

* some docs

* linting

---------

Co-authored-by: Shane Osbourne <sosbourne@duckduckgo.com>
  • Loading branch information
shakyShane and Shane Osbourne authored Jul 11, 2024
1 parent 081971c commit 41874eb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 33 deletions.
4 changes: 2 additions & 2 deletions packages/special-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"build": "node index.mjs",
"build.dev": "node index.mjs --env development",
"test": "npm run test.unit && playwright test",
"test.windows": "npm run test -- --project duckplayer-windows",
"test.apple": "npm run test -- --project duckplayer-apple",
"test.windows": "npm run test -- --project windows",
"test.macos": "npm run test -- --project macos",
"test.headed": "npm run test -- --headed",
"test.ui": "npm run test -- --ui",
"test.unit": "node --test unit-test/* ",
Expand Down
43 changes: 12 additions & 31 deletions packages/special-pages/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,25 @@ import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
projects: [
{
name: 'duckplayer-windows',
testMatch: 'duckplayer.spec.js',
name: 'windows',
testMatch: [
'duckplayer.spec.js',
'onboarding.spec.js'
],
use: {
...devices['Desktop Edge'],
injectName: 'windows',
platform: 'windows'
}
},
{
name: 'duckplayer-apple',
testMatch: 'duckplayer.spec.js',
use: {
...devices['Desktop Safari'],
injectName: 'apple',
platform: 'macos'
}
},
{
name: 'sslerrorpage-apple',
testMatch: 'sslerror.spec.js',
use: {
...devices['Desktop Safari'],
injectName: 'apple',
platform: 'macos'
}
},
{
name: 'onboarding-windows',
testMatch: 'onboarding.spec.js',
use: {
...devices['Desktop Edge'],
injectName: 'windows',
platform: 'windows'
}
},
{
name: 'onboarding-apple',
testMatch: 'onboarding.spec.js',
name: 'macos',
testMatch: [
'duckplayer.spec.js',
'onboarding.spec.js',
'sslerror.spec.js'

],
use: {
...devices['Desktop Safari'],
injectName: 'apple',
Expand Down
38 changes: 38 additions & 0 deletions packages/special-pages/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,41 @@ Would translate into the following build output
- `build/windows/pages/duckplayer`

This allows each respective platform to configure their integrations to use the known page.

## Running Tests

To run tests, use the script command `npm run test`. The process is as follows:

```mermaid
graph TD
A[npm run test] --> B[Run 'pretest' script]
B --> C[Execute `npm run build.dev` to build all pages]
C --> E[Run test.unit]
E --> F[Execute unit tests in unit-test/*]
F --> G[Run playwright test]
G --> H[Execute Playwright tests]
%% Adding conditional branches for project-specific tests
G --> I[Check if project is Windows]
G --> J[Check if project is Apple]
I --> K[Execute npm run test.windows]
J --> L[Execute npm run test.apple]
%% Continue with normal flow after conditional branches
K --> H
L --> H
%% Adding branches for additional test scripts
G --> M[Check if --headed flag]
M --> N[Execute npm run test.headed]
N --> H
G --> O[Check if --ui flag]
O --> P[Execute npm run test.ui]
P --> H
```

## Running tests for a single platform

You can run `npm run test.windows` or `npm run test.macos` to run only tests for a single platform. Consult the file `playwright.config.js` to see what's available.

0 comments on commit 41874eb

Please sign in to comment.