feat: initialize TJWater WebGIS frontend

This commit is contained in:
2026-07-21 18:31:08 +08:00
commit ad5e5d3133
191 changed files with 37963 additions and 0 deletions
@@ -0,0 +1,44 @@
import { describe, expect, it, vi } from "vitest";
import {
clearMapFeatureInteractionState,
setMapFeatureInteractionState,
toMapFeatureReference
} from "./use-map-interactions";
import { INTERACTIVE_HIT_LAYER_IDS } from "../map/layers";
describe("map feature interaction state", () => {
const feature = { source: "junctions", sourceLayer: "geo_junctions_mat", id: "junction-7" } as const;
it("maps selected business features to promoted vector feature references", () => {
expect(toMapFeatureReference({ id: "junction-7", layer: "junctions" })).toEqual(feature);
expect(toMapFeatureReference(null)).toBeNull();
});
it("sets hover and selected through feature-state", () => {
const map = { setFeatureState: vi.fn(), removeFeatureState: vi.fn() };
setMapFeatureInteractionState(map, feature, { selected: true, hovered: false });
expect(map.setFeatureState).toHaveBeenCalledWith(
{ source: "junctions", sourceLayer: "geo_junctions_mat", id: "junction-7" },
{ selected: true, hovered: false }
);
});
it("clears only the requested state key", () => {
const map = { setFeatureState: vi.fn(), removeFeatureState: vi.fn() };
clearMapFeatureInteractionState(map, feature, "selected");
expect(map.removeFeatureState).toHaveBeenCalledWith(
{ source: "junctions", sourceLayer: "geo_junctions_mat", id: "junction-7" },
"selected"
);
});
it("uses transparent hit layers for pointer interactions", () => {
expect(INTERACTIVE_HIT_LAYER_IDS).toEqual([
"pipes-hit",
"junctions-hit",
"valves-hit",
"reservoirs-hit",
"scada-hit"
]);
});
});