mirror of
https://github.com/maputnik/editor.git
synced 2026-07-08 23:17:26 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| faae8d00d8 |
@@ -10,7 +10,6 @@ export default defineConfig({
|
||||
},
|
||||
|
||||
e2e: {
|
||||
specPattern: "e2e/**/*.spec.ts",
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
require("@cypress/code-coverage/task")(on, config);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
|
||||
const test = it;
|
||||
|
||||
describe("accessibility", () => {
|
||||
const { beforeAndAfter, get, when, then } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
@@ -11,7 +9,7 @@ describe("accessibility", () => {
|
||||
when.setStyle("layer");
|
||||
});
|
||||
|
||||
test("skip link to layer list", () => {
|
||||
it("skip link to layer list", () => {
|
||||
const selector = "root:skip:layer-list";
|
||||
then(get.elementByTestId(selector)).shouldExist();
|
||||
when.tab();
|
||||
@@ -20,7 +18,7 @@ describe("accessibility", () => {
|
||||
then(get.skipTargetLayerList()).shouldBeFocused();
|
||||
});
|
||||
|
||||
test("skip link to layer editor", () => {
|
||||
it("skip link to layer editor", () => {
|
||||
const selector = "root:skip:layer-editor";
|
||||
then(get.elementByTestId(selector)).shouldExist();
|
||||
then(get.elementByTestId("skip-target-layer-editor")).shouldExist();
|
||||
@@ -30,7 +28,7 @@ describe("accessibility", () => {
|
||||
then(get.skipTargetLayerEditor()).shouldBeFocused();
|
||||
});
|
||||
|
||||
test("skip link to map view", () => {
|
||||
it("skip link to map view", () => {
|
||||
const selector = "root:skip:map-view";
|
||||
then(get.elementByTestId(selector)).shouldExist();
|
||||
when.tab().tab().tab();
|
||||
@@ -1,17 +1,15 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
|
||||
const test = it;
|
||||
|
||||
describe("code editor", () => {
|
||||
const { beforeAndAfter, when, get, then } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
|
||||
test("open code editor", () => {
|
||||
it("open code editor", () => {
|
||||
when.click("nav:code-editor");
|
||||
then(get.element(".maputnik-code-editor")).shouldExist();
|
||||
});
|
||||
|
||||
test("closes code editor", () => {
|
||||
it("closes code editor", () => {
|
||||
when.click("nav:code-editor");
|
||||
then(get.element(".maputnik-code-editor")).shouldExist();
|
||||
when.click("nav:code-editor");
|
||||
@@ -1,7 +1,5 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
|
||||
const test = it;
|
||||
|
||||
describe("history", () => {
|
||||
const { beforeAndAfter, when, get, then } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
@@ -15,7 +13,7 @@ describe("history", () => {
|
||||
redoKeyCombo = isMac ? "{meta}{shift}z" : "{ctrl}y";
|
||||
});
|
||||
|
||||
test("undo/redo", () => {
|
||||
it("undo/redo", () => {
|
||||
when.setStyle("geojson");
|
||||
when.modal.open();
|
||||
|
||||
@@ -89,7 +87,7 @@ describe("history", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("should not redo after undo and value change", () => {
|
||||
it("should not redo after undo and value change", () => {
|
||||
when.setStyle("geojson");
|
||||
when.modal.open();
|
||||
when.modal.fillLayers({
|
||||
@@ -1,19 +1,17 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
|
||||
const test = it;
|
||||
|
||||
describe("i18n", () => {
|
||||
const { beforeAndAfter, get, when, then } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
|
||||
describe("language detector", () => {
|
||||
test("English", () => {
|
||||
it("English", () => {
|
||||
const url = "?lng=en";
|
||||
when.visit(url);
|
||||
then(get.elementByTestId("maputnik-lang-select")).shouldHaveValue("en");
|
||||
});
|
||||
|
||||
test("Japanese", () => {
|
||||
it("Japanese", () => {
|
||||
const url = "?lng=ja";
|
||||
when.visit(url);
|
||||
then(get.elementByTestId("maputnik-lang-select")).shouldHaveValue("ja");
|
||||
@@ -25,7 +23,7 @@ describe("i18n", () => {
|
||||
when.setStyle("layer");
|
||||
});
|
||||
|
||||
test("the language switcher switches to Japanese", () => {
|
||||
it("the language switcher switches to Japanese", () => {
|
||||
const selector = "maputnik-lang-select";
|
||||
then(get.elementByTestId(selector)).shouldExist();
|
||||
when.select(selector, "ja");
|
||||
@@ -1,5 +1,4 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
const test = it;
|
||||
|
||||
describe("keyboard", () => {
|
||||
const { beforeAndAfter, given, when, get, then } = new MaputnikDriver();
|
||||
@@ -10,7 +9,7 @@ describe("keyboard", () => {
|
||||
when.setStyle("");
|
||||
});
|
||||
|
||||
test("ESC should unfocus", () => {
|
||||
it("ESC should unfocus", () => {
|
||||
const targetSelector = "maputnik-select";
|
||||
when.focus(targetSelector);
|
||||
then(get.elementByTestId(targetSelector)).shouldBeFocused();
|
||||
@@ -18,42 +17,42 @@ describe("keyboard", () => {
|
||||
then(get.elementByTestId(targetSelector)).shouldNotBeFocused();
|
||||
});
|
||||
|
||||
test("'?' should show shortcuts modal", () => {
|
||||
it("'?' should show shortcuts modal", () => {
|
||||
when.typeKeys("?");
|
||||
then(get.elementByTestId("modal:shortcuts")).shouldBeVisible();
|
||||
});
|
||||
|
||||
test("'o' should show open modal", () => {
|
||||
it("'o' should show open modal", () => {
|
||||
when.typeKeys("o");
|
||||
then(get.elementByTestId("modal:open")).shouldBeVisible();
|
||||
});
|
||||
|
||||
test("'e' should show export modal", () => {
|
||||
it("'e' should show export modal", () => {
|
||||
when.typeKeys("e");
|
||||
then(get.elementByTestId("modal:export")).shouldBeVisible();
|
||||
});
|
||||
|
||||
test("'d' should show sources modal", () => {
|
||||
it("'d' should show sources modal", () => {
|
||||
when.typeKeys("d");
|
||||
then(get.elementByTestId("modal:sources")).shouldBeVisible();
|
||||
});
|
||||
|
||||
test("'s' should show settings modal", () => {
|
||||
it("'s' should show settings modal", () => {
|
||||
when.typeKeys("s");
|
||||
then(get.elementByTestId("modal:settings")).shouldBeVisible();
|
||||
});
|
||||
|
||||
test("'i' should change map to inspect mode", () => {
|
||||
it("'i' should change map to inspect mode", () => {
|
||||
when.typeKeys("i");
|
||||
then(get.inputValue("maputnik-select")).shouldEqual("inspect");
|
||||
});
|
||||
|
||||
test("'m' should focus map", () => {
|
||||
it("'m' should focus map", () => {
|
||||
when.typeKeys("m");
|
||||
then(get.canvas()).shouldBeFocused();
|
||||
});
|
||||
|
||||
test("'!' should show debug modal", () => {
|
||||
it("'!' should show debug modal", () => {
|
||||
when.typeKeys("!");
|
||||
then(get.elementByTestId("modal:debug")).shouldBeVisible();
|
||||
});
|
||||
@@ -1,8 +1,6 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
import { v1 as uuid } from "uuid";
|
||||
|
||||
const test = it;
|
||||
|
||||
describe("layer editor", () => {
|
||||
const { beforeAndAfter, get, when, then } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
@@ -30,8 +28,8 @@ describe("layer editor", () => {
|
||||
return id;
|
||||
}
|
||||
|
||||
test("expand/collapse");
|
||||
test("id", () => {
|
||||
it("expand/collapse");
|
||||
it("id", () => {
|
||||
const bgId = createBackground();
|
||||
|
||||
when.click("layer-list-item:background:" + bgId);
|
||||
@@ -51,7 +49,7 @@ describe("layer editor", () => {
|
||||
});
|
||||
|
||||
describe("source", () => {
|
||||
test("should show error when the source is invalid", () => {
|
||||
it("should show error when the source is invalid", () => {
|
||||
when.modal.fillLayers({
|
||||
type: "circle",
|
||||
layer: "invalid",
|
||||
@@ -70,7 +68,7 @@ describe("layer editor", () => {
|
||||
when.click("layer-editor.layer-id");
|
||||
});
|
||||
|
||||
test("should update min-zoom in local storage", () => {
|
||||
it("should update min-zoom in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -107,7 +105,7 @@ describe("layer editor", () => {
|
||||
when.click("layer-editor.layer-id");
|
||||
});
|
||||
|
||||
test("should update style in local storage", () => {
|
||||
it("should update style in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -131,7 +129,7 @@ describe("layer editor", () => {
|
||||
when.click("layer-editor.layer-id");
|
||||
});
|
||||
|
||||
test("should update style in local storage", () => {
|
||||
it("should update style in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -151,7 +149,7 @@ describe("layer editor", () => {
|
||||
when.click("min-zoom.input-text");
|
||||
});
|
||||
|
||||
test("should update style in local storage", () => {
|
||||
it("should update style in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -172,7 +170,7 @@ describe("layer editor", () => {
|
||||
when.click("spec-field:background-color");
|
||||
});
|
||||
|
||||
test("should update style in local storage", () => {
|
||||
it("should update style in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -192,11 +190,11 @@ describe("layer editor", () => {
|
||||
when.type("spec-field-input:background-opacity", "0.");
|
||||
});
|
||||
|
||||
test("should keep '.' in the input field", () => {
|
||||
it("should keep '.' in the input field", () => {
|
||||
then(get.elementByTestId("spec-field-input:background-opacity")).shouldHaveValue("0.");
|
||||
});
|
||||
|
||||
test("should revert to a valid value when focus out", () => {
|
||||
it("should revert to a valid value when focus out", () => {
|
||||
when.click("layer-list-item:background:" + bgId);
|
||||
then(get.elementByTestId("spec-field-input:background-opacity")).shouldHaveValue("0");
|
||||
});
|
||||
@@ -205,12 +203,12 @@ describe("layer editor", () => {
|
||||
|
||||
|
||||
describe("filter", () => {
|
||||
test("expand/collapse");
|
||||
test("compound filter");
|
||||
it("expand/collapse");
|
||||
it("compound filter");
|
||||
});
|
||||
|
||||
describe("layout", () => {
|
||||
test("text-font", () => {
|
||||
it("text-font", () => {
|
||||
when.setStyle("font");
|
||||
when.collapseGroupInLayerEditor();
|
||||
when.collapseGroupInLayerEditor(1);
|
||||
@@ -224,14 +222,14 @@ describe("layer editor", () => {
|
||||
});
|
||||
|
||||
describe("paint", () => {
|
||||
test("expand/collapse");
|
||||
test("color");
|
||||
test("pattern");
|
||||
test("opacity");
|
||||
it("expand/collapse");
|
||||
it("color");
|
||||
it("pattern");
|
||||
it("opacity");
|
||||
});
|
||||
|
||||
describe("json-editor", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "circle",
|
||||
layer: "example",
|
||||
@@ -256,10 +254,10 @@ describe("layer editor", () => {
|
||||
});
|
||||
|
||||
|
||||
test("expand/collapse");
|
||||
test("modify");
|
||||
it("expand/collapse");
|
||||
it("modify");
|
||||
|
||||
test("parse error", () => {
|
||||
it("parse error", () => {
|
||||
const bgId = createBackground();
|
||||
|
||||
when.click("layer-list-item:background:" + bgId);
|
||||
@@ -275,7 +273,7 @@ describe("layer editor", () => {
|
||||
});
|
||||
|
||||
describe("sticky header", () => {
|
||||
test("should keep layer header visible when scrolling properties", () => {
|
||||
it("should keep layer header visible when scrolling properties", () => {
|
||||
// Setup: Create a layer with many properties (e.g., symbol layer)
|
||||
when.modal.fillLayers({
|
||||
type: "symbol",
|
||||
@@ -1,5 +1,4 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
const test = it;
|
||||
|
||||
describe("layers list", () => {
|
||||
const { beforeAndAfter, get, when, then } = new MaputnikDriver();
|
||||
@@ -17,7 +16,7 @@ describe("layers list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("should update layers in local storage", () => {
|
||||
it("should update layers in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -32,7 +31,7 @@ describe("layers list", () => {
|
||||
beforeEach(() => {
|
||||
when.click("layer-list-item:" + id + ":delete");
|
||||
});
|
||||
test("should empty layers in local storage", () => {
|
||||
it("should empty layers in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [],
|
||||
});
|
||||
@@ -43,7 +42,7 @@ describe("layers list", () => {
|
||||
beforeEach(() => {
|
||||
when.click("layer-list-item:" + id + ":copy");
|
||||
});
|
||||
test("should add copy layer in local storage", () => {
|
||||
it("should add copy layer in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -64,7 +63,7 @@ describe("layers list", () => {
|
||||
when.click("layer-list-item:" + id + ":toggle-visibility");
|
||||
});
|
||||
|
||||
test("should update visibility to none in local storage", () => {
|
||||
it("should update visibility to none in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -83,7 +82,7 @@ describe("layers list", () => {
|
||||
when.click("layer-list-item:" + id + ":toggle-visibility");
|
||||
});
|
||||
|
||||
test("should update visibility to visible in local storage", () => {
|
||||
it("should update visibility to visible in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
layers: [
|
||||
{
|
||||
@@ -107,7 +106,7 @@ describe("layers list", () => {
|
||||
type: "background",
|
||||
});
|
||||
});
|
||||
test("should show the selected layer in the editor", () => {
|
||||
it("should show the selected layer in the editor", () => {
|
||||
when.realClick("layer-list-item:" + secondId);
|
||||
then(get.elementByTestId("layer-editor.layer-id.input")).shouldHaveValue(secondId);
|
||||
when.realClick("layer-list-item:" + id);
|
||||
@@ -118,7 +117,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("background", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "background",
|
||||
});
|
||||
@@ -136,7 +135,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("fill", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "fill",
|
||||
layer: "example",
|
||||
@@ -154,11 +153,11 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
// TODO: Change source
|
||||
test("change source");
|
||||
it("change source");
|
||||
});
|
||||
|
||||
describe("line", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "line",
|
||||
layer: "example",
|
||||
@@ -175,7 +174,7 @@ describe("layers list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("groups", () => {
|
||||
it("groups", () => {
|
||||
when.modal.open();
|
||||
const id1 = when.modal.fillLayers({
|
||||
id: "aa",
|
||||
@@ -231,7 +230,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("symbol", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "symbol",
|
||||
layer: "example",
|
||||
@@ -248,7 +247,7 @@ describe("layers list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("should show spec info when hovering and clicking single line property", () => {
|
||||
it("should show spec info when hovering and clicking single line property", () => {
|
||||
when.modal.fillLayers({
|
||||
type: "symbol",
|
||||
layer: "example",
|
||||
@@ -260,7 +259,7 @@ describe("layers list", () => {
|
||||
then(get.elementByTestId("spec-field-doc")).shouldContainText("Rotates the ");
|
||||
});
|
||||
|
||||
test("should show spec info when hovering and clicking multi line property", () => {
|
||||
it("should show spec info when hovering and clicking multi line property", () => {
|
||||
when.modal.fillLayers({
|
||||
type: "symbol",
|
||||
layer: "example",
|
||||
@@ -272,7 +271,7 @@ describe("layers list", () => {
|
||||
then(get.elementByTestId("spec-field-doc")).shouldContainText("Offset distance");
|
||||
});
|
||||
|
||||
test("should hide spec info when clicking a second time", () => {
|
||||
it("should hide spec info when clicking a second time", () => {
|
||||
when.modal.fillLayers({
|
||||
type: "symbol",
|
||||
layer: "example",
|
||||
@@ -288,7 +287,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("raster", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "raster",
|
||||
layer: "raster",
|
||||
@@ -307,7 +306,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("circle", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "circle",
|
||||
layer: "example",
|
||||
@@ -326,7 +325,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("fill extrusion", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "fill-extrusion",
|
||||
layer: "example",
|
||||
@@ -345,7 +344,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("hillshade", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "hillshade",
|
||||
layer: "example",
|
||||
@@ -362,7 +361,7 @@ describe("layers list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("set hillshade illumination direction array", () => {
|
||||
it("set hillshade illumination direction array", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "hillshade",
|
||||
layer: "example",
|
||||
@@ -388,7 +387,7 @@ describe("layers list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("set hillshade highlight color array", () => {
|
||||
it("set hillshade highlight color array", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "hillshade",
|
||||
layer: "example",
|
||||
@@ -414,7 +413,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("color-relief", () => {
|
||||
test("add", () => {
|
||||
it("add", () => {
|
||||
const id = when.modal.fillLayers({
|
||||
type: "color-relief",
|
||||
layer: "example",
|
||||
@@ -431,7 +430,7 @@ describe("layers list", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("adds elevation expression when clicking the elevation button", () => {
|
||||
it("adds elevation expression when clicking the elevation button", () => {
|
||||
when.modal.fillLayers({
|
||||
type: "color-relief",
|
||||
layer: "example",
|
||||
@@ -443,7 +442,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("groups", () => {
|
||||
test("simple", () => {
|
||||
it("simple", () => {
|
||||
when.setStyle("geojson");
|
||||
|
||||
when.modal.open();
|
||||
@@ -479,7 +478,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("drag and drop", () => {
|
||||
test("move layer should update local storage", () => {
|
||||
it("move layer should update local storage", () => {
|
||||
when.modal.open();
|
||||
const firstId = when.modal.fillLayers({
|
||||
id: "a",
|
||||
@@ -518,7 +517,7 @@ describe("layers list", () => {
|
||||
});
|
||||
|
||||
describe("sticky header", () => {
|
||||
test("should keep header visible when scrolling layer list", () => {
|
||||
it("should keep header visible when scrolling layer list", () => {
|
||||
// Setup: Create multiple layers to enable scrolling
|
||||
for (let i = 0; i < 20; i++) {
|
||||
when.modal.open();
|
||||
@@ -1,12 +1,10 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
|
||||
const test = it;
|
||||
|
||||
describe("map", () => {
|
||||
const { beforeAndAfter, get, when, then } = new MaputnikDriver();
|
||||
beforeAndAfter();
|
||||
describe("zoom level", () => {
|
||||
test("via url", () => {
|
||||
it("via url", () => {
|
||||
const zoomLevel = 12.37;
|
||||
when.setStyle("geojson", zoomLevel);
|
||||
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible();
|
||||
@@ -15,7 +13,7 @@ describe("map", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("via map controls", () => {
|
||||
it("via map controls", () => {
|
||||
const zoomLevel = 12.37;
|
||||
when.setStyle("geojson", zoomLevel);
|
||||
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible();
|
||||
@@ -25,7 +23,7 @@ describe("map", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("via style file definition", () => {
|
||||
it("via style file definition", () => {
|
||||
when.setStyle("zoom_7_center_0_51");
|
||||
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible();
|
||||
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldContainText(
|
||||
@@ -42,7 +40,7 @@ describe("map", () => {
|
||||
});
|
||||
|
||||
describe("search", () => {
|
||||
test("should exist", () => {
|
||||
it("should exist", () => {
|
||||
then(get.searchControl()).shouldBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -52,12 +50,12 @@ describe("map", () => {
|
||||
when.setStyle("rectangles");
|
||||
then(get.locationHash().should("exist"));
|
||||
});
|
||||
test("should open on feature click", () => {
|
||||
it("should open on feature click", () => {
|
||||
when.clickCenter("maplibre:map");
|
||||
then(get.elementByTestId("feature-layer-popup")).shouldBeVisible();
|
||||
});
|
||||
|
||||
test("should open a second feature after closing popup", () => {
|
||||
it("should open a second feature after closing popup", () => {
|
||||
when.clickCenter("maplibre:map");
|
||||
then(get.elementByTestId("feature-layer-popup")).shouldBeVisible();
|
||||
when.closePopup();
|
||||
@@ -1,6 +1,5 @@
|
||||
import { MaputnikDriver } from "./maputnik-driver";
|
||||
import tokens from "../src/config/tokens.json" with {type: "json"};
|
||||
const test = it;
|
||||
import tokens from "../../src/config/tokens.json" with {type: "json"};
|
||||
|
||||
describe("modals", () => {
|
||||
const { beforeAndAfter, when, get, given, then } = new MaputnikDriver();
|
||||
@@ -14,17 +13,17 @@ describe("modals", () => {
|
||||
when.click("nav:open");
|
||||
});
|
||||
|
||||
test("close", () => {
|
||||
it("close", () => {
|
||||
when.modal.close("modal:open");
|
||||
then(get.elementByTestId("modal:open")).shouldNotExist();
|
||||
});
|
||||
|
||||
test("upload", () => {
|
||||
it("upload", () => {
|
||||
when.chooseExampleFile();
|
||||
then(get.fixture("example-style.json")).shouldEqualToStoredStyle();
|
||||
});
|
||||
|
||||
test("upload via drag and drop", () => {
|
||||
it("upload via drag and drop", () => {
|
||||
when.dropExampleFile();
|
||||
then(get.fixture("example-style.json")).shouldEqualToStoredStyle();
|
||||
});
|
||||
@@ -37,14 +36,14 @@ describe("modals", () => {
|
||||
when.click("modal:open.url.button");
|
||||
when.wait(200);
|
||||
});
|
||||
test("load from url", () => {
|
||||
it("load from url", () => {
|
||||
then(get.responseBody("example-style.json")).shouldEqualToStoredStyle();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("shortcuts", () => {
|
||||
test("open/close", () => {
|
||||
it("open/close", () => {
|
||||
when.setStyle("");
|
||||
when.typeKeys("?");
|
||||
when.modal.close("modal:shortcuts");
|
||||
@@ -57,13 +56,13 @@ describe("modals", () => {
|
||||
when.click("nav:export");
|
||||
});
|
||||
|
||||
test("close", () => {
|
||||
it("close", () => {
|
||||
when.modal.close("modal:export");
|
||||
then(get.elementByTestId("modal:export")).shouldNotExist();
|
||||
});
|
||||
|
||||
// TODO: Work out how to download a file and check the contents
|
||||
test("download");
|
||||
it("download");
|
||||
});
|
||||
|
||||
describe("sources", () => {
|
||||
@@ -72,10 +71,10 @@ describe("modals", () => {
|
||||
when.click("nav:sources");
|
||||
});
|
||||
|
||||
test("active sources");
|
||||
test("public source");
|
||||
it("active sources");
|
||||
it("public source");
|
||||
|
||||
test("add new source", () => {
|
||||
it("add new source", () => {
|
||||
const sourceId = "n1z2v3r";
|
||||
when.setValue("modal:sources.add.source_id", sourceId);
|
||||
when.select("modal:sources.add.source_type", "tile_vector");
|
||||
@@ -89,7 +88,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("add new pmtiles source", () => {
|
||||
it("add new pmtiles source", () => {
|
||||
const sourceId = "pmtilestest";
|
||||
when.setValue("modal:sources.add.source_id", sourceId);
|
||||
when.select("modal:sources.add.source_type", "pmtiles_vector");
|
||||
@@ -107,7 +106,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("add new raster source", () => {
|
||||
it("add new raster source", () => {
|
||||
const sourceId = "rastertest";
|
||||
when.setValue("modal:sources.add.source_id", sourceId);
|
||||
when.select("modal:sources.add.source_type", "tile_raster");
|
||||
@@ -124,7 +123,7 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
describe("inspect", () => {
|
||||
test("toggle", () => {
|
||||
it("toggle", () => {
|
||||
// There is no assertion in this test
|
||||
when.setStyle("geojson");
|
||||
when.select("maputnik-select", "inspect");
|
||||
@@ -141,7 +140,7 @@ describe("modals", () => {
|
||||
when.click("field-doc-button-Name");
|
||||
});
|
||||
|
||||
test("should show the spec information", () => {
|
||||
it("should show the spec information", () => {
|
||||
then(get.elementsText("spec-field-doc")).shouldInclude(
|
||||
"name for the style"
|
||||
);
|
||||
@@ -155,7 +154,7 @@ describe("modals", () => {
|
||||
when.wait(200);
|
||||
});
|
||||
|
||||
test("show name specifications", () => {
|
||||
it("show name specifications", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
name: "foobar",
|
||||
});
|
||||
@@ -168,14 +167,14 @@ describe("modals", () => {
|
||||
when.click("modal:settings.name");
|
||||
when.wait(200);
|
||||
});
|
||||
test("should update owner in local storage", () => {
|
||||
it("should update owner in local storage", () => {
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
owner: "foobar",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("sprite url", () => {
|
||||
it("sprite url", () => {
|
||||
when.setTextInJsonEditor("\"http://example.com\"");
|
||||
when.click("modal:settings.name");
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
@@ -183,7 +182,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("sprite object", () => {
|
||||
it("sprite object", () => {
|
||||
when.setTextInJsonEditor(JSON.stringify([{ id: "1", url: "2" }]));
|
||||
|
||||
when.click("modal:settings.name");
|
||||
@@ -192,7 +191,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("glyphs url", () => {
|
||||
it("glyphs url", () => {
|
||||
const glyphsUrl = "http://example.com/{fontstack}/{range}.pbf";
|
||||
when.setValue("modal:settings.glyphs", glyphsUrl);
|
||||
when.click("modal:settings.name");
|
||||
@@ -201,7 +200,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("maptiler access token", () => {
|
||||
it("maptiler access token", () => {
|
||||
const apiKey = "testing123";
|
||||
when.setValue(
|
||||
"modal:settings.maputnik:openmaptiles_access_token",
|
||||
@@ -215,7 +214,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("thunderforest access token", () => {
|
||||
it("thunderforest access token", () => {
|
||||
const apiKey = "testing123";
|
||||
when.setValue(
|
||||
"modal:settings.maputnik:thunderforest_access_token",
|
||||
@@ -227,7 +226,7 @@ describe("modals", () => {
|
||||
).shouldInclude({ "maputnik:thunderforest_access_token": apiKey });
|
||||
});
|
||||
|
||||
test("stadia access token", () => {
|
||||
it("stadia access token", () => {
|
||||
const apiKey = "testing123";
|
||||
when.setValue(
|
||||
"modal:settings.maputnik:stadia_access_token",
|
||||
@@ -239,7 +238,7 @@ describe("modals", () => {
|
||||
).shouldInclude({ "maputnik:stadia_access_token": apiKey });
|
||||
});
|
||||
|
||||
test("locationiq access token", () => {
|
||||
it("locationiq access token", () => {
|
||||
const apiKey = "testing123";
|
||||
when.setValue(
|
||||
"modal:settings.maputnik:locationiq_access_token",
|
||||
@@ -251,14 +250,14 @@ describe("modals", () => {
|
||||
).shouldInclude({ "maputnik:locationiq_access_token": apiKey });
|
||||
});
|
||||
|
||||
test("style projection mercator", () => {
|
||||
it("style projection mercator", () => {
|
||||
when.select("modal:settings.projection", "mercator");
|
||||
then(
|
||||
get.styleFromLocalStorage().then((style) => style.projection)
|
||||
).shouldInclude({ type: "mercator" });
|
||||
});
|
||||
|
||||
test("style projection globe", () => {
|
||||
it("style projection globe", () => {
|
||||
when.select("modal:settings.projection", "globe");
|
||||
then(
|
||||
get.styleFromLocalStorage().then((style) => style.projection)
|
||||
@@ -266,7 +265,7 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
|
||||
test("style projection vertical-perspective", () => {
|
||||
it("style projection vertical-perspective", () => {
|
||||
when.select("modal:settings.projection", "vertical-perspective");
|
||||
then(
|
||||
get.styleFromLocalStorage().then((style) => style.projection)
|
||||
@@ -274,7 +273,7 @@ describe("modals", () => {
|
||||
|
||||
});
|
||||
|
||||
test("style renderer", () => {
|
||||
it("style renderer", () => {
|
||||
cy.on("uncaught:exception", () => false); // this is due to the fact that this is an invalid style for openlayers
|
||||
when.select("modal:settings.maputnik:renderer", "ol");
|
||||
then(get.inputValue("modal:settings.maputnik:renderer")).shouldEqual(
|
||||
@@ -289,7 +288,7 @@ describe("modals", () => {
|
||||
|
||||
|
||||
|
||||
test("include API key when change renderer", () => {
|
||||
it("include API key when change renderer", () => {
|
||||
|
||||
when.click("modal:settings.close-modal");
|
||||
when.click("nav:open");
|
||||
@@ -328,7 +327,7 @@ describe("modals", () => {
|
||||
when.modal.open();
|
||||
});
|
||||
|
||||
test("shows duplicate id error", () => {
|
||||
it("shows duplicate id error", () => {
|
||||
when.setValue("add-layer.layer-id.input", "background");
|
||||
when.click("add-layer");
|
||||
then(get.elementByTestId("modal:add-layer")).shouldExist();
|
||||
@@ -339,7 +338,7 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
describe("sources", () => {
|
||||
test("toggle");
|
||||
it("toggle");
|
||||
});
|
||||
|
||||
describe("global state", () => {
|
||||
@@ -347,7 +346,7 @@ describe("modals", () => {
|
||||
when.click("nav:global-state");
|
||||
});
|
||||
|
||||
test("add variable", () => {
|
||||
it("add variable", () => {
|
||||
when.wait(100);
|
||||
when.click("global-state-add-variable");
|
||||
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
||||
@@ -356,7 +355,7 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
|
||||
test("add multiple variables", () => {
|
||||
it("add multiple variables", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.click("global-state-add-variable");
|
||||
when.click("global-state-add-variable");
|
||||
@@ -366,7 +365,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("remove variable", () => {
|
||||
it("remove variable", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.click("global-state-add-variable");
|
||||
when.click("global-state-add-variable");
|
||||
@@ -377,7 +376,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("edit variable key", () => {
|
||||
it("edit variable key", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.wait(100);
|
||||
when.setValue("global-state-variable-key:0", "mykey");
|
||||
@@ -388,7 +387,7 @@ describe("modals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("edit variable value", () => {
|
||||
it("edit variable value", () => {
|
||||
when.click("global-state-add-variable");
|
||||
when.wait(100);
|
||||
when.setValue("global-state-variable-value:0", "myvalue");
|
||||
@@ -401,11 +400,11 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
describe("error panel", () => {
|
||||
test("not visible when no errors", () => {
|
||||
it("not visible when no errors", () => {
|
||||
then(get.element("maputnik-message-panel-error")).shouldNotExist();
|
||||
});
|
||||
|
||||
test("visible on style error", () => {
|
||||
it("visible on style error", () => {
|
||||
when.modal.open();
|
||||
when.modal.fillLayers({
|
||||
type: "circle",
|
||||
@@ -416,7 +415,7 @@ describe("modals", () => {
|
||||
});
|
||||
|
||||
describe("Handle localStorage QuotaExceededError", () => {
|
||||
test("handles quota exceeded error when opening style from URL", () => {
|
||||
it("handles quota exceeded error when opening style from URL", () => {
|
||||
// Clear localStorage to start fresh
|
||||
cy.clearLocalStorage();
|
||||
|
||||
Generated
+773
-984
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -133,7 +133,7 @@
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.3",
|
||||
"i18next-cli": "^1.65.0",
|
||||
"i18next-cli": "^1.53.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"istanbul-lib-coverage": "^3.2.2",
|
||||
"postcss": "^8.5.16",
|
||||
@@ -145,7 +145,7 @@
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.62.1",
|
||||
"uuid": "^14.0.1",
|
||||
"vite": "^7.3.2",
|
||||
"vite": "^8.1.3",
|
||||
"vite-plugin-istanbul": "^9.0.1",
|
||||
"vitest": "^4.1.9"
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src", "cypress/e2e", "e2e/maputnik-cypress-helper.ts"],
|
||||
"include": ["src", "cypress/e2e"],
|
||||
"exclude": ["dist"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }],
|
||||
// TODO: Remove when issue is resolved https://github.com/cypress-io/cypress/issues/27448
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
// Only the unit tests that live next to the source are run by Vitest. The
|
||||
// e2e specs (*.spec.ts) are run by their own runner, and the component
|
||||
// browser test is run separately.
|
||||
include: ["src/**/*.test.{ts,tsx}"],
|
||||
exclude: ["**/node_modules/**", "e2e/**", "**/*.browser.test.tsx"],
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user