Skip to content

Commit 00f7785

Browse files
committed
tests(e2e): provide tests for controls
1 parent e1c9ecf commit 00f7785

22 files changed

+235
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ components/*.d.ts
3333
/test-results/
3434
/playwright-report/
3535
/playwright/.cache/
36+
tests/downloads

tests/MapPage.ts

+4
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ export class MapPage {
3939
timeout: 3000,
4040
});
4141
}
42+
43+
async canvasBBox() {
44+
return await this.page.locator("canvas").boundingBox();
45+
}
4246
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

tests/controls.test.ts

+230
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
import { MapPage } from "./MapPage";
4+
5+
test.describe("ol-control-bar", () => {
6+
test("should render", async ({ page }) => {
7+
const map = new MapPage(page);
8+
await map.goto("/componentsguide/mapcontrols/controlbar/");
9+
await map.waitUntilReady();
10+
await map.waitUntilCanvasLoaded();
11+
await expect(page.locator(".ol-bar")).toHaveScreenshot({
12+
timeout: 3000,
13+
});
14+
});
15+
});
16+
17+
test.describe("ol-attribution-control", () => {
18+
test("should render", async ({ page }) => {
19+
const map = new MapPage(page);
20+
await map.goto("/componentsguide/mapcontrols/attribution/");
21+
await map.waitUntilReady();
22+
await map.waitUntilCanvasLoaded();
23+
await map.checkCanvasScreenshot();
24+
});
25+
});
26+
27+
test.describe("ol-context-menu-control", () => {
28+
test("should render", async ({ page }) => {
29+
const map = new MapPage(page);
30+
await map.goto("/componentsguide/mapcontrols/contextmenu/");
31+
await map.waitUntilReady();
32+
await map.waitUntilCanvasLoaded();
33+
await page.locator("canvas").click({ button: "right" });
34+
await map.page.waitForSelector(".ol-ctx-menu-container");
35+
await map.checkCanvasScreenshot();
36+
});
37+
});
38+
39+
test.describe("ol-fullscreen-control", () => {
40+
test("should render", async ({ page }) => {
41+
const map = new MapPage(page);
42+
await map.goto("/componentsguide/mapcontrols/fullscreen/");
43+
await map.waitUntilReady();
44+
await map.waitUntilCanvasLoaded();
45+
await map.checkCanvasScreenshot();
46+
});
47+
});
48+
49+
test.describe("ol-layerswitcher-control", () => {
50+
test("should render", async ({ page }) => {
51+
const map = new MapPage(page);
52+
await map.goto("/componentsguide/mapcontrols/layerswitcher/");
53+
await map.waitUntilReady();
54+
await map.waitUntilCanvasLoaded();
55+
await map.page.locator(".ol-layerswitcher").click();
56+
await map.checkCanvasScreenshot();
57+
});
58+
});
59+
60+
test.describe("ol-layerswitcherimage-control", () => {
61+
test("should render", async ({ page }) => {
62+
const map = new MapPage(page);
63+
await map.goto("/componentsguide/mapcontrols/layerswitcherimage/");
64+
await map.waitUntilReady();
65+
await map.waitUntilCanvasLoaded();
66+
await map.page.locator(".ol-layerswitcher-image").click();
67+
await map.checkCanvasScreenshot();
68+
});
69+
});
70+
71+
test.describe("ol-mouseposition-control", () => {
72+
test("should render", async ({ page }) => {
73+
const map = new MapPage(page);
74+
await map.goto("/componentsguide/mapcontrols/mouseposition/");
75+
await map.waitUntilReady();
76+
await map.waitUntilCanvasLoaded();
77+
78+
// Get the bounding box of the canvas
79+
const boundingBox = await map.canvasBBox();
80+
if (boundingBox) {
81+
const newX = boundingBox.x + 10;
82+
const newY = boundingBox.y + 20;
83+
await page.mouse.move(newX, newY);
84+
} else {
85+
console.error("Canvas element not found or not visible");
86+
}
87+
await map.checkCanvasScreenshot();
88+
});
89+
});
90+
91+
test.describe("ol-overviewmap-control", () => {
92+
test("should render", async ({ page }) => {
93+
const map = new MapPage(page);
94+
await map.goto("/componentsguide/mapcontrols/overviewmap/");
95+
await map.waitUntilReady();
96+
await map.waitUntilCanvasLoaded();
97+
await map.checkCanvasScreenshot();
98+
});
99+
});
100+
101+
test.describe("ol-printdialog-control", () => {
102+
test("should render", async ({ page }) => {
103+
const map = new MapPage(page);
104+
await map.goto("/componentsguide/mapcontrols/printdialog/");
105+
await map.waitUntilReady();
106+
await map.waitUntilCanvasLoaded();
107+
await map.checkCanvasScreenshot();
108+
});
109+
});
110+
111+
test.describe("ol-rotate-control", () => {
112+
test("should render", async ({ page }) => {
113+
const map = new MapPage(page);
114+
await map.goto("/componentsguide/mapcontrols/rotate/");
115+
await map.waitUntilReady();
116+
await map.waitUntilCanvasLoaded();
117+
await map.checkCanvasScreenshot();
118+
});
119+
});
120+
121+
test.describe("ol-search-control", () => {
122+
test("should render", async ({ page }) => {
123+
const map = new MapPage(page);
124+
await map.goto("/componentsguide/mapcontrols/search/");
125+
await map.waitUntilReady();
126+
await map.waitUntilCanvasLoaded();
127+
await map.page.locator(".ol-search button").click();
128+
await map.page.locator(".ol-search input").pressSequentially("B");
129+
await map.waitMs(100); // search is debounced
130+
await map.checkCanvasScreenshot();
131+
});
132+
});
133+
134+
test.describe("ol-scaleline-control", () => {
135+
test("should render", async ({ page }) => {
136+
const map = new MapPage(page);
137+
await map.goto("/componentsguide/mapcontrols/scaleline/");
138+
await map.waitUntilReady();
139+
await map.waitUntilCanvasLoaded();
140+
await map.checkCanvasScreenshot();
141+
});
142+
});
143+
144+
test.describe("ol-swipe-control", () => {
145+
test("should render", async ({ page }) => {
146+
const map = new MapPage(page);
147+
await map.goto("/componentsguide/mapcontrols/swipe/");
148+
await map.waitUntilReady();
149+
await map.waitUntilCanvasLoaded();
150+
await map.checkCanvasScreenshot();
151+
});
152+
});
153+
154+
test.describe("ol-toggle-control", () => {
155+
test("should render", async ({ page }) => {
156+
const map = new MapPage(page);
157+
await map.goto("/componentsguide/mapcontrols/toggle/");
158+
await map.waitUntilReady();
159+
await map.waitUntilCanvasLoaded();
160+
await map.checkCanvasScreenshot();
161+
});
162+
});
163+
164+
test.describe("ol-videorecorder-control", () => {
165+
test("should render", async ({ page }) => {
166+
const map = new MapPage(page);
167+
await map.goto("/componentsguide/mapcontrols/videorecorder/");
168+
await map.waitUntilReady();
169+
await map.waitUntilCanvasLoaded();
170+
await map.checkCanvasScreenshot();
171+
});
172+
173+
test("should record and download", async ({ page }) => {
174+
const map = new MapPage(page);
175+
await map.goto("/componentsguide/mapcontrols/videorecorder/");
176+
await map.waitUntilReady();
177+
await map.waitUntilCanvasLoaded();
178+
const downloadPromise = page.waitForEvent("download");
179+
await map.page.getByTitle("start video").click();
180+
await map.waitMs(100);
181+
await map.page.getByTitle("pause").click();
182+
await map.waitMs(100);
183+
await map.page.getByTitle("resume").click();
184+
await map.waitMs(100);
185+
await map.page.getByTitle("stop").click();
186+
const download = await downloadPromise;
187+
await download.saveAs("tests/downloads/" + download.suggestedFilename());
188+
});
189+
});
190+
191+
test.describe("ol-zone-control", () => {
192+
test("should render", async ({ page }) => {
193+
const map = new MapPage(page);
194+
await map.goto("/componentsguide/mapcontrols/zone/");
195+
await map.waitUntilReady();
196+
await map.waitUntilCanvasLoaded();
197+
await map.page.locator(".ol-control.ol-mapzone").nth(1).click();
198+
await map.checkCanvasScreenshot();
199+
});
200+
});
201+
202+
test.describe("ol-zoom-control", () => {
203+
test("should render", async ({ page }) => {
204+
const map = new MapPage(page);
205+
await map.goto("/componentsguide/mapcontrols/zoom/");
206+
await map.waitUntilReady();
207+
await map.waitUntilCanvasLoaded();
208+
await map.checkCanvasScreenshot();
209+
});
210+
});
211+
212+
test.describe("ol-zoomslider-control", () => {
213+
test("should render", async ({ page }) => {
214+
const map = new MapPage(page);
215+
await map.goto("/componentsguide/mapcontrols/zoomslider/");
216+
await map.waitUntilReady();
217+
await map.waitUntilCanvasLoaded();
218+
await map.checkCanvasScreenshot();
219+
});
220+
});
221+
222+
test.describe("ol-zoomtoextent-control", () => {
223+
test("should render", async ({ page }) => {
224+
const map = new MapPage(page);
225+
await map.goto("/componentsguide/mapcontrols/zoomtoextent/");
226+
await map.waitUntilReady();
227+
await map.waitUntilCanvasLoaded();
228+
await map.checkCanvasScreenshot();
229+
});
230+
});

0 commit comments

Comments
 (0)