mirror of
https://github.com/maputnik/editor.git
synced 2026-07-09 15:37:28 +00:00
Remove circular dependency.
This commit is contained in:
@@ -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 = <T>(target: T) => new Assertable(target);
|
||||
then = this.helper.then;
|
||||
|
||||
/** Reads the maputnik style currently persisted in localStorage. */
|
||||
private async readStoredStyle(): Promise<any> {
|
||||
|
||||
+5
-5
@@ -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");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -202,6 +202,9 @@ export class PlaywrightHelper {
|
||||
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 = {
|
||||
intercept: async (pattern: RegExp, alias: string, _method = "GET") => {
|
||||
this.recordedRequests.set(alias, []);
|
||||
|
||||
Reference in New Issue
Block a user