fix: hide unavailable GeoServer layers
This commit is contained in:
@@ -21,6 +21,43 @@ describe("WorkbenchMapController", () => {
|
||||
expect(map.removeFeatureState).not.toHaveBeenCalledWith(expect.anything(), "selected");
|
||||
});
|
||||
|
||||
it("clears a stale highlight without touching a removed source", async () => {
|
||||
const map = createMap();
|
||||
const controller = createController(map, pointCollection);
|
||||
await controller.highlight({ sourceId: "junctions", featureId: "J-1" });
|
||||
map.getSource.mockReturnValue(undefined);
|
||||
|
||||
controller.clearHighlight();
|
||||
|
||||
expect(map.removeFeatureState).not.toHaveBeenCalled();
|
||||
expect(controller.getSnapshot().target).toBeNull();
|
||||
});
|
||||
|
||||
it("ignores a resolved highlight after its source has been removed", async () => {
|
||||
const map = createMap();
|
||||
map.getSource.mockReturnValue(undefined);
|
||||
const controller = createController(map, pointCollection);
|
||||
|
||||
await controller.highlight({ sourceId: "junctions", featureId: "J-1" });
|
||||
|
||||
expect(map.setFeatureState).not.toHaveBeenCalled();
|
||||
expect(controller.getSnapshot().target).toBeNull();
|
||||
expect(controller.getSnapshot().errorCode).toBe("FEATURE_NOT_FOUND");
|
||||
});
|
||||
|
||||
it("does not move to a cached feature after its source has been removed", async () => {
|
||||
const map = createMap();
|
||||
const controller = createController(map, pointCollection);
|
||||
const target = { sourceId: "junctions" as const, featureId: "J-1" };
|
||||
await controller.locateAndHighlight(target);
|
||||
map.getSource.mockReturnValue(undefined);
|
||||
|
||||
await controller.locateAndHighlight(target);
|
||||
|
||||
expect(map.easeTo).toHaveBeenCalledTimes(1);
|
||||
expect(controller.getSnapshot().errorCode).toBe("FEATURE_NOT_FOUND");
|
||||
});
|
||||
|
||||
it("fits line bounds and uses responsive workbench padding", async () => {
|
||||
const map = createMap();
|
||||
const padding = { top: 50, right: 420, bottom: 50, left: 320 };
|
||||
@@ -281,7 +318,7 @@ function createMap() {
|
||||
const images = new Set<string>();
|
||||
return {
|
||||
easeTo: vi.fn(), fitBounds: vi.fn(), setFeatureState: vi.fn(), removeFeatureState: vi.fn(),
|
||||
getSource: vi.fn(), getLayer: vi.fn(), addLayer: vi.fn(), setPaintProperty: vi.fn(),
|
||||
getSource: vi.fn((_id: string): unknown => ({})), getLayer: vi.fn(), addLayer: vi.fn(), setPaintProperty: vi.fn(),
|
||||
setLayoutProperty: vi.fn(), setFilter: vi.fn(), removeControl: vi.fn(), triggerRepaint: vi.fn(),
|
||||
hasImage: vi.fn((id: string) => images.has(id)),
|
||||
addImage: vi.fn((id: string) => {
|
||||
|
||||
Reference in New Issue
Block a user