diff --git a/e2e/maputnik-driver.ts b/e2e/maputnik-driver.ts index 4ef28ce2..ad594a9e 100644 --- a/e2e/maputnik-driver.ts +++ b/e2e/maputnik-driver.ts @@ -1,4 +1,4 @@ -import { Assertable, PlaywrightHelper } from "./playwright-helper"; +import { PlaywrightHelper } from "./playwright-helper"; import { ModalDriver } from "./modal-driver"; const baseUrl = "http://localhost:8888/"; @@ -12,9 +12,9 @@ const isMac = process.platform === "darwin"; */ export class MaputnikDriver { private readonly helper = new PlaywrightHelper(); - private readonly modalDriver = new ModalDriver(this); + private readonly modalDriver = new ModalDriver(); - then = (target: T) => new Assertable(target); + then = this.helper.then; /** Reads the maputnik style currently persisted in localStorage. */ private async readStoredStyle(): Promise { diff --git a/e2e/modal-driver.ts b/e2e/modal-driver.ts index f822df72..3f7e4915 100644 --- a/e2e/modal-driver.ts +++ b/e2e/modal-driver.ts @@ -1,12 +1,12 @@ import { v1 as uuid } from "uuid"; -import type { MaputnikDriver } from "./maputnik-driver"; +import { PlaywrightHelper } from "./playwright-helper"; export class ModalDriver { - constructor(private readonly driver: MaputnikDriver) {} + private readonly helper = new PlaywrightHelper(); public when = { fillLayers: async (opts: { type: string; layer?: string; id?: string }) => { - const { when, get, then } = this.driver; + const { when, get, then } = this.helper; const id = opts.id ?? `${opts.type}:${uuid()}`; await when.select("add-layer.layer-type.select", opts.type); @@ -28,11 +28,11 @@ export class ModalDriver { }, open: async () => { - await this.driver.when.click("layer-list:add-layer"); + await this.helper.when.click("layer-list:add-layer"); }, close: async (key: string) => { - await this.driver.when.click(key + ".close-modal"); + await this.helper.when.click(key + ".close-modal"); }, }; } diff --git a/e2e/playwright-helper.ts b/e2e/playwright-helper.ts index 3b2f0bc8..58dabfe5 100644 --- a/e2e/playwright-helper.ts +++ b/e2e/playwright-helper.ts @@ -202,6 +202,9 @@ export class PlaywrightHelper { return new Query(getter); } + /** Entry point for fluent assertions over a Locator or a value/Query. */ + public then = (target: T): Assertable => new Assertable(target); + public given = { intercept: async (pattern: RegExp, alias: string, _method = "GET") => { this.recordedRequests.set(alias, []);