feat(map): manage agent overlays in layer panel
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { investigationFixture, mockInvestigationPresentation, selectInvestigation } from "./support/mock-investigation-presentation";
|
||||
|
||||
test("lists Agent overlays in the layer panel and synchronizes visibility and cleanup", async ({ page }, testInfo) => {
|
||||
test.setTimeout(60_000);
|
||||
const task = investigationFixture(1, "覆盖面图层核验");
|
||||
const mock = await mockInvestigationPresentation(page, [task]);
|
||||
await page.emulateMedia({ reducedMotion: "reduce" });
|
||||
await selectInvestigation(page, task.title);
|
||||
await expect.poll(() => page.evaluate(() => Boolean(window.__waterNetworkMap?.getLayer("simulation-backend-analysis-fill")))).toBe(true);
|
||||
expect(await page.evaluate(() => Boolean(window.__waterNetworkMap?.getSource("simulation-impact-area")))).toBe(false);
|
||||
const layerTool = page.getByRole("button", { name: /图层:管理地图图层/ });
|
||||
await layerTool.click();
|
||||
const panel = page.getByRole("region", { name: "图层", exact: true });
|
||||
await expect(panel.getByText("模拟结果", { exact: true })).toHaveCount(0);
|
||||
await expect(panel.getByText("分析覆盖", { exact: true })).toHaveCount(0);
|
||||
|
||||
const command = { action: "set_overlay", overlay_id: "affected-area", title: "爆管影响范围", mode: "geometry", evidence_id: "test:area", data: {
|
||||
type: "FeatureCollection", features: [{ type: "Feature", properties: {}, geometry: {
|
||||
type: "Polygon", coordinates: [[[121.48, 31.1], [121.49, 31.1], [121.49, 31.11], [121.48, 31.1]]]
|
||||
} }]
|
||||
} };
|
||||
await mock.emit(task, command);
|
||||
const row = panel.getByRole("button", { name: /^爆管影响范围,/ });
|
||||
await expect(row).toBeVisible();
|
||||
await expect(row).toHaveAttribute("aria-pressed", "true");
|
||||
const visibility = () => page.evaluate(() => window.__waterNetworkMap?.getLayoutProperty("investigation-presentation-overlay-fill", "visibility"));
|
||||
await expect.poll(visibility).toBe("visible");
|
||||
await row.click();
|
||||
await expect(row).toHaveAttribute("aria-pressed", "false");
|
||||
await expect.poll(visibility).toBe("none");
|
||||
await layerTool.click();
|
||||
const display = page.getByLabel("调查实时展示", { exact: true });
|
||||
await display.getByRole("button", { name: "显示覆盖层", exact: true }).click();
|
||||
await expect.poll(visibility).toBe("visible");
|
||||
await layerTool.click();
|
||||
await expect(row).toHaveAttribute("aria-pressed", "true");
|
||||
await page.screenshot({ path: testInfo.outputPath("agent-overlay-layer-desktop.png"), animations: "disabled" });
|
||||
|
||||
await page.setViewportSize({ width: 390, height: 844 });
|
||||
await row.scrollIntoViewIfNeeded();
|
||||
await expect(row).toBeVisible();
|
||||
await row.click();
|
||||
await expect.poll(visibility).toBe("none");
|
||||
await row.click();
|
||||
await expect.poll(visibility).toBe("visible");
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390);
|
||||
await page.screenshot({ path: testInfo.outputPath("agent-overlay-layer-mobile.png"), animations: "disabled" });
|
||||
|
||||
await mock.emit(task, { action: "clear_overlay", overlay_id: "affected-area" });
|
||||
await expect(row).toHaveCount(0);
|
||||
await expect(panel.getByText("分析覆盖", { exact: true })).toHaveCount(0);
|
||||
expect(mock.mutations).toEqual([]);
|
||||
});
|
||||
@@ -103,7 +103,7 @@ test("shows data-dependent layer controls only when GeoServer reports features",
|
||||
const layerIds = globalThis.__waterNetworkMap?.getStyle().layers.map((layer) => layer.id) ?? [];
|
||||
return {
|
||||
valveLabel: layerIds.indexOf("workbench-value-label-valves"),
|
||||
simulationLabel: layerIds.indexOf("simulation-burst-label")
|
||||
simulationLabel: layerIds.indexOf("simulation-backend-analysis-label")
|
||||
};
|
||||
})).toMatchObject({
|
||||
valveLabel: expect.any(Number),
|
||||
@@ -113,7 +113,7 @@ test("shows data-dependent layer controls only when GeoServer reports features",
|
||||
const layerIds = globalThis.__waterNetworkMap?.getStyle().layers.map((layer) => layer.id) ?? [];
|
||||
return [
|
||||
layerIds.indexOf("workbench-value-label-valves"),
|
||||
layerIds.indexOf("simulation-burst-label")
|
||||
layerIds.indexOf("simulation-backend-analysis-label")
|
||||
];
|
||||
});
|
||||
expect(layerOrder[0]).toBeGreaterThanOrEqual(0);
|
||||
|
||||
@@ -377,9 +377,8 @@ test("keeps a non-spatial backend result in the analysis workspace without demo
|
||||
await expect.poll(() => page.evaluate(() => ({
|
||||
backend: window.__waterNetworkMap
|
||||
?.querySourceFeatures("simulation-backend-analysis").length ?? 0,
|
||||
demo: window.__waterNetworkMap
|
||||
?.querySourceFeatures("simulation-impact-area").length ?? 0
|
||||
}))).toEqual({ backend: 0, demo: 0 });
|
||||
demoSource: Boolean(window.__waterNetworkMap?.getSource("simulation-impact-area"))
|
||||
}))).toEqual({ backend: 0, demoSource: false });
|
||||
});
|
||||
|
||||
test("keeps mock conditions while using backend work orders and alerts", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user