feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -4,18 +4,14 @@ test("opening Agent and condition panels does not move the map camera", async ({
|
||||
await page.goto("/", { waitUntil: "domcontentloaded" });
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
Boolean(window.__waterNetworkMap?.getLayer("scada-hit")) &&
|
||||
Boolean(window.__waterNetworkMap?.getLayer("scada-pressure-hit")) &&
|
||||
!window.__waterNetworkMap?.isMoving()
|
||||
);
|
||||
await page.evaluate(() => {
|
||||
const map = window.__waterNetworkMap;
|
||||
document.documentElement.dataset.panelCameraMoveCount = "0";
|
||||
map?.on("movestart", () => {
|
||||
const currentCount = Number(document.documentElement.dataset.panelCameraMoveCount ?? "0");
|
||||
document.documentElement.dataset.panelCameraMoveCount = String(currentCount + 1);
|
||||
});
|
||||
});
|
||||
const initialCamera = await readCamera(page);
|
||||
|
||||
await expect(page.locator('aside[aria-label="Agent 折叠栏"]')).toBeVisible();
|
||||
await page.getByRole("button", { name: /展开 Agent 助手面板/ }).click();
|
||||
await expect(page.locator('aside[aria-label="Agent 命令面板"]')).toBeVisible();
|
||||
await page.getByRole("button", { name: "折叠 Agent 面板" }).click();
|
||||
await expect(page.locator('aside[aria-label="Agent 折叠栏"]')).toBeVisible();
|
||||
await page.getByRole("button", { name: /展开 Agent 助手面板/ }).click();
|
||||
@@ -24,9 +20,33 @@ test("opening Agent and condition panels does not move the map camera", async ({
|
||||
await page.getByRole("button", { name: "工况任务", exact: true }).click();
|
||||
const conditionPanel = page.getByRole("region", { name: "工况任务", exact: true });
|
||||
await conditionPanel.getByRole("button", { name: "展开工况任务" }).click();
|
||||
await expect(conditionPanel).toHaveCSS("width", "880px");
|
||||
await expect(conditionPanel.getByRole("button", { name: "收起工况任务" })).toBeVisible();
|
||||
await expect
|
||||
.poll(async () => (await conditionPanel.boundingBox())?.width ?? 0)
|
||||
.toBeGreaterThan(800);
|
||||
|
||||
expect(await page.evaluate(() => document.documentElement.dataset.panelCameraMoveCount)).toBe(
|
||||
"0"
|
||||
);
|
||||
await page.waitForFunction(() => !window.__waterNetworkMap?.isMoving());
|
||||
const finalCamera = await readCamera(page);
|
||||
|
||||
expect(finalCamera.longitude).toBeCloseTo(initialCamera.longitude, 10);
|
||||
expect(finalCamera.latitude).toBeCloseTo(initialCamera.latitude, 10);
|
||||
expect(finalCamera.zoom).toBeCloseTo(initialCamera.zoom, 10);
|
||||
expect(finalCamera.bearing).toBeCloseTo(initialCamera.bearing, 10);
|
||||
expect(finalCamera.pitch).toBeCloseTo(initialCamera.pitch, 10);
|
||||
});
|
||||
|
||||
async function readCamera(page: import("@playwright/test").Page) {
|
||||
return page.evaluate(() => {
|
||||
const map = window.__waterNetworkMap;
|
||||
if (!map) throw new Error("Map is not ready");
|
||||
const center = map.getCenter();
|
||||
|
||||
return {
|
||||
longitude: center.lng,
|
||||
latitude: center.lat,
|
||||
zoom: map.getZoom(),
|
||||
bearing: map.getBearing(),
|
||||
pitch: map.getPitch()
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user