From dd04c14d9618dd2a0d07e3d922807ecf36900ead Mon Sep 17 00:00:00 2001 From: HarelM Date: Thu, 9 Jul 2026 15:28:36 +0300 Subject: [PATCH] Remove maputnik assertable --- e2e/maputnik-driver.ts | 24 +++--------------------- e2e/modals.spec.ts | 8 ++++---- e2e/playwright-helper.ts | 7 +------ 3 files changed, 8 insertions(+), 31 deletions(-) diff --git a/e2e/maputnik-driver.ts b/e2e/maputnik-driver.ts index 57739833..4ef28ce2 100644 --- a/e2e/maputnik-driver.ts +++ b/e2e/maputnik-driver.ts @@ -4,24 +4,6 @@ import { ModalDriver } from "./modal-driver"; const baseUrl = "http://localhost:8888/"; const isMac = process.platform === "darwin"; -export class MaputnikAssertable extends Assertable { - constructor(target: T, private readonly getStoredStyle: () => Promise) { - super(target); - } - - /** - * Asserts that the object under test (a fixture / response body) contains every - * top-level property of the style currently stored in localStorage. - */ - shouldEqualToStoredStyle = async () => { - const expected = await (this.target as any); - await this.retry(async () => { - const stored = await this.getStoredStyle(); - this.assertDeepNestedInclude(expected, stored); - }); - }; -} - /** * The maputnik-specific driver. It builds on the generic {@link PlaywrightHelper} * — spreading its `given`/`when`/`get` primitives and adding domain concepts @@ -32,7 +14,7 @@ export class MaputnikDriver { private readonly helper = new PlaywrightHelper(); private readonly modalDriver = new ModalDriver(this); - then = (target: T) => new MaputnikAssertable(target, () => this.readStoredStyle()); + then = (target: T) => new Assertable(target); /** Reads the maputnik style currently persisted in localStorage. */ private async readStoredStyle(): Promise { @@ -197,12 +179,12 @@ export class MaputnikDriver { styleFromLocalStorage: () => this.helper.query(() => this.readStoredStyle()), - fixture: (name: string) => Promise.resolve(this.helper.readFixture(name)), + fixture: (name: string) => this.helper.readFixture(name), responseBody: (alias: string) => { // Our mocked style responses always return the matching fixture. const name = alias.endsWith(".json") ? alias : `${alias}.json`; - return Promise.resolve(this.helper.readFixture(name)); + return this.helper.readFixture(name); }, exampleFileUrl: () => baseUrl + "example-style.json", diff --git a/e2e/modals.spec.ts b/e2e/modals.spec.ts index a1533cf7..370fb556 100644 --- a/e2e/modals.spec.ts +++ b/e2e/modals.spec.ts @@ -23,12 +23,12 @@ describe("modals", () => { test("upload", async () => { await when.chooseExampleFile(); - await then(get.fixture("example-style.json")).shouldEqualToStoredStyle(); + await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.fixture("example-style.json")); }); test("upload via drag and drop", async () => { await when.dropExampleFile(); - await then(get.fixture("example-style.json")).shouldEqualToStoredStyle(); + await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.fixture("example-style.json")); }); describe("when click open url", () => { @@ -40,7 +40,7 @@ describe("modals", () => { await when.wait(200); }); test("load from url", async () => { - await then(get.responseBody("example-style.json")).shouldEqualToStoredStyle(); + await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.responseBody("example-style.json")); }); }); }); @@ -398,7 +398,7 @@ describe("modals", () => { await when.setValue("modal:open.url.input", get.exampleFileUrl()); await when.click("modal:open.url.button"); - await then(get.responseBody("example-style.json")).shouldEqualToStoredStyle(); + await then(get.styleFromLocalStorage()).shouldDeepNestedInclude(get.responseBody("example-style.json")); await then(get.styleFromLocalStorage()).shouldExist(); }); }); diff --git a/e2e/playwright-helper.ts b/e2e/playwright-helper.ts index c2dcd310..3b2f0bc8 100644 --- a/e2e/playwright-helper.ts +++ b/e2e/playwright-helper.ts @@ -75,12 +75,7 @@ function assertDeepNestedInclude(actual: any, expected: Record) * assertable extends. */ export class Assertable { - constructor(protected readonly target: T) {} - - // Exposed to subclasses (e.g. MaputnikAssertable) so custom assertions can be - // built without re-importing these module-private helpers. - protected readonly retry = retry; - protected readonly assertDeepNestedInclude = assertDeepNestedInclude; + constructor(private readonly target: T) {} private locator(): Locator { if (!isLocator(this.target)) throw new Error("Expected a Locator target for this assertion");