Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Improve tests, lint, and add more drivers #855

Merged
merged 6 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"react/prop-types": ["off"],
// Disable no-undef. It's covered by @typescript-eslint
"no-undef": "off",
"indent": ["error", 2]
"indent": ["error", 2],
"no-var": ["error"]
},
"globals": {
"global": "readonly"
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/accessibility.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MaputnikDriver from "./driver";
import MaputnikDriver from "./maputnik-driver";

describe("accessibility", () => {
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
let { beforeAndAfter, when, should } = new MaputnikDriver();
beforeAndAfter();

describe("skip links", () => {
Expand Down
41 changes: 41 additions & 0 deletions cypress/e2e/cypress-wrapper-driver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { CypressHelper } from "@shellygo/cypress-test-utils";

export default class CypressWrapperDriver {
private helper = new CypressHelper({ defaultDataAttribute: "data-wd-key" });

public 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 = {
...this.helper.get,
elementByClassOrType(slector: string) {
return cy.get(slector);
}
}

public when = {
...this.helper.when,
visit(address: string) {
cy.visit(address);
},
confirmAlert() {
cy.on("window:confirm", () => true);
}
}

public beforeAndAfter = this.helper.beforeAndAfter;
}
12 changes: 6 additions & 6 deletions cypress/e2e/history.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MaputnikDriver from "./driver";
import MaputnikDriver from "./maputnik-driver";

describe("history", () => {
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
let { beforeAndAfter, when, get, should } = new MaputnikDriver();
beforeAndAfter();

let undoKeyCombo: string;
Expand All @@ -15,11 +15,11 @@ describe("history", () => {

it("undo/redo", () => {
when.setStyle("geojson");
when.openLayersModal();
when.modal.open();

should.equalStyleStore((a: any) => a.layers, []);

when.fillLayersModal({
when.modal.fillLayers({
id: "step 1",
type: "background",
});
Expand All @@ -34,8 +34,8 @@ describe("history", () => {
]
);

when.openLayersModal();
when.fillLayersModal({
when.modal.open();
when.modal.fillLayers({
id: "step 2",
type: "background",
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/keyboard.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MaputnikDriver from "./driver";
import MaputnikDriver from "./maputnik-driver";

describe("keyboard", () => {
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
let { beforeAndAfter, given, when, should } = new MaputnikDriver();
beforeAndAfter();
describe("shortcuts", () => {
beforeEach(() => {
Expand Down
60 changes: 29 additions & 31 deletions cypress/e2e/layers.cy.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { v1 as uuid } from "uuid";
import MaputnikDriver from "./driver";
import MaputnikDriver from "./maputnik-driver";

describe("layers", () => {
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
let { beforeAndAfter, when, should } = new MaputnikDriver();
beforeAndAfter();
beforeEach(() => {
when.setStyle("both");
when.openLayersModal();
when.modal.open();
});

describe("ops", () => {
it("delete", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "background",
});

Expand All @@ -31,8 +31,7 @@ describe("layers", () => {
});

it("duplicate", () => {
var styleObj;
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "background",
});

Expand Down Expand Up @@ -64,8 +63,7 @@ describe("layers", () => {
});

it("hide", () => {
var styleObj;
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "background",
});

Expand Down Expand Up @@ -113,7 +111,7 @@ describe("layers", () => {

describe("background", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "background",
});

Expand All @@ -131,7 +129,7 @@ describe("layers", () => {
describe("modify", () => {
function createBackground() {
// Setup
var id = uuid();
let id = uuid();

when.selectWithin("add-layer.layer-type", "background");
when.setValue("add-layer.layer-id.input", "background:" + id);
Expand All @@ -154,11 +152,11 @@ describe("layers", () => {
describe("layer", () => {
it("expand/collapse");
it("id", () => {
var bgId = createBackground();
let bgId = createBackground();

when.click("layer-list-item:background:" + bgId);

var id = uuid();
let id = uuid();
when.setValue("layer-editor.layer-id.input", "foobar:" + id);
when.click("min-zoom");

Expand All @@ -174,7 +172,7 @@ describe("layers", () => {
});

it("min-zoom", () => {
var bgId = createBackground();
let bgId = createBackground();

when.click("layer-list-item:background:" + bgId);
when.setValue("min-zoom.input-text", "1");
Expand Down Expand Up @@ -203,7 +201,7 @@ describe("layers", () => {
});

it("max-zoom", () => {
var bgId = createBackground();
let bgId = createBackground();

when.click("layer-list-item:background:" + bgId);
when.setValue("max-zoom.input-text", "1");
Expand All @@ -223,8 +221,8 @@ describe("layers", () => {
});

it("comments", () => {
var bgId = createBackground();
var comment = "42";
let bgId = createBackground();
let comment = "42";

when.click("layer-list-item:background:" + bgId);
when.setValue("layer-comment.input", comment);
Expand Down Expand Up @@ -255,7 +253,7 @@ describe("layers", () => {
});

it("color", () => {
var bgId = createBackground();
let bgId = createBackground();

when.click("layer-list-item:background:" + bgId);

Expand Down Expand Up @@ -292,11 +290,11 @@ describe("layers", () => {

// TODO
it.skip("parse error", () => {
var bgId = createBackground();
let bgId = createBackground();

when.click("layer-list-item:background:" + bgId);

var errorSelector = ".CodeMirror-lint-marker-error";
let errorSelector = ".CodeMirror-lint-marker-error";
should.notExist(errorSelector);

when.click(".CodeMirror");
Expand All @@ -311,7 +309,7 @@ describe("layers", () => {

describe("fill", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "fill",
layer: "example",
});
Expand All @@ -334,7 +332,7 @@ describe("layers", () => {

describe("line", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "line",
layer: "example",
});
Expand All @@ -359,7 +357,7 @@ describe("layers", () => {

describe("symbol", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "symbol",
layer: "example",
});
Expand All @@ -379,7 +377,7 @@ describe("layers", () => {

describe("raster", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "raster",
layer: "raster",
});
Expand All @@ -399,7 +397,7 @@ describe("layers", () => {

describe("circle", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "circle",
layer: "example",
});
Expand All @@ -419,7 +417,7 @@ describe("layers", () => {

describe("fill extrusion", () => {
it("add", () => {
var id = when.fillLayersModal({
let id = when.modal.fillLayers({
type: "fill-extrusion",
layer: "example",
});
Expand All @@ -441,20 +439,20 @@ describe("layers", () => {
it("simple", () => {
when.setStyle("geojson");

when.openLayersModal();
when.fillLayersModal({
when.modal.open();
when.modal.fillLayers({
id: "foo",
type: "background",
});

when.openLayersModal();
when.fillLayersModal({
when.modal.open();
when.modal.fillLayers({
id: "foo_bar",
type: "background",
});

when.openLayersModal();
when.fillLayersModal({
when.modal.open();
when.modal.fillLayers({
id: "foo_bar_baz",
type: "background",
});
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/map.cy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import MaputnikDriver from "./driver";
import MaputnikDriver from "./maputnik-driver";

describe("map", () => {
let { beforeAndAfter, given, when, get, should } = new MaputnikDriver();
let { beforeAndAfter, when, should } = new MaputnikDriver();
beforeAndAfter();
describe("zoom level", () => {
it("via url", () => {
var zoomLevel = 12.37;
let zoomLevel = 12.37;
when.setStyle("geojson", zoomLevel);
should.beVisible("maplibre:ctrl-zoom");
should.containText("maplibre:ctrl-zoom", "Zoom: " + zoomLevel);
});

it("via map controls", () => {
var zoomLevel = 12.37;
let zoomLevel = 12.37;
when.setStyle("geojson", zoomLevel);

should.beVisible("maplibre:ctrl-zoom");
Expand Down
Loading
Loading