| @@ -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 |
| @@ -118,17 +119,17 @@ | ||
| 118 | 119 | |
| 119 | 120 | // @wordpress/e2e-test-utils-playwright's RequestUtils HEADs process.env.WP_BASE_URL |
| 120 | 121 | // (default http://localhost:8889 — wp-env's default port) to find the REST root, |
| 121 | 122 | // regardless of each request context's configured baseURL. Pin it to the selected |
| 122 | -// project's playground port so requestUtils.login() reaches the right server. | |
| 123 | +// project's own site so requestUtils.login() reaches the right server. | |
| 123 | 124 | if (projects.length > 0 && !process.env.WP_BASE_URL) { |
| 124 | - const firstPort = new URL(projects[0].use.baseURL).port; | |
| 125 | - process.env.WP_BASE_URL = `http://127.0.0.1:${firstPort}`; | |
| 125 | + process.env.WP_BASE_URL = new URL(projects[0].use.baseURL).origin; | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | export default defineConfig({ |
| 129 | 129 | testDir: TEST_DIR, |
| 130 | - 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', | |
| 131 | 132 | forbidOnly: !!process.env.CI, |
| 132 | 133 | retries: process.env.CI ? 1 : 0, |
| 133 | 134 | workers: 1, |
| 134 | 135 | // 30s default is too tight for this wp-playground suite on cold CI — the |