PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | playwright.config.ts +18 -6 3.1.3 → trunk View file →
@@ -6,8 +6,9 @@
6 6 const TEST_DIR = resolve(ROOT, 'tests/playwright');
7 7 const BASE_PORT = Number(process.env.BASE_PORT ?? 9400);
8 8 const WP_VERSION = process.env.WP_VERSION ?? 'latest';
9 9 const RUN_PROJECT = process.env.RUN_PROJECT;
10 +const PREVIEW_URL = process.env.PREVIEW_URL;
10 11
11 12 const walkSpecs = (dir: string): string[] => {
12 13 const out: string[] = [];
13 14 for (const entry of readdirSync(dir)) {
@@ -72,9 +73,9 @@
72 73 name,
73 74 testMatch: relative(ROOT, spec),
74 75 use: {
75 76 ...devices['Desktop Chrome'],
76 - baseURL: `http://127.0.0.1:${port}`,
77 + baseURL: PREVIEW_URL ?? `http://127.0.0.1:${port}`,
77 78 },
78 79 };
79 80 })
80 81 .filter((p): p is NonNullable<typeof p> => p !== null);
@@ -88,9 +89,9 @@
88 89 // and burns ports.
89 90 const activeBlueprints = new Set(
90 91 projects.map((p) => projectBlueprint.get(p.name)).filter(Boolean) as string[],
91 92 );
92 -const webServers = [...blueprintPort.entries()]
93 +const webServers = (PREVIEW_URL ? [] : [...blueprintPort.entries()])
93 94 .filter(([blueprint]) => activeBlueprints.has(blueprint))
94 95 .map(([blueprint, port]) => ({
95 96 // PHP version is pinned per-blueprint via `preferredVersions.php` — the
96 97 // CLI `--php` flag is silently ignored by wp-playground-cli. Pinned to
@@ -104,20 +105,31 @@
104 105 stdout: 'pipe' as const,
105 106 stderr: 'pipe' as const,
106 107 }));
107 108
109 +// RequestUtils caches the discovered REST root to this file and reuses it
110 +// whenever it is already populated, skipping rediscovery. The default path is
111 +// one shared file and playground ports shift between runs, so a later run can
112 +// POST to whichever server held that port before. Scope it to the process.
113 +if (!process.env.STORAGE_STATE_PATH) {
114 + process.env.STORAGE_STATE_PATH = resolve(
115 + ROOT,
116 + `artifacts/storage-states/admin-${process.pid}.json`,
117 + );
118 +}
119 +
108 120 // @wordpress/e2e-test-utils-playwright's RequestUtils HEADs process.env.WP_BASE_URL
109 121 // (default http://localhost:8889 — wp-env's default port) to find the REST root,
110 122 // regardless of each request context's configured baseURL. Pin it to the selected
111 -// project's playground port so requestUtils.login() reaches the right server.
123 +// project's own site so requestUtils.login() reaches the right server.
112 124 if (projects.length > 0 && !process.env.WP_BASE_URL) {
113 - const firstPort = new URL(projects[0].use.baseURL).port;
114 - process.env.WP_BASE_URL = `http://127.0.0.1:${firstPort}`;
125 + process.env.WP_BASE_URL = new URL(projects[0].use.baseURL).origin;
115 126 }
116 127
117 128 export default defineConfig({
118 129 testDir: TEST_DIR,
119 - globalSetup: './tests/playwright/global-setup.ts',
130 + // An `active` site has already applied its blueprint; only playground needs the poll.
131 + globalSetup: PREVIEW_URL ? undefined : './tests/playwright/global-setup.ts',
120 132 forbidOnly: !!process.env.CI,
121 133 retries: process.env.CI ? 1 : 0,
122 134 workers: 1,
123 135 // 30s default is too tight for this wp-playground suite on cold CI — the