mock: 変化のないスナップショットをUndo履歴に積まない
数値欄の change がフォーカスを外したときにもう一度届くと、同じ値の変更が履歴に2回積まれ、 Undo 1回で戻らなかった。グループ編集の commit と同じく、直前と同じなら積まない。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017yoUu9Xd8dhwyQdCfKfaXG
This commit is contained in:
@@ -728,7 +728,7 @@ test("スイッチ・スタビの十字はトグルで出し、スタビ候補
|
||||
const switchX = async () => (await mark.locator(".switch").boundingBox())!.x;
|
||||
const before = await switchX();
|
||||
await page.getByLabel("switchOffset X").fill("0.625");
|
||||
await page.getByLabel("switchOffset X").blur();
|
||||
await page.getByLabel("switchOffset X").dispatchEvent("change");
|
||||
await expect.poll(switchX).toBeGreaterThan(before + 10);
|
||||
await expect(mark.locator(".stab")).toHaveCount(4);
|
||||
|
||||
|
||||
@@ -10,12 +10,13 @@ export class ProjectHistory {
|
||||
) {
|
||||
this.items = [structuredClone(initial)];
|
||||
}
|
||||
/** Adds one undoable snapshot unless a grouped edit is active. */
|
||||
/** Adds one undoable snapshot unless a grouped edit is active or nothing changed. */
|
||||
push(value: ProjectFile): void {
|
||||
if (this.pending) {
|
||||
this.replaceTop(value);
|
||||
return;
|
||||
}
|
||||
if (JSON.stringify(value) === JSON.stringify(this.items[this.cursor])) return;
|
||||
this.add(value);
|
||||
}
|
||||
/** Starts grouping subsequent pushes into a single operation. T-17. */
|
||||
|
||||
@@ -149,6 +149,16 @@ describe("domain project flow", () => {
|
||||
expect(h.undo().phy.metadata.name).toBe(p.phy.metadata.name);
|
||||
expect(h.redo().phy.metadata.name).toBe("drag");
|
||||
});
|
||||
it("does not add a history step for an unchanged snapshot", async () => {
|
||||
const p = await createProjectFromKle(kle, { idGenerator: gen }),
|
||||
h = new ProjectHistory(p);
|
||||
const q = structuredClone(p);
|
||||
q.phy.metadata.name = "edit";
|
||||
h.push(q);
|
||||
h.push(structuredClone(q));
|
||||
expect(h.undo().phy.metadata.name).toBe(p.phy.metadata.name);
|
||||
expect(h.canUndo).toBe(false);
|
||||
});
|
||||
it("imports the VIA geometry sample", async () => {
|
||||
const via = JSON.parse(
|
||||
readFileSync(new URL("../../samples/via/cr0wn60.json", import.meta.url), "utf8"),
|
||||
|
||||
Reference in New Issue
Block a user