Skip to content

Commit

Permalink
Remove BkgTopPlusOpen test layer source
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniave committed Feb 20, 2025
1 parent f327eec commit 86b4278
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 525 deletions.
12 changes: 12 additions & 0 deletions .changeset/ten-news-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@open-pioneer/basemap-switcher": patch
"@open-pioneer/map-test-utils": patch
"@open-pioneer/overview-map": patch
"@open-pioneer/map": patch
---

Removed BKGTopPlusOpen layer source. The BKGTopPlusOpen was an internal layer source only needed for tests. Please use own test sources instead.

```
```
24 changes: 0 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ <h2>Samples</h2>
<h2>Test applications</h2>
<p>These apps are primarily used for testing.</p>
<ul>
<li>
<a href="./samples/test-basemap-switcher/">Basemap switcher</a>
<br />
Test app for the basemap switcher.
</li>
<li>
<a href="./samples/test-result-list/">Result List</a>
<br />
Expand Down
82 changes: 14 additions & 68 deletions src/packages/basemap-switcher/BasemapSwitcher.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)
// SPDX-License-Identifier: Apache-2.0
import { nextTick } from "@conterra/reactivity-core";
import { BkgTopPlusOpen, SimpleLayer } from "@open-pioneer/map";
import { SimpleLayer } from "@open-pioneer/map";
import { createServiceOptions, setupMap } from "@open-pioneer/map-test-utils";
import { PackageContextProvider } from "@open-pioneer/test-utils/react";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
Expand Down Expand Up @@ -237,28 +237,9 @@ it("should update when a different basemap is activated from somewhere else", as
});

describe("should successfully select the correct basemap from basemap switcher", () => {
it("basemap with id `osm` is visible", async () => {
it("basemap with id `osm` (first in layers array) is visible", async () => {
const { mapId, registry } = await setupMap({
layers: [
{
id: "osm",
title: "OSM",
isBaseLayer: true,
visible: true,
olLayer: new TileLayer({
source: new OSM()
})
},
{
id: "topplus-open",
title: "TopPlus Open",
isBaseLayer: true,
visible: false,
olLayer: new TileLayer({
source: new BkgTopPlusOpen()
})
}
]
layers: defaultBasemapConfig
});

const map = await registry.expectMapModel(mapId);
Expand All @@ -278,7 +259,7 @@ describe("should successfully select the correct basemap from basemap switcher",
expect(activeBaseLayer?.id).toBe("osm");
});

it("basemap with id `toner` is visible", async () => {
it("basemap with id `topplus-open` (second in layers array) is visible", async () => {
const { mapId, registry } = await setupMap({
layers: [
{
Expand All @@ -295,9 +276,7 @@ describe("should successfully select the correct basemap from basemap switcher",
title: "TopPlus Open",
isBaseLayer: true,
visible: true,
olLayer: new TileLayer({
source: new BkgTopPlusOpen()
})
olLayer: new TileLayer({})
}
]
});
Expand All @@ -320,9 +299,12 @@ describe("should successfully select the correct basemap from basemap switcher",
});
});

it("should deactivate unavailable layers for selection", async () => {
it("should disable selection of unavailable layers and show a warning", async () => {
const osmSource = new OSM();
const topPlusSource = new BkgTopPlusOpen();

act(() => {
osmSource.setState("error");
});

const { mapId, registry } = await setupMap({
layers: [
Expand All @@ -336,17 +318,14 @@ it("should deactivate unavailable layers for selection", async () => {
})
},
{
id: "topplus-open",
title: "TopPlus Open",
id: "empty-tile",
title: "Empty tile",
isBaseLayer: true,
visible: true,
olLayer: new TileLayer({
source: topPlusSource
})
olLayer: new TileLayer()
}
]
});
const map = await registry.expectMapModel(mapId);

const injectedServices = createServiceOptions({ registry });
render(
Expand All @@ -358,46 +337,13 @@ it("should deactivate unavailable layers for selection", async () => {
// basemap switcher is mounted
const { switcherSelect } = await waitForBasemapSwitcher();

let activeBaseLayer = map.layers.getActiveBaseLayer();
expect(activeBaseLayer?.id).toBe("osm");

showDropdown(switcherSelect);
expect(switcherSelect).toMatchSnapshot();

act(() => {
osmSource.setState("error");
});

// switch active layer
activeBaseLayer = map.layers.getActiveBaseLayer();
expect(activeBaseLayer?.id).toBe("osm");

// option disabled, warning icon shown and selected option changed?
expect(switcherSelect).toMatchSnapshot();
});

it("should update the ui when a layer title changes", async () => {
const { mapId, registry } = await setupMap({
layers: [
{
id: "osm",
title: "OSM",
isBaseLayer: true,
visible: true,
olLayer: new TileLayer({
source: new OSM()
})
},
{
id: "topplus-open",
title: "TopPlus Open",
isBaseLayer: true,
visible: true,
olLayer: new TileLayer({
source: new BkgTopPlusOpen()
})
}
]
layers: defaultBasemapConfig
});
const map = await registry.expectMapModel(mapId);

Expand Down
Loading

0 comments on commit 86b4278

Please sign in to comment.