Enhance path point editing integration tests to cover full keyboard shortcut coverage (add, delete, undo, redo).
This commit is contained in:
@@ -174,7 +174,7 @@ describe("Path point editing integration", () => {
|
|||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("moves selected path points and supports Shift+W add, delete, undo, and redo", async () => {
|
it("moves selected path points and supports keyboard add, delete, undo, and redo", async () => {
|
||||||
const path = createScenePath({
|
const path = createScenePath({
|
||||||
id: "path-edit-main",
|
id: "path-edit-main",
|
||||||
name: "Patrol Route",
|
name: "Patrol Route",
|
||||||
@@ -285,14 +285,31 @@ describe("Path point editing integration", () => {
|
|||||||
expect(store.getState().document.paths[path.id]?.points).toHaveLength(3);
|
expect(store.getState().document.paths[path.id]?.points).toHaveLength(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectionAfterAdd = store.getState().selection;
|
const selectionAfterShiftWAdd = store.getState().selection;
|
||||||
|
|
||||||
expect(selectionAfterAdd.kind).toBe("pathPoint");
|
expect(selectionAfterShiftWAdd.kind).toBe("pathPoint");
|
||||||
if (selectionAfterAdd.kind !== "pathPoint") {
|
if (selectionAfterShiftWAdd.kind !== "pathPoint") {
|
||||||
throw new Error("Expected the appended path point to be selected.");
|
throw new Error("Expected the Shift+W appended point to be selected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const appendedPointId = selectionAfterAdd.pointId;
|
fireEvent.keyDown(window, {
|
||||||
|
key: "D",
|
||||||
|
code: "KeyD",
|
||||||
|
shiftKey: true
|
||||||
|
});
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(store.getState().document.paths[path.id]?.points).toHaveLength(4);
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectionAfterShiftDAdd = store.getState().selection;
|
||||||
|
|
||||||
|
expect(selectionAfterShiftDAdd.kind).toBe("pathPoint");
|
||||||
|
if (selectionAfterShiftDAdd.kind !== "pathPoint") {
|
||||||
|
throw new Error("Expected the Shift+D appended point to be selected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const appendedPointId = selectionAfterShiftDAdd.pointId;
|
||||||
|
|
||||||
fireEvent.keyDown(window, {
|
fireEvent.keyDown(window, {
|
||||||
key: "Delete",
|
key: "Delete",
|
||||||
@@ -300,7 +317,7 @@ describe("Path point editing integration", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(store.getState().document.paths[path.id]?.points).toHaveLength(2);
|
expect(store.getState().document.paths[path.id]?.points).toHaveLength(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@@ -323,6 +340,14 @@ describe("Path point editing integration", () => {
|
|||||||
ctrlKey: true
|
ctrlKey: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
expect(store.getState().document.paths[path.id]?.points).toHaveLength(3);
|
||||||
|
|
||||||
|
fireEvent.keyDown(window, {
|
||||||
|
key: "z",
|
||||||
|
code: "KeyZ",
|
||||||
|
ctrlKey: true
|
||||||
|
});
|
||||||
|
|
||||||
expect(store.getState().document.paths[path.id]?.points).toHaveLength(2);
|
expect(store.getState().document.paths[path.id]?.points).toHaveLength(2);
|
||||||
|
|
||||||
fireEvent.keyDown(window, {
|
fireEvent.keyDown(window, {
|
||||||
@@ -350,6 +375,11 @@ describe("Path point editing integration", () => {
|
|||||||
code: "KeyY",
|
code: "KeyY",
|
||||||
ctrlKey: true
|
ctrlKey: true
|
||||||
});
|
});
|
||||||
|
fireEvent.keyDown(window, {
|
||||||
|
key: "y",
|
||||||
|
code: "KeyY",
|
||||||
|
ctrlKey: true
|
||||||
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
store.getState().document.paths[path.id]?.points[1]?.position
|
store.getState().document.paths[path.id]?.points[1]?.position
|
||||||
@@ -358,6 +388,6 @@ describe("Path point editing integration", () => {
|
|||||||
y: 0,
|
y: 0,
|
||||||
z: 0
|
z: 0
|
||||||
});
|
});
|
||||||
expect(store.getState().document.paths[path.id]?.points).toHaveLength(2);
|
expect(store.getState().document.paths[path.id]?.points).toHaveLength(3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user