From f7e856b082cf73af28a12401d963d6eb4cb5034d Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Fri, 10 Jul 2026 14:30:24 +0100 Subject: [PATCH] test(editor): cover Enter-accepts and Escape newline semantics --- src/components/PlanEditor.test.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/PlanEditor.test.ts b/src/components/PlanEditor.test.ts index fcfd294..eb1ddfc 100644 --- a/src/components/PlanEditor.test.ts +++ b/src/components/PlanEditor.test.ts @@ -54,20 +54,21 @@ describe("PlanEditor completion keys", () => { expect(wrapper.find(".completion").exists()).toBe(false) }) - it("Enter does not accept an untouched popup — it closes instead", async () => { + it("Enter accepts the selected item without navigating first", async () => { const wrapper = mountEditor() await type(wrapper, "t") await wrapper.find("textarea").trigger("keydown", { key: "Enter" }) - // No accept happened: the last emit is still the raw typed value. - expect(lastEmit(wrapper)).toBe("t") + expect(lastEmit(wrapper)).toBe("title = ") expect(wrapper.find(".completion").exists()).toBe(false) }) - it("Enter accepts once the author has navigated the popup", async () => { + it("Escape dismisses the popup so the next Enter is a newline, not an accept", async () => { const wrapper = mountEditor() await type(wrapper, "t") - await wrapper.find("textarea").trigger("keydown", { key: "ArrowDown" }) + await wrapper.find("textarea").trigger("keydown", { key: "Escape" }) + expect(wrapper.find(".completion").exists()).toBe(false) await wrapper.find("textarea").trigger("keydown", { key: "Enter" }) - expect(lastEmit(wrapper)).toBe("title = ") + // Popup is gone, so Enter accepts nothing — the value stays as typed. + expect(lastEmit(wrapper)).toBe("t") }) })