Files
kandev/apps/web/e2e/helpers/boot-payload.ts
T
2026-07-29 22:10:19 +01:00

18 lines
625 B
TypeScript

import type { Page } from "@playwright/test";
export async function rewriteBackendHostOS(page: Page, hostOS: string): Promise<void> {
await page.route("**/*", async (route) => {
if (route.request().resourceType() !== "document") {
await route.continue();
return;
}
const response = await route.fetch();
const body = await response.text();
const rewritten = body.replace(/"hostOS":"[^"]*"/, `"hostOS":"${hostOS}"`);
if (rewritten === body) {
throw new Error("The boot document did not contain runtime.hostOS");
}
await route.fulfill({ response, body: rewritten });
});
}