feat(workbench): align v2 GIS and SCADA API
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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: "{}" });
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user