mirror of
https://github.com/maputnik/editor.git
synced 2026-09-01 09:57:27 +00:00
Compare commits
6 Commits
v2.1.0
...
085eda76a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 085eda76a1 | |||
| 0dc3f4bf5d | |||
| efc507aecd | |||
| ef902910c8 | |||
| 6ed08c7416 | |||
| 9014e12ca6 |
@@ -1,7 +1,8 @@
|
|||||||
|
import { then } from "@shellygo/cypress-test-utils/assertable";
|
||||||
import MaputnikDriver from "./maputnik-driver";
|
import MaputnikDriver from "./maputnik-driver";
|
||||||
|
|
||||||
describe("accessibility", () => {
|
describe("accessibility", () => {
|
||||||
let { beforeAndAfter, when, should } = new MaputnikDriver();
|
let { beforeAndAfter, get, when, should } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
|
|
||||||
describe("skip links", () => {
|
describe("skip links", () => {
|
||||||
@@ -15,7 +16,7 @@ describe("accessibility", () => {
|
|||||||
when.tab();
|
when.tab();
|
||||||
should.beFocused(selector);
|
should.beFocused(selector);
|
||||||
when.click(selector);
|
when.click(selector);
|
||||||
should.beFocused("skip-target-layer-list");
|
then(get.skipTargetLayerList()).shouldBeFocused();
|
||||||
});
|
});
|
||||||
|
|
||||||
// This fails for some reason only in Chrome, but passes in firefox. Adding a skip here to allow merge and later on we'll decide if we want to fix this or not.
|
// This fails for some reason only in Chrome, but passes in firefox. Adding a skip here to allow merge and later on we'll decide if we want to fix this or not.
|
||||||
@@ -25,7 +26,7 @@ describe("accessibility", () => {
|
|||||||
when.tab().tab();
|
when.tab().tab();
|
||||||
should.beFocused(selector);
|
should.beFocused(selector);
|
||||||
when.click(selector);
|
when.click(selector);
|
||||||
should.beFocused("skip-target-layer-editor");
|
then(get.skipTargetLayerEditor()).shouldBeFocused();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("skip link to map view", () => {
|
it("skip link to map view", () => {
|
||||||
@@ -34,7 +35,7 @@ describe("accessibility", () => {
|
|||||||
when.tab().tab().tab();
|
when.tab().tab().tab();
|
||||||
should.beFocused(selector);
|
should.beFocused(selector);
|
||||||
when.click(selector);
|
when.click(selector);
|
||||||
should.canvasBeFocused();
|
then(get.canvas()).shouldBeFocused();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,37 +5,18 @@ export default class CypressWrapperDriver {
|
|||||||
|
|
||||||
public given = {
|
public given = {
|
||||||
...this.helper.given,
|
...this.helper.given,
|
||||||
/**
|
};
|
||||||
*
|
|
||||||
* @param url a url to a file, this assumes the file name is the last part of the url
|
|
||||||
* @param alias
|
|
||||||
*/
|
|
||||||
interceptGetToFile(url: string) {
|
|
||||||
let fileNameAndAlias = url.split('/').pop();
|
|
||||||
cy.intercept('GET', url, { fixture: fileNameAndAlias }).as(fileNameAndAlias!);
|
|
||||||
},
|
|
||||||
|
|
||||||
interceptAndIgnore(url: string) {
|
|
||||||
cy.intercept({ method: "GET", url }, []);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public get = {
|
public get = {
|
||||||
...this.helper.get,
|
...this.helper.get,
|
||||||
elementByClassOrType(slector: string) {
|
};
|
||||||
return cy.get(slector);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public when = {
|
public when = {
|
||||||
...this.helper.when,
|
...this.helper.when,
|
||||||
visit(address: string) {
|
|
||||||
cy.visit(address);
|
|
||||||
},
|
|
||||||
confirmAlert() {
|
confirmAlert() {
|
||||||
cy.on("window:confirm", () => true);
|
cy.on("window:confirm", () => true);
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
public beforeAndAfter = this.helper.beforeAndAfter;
|
public beforeAndAfter = this.helper.beforeAndAfter;
|
||||||
}
|
}
|
||||||
+13
-13
@@ -1,61 +1,61 @@
|
|||||||
|
import { then } from "@shellygo/cypress-test-utils/assertable";
|
||||||
import MaputnikDriver from "./maputnik-driver";
|
import MaputnikDriver from "./maputnik-driver";
|
||||||
|
|
||||||
describe("keyboard", () => {
|
describe("keyboard", () => {
|
||||||
let { beforeAndAfter, given, when, should } = new MaputnikDriver();
|
let { beforeAndAfter, given, when, get } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
describe("shortcuts", () => {
|
describe("shortcuts", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
given.setupInterception();
|
given.setupMockBackedResponses();
|
||||||
when.setStyle("");
|
when.setStyle("");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ESC should unfocus", () => {
|
it("ESC should unfocus", () => {
|
||||||
const targetSelector = "maputnik-select";
|
const targetSelector = "maputnik-select";
|
||||||
when.focus(targetSelector);
|
when.focus(targetSelector);
|
||||||
should.beFocused(targetSelector);
|
then(get.elementByTestId(targetSelector)).shouldBeFocused();
|
||||||
|
|
||||||
when.typeKeys("{esc}");
|
when.typeKeys("{esc}");
|
||||||
expect(should.notBeFocused(targetSelector));
|
then(get.elementByTestId(targetSelector)).shouldNotBeFocused();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'?' should show shortcuts modal", () => {
|
it("'?' should show shortcuts modal", () => {
|
||||||
when.typeKeys("?");
|
when.typeKeys("?");
|
||||||
should.beVisible("modal:shortcuts");
|
then(get.elementByTestId("modal:shortcuts")).shouldBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'o' should show open modal", () => {
|
it("'o' should show open modal", () => {
|
||||||
when.typeKeys("o");
|
when.typeKeys("o");
|
||||||
should.beVisible("modal:open");
|
then(get.elementByTestId("modal:open")).shouldBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'e' should show export modal", () => {
|
it("'e' should show export modal", () => {
|
||||||
when.typeKeys("e");
|
when.typeKeys("e");
|
||||||
should.beVisible("modal:export");
|
then(get.elementByTestId("modal:export")).shouldBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'d' should show sources modal", () => {
|
it("'d' should show sources modal", () => {
|
||||||
when.typeKeys("d");
|
when.typeKeys("d");
|
||||||
should.beVisible("modal:sources");
|
then(get.elementByTestId("modal:sources")).shouldBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'s' should show settings modal", () => {
|
it("'s' should show settings modal", () => {
|
||||||
when.typeKeys("s");
|
when.typeKeys("s");
|
||||||
should.beVisible("modal:settings");
|
then(get.elementByTestId("modal:settings")).shouldBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'i' should change map to inspect mode", () => {
|
it("'i' should change map to inspect mode", () => {
|
||||||
when.typeKeys("i");
|
when.typeKeys("i");
|
||||||
should.beSelected("nav:inspect", "inspect");
|
then(get.inputValue("maputnik-select")).shouldEqual("inspect");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'m' should focus map", () => {
|
it("'m' should focus map", () => {
|
||||||
when.typeKeys("m");
|
when.typeKeys("m");
|
||||||
should.canvasBeFocused();
|
then(get.canvas()).shouldBeFocused();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'!' should show debug modal", () => {
|
it("'!' should show debug modal", () => {
|
||||||
when.typeKeys("!");
|
when.typeKeys("!");
|
||||||
should.beVisible("modal:debug");
|
then(get.elementByTestId("modal:debug")).shouldBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+71
-69
@@ -1,8 +1,9 @@
|
|||||||
|
import { then } from "@shellygo/cypress-test-utils/assertable";
|
||||||
import { v1 as uuid } from "uuid";
|
import { v1 as uuid } from "uuid";
|
||||||
import MaputnikDriver from "./maputnik-driver";
|
import MaputnikDriver from "./maputnik-driver";
|
||||||
|
|
||||||
describe("layers", () => {
|
describe("layers", () => {
|
||||||
let { beforeAndAfter, when, should } = new MaputnikDriver();
|
let { beforeAndAfter, get, when, should } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
when.setStyle("both");
|
when.setStyle("both");
|
||||||
@@ -10,46 +11,42 @@ describe("layers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("ops", () => {
|
describe("ops", () => {
|
||||||
it("delete", () => {
|
let id: string;
|
||||||
let id = when.modal.fillLayers({
|
beforeEach(() => {
|
||||||
|
id = when.modal.fillLayers({
|
||||||
type: "background",
|
type: "background",
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
should.equalStyleStore(
|
it("should update layers in local storage", () => {
|
||||||
(a: any) => a.layers,
|
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||||
[
|
layers: [
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
type: "background",
|
type: "background",
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when clicking delete", () => {
|
||||||
|
beforeEach(() => {
|
||||||
when.click("layer-list-item:" + id + ":delete");
|
when.click("layer-list-item:" + id + ":delete");
|
||||||
|
});
|
||||||
should.equalStyleStore((a: any) => a.layers, []);
|
it("should empty layers in local storage", () => {
|
||||||
|
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||||
|
layers: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("duplicate", () => {
|
describe("when clicking duplicate", () => {
|
||||||
let id = when.modal.fillLayers({
|
beforeEach(() => {
|
||||||
type: "background",
|
|
||||||
});
|
|
||||||
|
|
||||||
should.equalStyleStore(
|
|
||||||
(a: any) => a.layers,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: id,
|
|
||||||
type: "background",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
when.click("layer-list-item:" + id + ":copy");
|
when.click("layer-list-item:" + id + ":copy");
|
||||||
|
});
|
||||||
should.equalStyleStore(
|
it("should add copy layer in local storage", () => {
|
||||||
(a: any) => a.layers,
|
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||||
[
|
layers: [
|
||||||
{
|
{
|
||||||
id: id + "-copy",
|
id: id + "-copy",
|
||||||
type: "background",
|
type: "background",
|
||||||
@@ -58,30 +55,19 @@ describe("layers", () => {
|
|||||||
id: id,
|
id: id,
|
||||||
type: "background",
|
type: "background",
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
);
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("hide", () => {
|
describe("when clicking hide", () => {
|
||||||
let id = when.modal.fillLayers({
|
beforeEach(() => {
|
||||||
type: "background",
|
|
||||||
});
|
|
||||||
|
|
||||||
should.equalStyleStore(
|
|
||||||
(a: any) => a.layers,
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: id,
|
|
||||||
type: "background",
|
|
||||||
},
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
when.click("layer-list-item:" + id + ":toggle-visibility");
|
when.click("layer-list-item:" + id + ":toggle-visibility");
|
||||||
|
});
|
||||||
|
|
||||||
should.equalStyleStore(
|
it("should update visibility to none in local storage", () => {
|
||||||
(a: any) => a.layers,
|
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||||
[
|
layers: [
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
type: "background",
|
type: "background",
|
||||||
@@ -89,14 +75,18 @@ describe("layers", () => {
|
|||||||
visibility: "none",
|
visibility: "none",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
);
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when clicking show", () => {
|
||||||
|
beforeEach(() => {
|
||||||
when.click("layer-list-item:" + id + ":toggle-visibility");
|
when.click("layer-list-item:" + id + ":toggle-visibility");
|
||||||
|
});
|
||||||
|
|
||||||
should.equalStyleStore(
|
it("should update visibility to visible in local storage", () => {
|
||||||
(a: any) => a.layers,
|
then(get.maputnikStyleFromLocalStorage()).shouldDeepNestedInclude({
|
||||||
[
|
layers: [
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
type: "background",
|
type: "background",
|
||||||
@@ -104,11 +94,12 @@ describe("layers", () => {
|
|||||||
visibility: "visible",
|
visibility: "visible",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
);
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("background", () => {
|
describe("background", () => {
|
||||||
it("add", () => {
|
it("add", () => {
|
||||||
let id = when.modal.fillLayers({
|
let id = when.modal.fillLayers({
|
||||||
@@ -191,13 +182,18 @@ describe("layers", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// AND RESET!
|
// AND RESET!
|
||||||
when.typeKeys("{backspace}", "min-zoom.input-text");
|
when.type("{backspace}", "min-zoom.input-text");
|
||||||
when.click("max-zoom.input-text");
|
when.click("max-zoom.input-text");
|
||||||
|
|
||||||
should.equalStyleStore((a: any) => a.layers, [{
|
should.equalStyleStore(
|
||||||
"id": 'background:'+bgId,
|
(a: any) => a.layers,
|
||||||
"type": 'background'
|
[
|
||||||
}]);
|
{
|
||||||
|
id: "background:" + bgId,
|
||||||
|
type: "background",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("max-zoom", () => {
|
it("max-zoom", () => {
|
||||||
@@ -243,13 +239,18 @@ describe("layers", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Unset it again.
|
// Unset it again.
|
||||||
when.typeKeys("{backspace}{backspace}", "layer-comment.input");
|
when.type("{backspace}{backspace}", "layer-comment.input");
|
||||||
when.click("min-zoom.input-text");
|
when.click("min-zoom.input-text");
|
||||||
|
|
||||||
should.equalStyleStore((a: any) => a.layers, [{
|
should.equalStyleStore(
|
||||||
"id": 'background:' + bgId,
|
(a: any) => a.layers,
|
||||||
"type": 'background'
|
[
|
||||||
}]);
|
{
|
||||||
|
id: "background:" + bgId,
|
||||||
|
type: "background",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("color", () => {
|
it("color", () => {
|
||||||
@@ -295,13 +296,14 @@ describe("layers", () => {
|
|||||||
when.click("layer-list-item:background:" + bgId);
|
when.click("layer-list-item:background:" + bgId);
|
||||||
|
|
||||||
let errorSelector = ".CodeMirror-lint-marker-error";
|
let errorSelector = ".CodeMirror-lint-marker-error";
|
||||||
should.notExist(errorSelector);
|
// Not a good idea to check that something doesn't exist. infinite things don't exist.
|
||||||
|
then(get.elementByTestId(errorSelector)).shouldNotExist();
|
||||||
|
|
||||||
when.click(".CodeMirror");
|
when.click(".CodeMirror");
|
||||||
when.typeKeys(
|
when.typeKeys(
|
||||||
"\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013 {"
|
"\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013 {"
|
||||||
);
|
);
|
||||||
should.exist(errorSelector);
|
then(get.elementByTestId(errorSelector)).shouldExist();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+11
-7
@@ -1,23 +1,27 @@
|
|||||||
|
import { then } from "@shellygo/cypress-test-utils/assertable";
|
||||||
import MaputnikDriver from "./maputnik-driver";
|
import MaputnikDriver from "./maputnik-driver";
|
||||||
|
|
||||||
describe("map", () => {
|
describe("map", () => {
|
||||||
let { beforeAndAfter, when, should } = new MaputnikDriver();
|
let { beforeAndAfter, get, when } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
describe("zoom level", () => {
|
describe("zoom level", () => {
|
||||||
it("via url", () => {
|
it("via url", () => {
|
||||||
let zoomLevel = 12.37;
|
let zoomLevel = 12.37;
|
||||||
when.setStyle("geojson", zoomLevel);
|
when.setStyle("geojson", zoomLevel);
|
||||||
should.beVisible("maplibre:ctrl-zoom");
|
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible();
|
||||||
should.containText("maplibre:ctrl-zoom", "Zoom: " + zoomLevel);
|
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldContainText(
|
||||||
|
"Zoom: " + zoomLevel
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("via map controls", () => {
|
it("via map controls", () => {
|
||||||
let zoomLevel = 12.37;
|
let zoomLevel = 12.37;
|
||||||
when.setStyle("geojson", zoomLevel);
|
when.setStyle("geojson", zoomLevel);
|
||||||
|
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible();
|
||||||
should.beVisible("maplibre:ctrl-zoom");
|
then(get.elementByTestId("maplibre:ctrl-zoom")).shouldContainText(
|
||||||
when.clickZoomin();
|
"Zoom: " + (zoomLevel + 1)
|
||||||
should.containText("maplibre:ctrl-zoom", "Zoom: "+(zoomLevel + 1));
|
);
|
||||||
|
when.clickZoomIn();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+100
-55
@@ -1,7 +1,7 @@
|
|||||||
import CypressWrapperDriver from "./cypress-wrapper-driver";
|
import CypressWrapperDriver from "./cypress-wrapper-driver";
|
||||||
import ModalDriver from "./modal-driver";
|
import ModalDriver from "./modal-driver";
|
||||||
|
|
||||||
const SERVER_ADDRESS = "http://localhost:8888/";
|
const baseUrl = "http://localhost:8888/";
|
||||||
|
|
||||||
export default class MaputnikDriver {
|
export default class MaputnikDriver {
|
||||||
private helper = new CypressWrapperDriver();
|
private helper = new CypressWrapperDriver();
|
||||||
@@ -9,38 +9,76 @@ export default class MaputnikDriver {
|
|||||||
|
|
||||||
public beforeAndAfter = () => {
|
public beforeAndAfter = () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
this.given.setupInterception();
|
this.given.setupMockBackedResponses();
|
||||||
this.when.setStyle("both");
|
this.when.setStyle("both");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
public given = {
|
public given = {
|
||||||
setupInterception: () => {
|
setupMockBackedResponses: () => {
|
||||||
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "example-style.json");
|
this.helper.given.interceptAndMockResponse({
|
||||||
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "example-layer-style.json");
|
method: "GET",
|
||||||
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "geojson-style.json");
|
url: baseUrl + "example-style.json",
|
||||||
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "raster-style.json");
|
response: {
|
||||||
this.helper.given.interceptGetToFile(SERVER_ADDRESS + "geojson-raster-style.json");
|
fixture: "example-style.json",
|
||||||
|
},
|
||||||
this.helper.given.interceptAndIgnore("*example.local/*");
|
alias: "example-style.json",
|
||||||
this.helper.given.interceptAndIgnore("*example.com/*");
|
});
|
||||||
|
this.helper.given.interceptAndMockResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: baseUrl + "/example-layer-style.json",
|
||||||
|
response: {
|
||||||
|
fixture: "example-layer-style.json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.helper.given.interceptAndMockResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: baseUrl + "geojson-style.json",
|
||||||
|
response: {
|
||||||
|
fixture: "geojson-style.json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.helper.given.interceptAndMockResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: baseUrl + "raster-style.json",
|
||||||
|
response: {
|
||||||
|
fixture: "raster-style.json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.helper.given.interceptAndMockResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: baseUrl + "geojson-raster-style.json",
|
||||||
|
response: {
|
||||||
|
fixture: "geojson-raster-style.json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
this.helper.given.interceptAndMockResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "*example.local/*",
|
||||||
|
response: [],
|
||||||
|
});
|
||||||
|
this.helper.given.interceptAndMockResponse({
|
||||||
|
method: "GET",
|
||||||
|
url: "*example.com/*",
|
||||||
|
response: [],
|
||||||
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
public when = {
|
public when = {
|
||||||
|
...this.helper.when,
|
||||||
modal: this.modalDriver.when,
|
modal: this.modalDriver.when,
|
||||||
within: (selector: string, fn: () => void) => {
|
within: (selector: string, fn: () => void) => {
|
||||||
this.helper.when.within(fn, selector);
|
this.helper.when.within(fn, selector);
|
||||||
},
|
},
|
||||||
tab: () => this.helper.get.elementByClassOrType("body").tab(),
|
tab: () => this.helper.get.element("body").tab(),
|
||||||
waitForExampleFileRequset: () => {
|
waitForExampleFileRequset: () => {
|
||||||
this.helper.when.waitForResponse("example-style.json");
|
this.helper.when.waitForResponse("example-style.json");
|
||||||
},
|
},
|
||||||
chooseExampleFile: () => {
|
chooseExampleFile: () => {
|
||||||
this.helper.get.elementByClassOrType("input[type='file']").selectFile(
|
this.helper.get
|
||||||
"cypress/fixtures/example-style.json",
|
.bySelector("type", "file")
|
||||||
{ force: true }
|
.selectFile("cypress/fixtures/example-style.json", { force: true });
|
||||||
);
|
|
||||||
},
|
},
|
||||||
setStyle: (
|
setStyle: (
|
||||||
styleProperties: "geojson" | "raster" | "both" | "layer" | "",
|
styleProperties: "geojson" | "raster" | "both" | "layer" | "",
|
||||||
@@ -49,52 +87,43 @@ export default class MaputnikDriver {
|
|||||||
let url = "?debug";
|
let url = "?debug";
|
||||||
switch (styleProperties) {
|
switch (styleProperties) {
|
||||||
case "geojson":
|
case "geojson":
|
||||||
url += `&style=${SERVER_ADDRESS}geojson-style.json`;
|
url += `&style=${baseUrl}geojson-style.json`;
|
||||||
break;
|
break;
|
||||||
case "raster":
|
case "raster":
|
||||||
url += `&style=${SERVER_ADDRESS}raster-style.json`;
|
url += `&style=${baseUrl}raster-style.json`;
|
||||||
break;
|
break;
|
||||||
case "both":
|
case "both":
|
||||||
url += `&style=${SERVER_ADDRESS}geojson-raster-style.json`;
|
url += `&style=${baseUrl}geojson-raster-style.json`;
|
||||||
break;
|
break;
|
||||||
case "layer":
|
case "layer":
|
||||||
url += `&style=${SERVER_ADDRESS}/example-layer-style.json`;
|
url += `&style=${baseUrl}/example-layer-style.json`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (zoom) {
|
if (zoom) {
|
||||||
url += `#${zoom}/41.3805/2.1635`;
|
url += `#${zoom}/41.3805/2.1635`;
|
||||||
}
|
}
|
||||||
this.helper.when.visit(SERVER_ADDRESS + url);
|
this.helper.when.visit(baseUrl + url);
|
||||||
if (styleProperties) {
|
if (styleProperties) {
|
||||||
this.helper.when.confirmAlert();
|
this.helper.when.confirmAlert();
|
||||||
}
|
}
|
||||||
this.helper.get.element("toolbar:link").should("be.visible");
|
this.helper.get.elementByTestId("toolbar:link").should("be.visible");
|
||||||
},
|
},
|
||||||
|
|
||||||
typeKeys: (keys: string, selector?: string) => {
|
typeKeys: (keys: string, selector?: string) =>
|
||||||
if (selector) {
|
this.helper.get.element("body").type(keys),
|
||||||
this.helper.get.element(selector).type(keys);
|
|
||||||
} else {
|
|
||||||
this.helper.get.elementByClassOrType("body").type(keys);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
click: (selector: string) => {
|
clickZoomIn: () => {
|
||||||
this.helper.when.click(selector);
|
this.helper.get.element(".maplibregl-ctrl-zoom-in").click();
|
||||||
},
|
|
||||||
|
|
||||||
clickZoomin: () => {
|
|
||||||
this.helper.get.elementByClassOrType(".maplibregl-ctrl-zoom-in").click();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
selectWithin: (selector: string, value: string) => {
|
selectWithin: (selector: string, value: string) => {
|
||||||
this.when.within(selector, () => {
|
this.when.within(selector, () => {
|
||||||
this.helper.get.elementByClassOrType("select").select(value);
|
this.helper.get.element("select").select(value);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
select: (selector: string, value: string) => {
|
select: (selector: string, value: string) => {
|
||||||
this.helper.get.element(selector).select(value);
|
this.helper.get.elementByTestId(selector).select(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: (selector: string) => {
|
focus: (selector: string) => {
|
||||||
@@ -102,11 +131,15 @@ export default class MaputnikDriver {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setValue: (selector: string, text: string) => {
|
setValue: (selector: string, text: string) => {
|
||||||
this.helper.get.element(selector).clear().type(text, { parseSpecialCharSequences: false });
|
this.helper.get
|
||||||
|
.elementByTestId(selector)
|
||||||
|
.clear()
|
||||||
|
.type(text, { parseSpecialCharSequences: false });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
public get = {
|
public get = {
|
||||||
|
...this.helper.get,
|
||||||
isMac: () => {
|
isMac: () => {
|
||||||
return Cypress.platform === "darwin";
|
return Cypress.platform === "darwin";
|
||||||
},
|
},
|
||||||
@@ -116,34 +149,41 @@ export default class MaputnikDriver {
|
|||||||
const obj = JSON.parse(styleItem || "");
|
const obj = JSON.parse(styleItem || "");
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
exampleFileUrl: () => {
|
|
||||||
return SERVER_ADDRESS + "example-style.json";
|
maputnikStyleFromLocalStorage: () => {
|
||||||
|
const styleId = localStorage.getItem("maputnik:latest_style");
|
||||||
|
const styleItem = localStorage.getItem(`maputnik:style:${styleId}`);
|
||||||
|
const obj = JSON.parse(styleItem || "");
|
||||||
|
return cy.wrap(obj);
|
||||||
},
|
},
|
||||||
|
exampleFileUrl: () => {
|
||||||
|
return baseUrl + "example-style.json";
|
||||||
|
},
|
||||||
|
skipTargetLayerList: () =>
|
||||||
|
this.helper.get.elementByTestId("skip-target-layer-list"),
|
||||||
|
skipTargetLayerEditor: () =>
|
||||||
|
this.helper.get.elementByTestId("skip-target-layer-editor"),
|
||||||
|
canvas: () => this.helper.get.element("canvas"),
|
||||||
};
|
};
|
||||||
|
|
||||||
public should = {
|
public should = {
|
||||||
canvasBeFocused: () => {
|
|
||||||
this.when.within("maplibre:map", () => {
|
|
||||||
this.helper.get.elementByClassOrType("canvas").should("be.focused");
|
|
||||||
});
|
|
||||||
},
|
|
||||||
notExist: (selector: string) => {
|
notExist: (selector: string) => {
|
||||||
this.helper.get.elementByClassOrType(selector).should("not.exist");
|
this.helper.get.element(selector).should("not.exist");
|
||||||
},
|
},
|
||||||
beFocused: (selector: string) => {
|
beFocused: (selector: string) => {
|
||||||
this.helper.get.element(selector).should("have.focus");
|
this.helper.get.elementByTestId(selector).should("have.focus");
|
||||||
},
|
},
|
||||||
|
|
||||||
notBeFocused: (selector: string) => {
|
notBeFocused: (selector: string) => {
|
||||||
this.helper.get.element(selector).should("not.have.focus");
|
this.helper.get.elementByTestId(selector).should("not.have.focus");
|
||||||
},
|
},
|
||||||
|
|
||||||
beVisible: (selector: string) => {
|
beVisible: (selector: string) => {
|
||||||
this.helper.get.element(selector).should("be.visible");
|
this.helper.get.elementByTestId(selector).should("be.visible");
|
||||||
},
|
},
|
||||||
|
|
||||||
notBeVisible: (selector: string) => {
|
notBeVisible: (selector: string) => {
|
||||||
this.helper.get.element(selector).should("not.be.visible");
|
this.helper.get.elementByTestId(selector).should("not.be.visible");
|
||||||
},
|
},
|
||||||
|
|
||||||
equalStyleStore: (getter: (obj: any) => any, styleObj: any) => {
|
equalStyleStore: (getter: (obj: any) => any, styleObj: any) => {
|
||||||
@@ -156,18 +196,23 @@ export default class MaputnikDriver {
|
|||||||
styleStoreEqualToExampleFileData: () => {
|
styleStoreEqualToExampleFileData: () => {
|
||||||
cy.window().then((win: any) => {
|
cy.window().then((win: any) => {
|
||||||
const obj = this.get.styleFromWindow(win);
|
const obj = this.get.styleFromWindow(win);
|
||||||
this.helper.given.fixture("example-style.json", "file:example-style.json").should("deep.equal", obj);
|
this.helper.given
|
||||||
|
.fixture("example-style.json", "file:example-style.json")
|
||||||
|
.should("deep.equal", obj);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
exist: (selector: string) => {
|
exist: (selector: string) => {
|
||||||
this.helper.get.element(selector).should("exist");
|
this.helper.get.elementByTestId(selector).should("exist");
|
||||||
},
|
},
|
||||||
beSelected: (selector: string, value: string) => {
|
beSelected: (selector: string, value: string) => {
|
||||||
this.helper.get.element(selector).find(`option[value="${value}"]`).should("be.selected");
|
this.helper.get
|
||||||
|
.elementByTestId(selector)
|
||||||
|
.find(`option[value="${value}"]`)
|
||||||
|
.should("be.selected");
|
||||||
},
|
},
|
||||||
containText: (selector: string, text: string) => {
|
containText: (selector: string, text: string) => {
|
||||||
this.helper.get.element(selector).should("contain.text", text);
|
this.helper.get.elementByTestId(selector).should("contain.text", text);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export default class ModalDriver {
|
|||||||
private helper = new CypressWrapperDriver();
|
private helper = new CypressWrapperDriver();
|
||||||
|
|
||||||
public when = {
|
public when = {
|
||||||
fillLayers: (opts: {type: string, layer?: string, id?: string}) => {
|
fillLayers: (opts: { type: string; layer?: string; id?: string }) => {
|
||||||
let type = opts.type;
|
let type = opts.type;
|
||||||
let layer = opts.layer;
|
let layer = opts.layer;
|
||||||
let id;
|
let id;
|
||||||
@@ -14,13 +14,13 @@ export default class ModalDriver {
|
|||||||
} else {
|
} else {
|
||||||
id = `${type}:${uuid()}`;
|
id = `${type}:${uuid()}`;
|
||||||
}
|
}
|
||||||
|
this.helper.when.selectOption("add-layer.layer-type.select", type);
|
||||||
|
this.helper.when.type("add-layer.layer-id.input", id);
|
||||||
|
|
||||||
this.helper.get.element("add-layer.layer-type.select").select(type);
|
|
||||||
this.helper.get.element("add-layer.layer-id.input").type(id);
|
|
||||||
if (layer) {
|
if (layer) {
|
||||||
this.helper.when.within(() => {
|
this.helper.when.within(() => {
|
||||||
this.helper.get.elementByClassOrType("input").type(layer!);
|
this.helper.get.element("input").type(layer!);
|
||||||
}, "add-layer.layer-source-block")
|
}, "add-layer.layer-source-block");
|
||||||
}
|
}
|
||||||
this.helper.when.click("add-layer");
|
this.helper.when.click("add-layer");
|
||||||
|
|
||||||
@@ -29,14 +29,10 @@ export default class ModalDriver {
|
|||||||
|
|
||||||
open: () => {
|
open: () => {
|
||||||
this.helper.when.click("layer-list:add-layer");
|
this.helper.when.click("layer-list:add-layer");
|
||||||
|
|
||||||
this.helper.get.element("modal:add-layer").should("exist");
|
|
||||||
this.helper.get.element("modal:add-layer").should("be.visible");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
close: (key: string) => {
|
close: (key: string) => {
|
||||||
this.helper.when.waitUntil(() => this.helper.get.element(key));
|
|
||||||
this.helper.when.click(key + ".close-modal");
|
this.helper.when.click(key + ".close-modal");
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ describe("modals", () => {
|
|||||||
when.click("nav:open");
|
when.click("nav:open");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("close", () => {
|
it.only("close", () => {
|
||||||
when.modal.close("modal:open");
|
when.modal.close("modal:open");
|
||||||
should.notExist("modal:open");
|
should.notExist("modal:open");
|
||||||
});
|
});
|
||||||
@@ -125,7 +125,10 @@ describe("modals", () => {
|
|||||||
|
|
||||||
it("thunderforest access token", () => {
|
it("thunderforest access token", () => {
|
||||||
let apiKey = "testing123";
|
let apiKey = "testing123";
|
||||||
when.setValue("modal:settings.maputnik:thunderforest_access_token", apiKey);
|
when.setValue(
|
||||||
|
"modal:settings.maputnik:thunderforest_access_token",
|
||||||
|
apiKey
|
||||||
|
);
|
||||||
when.click("modal:settings.name");
|
when.click("modal:settings.name");
|
||||||
|
|
||||||
should.equalStyleStore(
|
should.equalStyleStore(
|
||||||
|
|||||||
Generated
+2569
-962
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -91,7 +91,7 @@
|
|||||||
"@cypress/code-coverage": "^3.12.15",
|
"@cypress/code-coverage": "^3.12.15",
|
||||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||||
"@rollup/plugin-replace": "^5.0.5",
|
"@rollup/plugin-replace": "^5.0.5",
|
||||||
"@shellygo/cypress-test-utils": "^2.0.9",
|
"@shellygo/cypress-test-utils": "^2.0.14",
|
||||||
"@storybook/addon-a11y": "^7.6.5",
|
"@storybook/addon-a11y": "^7.6.5",
|
||||||
"@storybook/addon-actions": "^7.6.5",
|
"@storybook/addon-actions": "^7.6.5",
|
||||||
"@storybook/addon-links": "^7.6.5",
|
"@storybook/addon-links": "^7.6.5",
|
||||||
|
|||||||
Reference in New Issue
Block a user