added cypress e2e test (using cypress-image-diff)

This commit is contained in:
prusswan
2025-01-28 23:33:36 +08:00
parent d6cde2fc0f
commit 40bfbef312
11 changed files with 1673 additions and 5 deletions

View File

@@ -0,0 +1,47 @@
import { MaputnikDriver } from "./maputnik-driver";
describe("local file", () => {
const { when, get } = new MaputnikDriver();
beforeEach(() => {
when.setStyle("");
});
describe("PMTiles", () => {
it("loads local file for tile inspect", () => {
const sourceId = "source";
const fileName = "polygon-z0.pmtiles" // a small polygon located at Null Island
const baseUrl = "http://localhost:8888/";
const zoomTarget = "#14/0.5/0.5";
when.visit(`${baseUrl}${zoomTarget}`);
get
.bySelector("file", "type")
.selectFile(`cypress/fixtures/${fileName}`, { force: true });
when.click("nav:sources");
when.setValue("modal:sources.add.source_id", sourceId);
when.select("modal:sources.add.source_type", "tile_vector");
get.elementByTestId("modal:sources.add.tile_url").find('.maputnik-string')
.clear()
.type(`pmtiles://${fileName}/{z}/{x}/{y}`, { parseSpecialCharSequences: false });
when.select("modal:sources.add.scheme_type", "xyz");
when.setValue("modal:sources.add.maxzoom", "0");
when.click("modal:sources.add.add_source");
when.click("modal:sources.close-modal");
when.wait(200);
when.select("maputnik-select", "inspect");
get.element(".maplibregl-map").trigger("mouseover", { force: true, waitForAnimations: true }).wait(2000)
// @ts-ignore
.compareSnapshot({
name: 'local-pmtiles-inspect',
cypressScreenshotOptions: {
clip: { x: 100, y: 100, width: 10, height: 10 }
}
});
});
});
});

Binary file not shown.

View File

@@ -18,5 +18,8 @@ import "@cypress/code-coverage/support";
import "cypress-plugin-tab";
import "./commands";
import compareSnapshotCommand from 'cypress-image-diff-js/command';
compareSnapshotCommand();
// Alternatively you can use CommonJS syntax:
// require('./commands')