test: cover note editor enter behavior

This commit is contained in:
Erik Kotsiuba
2026-04-28 22:35:43 +02:00
parent c9930b494f
commit b030b90257
3 changed files with 23 additions and 2 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ Ask the agent to elaborate on notes before finalizing choices.
| `↑` `↓` | Review tab | Change highlighted review action | | `↑` `↓` | Review tab | Change highlighted review action |
| `Enter` | Review tab | Confirm highlighted review action | | `Enter` | Review tab | Confirm highlighted review action |
| `Enter` | Free-form answer editor | Save and submit current input | | `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 | | `Esc` | Free-form or note editor | Save draft and close editor |
| `Ctrl+C` | Anywhere | Dismiss entire ask flow immediately | | `Ctrl+C` | Anywhere | Dismiss entire ask flow immediately |
| `↑` `↓` | Empty editor | Move options without closing editor | | `↑` `↓` | Empty editor | Move options without closing editor |
+1 -1
View File
@@ -218,7 +218,7 @@ Main flow:
Editing 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 - `Esc`: save draft and close the editor
- `Ctrl+C`: dismiss the entire flow immediately without saving the current editor draft - `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 - `?`: open the key bindings modal when the editor is empty; otherwise enter `?` as text
+21
View File
@@ -66,6 +66,27 @@ test("submitEditorDraft advances submitted custom answers", () => {
assert.equal(next.view.kind, "submit"); 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", () => { test("getEditorDraft reads saved note and custom text from view", () => {
let state = syncStateToSelection({ let state = syncStateToSelection({
...createInitialState({ ...createInitialState({