PluginProbe
Extendify / 3.1.0
Extendify v3.1.0
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
extendify / tests / playwright / global-setup.ts

global-setup.ts in Extendify 3.1.0, at tests/playwright/global-setup.ts

43 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import type { FullConfig } from '@playwright/test';
2
3 // wp-playground-cli opens its HTTP port before the blueprint finishes
4 // applying. Playwright's webServer.url check returns 200 from that
5 // pre-blueprint state, so tests can race past steps like installTheme +
6 // runPHP. Poll the REST root for the blogdescription sentinel that
7 // setup.php writes — last blueprint step, theme-agnostic, no auth needed.
8 const READY_MARKER = 'extendify-pw-blueprint-ready';
9 const TIMEOUT_MS = 180_000;
10 const POLL_MS = 1_000;
11
12 const isReady = async (baseURL: string) => {
13 try {
14 const res = await fetch(`${baseURL}/?rest_route=/`);
15 if (!res.ok) return false;
16 return (await res.text()).includes(READY_MARKER);
17 } catch {
18 return false;
19 }
20 };
21
22 export default async (config: FullConfig) => {
23 const baseURLs = Array.from(
24 new Set(
25 config.projects
26 .map((p) => p.use.baseURL)
27 .filter((u): u is string => Boolean(u)),
28 ),
29 );
30 await Promise.all(
31 baseURLs.map(async (baseURL) => {
32 const start = Date.now();
33 while (Date.now() - start < TIMEOUT_MS) {
34 if (await isReady(baseURL)) return;
35 await new Promise((r) => setTimeout(r, POLL_MS));
36 }
37 throw new Error(
38 `Playground at ${baseURL} did not reach ready state within ${TIMEOUT_MS / 1000}s`,
39 );
40 }),
41 );
42 };
43