Skip to content

Commit 40bfbef

Browse files
committed
added cypress e2e test (using cypress-image-diff)
1 parent d6cde2f commit 40bfbef

File tree

11 files changed

+1768
-100
lines changed

11 files changed

+1768
-100
lines changed
98 Bytes
Loading

cypress.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { defineConfig } from "cypress";
22
import { createRequire } from "module";
3+
import getCompareSnapshotsPlugin from 'cypress-image-diff-js/plugin';
34
const require = createRequire(import.meta.url);
45

56
export default defineConfig({
@@ -12,7 +13,7 @@ export default defineConfig({
1213
setupNodeEvents(on, config) {
1314
// implement node event listeners here
1415
require("@cypress/code-coverage/task")(on, config);
15-
return config;
16+
return getCompareSnapshotsPlugin(on, config);
1617
},
1718
baseUrl: "http://localhost:8888",
1819
retries: {

cypress/e2e/local-file.cy.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { MaputnikDriver } from "./maputnik-driver";
2+
3+
describe("local file", () => {
4+
const { when, get } = new MaputnikDriver();
5+
6+
beforeEach(() => {
7+
when.setStyle("");
8+
});
9+
10+
describe("PMTiles", () => {
11+
it("loads local file for tile inspect", () => {
12+
const sourceId = "source";
13+
const fileName = "polygon-z0.pmtiles" // a small polygon located at Null Island
14+
const baseUrl = "http://localhost:8888/";
15+
const zoomTarget = "#14/0.5/0.5";
16+
17+
when.visit(`${baseUrl}${zoomTarget}`);
18+
19+
get
20+
.bySelector("file", "type")
21+
.selectFile(`cypress/fixtures/${fileName}`, { force: true });
22+
23+
when.click("nav:sources");
24+
when.setValue("modal:sources.add.source_id", sourceId);
25+
when.select("modal:sources.add.source_type", "tile_vector");
26+
get.elementByTestId("modal:sources.add.tile_url").find('.maputnik-string')
27+
.clear()
28+
.type(`pmtiles://${fileName}/{z}/{x}/{y}`, { parseSpecialCharSequences: false });
29+
when.select("modal:sources.add.scheme_type", "xyz");
30+
when.setValue("modal:sources.add.maxzoom", "0");
31+
when.click("modal:sources.add.add_source");
32+
when.click("modal:sources.close-modal");
33+
when.wait(200);
34+
35+
when.select("maputnik-select", "inspect");
36+
37+
get.element(".maplibregl-map").trigger("mouseover", { force: true, waitForAnimations: true }).wait(2000)
38+
// @ts-ignore
39+
.compareSnapshot({
40+
name: 'local-pmtiles-inspect',
41+
cypressScreenshotOptions: {
42+
clip: { x: 100, y: 100, width: 10, height: 10 }
43+
}
44+
});
45+
});
46+
});
47+
});
468 Bytes
Binary file not shown.

cypress/support/e2e.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ import "@cypress/code-coverage/support";
1818
import "cypress-plugin-tab";
1919
import "./commands";
2020

21+
import compareSnapshotCommand from 'cypress-image-diff-js/command';
22+
compareSnapshotCommand();
23+
2124
// Alternatively you can use CommonJS syntax:
2225
// require('./commands')

0 commit comments

Comments
 (0)