Repository navigation
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
500 lines (481 loc) · 15.9 KB
/
Copy pathplaywright.config.ts
File metadata and controls
500 lines (481 loc) · 15.9 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
import { defineConfig, devices } from '@playwright/test';
import { t } from './e2e-tests/globals';
// load environment variables from .env file in the e2e-tests directory
// (copy e2e-tests/example.env). Outside CI, the .env values OVERRIDE variables set in the
// shell: `SANDBOX_URL=http://127.0.0.1:8000 npx playwright test` still runs against .env's
// SANDBOX_URL if .env sets one. Edit .env, or set CI=1 to skip it. In CI the file doesn't exist
// and is never read; the workflow passes SANDBOX_URL and the PLAYWRIGHT_* credentials as
// environment variables instead.
if (!process.env.CI) {
const env = require('dotenv').config({ path: './e2e-tests/.env' }).parsed;
process.env = {
...process.env,
...env,
};
}
// Extract domain from SANDBOX_URL
const SANDBOX_DOMAIN = process.env.SANDBOX_URL?.replace(/^https?:\/\//, '').replace(/^www\./, '')
const SANDBOX_DOMAIN_IL = process.env.SANDBOX_URL_IL?.replace(/^https?:\/\//, '').replace(/^www\./, '')
const MODULE_URLS = {
EN: {
LIBRARY: `https://www.${SANDBOX_DOMAIN}`,
VOICES: `https://voices.${SANDBOX_DOMAIN}`
},
HE: {
LIBRARY: `https://www.${SANDBOX_DOMAIN_IL}`,
VOICES: `https://chiburim.${SANDBOX_DOMAIN_IL}`
}
} as const;
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e-tests',
/* Output directory for test results */
outputDir: './e2e-tests/e2e-test-logs/test-results',
/* Log in every test account once before any worker starts and write a
* read-only storage-state file per profile. See e2e-tests/global-setup.ts. */
globalSetup: './e2e-tests/global-setup.ts',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* timeout for each test */
timeout: t(50000),
/* timeout for each expect */
expect: {
timeout: t(10000),
},
/* Retry on CI only */
retries: process.env.CI ? 2 : 2,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI
? [['github']]
: process.env.GENERATE_REPORTS
? [
['list', { printSteps: true }],
['html', { outputFolder: './e2e-tests/e2e-test-logs/html-report' }],
['junit', { outputFile: './e2e-tests/e2e-test-logs/junit-results.xml' }]
]
: [['list', { printSteps: true }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.SANDBOX_URL,
/* Make browser appear to be in the US */
locale: 'en-US',
timezoneId: 'America/New_York',
geolocation: { latitude: 40.7128, longitude: -74.0060 }, // NYC
permissions: ['geolocation'],
/* Set US-specific HTTP headers */
extraHTTPHeaders: {
'Accept-Language': 'en-US,en;q=0.9',
},
/* Take screenshot on failure */
screenshot: 'only-on-failure',
/* Video is recorded for EVERY test under retain-on-failure (Playwright can't
* know which will fail), then discarded on pass — pure overhead on the happy
* path and largely redundant with the trace viewer's DOM snapshots. Off by
* default; the trace on first retry covers debugging. */
video: 'off',
/* No artifacts on the first pass (fast, low contention); a full trace is
* captured only when a failed test is retried. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
// Newsletter signup tests — kept as standalone projects during the
// integration window. TODO: fold into the per-module matrix once the
// newsletter tests align with an existing module's scope.
//
// The login step for chrome-newsletter-logged-in: logs in a real user and saves the
// session to .auth/setup_session.json.
{
name: 'chrome-newsletter-login',
testMatch: /auth\.setup\.js/,
},
// The logged-out newsletter specs (every newsletter-signup-*.spec.js except -real).
{
name: 'chrome-newsletter-logged-out',
testDir: './e2e-tests/tests',
testMatch: /newsletter-signup-.*\.spec\.js/,
testIgnore: [/.*-real\.spec\.js/],
use: {
...devices['Desktop Chrome'],
},
},
// Library-specific tests
{
name: 'chrome-library',
testDir: './e2e-tests/library',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Voices-specific tests
{
name: 'chrome-voices',
testDir: './e2e-tests/voices',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
{
name: 'chrome-misc',
testDir: './e2e-tests/Misc',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Strapi content tests (banners/modals/sidebar ads). HAR-driven and deliberately
// Strapi-ON: these specs bypass goToPageWithLang (which suppresses Strapi) and replay
// e2e-tests/fixtures/strapi-content.har via routeFromHAR. Kept as a standalone project,
// like the chrome-newsletter-* projects, so the fixtures/clock machinery stays isolated from the
// PageManager suites. See e2e-tests/tests/strapi.fixtures.js.
{
name: 'chrome-strapi',
testDir: './e2e-tests/tests',
testMatch: /strapi-.*\.spec\.js/,
use: {
...devices['Desktop Chrome'],
// No baseURL override: inherit the global `use.baseURL` (= SANDBOX_URL verbatim), like
// chrome-newsletter-logged-out. The MODULE_URLS defined in this file always build
// `https://www.<domain>`, which is correct for a remote sandbox but breaks a local one
// (`https://www.localhost:8000` → ERR_SSL_PROTOCOL_ERROR). Recording happens against a
// local Django + Strapi, so the raw SANDBOX_URL is what this suite needs.
},
},
// Sanity = TAG-scoped, not folder-scoped. Scans the whole tree and runs
// every test tagged `@sanity`, wherever it lives — the release-gate set is
// defined by the tag, not by any folder. (The Sanity/ folder is now docs
// only; the specs live in their feature folders.) Safe to give one baseURL
// because the suite navigates to absolute MODULE_URLS, never relative paths.
{
name: 'chrome-sanity',
testDir: './e2e-tests',
grep: /@sanity/,
// Mobile @sanity tests need the mobile viewport/config — exclude them here
// so this desktop project doesn't run them at a desktop viewport (they'd
// fail). They run under the mobile-sanity project in the mobile config.
testIgnore: '**/mobile web/**',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Library Assistant (chatbot) tests — run on Library module with LA-whitelisted user
{
name: 'chrome-assistant',
testDir: './e2e-tests/assistant',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Resource Panel (ConnectionsPanel) feature-coverage tests — Library module
{
name: 'chrome-resource-panel',
testDir: './e2e-tests/full-testing-by-feature/Resource Panel',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Voices Topics feature-coverage tests — Voices module
{
name: 'chrome-voices-topics',
testDir: './e2e-tests/full-testing-by-feature/Voices Topics',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
// Library Topics feature-coverage tests — Library module
{
name: 'chrome-library-topics',
testDir: './e2e-tests/full-testing-by-feature/Library Topics',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Voices Bookmarks & History feature-coverage tests — Voices module
{
name: 'chrome-bookmarks-(saved)-and-history',
testDir: './e2e-tests/full-testing-by-feature/Voices Bookmarks (Saved) and History',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
// Search feature-coverage tests — spans Library + Voices (navigates absolute MODULE_URLS)
{
name: 'chrome-search',
testDir: './e2e-tests/full-testing-by-feature/Search',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// User Menu feature-coverage tests (profile/account/language/module switcher/logout)
{
name: 'chrome-user-menu',
testDir: './e2e-tests/full-testing-by-feature/User Menu',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Cross-Module integration tests (auth persistence + redirects across Library/Voices)
{
name: 'chrome-cross-module',
testDir: './e2e-tests/full-testing-by-feature/Cross-Module',
use: {
...devices['Desktop Chrome'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// The logged-in newsletter specs. They start with the real Django session that
// chrome-newsletter-login saves. The pattern names the newsletter files on purpose:
// a bare /-real\.spec\.js/ also matched strapi-audience-real.spec.js, which then ran
// twice (it belongs to chrome-strapi).
{
name: 'chrome-newsletter-logged-in',
testDir: './e2e-tests/tests',
testMatch: /newsletter-signup-.*-real\.spec\.js/,
use: {
...devices['Desktop Chrome'],
storageState: 'e2e-tests/.auth/setup_session.json',
},
dependencies: ['chrome-newsletter-login'],
},
// Firefox - Library-specific modularization tests
{
name: 'firefox-library',
testDir: './e2e-tests/library',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Firefox - Voices-specific modularization tests
{
name: 'firefox-voices',
testDir: './e2e-tests/voices',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
// Firefox - Misc tests
{
name: 'firefox-misc',
testDir: './e2e-tests/Misc',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-sanity',
testDir: './e2e-tests',
grep: /@sanity/,
// Mobile @sanity tests need the mobile viewport/config — exclude them here
// so this desktop project doesn't run them at a desktop viewport (they'd
// fail). They run under the mobile-sanity project in the mobile config.
testIgnore: '**/mobile web/**',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-assistant',
testDir: './e2e-tests/assistant',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-resource-panel',
testDir: './e2e-tests/full-testing-by-feature/Resource Panel',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-voices-topics',
testDir: './e2e-tests/full-testing-by-feature/Voices Topics',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
{
name: 'firefox-library-topics',
testDir: './e2e-tests/full-testing-by-feature/Library Topics',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-voices-bookmarks',
testDir: './e2e-tests/full-testing-by-feature/Voices Bookmarks (Saved) and History',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
{
name: 'firefox-search',
testDir: './e2e-tests/full-testing-by-feature/Search',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-user-menu',
testDir: './e2e-tests/full-testing-by-feature/User Menu',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'firefox-cross-module',
testDir: './e2e-tests/full-testing-by-feature/Cross-Module',
use: {
...devices['Desktop Firefox'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Safari - Library-specific modularization tests
{
name: 'safari-library',
testDir: './e2e-tests/library',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
// Safari - Voices-specific modularization tests
{
name: 'safari-voices',
testDir: './e2e-tests/voices',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
// WebKit - Misc tests
{
name: 'safari-misc',
testDir: './e2e-tests/Misc',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-sanity',
testDir: './e2e-tests',
grep: /@sanity/,
// Mobile @sanity tests need the mobile viewport/config — exclude them here
// so this desktop project doesn't run them at a desktop viewport (they'd
// fail). They run under the mobile-sanity project in the mobile config.
testIgnore: '**/mobile web/**',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-assistant',
testDir: './e2e-tests/assistant',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-resource-panel',
testDir: './e2e-tests/full-testing-by-feature/Resource Panel',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-voices-topics',
testDir: './e2e-tests/full-testing-by-feature/Voices Topics',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
{
name: 'safari-library-topics',
testDir: './e2e-tests/full-testing-by-feature/Library Topics',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-voices-bookmarks',
testDir: './e2e-tests/full-testing-by-feature/Voices Bookmarks (Saved) and History',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.VOICES,
},
},
{
name: 'safari-search',
testDir: './e2e-tests/full-testing-by-feature/Search',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-user-menu',
testDir: './e2e-tests/full-testing-by-feature/User Menu',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
{
name: 'safari-cross-module',
testDir: './e2e-tests/full-testing-by-feature/Cross-Module',
use: {
...devices['Desktop Safari'],
baseURL: MODULE_URLS.EN.LIBRARY,
},
},
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ..devices['Desktop Chrome'], channel: 'chrome' },
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});