mirror of
https://github.com/maputnik/editor.git
synced 2026-08-25 14:37:27 +00:00
move then into driver
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { MaputnikDriver, then } from "./maputnik-driver";
|
import { MaputnikDriver } from "./maputnik-driver";
|
||||||
|
|
||||||
describe("accessibility", () => {
|
describe("accessibility", () => {
|
||||||
let { beforeAndAfter, get, when, should } = new MaputnikDriver();
|
let { beforeAndAfter, get, when, should, then } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
|
|
||||||
describe("skip links", () => {
|
describe("skip links", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { MaputnikDriver } from "./maputnik-driver";
|
import { MaputnikDriver } from "./maputnik-driver";
|
||||||
|
|
||||||
describe("history", () => {
|
describe("history", () => {
|
||||||
let { beforeAndAfter, when, get, should } = new MaputnikDriver();
|
let { beforeAndAfter, when, get, should, then } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
|
|
||||||
let undoKeyCombo: string;
|
let undoKeyCombo: string;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { MaputnikDriver, then } from "./maputnik-driver";
|
import { MaputnikDriver } from "./maputnik-driver";
|
||||||
|
|
||||||
describe("keyboard", () => {
|
describe("keyboard", () => {
|
||||||
let { beforeAndAfter, given, when, get } = new MaputnikDriver();
|
let { beforeAndAfter, given, when, get, then } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
describe("shortcuts", () => {
|
describe("shortcuts", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
+25
-27
@@ -1,8 +1,8 @@
|
|||||||
import { v1 as uuid } from "uuid";
|
import { v1 as uuid } from "uuid";
|
||||||
import { MaputnikDriver, then } from "./maputnik-driver";
|
import { MaputnikDriver } from "./maputnik-driver";
|
||||||
|
|
||||||
describe("layers", () => {
|
describe("layers", () => {
|
||||||
let { beforeAndAfter, get, when, should } = new MaputnikDriver();
|
let { beforeAndAfter, get, when, should, then } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
when.setStyle("both");
|
when.setStyle("both");
|
||||||
@@ -18,16 +18,14 @@ describe("layers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should update layers in local storage", () => {
|
it("should update layers in local storage", () => {
|
||||||
then(get.maputnikStyleFromLocalStorage()).shouldIncludeLocalStrorageStyle(
|
then(get.maputnikStyleFromLocalStorage()).shouldIncludeLocalStorageStyle({
|
||||||
{
|
layers: [
|
||||||
layers: [
|
{
|
||||||
{
|
id: id,
|
||||||
id: id,
|
type: "background",
|
||||||
type: "background",
|
},
|
||||||
},
|
],
|
||||||
],
|
});
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when clicking delete", () => {
|
describe("when clicking delete", () => {
|
||||||
@@ -37,7 +35,7 @@ describe("layers", () => {
|
|||||||
it("should empty layers in local storage", () => {
|
it("should empty layers in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [],
|
layers: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -50,7 +48,7 @@ describe("layers", () => {
|
|||||||
it("should add copy layer in local storage", () => {
|
it("should add copy layer in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: id + "-copy",
|
id: id + "-copy",
|
||||||
@@ -73,7 +71,7 @@ describe("layers", () => {
|
|||||||
it("should update visibility to none in local storage", () => {
|
it("should update visibility to none in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
@@ -94,7 +92,7 @@ describe("layers", () => {
|
|||||||
it("should update visibility to visible in local storage", () => {
|
it("should update visibility to visible in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: id,
|
id: id,
|
||||||
@@ -184,7 +182,7 @@ describe("layers", () => {
|
|||||||
it("should update min-zoom in local storage", () => {
|
it("should update min-zoom in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: "background:" + bgId,
|
id: "background:" + bgId,
|
||||||
@@ -200,7 +198,7 @@ describe("layers", () => {
|
|||||||
when.click("max-zoom.input-text");
|
when.click("max-zoom.input-text");
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: "background:" + bgId,
|
id: "background:" + bgId,
|
||||||
@@ -223,7 +221,7 @@ describe("layers", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should update style in local storage", () => {
|
it("should update style in local storage", () => {
|
||||||
then(cy.window()).shouldIncludeLocalStrorageStyle({
|
then(cy.window()).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: "background:" + bgId,
|
id: "background:" + bgId,
|
||||||
@@ -246,10 +244,10 @@ describe("layers", () => {
|
|||||||
when.click("layer-editor.layer-id");
|
when.click("layer-editor.layer-id");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update style in local stroage", () => {
|
it("should update style in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: "background:" + bgId,
|
id: "background:" + bgId,
|
||||||
@@ -264,14 +262,14 @@ describe("layers", () => {
|
|||||||
|
|
||||||
describe("when unsetting", () => {
|
describe("when unsetting", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
when.type("layer-comment.input", "{backspace}{backspace}");
|
when.clear("layer-comment.input");
|
||||||
when.click("min-zoom.input-text");
|
when.click("min-zoom.input-text");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should update style in local storage", () => {
|
it("should update style in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: "background:" + bgId,
|
id: "background:" + bgId,
|
||||||
@@ -294,7 +292,7 @@ describe("layers", () => {
|
|||||||
it("should update style in local storage", () => {
|
it("should update style in local storage", () => {
|
||||||
then(
|
then(
|
||||||
get.maputnikStyleFromLocalStorage()
|
get.maputnikStyleFromLocalStorage()
|
||||||
).shouldIncludeLocalStrorageStyle({
|
).shouldIncludeLocalStorageStyle({
|
||||||
layers: [
|
layers: [
|
||||||
{
|
{
|
||||||
id: "background:" + bgId,
|
id: "background:" + bgId,
|
||||||
@@ -501,10 +499,10 @@ describe("layers", () => {
|
|||||||
get.elementByTestId("layer-list-group:foo_bar_baz")
|
get.elementByTestId("layer-list-group:foo_bar_baz")
|
||||||
).shouldNotBeVisible();
|
).shouldNotBeVisible();
|
||||||
when.click("layer-list-group:foo-0");
|
when.click("layer-list-group:foo-0");
|
||||||
then(get.elementByTestId("layer-list-group:foo")).shouldBeVisible();
|
then(get.elementByTestId("layer-list-item:foo")).shouldBeVisible();
|
||||||
then(get.elementByTestId("layer-list-group:foo_bar")).shouldBeVisible();
|
then(get.elementByTestId("layer-list-item:foo_bar")).shouldBeVisible();
|
||||||
then(
|
then(
|
||||||
get.elementByTestId("layer-list-group:foo_bar_baz")
|
get.elementByTestId("layer-list-item:foo_bar_baz")
|
||||||
).shouldBeVisible();
|
).shouldBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { MaputnikDriver, then } from "./maputnik-driver";
|
import { MaputnikDriver } from "./maputnik-driver";
|
||||||
|
|
||||||
describe("map", () => {
|
describe("map", () => {
|
||||||
let { beforeAndAfter, get, when } = new MaputnikDriver();
|
let { beforeAndAfter, get, when, then } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
describe("zoom level", () => {
|
describe("zoom level", () => {
|
||||||
it("via url", () => {
|
it("via url", () => {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import { Assertable, then } from "@shellygo/cypress-test-utils/assertable";
|
||||||
Assertable,
|
|
||||||
then as baseThen,
|
|
||||||
} from "@shellygo/cypress-test-utils/assertable";
|
|
||||||
import CypressWrapperDriver from "./cypress-wrapper-driver";
|
import CypressWrapperDriver from "./cypress-wrapper-driver";
|
||||||
import ModalDriver from "./modal-driver";
|
import ModalDriver from "./modal-driver";
|
||||||
const baseUrl = "http://localhost:8888/";
|
const baseUrl = "http://localhost:8888/";
|
||||||
@@ -13,20 +10,17 @@ export class MaputnikAssertable<T> extends Assertable<T> {
|
|||||||
const obj = JSON.parse(styleItem || "");
|
const obj = JSON.parse(styleItem || "");
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
shouldIncludeLocalStrorageStyle = (styleObj: Object) =>
|
shouldIncludeLocalStorageStyle = (styleObj: Object) =>
|
||||||
baseThen(
|
then(
|
||||||
cy.window().then((win) => this.getStyleFromWindow(win))
|
cy.window().then((win) => this.getStyleFromWindow(win))
|
||||||
).shouldDeepNestedInclude(styleObj);
|
).shouldDeepNestedInclude(styleObj);
|
||||||
|
|
||||||
shouldHaveLocalStorageStyle = (styleObj: Object) =>
|
shouldHaveLocalStorageStyle = (styleObj: Object) =>
|
||||||
baseThen(
|
then(
|
||||||
cy.window().then((win) => this.getStyleFromWindow(win))
|
cy.window().then((win) => this.getStyleFromWindow(win))
|
||||||
).shouldDeepEqual(styleObj);
|
).shouldDeepEqual(styleObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const then = (chainable: Cypress.Chainable<any>) =>
|
|
||||||
new MaputnikAssertable(chainable);
|
|
||||||
|
|
||||||
export class MaputnikDriver {
|
export class MaputnikDriver {
|
||||||
private helper = new CypressWrapperDriver();
|
private helper = new CypressWrapperDriver();
|
||||||
private modalDriver = new ModalDriver();
|
private modalDriver = new ModalDriver();
|
||||||
@@ -38,6 +32,9 @@ export class MaputnikDriver {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public then = (chainable: Cypress.Chainable<any>) =>
|
||||||
|
new MaputnikAssertable(chainable);
|
||||||
|
|
||||||
public given = {
|
public given = {
|
||||||
...this.helper.given,
|
...this.helper.given,
|
||||||
setupMockBackedResponses: () => {
|
setupMockBackedResponses: () => {
|
||||||
@@ -111,18 +108,18 @@ export class MaputnikDriver {
|
|||||||
) => {
|
) => {
|
||||||
let url = "?debug";
|
let url = "?debug";
|
||||||
switch (styleProperties) {
|
switch (styleProperties) {
|
||||||
case "geojson":
|
case "geojson":
|
||||||
url += `&style=${baseUrl}geojson-style.json`;
|
url += `&style=${baseUrl}geojson-style.json`;
|
||||||
break;
|
break;
|
||||||
case "raster":
|
case "raster":
|
||||||
url += `&style=${baseUrl}raster-style.json`;
|
url += `&style=${baseUrl}raster-style.json`;
|
||||||
break;
|
break;
|
||||||
case "both":
|
case "both":
|
||||||
url += `&style=${baseUrl}geojson-raster-style.json`;
|
url += `&style=${baseUrl}geojson-raster-style.json`;
|
||||||
break;
|
break;
|
||||||
case "layer":
|
case "layer":
|
||||||
url += `&style=${baseUrl}/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`;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { MaputnikDriver, then } from "./maputnik-driver";
|
import { MaputnikDriver } from "./maputnik-driver";
|
||||||
|
|
||||||
describe("modals", () => {
|
describe("modals", () => {
|
||||||
let { beforeAndAfter, when, get } = new MaputnikDriver();
|
let { beforeAndAfter, when, get, then } = new MaputnikDriver();
|
||||||
beforeAndAfter();
|
beforeAndAfter();
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user