import type { Page } from "@playwright/test"; export async function mockScadaApi(page: Page, devices: unknown[] = []) { await page.route("https://tjwater-api.invalid/**", async (route) => { const url = new URL(route.request().url()); if (url.pathname === "/api/v1/projects") { await route.fulfill({ contentType: "application/json", body: JSON.stringify({ items: [{ project_id: "project-1", gs_workspace: "tjwater_next", status: "active" }], total: 1, limit: 1000, offset: 0 }) }); return; } if (url.pathname === "/api/v1/scada-devices") { await route.fulfill({ contentType: "application/json", body: JSON.stringify({ items: devices, total: devices.length, limit: 1000, offset: 0 }) }); return; } await route.fulfill({ status: 404, contentType: "application/json", body: "{}" }); }); }