test: instantiate MaputnikDriver once per describe block

Make the driver page-lazy (it resolves the running test's page on demand via
an auto fixture) so it can be created a single time at describe scope and
reused across the block's tests, matching the pre-migration ergonomics:

  const { given, get, when, then } = new MaputnikDriver();

instead of pulling `driver` out of a fixture and destructuring it in every
test. Coverage collection and dialog handling move into the auto fixture.

Also inject a bare invalid token ("zzz") in the json-editor parse-error test:
CodeMirror auto-closes brackets/quotes, so " {" no longer reliably breaks the
JSON.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
HarelM
2026-07-08 17:48:44 +03:00
parent 7c5e5358cb
commit ac9186e7f8
11 changed files with 302 additions and 343 deletions
+10 -6
View File
@@ -1,16 +1,20 @@
import { test, setupMaputnik } from "./fixtures";
import { test } from "./fixtures";
import { MaputnikDriver } from "./maputnik-driver";
test.describe("code editor", () => {
setupMaputnik();
const { given, get, when, then } = new MaputnikDriver();
test("open code editor", async ({ driver }) => {
const { when, get, then } = driver;
test.beforeEach(async () => {
await given.setupMockBackedResponses();
await when.setStyle("both");
});
test("open code editor", async () => {
await when.click("nav:code-editor");
await then(get.element(".maputnik-code-editor")).shouldExist();
});
test("closes code editor", async ({ driver }) => {
const { when, get, then } = driver;
test("closes code editor", async () => {
await when.click("nav:code-editor");
await then(get.element(".maputnik-code-editor")).shouldExist();
await when.click("nav:code-editor");