feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -3,20 +3,31 @@ import { mockScadaApi } from "./support/mock-scada-api";
|
||||
|
||||
test("loads SCADA from the backend API and aligns map features by device_id", async ({ page }) => {
|
||||
await mockRuntimeAndMap(page, { valves: 0, reservoirs: 0, pumps: 0, tanks: 0 });
|
||||
await mockScadaApi(page, [{
|
||||
device_id: "SCADA-1",
|
||||
device_type: "pressure",
|
||||
node_id: "J-1",
|
||||
link_id: null,
|
||||
api_query_id: "query-1",
|
||||
transmission_mode: "realtime",
|
||||
transmission_frequency: "2s",
|
||||
reliability: 100,
|
||||
x: 1,
|
||||
y: 2,
|
||||
longitude: 121.5,
|
||||
latitude: 30.9
|
||||
}]);
|
||||
await mockScadaApi(
|
||||
page,
|
||||
[{
|
||||
device_id: "SCADA-1",
|
||||
device_type: "pressure",
|
||||
node_id: "J-1",
|
||||
link_id: null,
|
||||
api_query_id: "query-1",
|
||||
measurement_unit: "MPa",
|
||||
transmission_mode: "realtime",
|
||||
transmission_frequency: "2s",
|
||||
reliability: 100,
|
||||
x: 1,
|
||||
y: 2,
|
||||
longitude: 121.5,
|
||||
latitude: 30.9
|
||||
}],
|
||||
undefined,
|
||||
[{
|
||||
time: "2026-09-17T02:29:00Z",
|
||||
device_id: "SCADA-1",
|
||||
monitored_value: 0.31,
|
||||
cleaned_value: 0.3
|
||||
}]
|
||||
);
|
||||
const deviceRequestPromise = page.waitForRequest((request) =>
|
||||
request.url().includes("/api/v1/scada-devices")
|
||||
);
|
||||
@@ -30,9 +41,16 @@ test("loads SCADA from the backend API and aligns map features by device_id", as
|
||||
if (!map) return [];
|
||||
return map.querySourceFeatures("scada").map((feature) => ({
|
||||
id: String(feature.id),
|
||||
deviceId: String(feature.properties?.device_id)
|
||||
deviceId: String(feature.properties?.device_id),
|
||||
latestValue: Number(feature.properties?.latest_value),
|
||||
latestValueWithUnit: String(feature.properties?.latest_value_with_unit)
|
||||
}));
|
||||
})).toContainEqual({ id: "SCADA-1", deviceId: "SCADA-1" });
|
||||
})).toContainEqual({
|
||||
id: "SCADA-1",
|
||||
deviceId: "SCADA-1",
|
||||
latestValue: 0.31,
|
||||
latestValueWithUnit: "0.31 MPa"
|
||||
});
|
||||
|
||||
const layerTool = page.getByRole("button", { name: /图层:管理地图图层/ });
|
||||
await expect(layerTool).toBeEnabled();
|
||||
|
||||
Reference in New Issue
Block a user