mirror of
https://github.com/maputnik/editor.git
synced 2026-07-08 23:17:26 +00:00
ac9186e7f8
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>
91 lines
2.5 KiB
TypeScript
91 lines
2.5 KiB
TypeScript
import { test } from "./fixtures";
|
|
import { MaputnikDriver } from "./maputnik-driver";
|
|
|
|
test.describe("history", () => {
|
|
const { given, get, when, then } = new MaputnikDriver();
|
|
|
|
const undoKeyCombo = process.platform === "darwin" ? "{meta}z" : "{ctrl}z";
|
|
const redoKeyCombo = process.platform === "darwin" ? "{meta}{shift}z" : "{ctrl}y";
|
|
|
|
test.beforeEach(async () => {
|
|
await given.setupMockBackedResponses();
|
|
await when.setStyle("both");
|
|
});
|
|
|
|
test("undo/redo", async () => {
|
|
await when.setStyle("geojson");
|
|
await when.modal.open();
|
|
|
|
await when.modal.fillLayers({
|
|
id: "step 1",
|
|
type: "background",
|
|
});
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [{ id: "step 1", type: "background" }],
|
|
});
|
|
|
|
await when.modal.open();
|
|
await when.modal.fillLayers({
|
|
id: "step 2",
|
|
type: "background",
|
|
});
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{ id: "step 1", type: "background" },
|
|
{ id: "step 2", type: "background" },
|
|
],
|
|
});
|
|
|
|
await when.typeKeys(undoKeyCombo);
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [{ id: "step 1", type: "background" }],
|
|
});
|
|
|
|
await when.typeKeys(undoKeyCombo);
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ layers: [] });
|
|
|
|
await when.typeKeys(redoKeyCombo);
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [{ id: "step 1", type: "background" }],
|
|
});
|
|
|
|
await when.typeKeys(redoKeyCombo);
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{ id: "step 1", type: "background" },
|
|
{ id: "step 2", type: "background" },
|
|
],
|
|
});
|
|
});
|
|
|
|
test("should not redo after undo and value change", async () => {
|
|
await when.setStyle("geojson");
|
|
await when.modal.open();
|
|
await when.modal.fillLayers({
|
|
id: "step 1",
|
|
type: "background",
|
|
});
|
|
|
|
await when.modal.open();
|
|
await when.modal.fillLayers({
|
|
id: "step 2",
|
|
type: "background",
|
|
});
|
|
|
|
await when.typeKeys(undoKeyCombo);
|
|
await when.typeKeys(undoKeyCombo);
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ layers: [] });
|
|
|
|
await when.modal.open();
|
|
await when.modal.fillLayers({
|
|
id: "step 3",
|
|
type: "background",
|
|
});
|
|
|
|
await when.typeKeys(redoKeyCombo);
|
|
await then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [{ id: "step 3", type: "background" }],
|
|
});
|
|
});
|
|
});
|