-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
131 lines (126 loc) · 6.56 KB
/
Copy pathplaywright.config.ts
File metadata and controls
131 lines (126 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { defineConfig, devices } from "playwright/test";
import { stableProjectPort } from "./src/lib/local-server-utils.mjs";
import { getPlaywrightBaseUrl } from "./scripts/playwright-base-url";
process.env.PORT = process.env.PORT || String(stableProjectPort(process.cwd()));
const baseURL = getPlaywrightBaseUrl({ allowEnsure: false });
// Sandboxed CI/cloud containers often ship a preinstalled Chromium and block
// browser downloads; point this at that binary instead of the managed one.
const chromiumExecutablePath = process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH;
// Prototype /mockups journeys live in their own advisory project so a red
// mockup can never mask a production-journey regression (PT-05). The two
// Tag-level filters keep production and prototype journeys disjoint even when
// they share a spec file. Every required browser project uses the same
// production matcher and tag exclusion.
// `phone-scroll` carries an open `-<suffix>` arm: that coverage is split across
// ui-phone-scroll{,-routes,-page-owned}.spec.ts so no single file can dominate a
// `--shard` (it was 65% of shard 1 at 267s). An exact `phone-scroll` alternative
// would silently leave the siblings uncollected, so the arm is open on purpose —
// a future ui-phone-scroll-*.spec.ts runs rather than quietly not running.
// `tests/playwright-project-isolation.test.ts` asserts every such file on disk is
// matched here.
const productionSpecPattern =
/.*(?:answer-progress-ui-smoke|dsm-ui-smoke|ui-(smoke|stress|accessibility|caring-contacts-workspace|clinical-ask|dictionary|document-canvas|tools|overlap|universal-search|specifiers|formulation(?:-result-cards)?|forms-section-nav|chrome-scroll|therapy-nav-scroll|therapy-pathways|mode-nav-density|phone-motion|phone-scroll(?:-[a-z0-9-]+)?|pwa|route-coverage|style-contract|visual-artifacts|hydration))\.spec\.ts/;
const mockupSpecPattern =
/.*ui-(answer-chat-perfected-mockup|care-plan-mockup|caring-contact-mockup|document-image-status-mockup|document-top-navigation-mockup|sidebar-live-mockup|therapy-navigation-mockup|tools|tools-collapse|tools-search-mode-mockup|tools-task-directory|ward-management|ward-coordinator|ward-roles|ward-discharges)\.spec\.ts/;
const mockupTag = /@mockup/;
export default defineConfig({
testDir: "./tests",
testMatch:
/.*(?:answer-progress-ui-smoke|dsm-ui-smoke|ui-(smoke|stress|accessibility|answer-chat-perfected-mockup|care-plan-mockup|caring-contact-mockup|caring-contacts-workspace|clinical-ask|dictionary|document-canvas|document-image-status-mockup|document-top-navigation-mockup|sidebar-live-mockup|therapy-navigation-mockup|tools|tools-collapse|tools-search-mode-mockup|tools-task-directory|ward-(?:management|coordinator|roles|discharges)|overlap|universal-search|specifiers|formulation(?:-result-cards)?|forms-section-nav|chrome-scroll|therapy-nav-scroll|therapy-pathways|mode-nav-density|phone-motion|phone-scroll(?:-[a-z0-9-]+)?|pwa|route-coverage|style-contract|visual-artifacts|hydration))\.spec\.ts/,
timeout: 60_000,
retries: 0,
// Fail the run if a stray `test.only` is committed: otherwise it silently
// narrows CI to that one test (and skips the whole release matrix) while the
// required check still reports green.
forbidOnly: !!process.env.CI,
expect: {
timeout: 10_000,
},
fullyParallel: false,
workers: 1,
reporter: process.env.CI
? [
["list"],
["junit", { outputFile: "test-results/playwright-junit.xml" }],
["json", { outputFile: "test-results/playwright-results.json" }],
]
: "list",
use: {
baseURL,
trace: "retain-on-failure",
screenshot: "only-on-failure",
// Dual-mode motion validation strategy (#75JA0P):
// 1. Suite-wide baseline: set contextOptions: { reducedMotion: "reduce" } to
// disable CSS/web animations suite-wide so clicks cannot land mid-transition
// on moving targets (preventing race conditions in ui-stress/ui-smoke).
// 2. Dual-mode per-test coverage: motion-sensitive journeys (e.g. ui-phone-motion,
// ui-phone-scroll, answer-progress-ui-smoke, ui-accessibility) explicitly
// exercise both default motion (page.emulateMedia({ reducedMotion: "no-preference" }))
// and reduced motion (page.emulateMedia({ reducedMotion: "reduce" })) to guarantee
// neither default active transitions nor reduced-motion accessibility fallbacks freeze
// or blank out UI elements.
contextOptions: { reducedMotion: "reduce" },
// Phone PWA standalone mode emulation strategy (#71NT23):
// Validates the phone PWA bounded scroll shell (globals.css:3755-3793) by
// allowing phone scroll journeys to emulate `display-mode: standalone` either
// through Chromium CDP session or the forceCompiledStandalonePhoneCss fixture.
// In production builds the PWA worker (public/sw.js) registers in every test,
// claims the page, and serves every subsequent navigation — bypassing route
// interception for navigations outright, and wedging Playwright-Firefox's
// reload path under an active route (the two ui-smoke reload hangs in matrix
// run 4012). Page routes also cannot intercept requests made by a controlling
// service worker. Only ui-pwa.spec.ts is meant to exercise the worker; it opts
// back in with test.use({ serviceWorkers: "allow" }).
serviceWorkers: "block",
},
projects: [
{
name: "chromium",
testMatch: productionSpecPattern,
grepInvert: mockupTag,
use: {
...devices["Desktop Chrome"],
...(chromiumExecutablePath ? { launchOptions: { executablePath: chromiumExecutablePath } } : {}),
},
},
{
name: "chromium-mockups",
testMatch: mockupSpecPattern,
grep: mockupTag,
use: {
...devices["Desktop Chrome"],
...(chromiumExecutablePath ? { launchOptions: { executablePath: chromiumExecutablePath } } : {}),
},
},
{
name: "firefox",
testMatch: productionSpecPattern,
grepInvert: mockupTag,
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
testMatch: productionSpecPattern,
grepInvert: mockupTag,
use: { ...devices["Desktop Safari"] },
},
{
name: "mobile-webkit",
testMatch: productionSpecPattern,
grepInvert: mockupTag,
use: { ...devices["iPhone 14"] },
},
{
name: "mobile-pwa-standalone",
testMatch: productionSpecPattern,
grepInvert: mockupTag,
use: {
...devices["iPhone 14"],
viewport: { width: 390, height: 844 },
deviceScaleFactor: 3,
isMobile: true,
hasTouch: true,
},
},
],
});