From b030b90257df5c60d03b75534455a390204eae5e Mon Sep 17 00:00:00 2001 From: Erik Kotsiuba Date: Tue, 28 Apr 2026 11:28:35 +0200 Subject: [PATCH] test: cover note editor enter behavior --- README.md | 2 +- docs/contract.md | 2 +- tests/editor-state.test.ts | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85450df..1cacb28 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ Ask the agent to elaborate on notes before finalizing choices. | `↑` `↓` | Review tab | Change highlighted review action | | `Enter` | Review tab | Confirm highlighted review action | | `Enter` | Free-form answer editor | Save and submit current input | -| `Enter` | Note editor | Save current note | +| `Enter` | Note editor | Save current note and return to navigation | | `Esc` | Free-form or note editor | Save draft and close editor | | `Ctrl+C` | Anywhere | Dismiss entire ask flow immediately | | `↑` `↓` | Empty editor | Move options without closing editor | diff --git a/docs/contract.md b/docs/contract.md index 48cd4d9..50c24ef 100644 --- a/docs/contract.md +++ b/docs/contract.md @@ -218,7 +218,7 @@ Main flow: Editing flow: -- `Enter`: save and submit the current input +- `Enter`: submit the current editor input and close the editor; in note editors this saves the note only and keeps the ask flow open - `Esc`: save draft and close the editor - `Ctrl+C`: dismiss the entire flow immediately without saving the current editor draft - `?`: open the key bindings modal when the editor is empty; otherwise enter `?` as text diff --git a/tests/editor-state.test.ts b/tests/editor-state.test.ts index 1318a9e..4824b76 100644 --- a/tests/editor-state.test.ts +++ b/tests/editor-state.test.ts @@ -66,6 +66,27 @@ test("submitEditorDraft advances submitted custom answers", () => { assert.equal(next.view.kind, "submit"); }); +test("submitEditorDraft saves notes without completing the ask flow", () => { + const state = enterQuestionNoteMode( + createInitialState({ + questions: [ + { + id: "q1", + prompt: "Question?", + options: [{ value: "a", label: "A" }], + }, + ], + }), + "q1" + ); + + const next = submitEditorDraft(state, "needs examples"); + assert.equal(next.answers.q1.note, "needs examples"); + assert.equal(next.view.kind, "navigate"); + assert.equal(next.completed, false); + assert.equal(next.cancelled, false); +}); + test("getEditorDraft reads saved note and custom text from view", () => { let state = syncStateToSelection({ ...createInitialState({