Skip to content

Commit 0eac21d

Browse files
committed
Add test / test data for map-extent issue. Closes #935
1 parent 9fdfb83 commit 0eac21d

File tree

5 files changed

+175
-0
lines changed

5 files changed

+175
-0
lines changed
799 KB
Loading
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { test, expect, chromium } from '@playwright/test';
2+
3+
test.describe('map-extent checked order tests', () => {
4+
let page;
5+
let context;
6+
test.beforeAll(async function () {
7+
context = await chromium.launchPersistentContext('', { slowMo: 500 });
8+
page =
9+
context.pages().find((page) => page.url() === 'about:blank') ||
10+
(await context.newPage());
11+
await page.goto('map-extent-checked.html');
12+
});
13+
test.only('map-extent layer control order correct when cycling checked state', async () => {
14+
// Fixed #935 https://github.com/Maps4HTML/Web-Map-Custom-Element/issues/935
15+
/*
16+
Go to this map map-extent-checked.html
17+
18+
Open the layer control for the layer settings.
19+
20+
Un-check the imagery layer <map-extent>
21+
Check the imagery layer <map-extent>
22+
23+
What should happen:
24+
The imagery layer <map-extent> should draw underneath the states layer.
25+
26+
What actually happens:
27+
The imagery layer <map-extent> draws on top of the states layer.
28+
* */
29+
const layerControl = page.locator('.leaflet-top.leaflet-right');
30+
await layerControl.hover();
31+
const layerSettings = layerControl.getByTitle('Layer Settings');
32+
await layerSettings.click();
33+
const imageryExtentCheckbox = layerControl.getByRole('checkbox', {
34+
name: 'Extent One'
35+
});
36+
await imageryExtentCheckbox.click(); // turn it off
37+
await imageryExtentCheckbox.click(); // turn it on
38+
const ext1 = page.getByTestId('ext1');
39+
let imageryZIndex = await ext1.evaluate((e) => {
40+
return +e._extentLayer._container.style.zIndex;
41+
});
42+
expect(imageryZIndex).toEqual(0);
43+
const ext2 = page.getByTestId('ext2');
44+
let statesZIndex = await ext2.evaluate((e) => {
45+
return +e._extentLayer._container.style.zIndex;
46+
});
47+
expect(statesZIndex).toEqual(1);
48+
// re-order them via the layer control
49+
const imageryFieldset = layerControl.getByRole('group', {
50+
name: 'Extent One'
51+
});
52+
let controlBBox = await imageryFieldset.boundingBox();
53+
let from = {
54+
x: controlBBox.x + controlBBox.width / 2,
55+
y: controlBBox.y + controlBBox.height / 2
56+
},
57+
to = { x: from.x, y: from.y + controlBBox.height * 1.1 };
58+
59+
await page.mouse.move(from.x, from.y);
60+
await page.mouse.down();
61+
await page.mouse.move(to.x, to.y);
62+
await page.mouse.up();
63+
imageryZIndex = await ext1.evaluate((e) => {
64+
return +e._extentLayer._container.style.zIndex;
65+
});
66+
expect(imageryZIndex).toEqual(1);
67+
statesZIndex = await ext2.evaluate((e) => {
68+
return +e._extentLayer._container.style.zIndex;
69+
});
70+
expect(statesZIndex).toEqual(0);
71+
72+
await page.mouse.move(from.x, from.y);
73+
await page.mouse.down();
74+
await page.mouse.move(to.x, to.y);
75+
await page.mouse.up();
76+
await imageryExtentCheckbox.click(); // turn it off
77+
await imageryExtentCheckbox.click(); // turn it on
78+
imageryZIndex = await ext1.evaluate((e) => {
79+
return +e._extentLayer._container.style.zIndex;
80+
});
81+
expect(imageryZIndex).toEqual(0);
82+
statesZIndex = await ext2.evaluate((e) => {
83+
return +e._extentLayer._container.style.zIndex;
84+
});
85+
expect(statesZIndex).toEqual(1);
86+
// TO DO re-order them via the DOM (insertAdjacentHTML),
87+
// ensure that
88+
// a) render order/z-index is correct
89+
// b) render order is reflected in layer control order as well
90+
// see https://github.com/Maps4HTML/Web-Map-Custom-Element/issues/956
91+
});
92+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<title>North America sample imagery,USA Population</title>
6+
<meta charset='utf-8'>
7+
<script type="module" src="mapml-viewer.js"></script>
8+
<style>
9+
html, body {
10+
height: 100%;
11+
}
12+
* {
13+
margin: 0;
14+
padding: 0;
15+
}
16+
mapml-viewer:defined {
17+
max-width: 100%;
18+
width: 100%;
19+
height: 100%;
20+
border: none;
21+
vertical-align: middle
22+
}
23+
mapml-viewer:not(:defined) > * {
24+
display: none;
25+
}
26+
nlayer- {
27+
display: none;
28+
}
29+
</style>
30+
<noscript>
31+
<style>
32+
mapml-viewer:not(:defined) > :not(layer-) {
33+
display: initial;
34+
}
35+
</style>
36+
</noscript>
37+
</head>
38+
<body>
39+
<mapml-viewer projection="OSMTILE" zoom="4" lat="37.163851" lon="-95.8506355" controls controlslist="geolocation">
40+
<layer- label="North America sample imagery,USA Population" src="map-extent-checked.mapml" checked></layer->
41+
</mapml-viewer>
42+
</body>
43+
</html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<mapml- xmlns="http://www.w3.org/1999/xhtml">
2+
<map-head>
3+
<map-title>North America sample imagery,USA Population</map-title>
4+
<map-meta charset="utf-8" />
5+
</map-head>
6+
<map-body>
7+
<map-extent data-testid="ext1" units="OSMTILE" label="Extent One" checked="checked">
8+
<map-input name="z" type="zoom" min="0" max="18" />
9+
<map-input name="xmin" type="location" rel="map" position="top-left" axis="easting"
10+
units="pcrs" min="-1.4566342387044378E7" max="-6902409.554433245" />
11+
<map-input name="ymin" type="location" rel="map" position="bottom-left" axis="northing"
12+
units="pcrs" min="2356761.351015427" max="7191795.151634117" />
13+
<map-input name="xmax" type="location" rel="map" position="top-right" axis="easting"
14+
units="pcrs" min="-1.4566342387044378E7" max="-6902409.554433245" />
15+
<map-input name="ymax" type="location" rel="map" position="top-left" axis="northing"
16+
units="pcrs" min="2356761.351015427" max="7191795.151634117" />
17+
<map-input name="w" type="width" min="1" max="10000" />
18+
<map-input name="h" type="height" min="1" max="10000" />
19+
<map-link
20+
tref="Img_Sample.png?request=GetMap&amp;crs=MapML:OSMTILE&amp;service=WMS&amp;bbox={xmin},{ymin},{xmax},{ymax}&amp;layers=Img_Sample&amp;format=image/png&amp;width={w}&amp;styles=raster&amp;language=en&amp;version=1.3.0&amp;transparent=true&amp;height={h}"
21+
rel="image" />
22+
</map-extent>
23+
<map-extent data-testid="ext2" units="OSMTILE" label="Extent Two" checked="checked">
24+
<map-input name="z" type="zoom" min="0" max="18" />
25+
<map-input name="xmin" type="location" rel="map" position="top-left" axis="easting"
26+
units="pcrs" min="-1.5446983430845503E7" max="-5893028.983427708" />
27+
<map-input name="ymin" type="location" rel="map" position="bottom-left" axis="northing"
28+
units="pcrs" min="2212675.7181225144" max="7142003.512445944" />
29+
<map-input name="xmax" type="location" rel="map" position="top-right" axis="easting"
30+
units="pcrs" min="-1.5446983430845503E7" max="-5893028.983427708" />
31+
<map-input name="ymax" type="location" rel="map" position="top-left" axis="northing"
32+
units="pcrs" min="2212675.7181225144" max="7142003.512445944" />
33+
<map-input name="w" type="width" min="1" max="10000" />
34+
<map-input name="h" type="height" min="1" max="10000" />
35+
<map-link
36+
tref="states.png?request=GetMap&amp;crs=MapML:OSMTILE&amp;service=WMS&amp;bbox={xmin},{ymin},{xmax},{ymax}&amp;layers=states&amp;format=image/png&amp;width={w}&amp;styles=population&amp;language=en&amp;version=1.3.0&amp;transparent=true&amp;height={h}"
37+
rel="image" />
38+
</map-extent>
39+
</map-body>
40+
</mapml->
97.8 KB
Loading

0 commit comments

Comments
 (0)