Remove circular dependency.

This commit is contained in:
HarelM
2026-07-09 15:38:41 +03:00
parent dd04c14d96
commit b76d9cbe29
3 changed files with 11 additions and 8 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
import { Assertable, PlaywrightHelper } from "./playwright-helper"; import { PlaywrightHelper } from "./playwright-helper";
import { ModalDriver } from "./modal-driver"; import { ModalDriver } from "./modal-driver";
const baseUrl = "http://localhost:8888/"; const baseUrl = "http://localhost:8888/";
@@ -12,9 +12,9 @@ const isMac = process.platform === "darwin";
*/ */
export class MaputnikDriver { export class MaputnikDriver {
private readonly helper = new PlaywrightHelper(); private readonly helper = new PlaywrightHelper();
private readonly modalDriver = new ModalDriver(this); private readonly modalDriver = new ModalDriver();
then = <T>(target: T) => new Assertable(target); then = this.helper.then;
/** Reads the maputnik style currently persisted in localStorage. */ /** Reads the maputnik style currently persisted in localStorage. */
private async readStoredStyle(): Promise<any> { private async readStoredStyle(): Promise<any> {
+5 -5
View File
@@ -1,12 +1,12 @@
import { v1 as uuid } from "uuid"; import { v1 as uuid } from "uuid";
import type { MaputnikDriver } from "./maputnik-driver"; import { PlaywrightHelper } from "./playwright-helper";
export class ModalDriver { export class ModalDriver {
constructor(private readonly driver: MaputnikDriver) {} private readonly helper = new PlaywrightHelper();
public when = { public when = {
fillLayers: async (opts: { type: string; layer?: string; id?: string }) => { 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()}`; const id = opts.id ?? `${opts.type}:${uuid()}`;
await when.select("add-layer.layer-type.select", opts.type); await when.select("add-layer.layer-type.select", opts.type);
@@ -28,11 +28,11 @@ export class ModalDriver {
}, },
open: async () => { open: async () => {
await this.driver.when.click("layer-list:add-layer"); await this.helper.when.click("layer-list:add-layer");
}, },
close: async (key: string) => { close: async (key: string) => {
await this.driver.when.click(key + ".close-modal"); await this.helper.when.click(key + ".close-modal");
}, },
}; };
} }
+3
View File
@@ -202,6 +202,9 @@ export class PlaywrightHelper {
return new Query<T>(getter); return new Query<T>(getter);
} }
/** Entry point for fluent assertions over a Locator or a value/Query. */
public then = <T>(target: T): Assertable<T> => new Assertable(target);
public given = { public given = {
intercept: async (pattern: RegExp, alias: string, _method = "GET") => { intercept: async (pattern: RegExp, alias: string, _method = "GET") => {
this.recordedRequests.set(alias, []); this.recordedRequests.set(alias, []);