feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { Map as MapLibreMap } from "maplibre-gl";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
SCADA_HIT_LAYER_ID,
|
||||
SCADA_HIT_LAYER_IDS,
|
||||
SCADA_ICON_EXPRESSION,
|
||||
SCADA_IMAGE_IDS,
|
||||
SCADA_MAP_ICON_PATHS,
|
||||
@@ -24,8 +24,8 @@ describe("SCADA map presentation", () => {
|
||||
});
|
||||
|
||||
it("keeps the hit target last in normal and fallback presentations", () => {
|
||||
expect(scadaLayers.at(-1)?.id).toBe(SCADA_HIT_LAYER_ID);
|
||||
expect(scadaFallbackLayers.at(-1)?.id).toBe(SCADA_HIT_LAYER_ID);
|
||||
expect(scadaLayers.slice(-2).map((layer) => layer.id)).toEqual(SCADA_HIT_LAYER_IDS);
|
||||
expect(scadaFallbackLayers.slice(-2).map((layer) => layer.id)).toEqual(SCADA_HIT_LAYER_IDS);
|
||||
});
|
||||
|
||||
it("renders every SCADA layer from GeoJSON without a GeoServer source-layer", () => {
|
||||
@@ -36,9 +36,9 @@ describe("SCADA map presentation", () => {
|
||||
});
|
||||
|
||||
it("keeps the icon and selected ring consistent with junction selection", () => {
|
||||
const symbolLayer = scadaLayers.find((layer) => layer.id === "scada-symbol");
|
||||
const outerLayer = scadaLayers.find((layer) => layer.id === "scada-selected-outer");
|
||||
const selectedLayer = scadaLayers.find((layer) => layer.id === "scada-selected");
|
||||
const symbolLayer = scadaLayers.find((layer) => layer.id === "scada-pressure-symbol");
|
||||
const outerLayer = scadaLayers.find((layer) => layer.id === "scada-pressure-selected-outer");
|
||||
const selectedLayer = scadaLayers.find((layer) => layer.id === "scada-pressure-selected");
|
||||
const junctionOuterLayer = waterNetworkLayers.find((layer) => layer.id === "junctions-selected-outer");
|
||||
const junctionSelectedLayer = waterNetworkLayers.find((layer) => layer.id === "junctions-selected");
|
||||
const junctionOuterPaint = junctionOuterLayer?.paint as Record<string, unknown> | undefined;
|
||||
@@ -47,7 +47,7 @@ describe("SCADA map presentation", () => {
|
||||
expect(symbolLayer).toMatchObject({
|
||||
type: "symbol",
|
||||
layout: {
|
||||
"icon-image": SCADA_ICON_EXPRESSION,
|
||||
"icon-image": SCADA_IMAGE_IDS.pressure,
|
||||
"icon-size": SUPPLY_LAYER_VISUALS.scada.iconSize
|
||||
}
|
||||
});
|
||||
@@ -68,12 +68,13 @@ describe("SCADA map presentation", () => {
|
||||
});
|
||||
|
||||
it("uses distinct colors for authoritative pressure and pipe flow types", () => {
|
||||
const fillLayer = scadaLayers.find((layer) => layer.id === "scada-fill");
|
||||
const colorExpression = JSON.stringify((fillLayer as { paint?: unknown })?.paint);
|
||||
const pressureFill = scadaLayers.find((layer) => layer.id === "scada-pressure-fill");
|
||||
const flowFill = scadaLayers.find((layer) => layer.id === "scada-flow-fill");
|
||||
|
||||
expect(colorExpression).toContain("pipe_flow");
|
||||
expect(colorExpression).toContain(MAP_STYLE_TOKENS.supply.scadaFlow);
|
||||
expect(colorExpression).toContain(MAP_STYLE_TOKENS.supply.scadaPressure);
|
||||
expect(JSON.stringify((pressureFill as { paint?: unknown })?.paint)).toContain(MAP_STYLE_TOKENS.supply.scadaPressure);
|
||||
expect(JSON.stringify((flowFill as { paint?: unknown })?.paint)).toContain(MAP_STYLE_TOKENS.supply.scadaFlow);
|
||||
expect(JSON.stringify(pressureFill && "filter" in pressureFill ? pressureFill.filter : undefined)).toContain("pressure");
|
||||
expect(JSON.stringify(flowFill && "filter" in flowFill ? flowFill.filter : undefined)).toContain("pipe_flow");
|
||||
});
|
||||
|
||||
it("uses MapLibre-compatible PNG assets", () => {
|
||||
@@ -112,9 +113,9 @@ describe("SCADA map presentation", () => {
|
||||
failedImageIds: Object.values(SCADA_IMAGE_IDS)
|
||||
});
|
||||
expect(scadaFallbackLayers.map((layer) => layer.id).slice(0, 3)).toEqual([
|
||||
"scada-casing",
|
||||
"scada-fill",
|
||||
"scada-fallback"
|
||||
"scada-pressure-casing",
|
||||
"scada-pressure-fill",
|
||||
"scada-pressure-fallback"
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user