-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathplaywright.config.js
More file actions
209 lines (193 loc) · 6.05 KB
/
Copy pathplaywright.config.js
File metadata and controls
209 lines (193 loc) · 6.05 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
import { defineConfig, devices } from '@playwright/test';
const CUSTOMER_EVENTS_SPEC = '**/events-test.spec.js';
const STOREFRONT_SPECS = [
CUSTOMER_EVENTS_SPEC,
];
const ADMIN_SPECS = [
'**/product-creation.spec.js',
'**/product-deletion.spec.js',
'**/product-batch.spec.js',
'**/product-category.spec.js',
'**/product-modification.spec.js',
'**/plugin-level-tests.spec.js',
'**/performance-sync.spec.js',
'**/sync-in-progress.spec.js',
'**/variable-product-depth.spec.js',
];
const commonTimeouts = {
actionTimeout: 180000,
navigationTimeout: 180000,
};
const privacySandboxOrigin = process.env.WORDPRESS_URL
? (() => {
try {
return new URL(process.env.WORDPRESS_URL).origin;
} catch {
return null;
}
})()
: null;
const privacySandboxArgs = [
'--enable-features=BrowsingTopics,InterestGroupStorage,AdInterestGroupAPI,Fledge,RunAdAuction,PrivacySandboxAdsAPIsOverride',
'--enable-blink-features=BrowsingTopics,InterestGroupStorage,AdInterestGroupAPI,RunAdAuction',
'--test-third-party-cookie-phaseout',
...(privacySandboxOrigin ? [`--unsafely-treat-insecure-origin-as-secure=${privacySandboxOrigin}`] : []),
];
const adminUse = {
...devices['Desktop Chrome'],
...commonTimeouts,
storageState: './tests/e2e/.auth/admin.json',
};
const customerUse = {
...devices['Desktop Chrome'],
...commonTimeouts,
storageState: './tests/e2e/.auth/customer.json',
};
const edgeExecutablePath = process.env.EDGE_EXECUTABLE_PATH;
const firefoxExecutablePath = process.env.FIREFOX_EXECUTABLE_PATH;
const braveExecutablePath = process.env.BRAVE_EXECUTABLE_PATH;
const operaExecutablePath = process.env.OPERA_EXECUTABLE_PATH;
const requireRealEdge = process.env.REQUIRE_REAL_EDGE === '1';
const requireRealFirefox = process.env.REQUIRE_REAL_FIREFOX === '1';
const requireRealBrave = process.env.REQUIRE_REAL_BRAVE === '1';
const requireRealOpera = process.env.REQUIRE_REAL_OPERA === '1';
if (requireRealEdge && !edgeExecutablePath) {
throw new Error('REQUIRE_REAL_EDGE=1 but EDGE_EXECUTABLE_PATH is not set. Refusing channel fallback.');
}
if (requireRealFirefox && firefoxExecutablePath) {
throw new Error('REQUIRE_REAL_FIREFOX=1 uses Playwright Firefox channel. Do not set FIREFOX_EXECUTABLE_PATH.');
}
if (requireRealBrave && !braveExecutablePath) {
throw new Error('REQUIRE_REAL_BRAVE=1 but BRAVE_EXECUTABLE_PATH is not set. Refusing Chromium fallback.');
}
if (requireRealOpera && !operaExecutablePath) {
throw new Error('REQUIRE_REAL_OPERA=1 but OPERA_EXECUTABLE_PATH is not set. Refusing Chromium fallback.');
}
export default defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : 1,
reporter: 'html',
timeout: 1000000,
globalSetup: './tests/e2e/global-setup.js',
use: {
baseURL: process.env.WORDPRESS_URL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
ignoreHTTPSErrors: true,
...commonTimeouts,
},
projects: [
// -------------------------
// Admin desktop coverage
// -------------------------
{
name: 'chromium-wp-admin',
testMatch: ADMIN_SPECS,
testIgnore: STOREFRONT_SPECS,
use: adminUse,
},
// -------------------------
// Customer/browser + mobile events coverage
// -------------------------
{
name: 'chromium-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: customerUse,
},
{
name: 'chromium-wp-customer-classic-theme',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: customerUse,
},
{
name: 'chromium-wp-customer-block-theme',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: customerUse,
},
{
name: 'chromium-privacy-sandbox-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...customerUse,
channel: 'chrome',
launchOptions: {
args: privacySandboxArgs,
},
},
},
{
name: 'edge-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...customerUse,
...(edgeExecutablePath
? { launchOptions: { executablePath: edgeExecutablePath } }
: { channel: 'msedge' }),
},
},
{
name: 'firefox-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...devices['Desktop Firefox'],
...commonTimeouts,
...(requireRealFirefox
? { channel: 'firefox' }
: (firefoxExecutablePath ? { launchOptions: { executablePath: firefoxExecutablePath } } : {})),
storageState: './tests/e2e/.auth/customer.json',
},
},
{
name: 'brave-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...customerUse,
...(requireRealBrave
? { launchOptions: { executablePath: braveExecutablePath } }
: { userAgent: `${devices['Desktop Chrome'].userAgent} Brave/1.0.0.0` }),
},
},
{
name: 'opera-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...customerUse,
...(requireRealOpera
? { launchOptions: { executablePath: operaExecutablePath } }
: { userAgent: `${devices['Desktop Chrome'].userAgent} OPR/100.0.0.0` }),
},
},
{
name: 'android-pixel-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...devices['Pixel 5'],
...commonTimeouts,
storageState: './tests/e2e/.auth/customer.json',
},
},
{
name: 'safari-ios-wp-customer',
testMatch: [CUSTOMER_EVENTS_SPEC],
use: {
...devices['iPhone 13'],
...commonTimeouts,
browserName: 'webkit',
// Real WebKit engine for Safari-like rendering/runtime behavior.
storageState: './tests/e2e/.auth/customer.json',
},
},
],
testMatch: '**/tests/e2e/**/*.spec.js',
webServer: (process.env.CI && !process.env.WORDPRESS_URL)
? {
command: 'php -S localhost:8080 -t /tmp/wordpress-e2e',
port: 8080,
reuseExistingServer: false,
}
: undefined,
});