Remove maputnik assertable

This commit is contained in:
HarelM
2026-07-09 15:28:36 +03:00
parent 6c31add041
commit dd04c14d96
3 changed files with 8 additions and 31 deletions
+3 -21
View File
@@ -4,24 +4,6 @@ import { ModalDriver } from "./modal-driver";
const baseUrl = "http://localhost:8888/";
const isMac = process.platform === "darwin";
export class MaputnikAssertable<T> extends Assertable<T> {
constructor(target: T, private readonly getStoredStyle: () => Promise<any>) {
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 = <T>(target: T) => new MaputnikAssertable(target, () => this.readStoredStyle());
then = <T>(target: T) => new Assertable(target);
/** Reads the maputnik style currently persisted in localStorage. */
private async readStoredStyle(): Promise<any> {
@@ -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",
+4 -4
View File
@@ -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();
});
});
+1 -6
View File
@@ -75,12 +75,7 @@ function assertDeepNestedInclude(actual: any, expected: Record<string, unknown>)
* assertable extends.
*/
export class Assertable<T> {
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");