From fa2dfa74801588baa3d5660786d39392ed7ce3bb Mon Sep 17 00:00:00 2001 From: shelly_goldblit Date: Sun, 31 Dec 2023 20:47:10 +0200 Subject: [PATCH] remove left overs --- cypress/e2e/cypress-wrapper-driver.ts | 5 +---- cypress/e2e/layers.cy.ts | 2 +- cypress/e2e/maputnik-driver.ts | 6 +++--- cypress/e2e/modal-driver.ts | 6 ++++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/cypress-wrapper-driver.ts b/cypress/e2e/cypress-wrapper-driver.ts index e1315518..ecabbc8d 100644 --- a/cypress/e2e/cypress-wrapper-driver.ts +++ b/cypress/e2e/cypress-wrapper-driver.ts @@ -1,6 +1,6 @@ import { CypressHelper } from "@shellygo/cypress-test-utils"; -export default class CypressWrapperDriver { +export default class MaputnikCypressHelper { private helper = new CypressHelper({ defaultDataAttribute: "data-wd-key" }); public given = { @@ -13,9 +13,6 @@ export default class CypressWrapperDriver { public when = { ...this.helper.when, - confirmAlert() { - cy.on("window:confirm", () => true); - }, }; public beforeAndAfter = this.helper.beforeAndAfter; diff --git a/cypress/e2e/layers.cy.ts b/cypress/e2e/layers.cy.ts index e3f76966..0b3342cb 100644 --- a/cypress/e2e/layers.cy.ts +++ b/cypress/e2e/layers.cy.ts @@ -2,7 +2,7 @@ import { v1 as uuid } from "uuid"; import { MaputnikDriver } from "./maputnik-driver"; describe("layers", () => { - let { beforeAndAfter, get, when, should, then } = new MaputnikDriver(); + let { beforeAndAfter, get, when, then } = new MaputnikDriver(); beforeAndAfter(); beforeEach(() => { when.setStyle("both"); diff --git a/cypress/e2e/maputnik-driver.ts b/cypress/e2e/maputnik-driver.ts index 39a11de4..b43885e1 100644 --- a/cypress/e2e/maputnik-driver.ts +++ b/cypress/e2e/maputnik-driver.ts @@ -1,6 +1,6 @@ import { CypressHelper } from "@shellygo/cypress-test-utils"; import { Assertable, then } from "@shellygo/cypress-test-utils/assertable"; -import CypressWrapperDriver from "./cypress-wrapper-driver"; +import MaputnikCypressHelper from "./cypress-wrapper-driver"; import ModalDriver from "./modal-driver"; const baseUrl = "http://localhost:8888/"; @@ -22,7 +22,7 @@ export class MaputnikAssertable extends Assertable { } export class MaputnikDriver { - private helper = new CypressWrapperDriver(); + private helper = new MaputnikCypressHelper(); private modalDriver = new ModalDriver(); public beforeAndAfter = () => { @@ -126,7 +126,7 @@ export class MaputnikDriver { } this.helper.when.visit(baseUrl + url); if (styleProperties) { - this.helper.when.confirmAlert(); + this.helper.when.acceptConfirm(); } // when methods should not include assertions this.helper.get.elementByTestId("toolbar:link").should("be.visible"); diff --git a/cypress/e2e/modal-driver.ts b/cypress/e2e/modal-driver.ts index e638dc0d..67a8a173 100644 --- a/cypress/e2e/modal-driver.ts +++ b/cypress/e2e/modal-driver.ts @@ -1,11 +1,13 @@ import { v1 as uuid } from "uuid"; -import CypressWrapperDriver from "./cypress-wrapper-driver"; +import MaputnikCypressHelper from "./cypress-wrapper-driver"; export default class ModalDriver { - private helper = new CypressWrapperDriver(); + private helper = new MaputnikCypressHelper(); public when = { fillLayers: (opts: { type: string; layer?: string; id?: string }) => { + // Having logic in test code is an anti pattern. + // This should be splitted to multiple single responsibility functions let type = opts.type; let layer = opts.layer; let id;