mirror of
https://github.com/maputnik/editor.git
synced 2025-12-06 06:10:00 +00:00
This is in order to reduce warnings in the console for React 19 usage. This removes the deprecated defaultProp and also move all the store initialization logic out of the App.tsx file, keeping it a lot more clean. It removes the `debug` flag from the supported urls along with the `localport` and `localhost`, which I'm not sure if and how they were ever used. The tests are using the `style` url, so I think it is covered in terms of tests. It also improves some typings along the project. It removes some callbacks from the code and moves to use promises. ## Launch Checklist - [x] Briefly describe the changes in this PR. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality. - [ ] Add an entry to `CHANGELOG.md` under the `## main` section. Before: <img width="1263" height="439" alt="image" src="https://github.com/user-attachments/assets/1988c4f7-39de-4fd2-b6da-b4736abc0441" /> After: <img width="1263" height="203" alt="image" src="https://github.com/user-attachments/assets/28079e6d-9de7-40a1-9869-01a0876ca79f" /> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
125 lines
2.6 KiB
TypeScript
125 lines
2.6 KiB
TypeScript
import { MaputnikDriver } from "./maputnik-driver";
|
|
|
|
describe("history", () => {
|
|
const { beforeAndAfter, when, get, then } = new MaputnikDriver();
|
|
beforeAndAfter();
|
|
|
|
let undoKeyCombo: string;
|
|
let redoKeyCombo: string;
|
|
|
|
before(() => {
|
|
const isMac = get.isMac();
|
|
undoKeyCombo = isMac ? "{meta}z" : "{ctrl}z";
|
|
redoKeyCombo = isMac ? "{meta}{shift}z" : "{ctrl}y";
|
|
});
|
|
|
|
it("undo/redo", () => {
|
|
when.setStyle("geojson");
|
|
when.modal.open();
|
|
|
|
when.modal.fillLayers({
|
|
id: "step 1",
|
|
type: "background",
|
|
});
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{
|
|
id: "step 1",
|
|
type: "background",
|
|
},
|
|
],
|
|
});
|
|
|
|
when.modal.open();
|
|
when.modal.fillLayers({
|
|
id: "step 2",
|
|
type: "background",
|
|
});
|
|
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{
|
|
id: "step 1",
|
|
type: "background",
|
|
},
|
|
{
|
|
id: "step 2",
|
|
type: "background",
|
|
},
|
|
],
|
|
});
|
|
|
|
when.typeKeys(undoKeyCombo);
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{
|
|
id: "step 1",
|
|
type: "background",
|
|
},
|
|
],
|
|
});
|
|
|
|
when.typeKeys(undoKeyCombo);
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ layers: [] });
|
|
|
|
when.typeKeys(redoKeyCombo);
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{
|
|
id: "step 1",
|
|
type: "background",
|
|
},
|
|
],
|
|
});
|
|
|
|
when.typeKeys(redoKeyCombo);
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{
|
|
id: "step 1",
|
|
type: "background",
|
|
},
|
|
{
|
|
id: "step 2",
|
|
type: "background",
|
|
},
|
|
],
|
|
});
|
|
});
|
|
|
|
it("should not redo after undo and value change", () => {
|
|
when.setStyle("geojson");
|
|
when.modal.open();
|
|
when.modal.fillLayers({
|
|
id: "step 1",
|
|
type: "background",
|
|
});
|
|
|
|
when.modal.open();
|
|
when.modal.fillLayers({
|
|
id: "step 2",
|
|
type: "background",
|
|
});
|
|
|
|
when.typeKeys(undoKeyCombo);
|
|
when.typeKeys(undoKeyCombo);
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({ layers: [] });
|
|
|
|
when.modal.open();
|
|
when.modal.fillLayers({
|
|
id: "step 3",
|
|
type: "background",
|
|
});
|
|
|
|
when.typeKeys(redoKeyCombo);
|
|
then(get.styleFromLocalStorage()).shouldDeepNestedInclude({
|
|
layers: [
|
|
{
|
|
id: "step 3",
|
|
type: "background",
|
|
},
|
|
],
|
|
});
|
|
});
|
|
});
|