From 085eda76a104d90596bbdaeaa02c90098d5c671f Mon Sep 17 00:00:00 2001 From: shelly_goldblit Date: Sat, 30 Dec 2023 18:48:17 +0200 Subject: [PATCH] convert more tests --- cypress/e2e/layers.cy.ts | 5 +++-- cypress/e2e/map.cy.ts | 18 +++++++++++------- cypress/e2e/maputnik-driver.ts | 7 +------ cypress/e2e/modal-driver.ts | 1 - cypress/e2e/modals.cy.ts | 7 +++++-- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cypress/e2e/layers.cy.ts b/cypress/e2e/layers.cy.ts index 74682b57..d7d034ed 100644 --- a/cypress/e2e/layers.cy.ts +++ b/cypress/e2e/layers.cy.ts @@ -296,13 +296,14 @@ describe("layers", () => { when.click("layer-list-item:background:" + bgId); 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.typeKeys( "\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013\uE013 {" ); - should.exist(errorSelector); + then(get.elementByTestId(errorSelector)).shouldExist(); }); }); }); diff --git a/cypress/e2e/map.cy.ts b/cypress/e2e/map.cy.ts index 6ed22553..f1700c1a 100644 --- a/cypress/e2e/map.cy.ts +++ b/cypress/e2e/map.cy.ts @@ -1,23 +1,27 @@ +import { then } from "@shellygo/cypress-test-utils/assertable"; import MaputnikDriver from "./maputnik-driver"; describe("map", () => { - let { beforeAndAfter, when, should } = new MaputnikDriver(); + let { beforeAndAfter, get, when } = new MaputnikDriver(); beforeAndAfter(); describe("zoom level", () => { it("via url", () => { let zoomLevel = 12.37; when.setStyle("geojson", zoomLevel); - should.beVisible("maplibre:ctrl-zoom"); - should.containText("maplibre:ctrl-zoom", "Zoom: " + zoomLevel); + then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible(); + then(get.elementByTestId("maplibre:ctrl-zoom")).shouldContainText( + "Zoom: " + zoomLevel + ); }); it("via map controls", () => { let zoomLevel = 12.37; when.setStyle("geojson", zoomLevel); - - should.beVisible("maplibre:ctrl-zoom"); - when.clickZoomin(); - should.containText("maplibre:ctrl-zoom", "Zoom: "+(zoomLevel + 1)); + then(get.elementByTestId("maplibre:ctrl-zoom")).shouldBeVisible(); + then(get.elementByTestId("maplibre:ctrl-zoom")).shouldContainText( + "Zoom: " + (zoomLevel + 1) + ); + when.clickZoomIn(); }); }); }); diff --git a/cypress/e2e/maputnik-driver.ts b/cypress/e2e/maputnik-driver.ts index 457665e9..66b73876 100644 --- a/cypress/e2e/maputnik-driver.ts +++ b/cypress/e2e/maputnik-driver.ts @@ -112,7 +112,7 @@ export default class MaputnikDriver { typeKeys: (keys: string, selector?: string) => this.helper.get.element("body").type(keys), - clickZoomin: () => { + clickZoomIn: () => { this.helper.get.element(".maplibregl-ctrl-zoom-in").click(); }, @@ -167,11 +167,6 @@ export default class MaputnikDriver { }; public should = { - canvasBeFocused: () => { - this.when.within("maplibre:map", () => { - this.helper.get.element("canvas").should("be.focused"); - }); - }, notExist: (selector: string) => { this.helper.get.element(selector).should("not.exist"); }, diff --git a/cypress/e2e/modal-driver.ts b/cypress/e2e/modal-driver.ts index 9a20aca7..e638dc0d 100644 --- a/cypress/e2e/modal-driver.ts +++ b/cypress/e2e/modal-driver.ts @@ -32,7 +32,6 @@ export default class ModalDriver { }, close: (key: string) => { - this.helper.when.waitUntil(() => this.helper.get.element(key)); this.helper.when.click(key + ".close-modal"); }, }; diff --git a/cypress/e2e/modals.cy.ts b/cypress/e2e/modals.cy.ts index b0713fb0..b1635edf 100644 --- a/cypress/e2e/modals.cy.ts +++ b/cypress/e2e/modals.cy.ts @@ -11,7 +11,7 @@ describe("modals", () => { when.click("nav:open"); }); - it("close", () => { + it.only("close", () => { when.modal.close("modal:open"); should.notExist("modal:open"); }); @@ -125,7 +125,10 @@ describe("modals", () => { it("thunderforest access token", () => { 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"); should.equalStyleStore(