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