feat: improve ask flow elaboration and validation

This commit is contained in:
Erik Kotsiuba
2026-04-24 19:13:10 +02:00
parent 0ee2d11ec9
commit b7c7301f97
16 changed files with 1270 additions and 134 deletions
+46 -6
View File
@@ -40,11 +40,12 @@ test("submit screen uses shorter action labels without extra prompt text", () =>
assert(!lines.some((line) => line.includes("Submit answers?")));
assert(lines.some((line) => line.includes("1. Submit")));
assert(lines.some((line) => line.includes("2. Cancel")));
assert(lines.some((line) => line.includes("2. Elaborate")));
assert(lines.some((line) => line.includes("3. Cancel")));
assert(!lines.some((line) => line.includes("1. Submit answers")));
});
test("submit screen renders indented notes before answer and separates questions", () => {
test("submit screen shows notes only for answered questions in submit mode", () => {
let state = createInitialState({
questions: [
{
@@ -88,16 +89,12 @@ test("submit screen renders indented notes before answer and separates questions
const secondQuestionIndex = lines.findIndex((line) =>
line.includes("<text>Multi</text>")
);
const secondQuestionNoteIndex = lines.findIndex((line) =>
line.includes("Second note")
);
assert.notEqual(firstQuestionIndex, -1);
assert.notEqual(firstQuestionNoteIndex, -1);
assert.notEqual(firstAnswerIndex, -1);
assert.notEqual(optionNoteIndex, -1);
assert.notEqual(secondQuestionIndex, -1);
assert.notEqual(secondQuestionNoteIndex, -1);
assert(firstQuestionNoteIndex < firstAnswerIndex);
assert(optionNoteIndex > firstAnswerIndex);
assert(lines[firstQuestionNoteIndex]?.startsWith(" "));
@@ -106,6 +103,7 @@ test("submit screen renders indented notes before answer and separates questions
assert(
lines.some((line) => line.includes("<syntaxString>Note:</syntaxString>"))
);
assert(!lines.some((line) => line.includes("Second note")));
assert(!lines.some((line) => line.includes("Question note:")));
assert(!lines.some((line) => line.includes("Code demo note:")));
assert(!lines.some((line) => line.includes("Pick one primary demo style.")));
@@ -114,6 +112,48 @@ test("submit screen renders indented notes before answer and separates questions
);
});
test("submit screen shows all notes when elaborate action is selected", () => {
let state = createInitialState({
questions: [
{
id: "q1",
label: "Single",
prompt: "Pick one primary demo style.",
options: [
{ value: "code", label: "Code demo" },
{ value: "slides", label: "Slides demo" },
],
},
{
id: "q2",
label: "Multi",
prompt: "Pick any extra things to include.",
options: [{ value: "extra", label: "Extra" }],
},
],
});
state = enterQuestionNoteMode(state, "q1");
state = saveNote(state, "Question note");
state = applyNumberShortcut(state, 1);
state = enterOptionNoteMode(state, "q1", "code");
state = saveNote(state, "Selected option note");
state = enterOptionNoteMode(state, "q1", "slides");
state = saveNote(state, "Unselected option note");
state = enterQuestionNoteMode(state, "q2");
state = saveNote(state, "Second note");
state = { ...state, activeSubmitActionIndex: 1 };
const lines: string[] = [];
renderSubmitScreen(lines, state, mockTheme(), 120);
assert(lines.some((line) => line.includes("Question note")));
assert(lines.some((line) => line.includes("Selected option note")));
assert(lines.some((line) => line.includes("Unselected option note")));
assert(lines.some((line) => line.includes("Slides demo Note:")));
assert(lines.some((line) => line.includes("Second note")));
});
test("submit screen renders multi-select option notes under their related answers", () => {
let state = createInitialState({
questions: [