uiPage

tcmts.cli.test.e2e.contributions.uiPage · #zi6t3cnb · term · runs anywhere

A page of a server, as a browser asks for it (server-rendered HTML), once it answers: the web UI starts when it's first asked for.

export async function uiPage(
  url: string,
  timeoutMs = 180_000,
): Promise<{ status: number; html: string }> {
  const until = Date.now() + timeoutMs;
  for (;;) {
    const res = await fetch(url, { headers: { accept: "text/html" }, redirect: "manual" });
    const html = await res.text();
    if (res.status !== 503 || Date.now() > until) return { status: res.status, html };
    await new Promise((r) => setTimeout(r, 1000));
  }
}

used by