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
+20 -23
View File
@@ -1,16 +1,21 @@
import { test, setupMaputnik } from "./fixtures";
import { test } from "./fixtures";
import { MaputnikDriver } from "./maputnik-driver";
test.describe("keyboard", () => {
setupMaputnik();
const { given, get, when, then } = new MaputnikDriver();
test.beforeEach(async () => {
await given.setupMockBackedResponses();
await when.setStyle("both");
});
test.describe("shortcuts", () => {
test.beforeEach(async ({ driver }) => {
await driver.given.setupMockBackedResponses();
await driver.when.setStyle("");
test.beforeEach(async () => {
await given.setupMockBackedResponses();
await when.setStyle("");
});
test("ESC should unfocus", async ({ driver }) => {
const { get, when, then } = driver;
test("ESC should unfocus", async () => {
const targetSelector = "maputnik-select";
await when.focus(targetSelector);
await then(get.elementByTestId(targetSelector)).shouldBeFocused();
@@ -18,50 +23,42 @@ test.describe("keyboard", () => {
await then(get.elementByTestId(targetSelector)).shouldNotBeFocused();
});
test("'?' should show shortcuts modal", async ({ driver }) => {
const { get, when, then } = driver;
test("'?' should show shortcuts modal", async () => {
await when.typeKeys("?");
await then(get.elementByTestId("modal:shortcuts")).shouldBeVisible();
});
test("'o' should show open modal", async ({ driver }) => {
const { get, when, then } = driver;
test("'o' should show open modal", async () => {
await when.typeKeys("o");
await then(get.elementByTestId("modal:open")).shouldBeVisible();
});
test("'e' should show export modal", async ({ driver }) => {
const { get, when, then } = driver;
test("'e' should show export modal", async () => {
await when.typeKeys("e");
await then(get.elementByTestId("modal:export")).shouldBeVisible();
});
test("'d' should show sources modal", async ({ driver }) => {
const { get, when, then } = driver;
test("'d' should show sources modal", async () => {
await when.typeKeys("d");
await then(get.elementByTestId("modal:sources")).shouldBeVisible();
});
test("'s' should show settings modal", async ({ driver }) => {
const { get, when, then } = driver;
test("'s' should show settings modal", async () => {
await when.typeKeys("s");
await then(get.elementByTestId("modal:settings")).shouldBeVisible();
});
test("'i' should change map to inspect mode", async ({ driver }) => {
const { get, when, then } = driver;
test("'i' should change map to inspect mode", async () => {
await when.typeKeys("i");
await then(get.inputValue("maputnik-select")).shouldEqual("inspect");
});
test("'m' should focus map", async ({ driver }) => {
const { get, when, then } = driver;
test("'m' should focus map", async () => {
await when.typeKeys("m");
await then(get.canvas()).shouldBeFocused();
});
test("'!' should show debug modal", async ({ driver }) => {
const { get, when, then } = driver;
test("'!' should show debug modal", async () => {
await when.typeKeys("!");
await then(get.elementByTestId("modal:debug")).shouldBeVisible();
});