Skip to content

Commit e85ab92

Browse files
committed
Add feature index overlay tests
1 parent ea0ade1 commit e85ab92

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<title>Feature Index Overlay</title>
6+
<meta charset="UTF-8">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<script type="module" src="mapml-viewer.js"></script>
9+
</head>
10+
11+
<body>
12+
<mapml-viewer style="width: 500px;height: 500px;" is="web-map" projection="CBMTILE" zoom="2" lat="45.5052040"
13+
lon="-75.2202344" controls>
14+
<layer- id="vector" label="vector states" src="data/us_pop_density.mapml" checked></layer->
15+
</mapml-viewer>
16+
</body>
17+
18+
</html>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
describe("Announce movement test", ()=> {
2+
beforeAll(async () => {
3+
await page.goto(PATH + "featureIndexOverlay.html");
4+
});
5+
6+
afterAll(async function () {
7+
await context.close();
8+
});
9+
10+
test("Feature index overlay and reticle shows on focus", async () => {
11+
const hiddenOverlay = await page.$eval(
12+
"div > output.mapml-feature-index",
13+
(output) => output.hasAttribute("hidden")
14+
);
15+
const hiddenReticle = await page.$eval(
16+
"div > div.mapml-feature-index-box",
17+
(div) => div.hasAttribute("hidden")
18+
);
19+
20+
await page.keyboard.press("Tab");
21+
await page.waitForTimeout(500);
22+
const afterTabOverlay = await page.$eval(
23+
"div > output.mapml-feature-index",
24+
(output) => output.hasAttribute("hidden")
25+
);
26+
const afterTabReticle = await page.$eval(
27+
"div > div.mapml-feature-index-box",
28+
(div) => div.hasAttribute("hidden")
29+
);
30+
31+
await expect(hiddenOverlay).toEqual(true);
32+
await expect(hiddenReticle).toEqual(true);
33+
await expect(afterTabOverlay).toEqual(false);
34+
await expect(afterTabReticle).toEqual(false);
35+
});
36+
37+
test("Feature index content is correct", async () => {
38+
const spanCount = await page.$eval(
39+
"div > output.mapml-feature-index > span",
40+
(span) => span.childElementCount
41+
);
42+
const firstFeature = await page.$eval(
43+
"div > output.mapml-feature-index > span > span:nth-child(1)",
44+
(span) => span.innerText
45+
);
46+
const lastSpan = await page.$eval(
47+
"div > output.mapml-feature-index > span > span:nth-child(8)",
48+
(span) => span.innerText
49+
);
50+
51+
await expect(spanCount).toEqual(8);
52+
await expect(firstFeature).toEqual("1 Vermont");
53+
await expect(lastSpan).toEqual("9 More results");
54+
});
55+
56+
test("Feature index more results are correct", async () => {
57+
await page.keyboard.press("9");
58+
await page.waitForTimeout(500);
59+
60+
const spanCount = await page.$eval(
61+
"div > output.mapml-feature-index > span",
62+
(span) => span.childElementCount
63+
);
64+
const firstFeature = await page.$eval(
65+
"div > output.mapml-feature-index > span > span:nth-child(1)",
66+
(span) => span.innerText
67+
);
68+
const lastSpan = await page.$eval(
69+
"div > output.mapml-feature-index > span > span:nth-child(3)",
70+
(span) => span.innerText
71+
);
72+
73+
await expect(spanCount).toEqual(3);
74+
await expect(firstFeature).toEqual("1 Pennsylvania");
75+
await expect(lastSpan).toEqual("8 Previous results");
76+
});
77+
78+
test("Feature index previous results are correct", async () => {
79+
await page.keyboard.press("8");
80+
const spanCount = await page.$eval(
81+
"div > output.mapml-feature-index > span",
82+
(span) => span.childElementCount
83+
);
84+
85+
await expect(spanCount).toEqual(8);
86+
});
87+
88+
});

0 commit comments

Comments
 (0)