fix: align drainage frontend configuration

This commit is contained in:
2026-07-22 15:01:35 +08:00
parent 72850761ce
commit 0995172828
45 changed files with 853 additions and 339 deletions
+15 -6
View File
@@ -4,7 +4,8 @@ test("frontend actions replace SCADA analysis results and remain legible at 375p
page
}) => {
const receipts: Array<Record<string, unknown>> = [];
await mockAgentActions(page, receipts);
const wfsRequests: string[] = [];
await mockAgentActions(page, receipts, wfsRequests);
await page.goto("/", { waitUntil: "domcontentloaded" });
await page.waitForFunction(() =>
Boolean(window.__waterNetworkMap?.getSource("agent-scada-analysis"))
@@ -105,6 +106,7 @@ test("frontend actions replace SCADA analysis results and remain legible at 375p
})
])
);
expect(wfsRequests).toEqual(expect.arrayContaining(["MP01", "MP02"]));
await page.setViewportSize({ width: 375, height: 812 });
await page.evaluate(() => window.__waterNetworkMap?.resize());
@@ -158,12 +160,19 @@ test("frontend actions replace SCADA analysis results and remain legible at 375p
await expect.poll(() => receipts.length).toBe(4);
});
async function mockAgentActions(page: Page, receipts: Array<Record<string, unknown>>) {
async function mockAgentActions(
page: Page,
receipts: Array<Record<string, unknown>>,
wfsRequests: string[]
) {
let streamRequestCount = 0;
await page.route("**/api/map-features", async (route) => {
const body = route.request().postDataJSON() as { featureIds?: string[] };
const sensorId = body.featureIds?.[0] ?? "";
await page.route(/\/wenzhou\/ows\?/, async (route) => {
const url = new URL(route.request().url());
expect(route.request().method()).toBe("GET");
expect(url.searchParams.get("typeNames")).toBe("wenzhou:geo_scadas_mat");
const sensorId = url.searchParams.get("cql_filter")?.match(/'([^']+)'/)?.[1] ?? "";
wfsRequests.push(sensorId);
if (sensorId === "MP01") await new Promise((resolve) => setTimeout(resolve, 150));
await route.fulfill({
json: {
@@ -179,7 +188,7 @@ async function mockAgentActions(page: Page, receipts: Array<Record<string, unkno
}
]
}
});
}).catch(() => undefined);
});
await page.route("**/api/v1/agent/chat/**", async (route) => {