22 * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
5+ /* eslint-disable jsdoc/require-jsdoc */
56
67import type { ReporterDescription } from '@playwright/test'
78
89import { defineConfig , devices } from '@playwright/test'
910
11+ const COMPARISON_E2E = process . env . TEXT_COMPARISON_E2E === '1'
12+ const COMPARISON_TESTS = / p l a y w r i g h t \/ c o m p a r i s o n \/ .* \. s p e c \. t s /
13+ const COMPARISON_BASE_URL = process . env . TEXT_COMPARISON_BASE_URL || process . env . baseURL || 'http://localhost:8089/index.php/'
14+ const EXTERNAL_COMPARISON_SERVER = Boolean ( process . env . TEXT_COMPARISON_BASE_URL || process . env . baseURL )
15+
16+ function comparisonProjects ( ) {
17+ if ( ! COMPARISON_E2E ) {
18+ return [ ]
19+ }
20+ return [ {
21+ name : 'comparison-chromium' ,
22+ testMatch : COMPARISON_TESTS ,
23+ grepInvert : / @ m e m o r y / ,
24+ use : {
25+ ...devices [ 'Desktop Chrome' ] ,
26+ baseURL : COMPARISON_BASE_URL ,
27+ ignoreHTTPSErrors : true ,
28+ screenshot : 'only-on-failure' as const ,
29+ trace : 'retain-on-failure' as const ,
30+ } ,
31+ } , {
32+ name : 'comparison-webkit' ,
33+ testMatch : COMPARISON_TESTS ,
34+ grepInvert : / @ m e m o r y / ,
35+ use : {
36+ ...devices [ 'Desktop Safari' ] ,
37+ baseURL : COMPARISON_BASE_URL ,
38+ ignoreHTTPSErrors : true ,
39+ screenshot : 'only-on-failure' as const ,
40+ trace : 'retain-on-failure' as const ,
41+ } ,
42+ } , {
43+ name : 'comparison-chromium-memory' ,
44+ testMatch : COMPARISON_TESTS ,
45+ grep : / @ m e m o r y / ,
46+ use : {
47+ ...devices [ 'Desktop Chrome' ] ,
48+ baseURL : COMPARISON_BASE_URL ,
49+ ignoreHTTPSErrors : true ,
50+ screenshot : 'only-on-failure' as const ,
51+ trace : 'retain-on-failure' as const ,
52+ } ,
53+ } ]
54+ }
55+
1056/**
1157 * Used locally - i.e. if `CI` is not set as an environment variable.
1258 */
@@ -24,55 +70,62 @@ const CI_CONFIG = {
2470 // blob (so we can merge reports and download them for inspection),
2571 // dot (so we have a quick overview in the logs while the tests are running)
2672 // github (to have annotations in the PR)
27- reporter : [ [ 'blob' ] , [ 'line' ] , [ 'github' ] ] as ReporterDescription [ ] ,
73+ reporter : [
74+ [ 'blob' ] ,
75+ [ 'json' , { outputFile : 'test-results/results.json' } ] ,
76+ [ 'line' ] ,
77+ [ 'github' ] ,
78+ ] as ReporterDescription [ ] ,
2879 retries : 1 ,
2980 timeout : 45_000 ,
3081 // we shard to speed up the tests so no parallelism in workers
3182 workers : 1 ,
3283} as const
3384
85+ function comparisonWebServer ( ) {
86+ if ( EXTERNAL_COMPARISON_SERVER ) {
87+ return undefined
88+ }
89+ return {
90+ command : 'npm run start:nextcloud' ,
91+ gracefulShutdown : {
92+ signal : 'SIGTERM' as const ,
93+ timeout : 10000 ,
94+ } ,
95+ reuseExistingServer : false ,
96+ stderr : 'pipe' as const ,
97+ stdout : 'pipe' as const ,
98+ timeout : 5 * 60 * 1000 ,
99+ wait : {
100+ stdout : / N e x t c l o u d i s n o w r e a d y t o u s e / ,
101+ } ,
102+ }
103+ }
104+
34105/**
35106 * See https://playwright.dev/docs/test-configuration.
36107 */
37108export default defineConfig ( {
38109 testDir : './playwright' ,
39110 ...( process . env . CI ? CI_CONFIG : LOCAL_CONFIG ) ,
111+ workers : COMPARISON_E2E ? 1 : undefined ,
40112 use : {
41113 // Base URL to use in actions like `await page.goto('./')`.
42- baseURL : process . env . baseURL ?? 'http://localhost:8089/index.php/' ,
114+ baseURL : COMPARISON_BASE_URL ,
43115 // record traces but only keep them when the test fails
44116 trace : 'on-first-retry' ,
45117 } ,
46118
47119 projects : [
48120 {
49121 name : 'chromium' ,
122+ testIgnore : COMPARISON_TESTS ,
50123 use : {
51124 ...devices [ 'Desktop Chrome' ] ,
52125 } ,
53126 } ,
127+ ...comparisonProjects ( ) ,
54128 ] ,
55129
56- webServer : {
57- // Don't set `url` as it would take precedence over `wait.stdout` and tests start too early
58- // url: 'http://127.0.0.1:8089',
59- // Starts the Nextcloud docker container
60- command : 'npm run start:nextcloud' ,
61- // we use sigterm to notify the script to stop the container
62- // if it does not respond, we force kill it after 10 seconds
63- gracefulShutdown : {
64- signal : 'SIGTERM' ,
65- timeout : 10000 ,
66- } ,
67- // `start-nextcloud-server.mjs` only starts the server if not reachable yet.
68- reuseExistingServer : false ,
69- stderr : 'pipe' ,
70- stdout : 'pipe' ,
71- // max. 5 minutes for creating the container
72- timeout : 5 * 60 * 1000 ,
73- wait : {
74- // we wait for this line to appear in the output of the webserver until consider it done
75- stdout : / N e x t c l o u d i s n o w r e a d y t o u s e / ,
76- } ,
77- } ,
130+ webServer : comparisonWebServer ( ) ,
78131} )
0 commit comments