feat: support ctrl+c dismissal in ask flow
This commit is contained in:
@@ -79,3 +79,27 @@ test("note editing mode delegates arrows and tab to the editor", () => {
|
||||
kind: "delegateToEditor",
|
||||
});
|
||||
});
|
||||
|
||||
test("ctrl+c dismisses the flow from both navigation and editing modes", () => {
|
||||
const navigation = createInitialState({
|
||||
questions: [
|
||||
{
|
||||
id: "q1",
|
||||
prompt: "Question?",
|
||||
options: [{ value: "a", label: "A" }],
|
||||
},
|
||||
],
|
||||
});
|
||||
const input = inputState();
|
||||
const note = enterQuestionNoteMode(navigation, "q1");
|
||||
|
||||
assert.deepEqual(getInputCommand(navigation, "\u0003"), {
|
||||
kind: "dismiss",
|
||||
});
|
||||
assert.deepEqual(getInputCommand(input, "\u0003"), {
|
||||
kind: "dismiss",
|
||||
});
|
||||
assert.deepEqual(getInputCommand(note, "\u0003"), {
|
||||
kind: "dismiss",
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
applyNumberShortcut,
|
||||
cancelFlow,
|
||||
confirmCurrentSelection,
|
||||
dismissFlow,
|
||||
enterOptionNoteMode,
|
||||
enterQuestionNoteMode,
|
||||
moveOption,
|
||||
@@ -473,3 +474,27 @@ test("escape cancels from main flow but only exits input and note modes when edi
|
||||
assert.equal(state.view.kind, "navigate");
|
||||
assert.equal(state.cancelled, false);
|
||||
});
|
||||
|
||||
test("dismissFlow cancels the tool even from editing modes", () => {
|
||||
let state = createInitialState({
|
||||
questions: [
|
||||
{ id: "q", prompt: "Q?", options: [{ value: "a", label: "A" }] },
|
||||
],
|
||||
});
|
||||
state = applyNumberShortcut(state, 2);
|
||||
assert.equal(state.view.kind, "input");
|
||||
state = dismissFlow(state);
|
||||
assert.equal(state.cancelled, true);
|
||||
assert.equal(state.completed, true);
|
||||
|
||||
state = createInitialState({
|
||||
questions: [
|
||||
{ id: "q", prompt: "Q?", options: [{ value: "a", label: "A" }] },
|
||||
],
|
||||
});
|
||||
state = enterQuestionNoteMode(state, "q");
|
||||
assert.equal(state.view.kind, "note");
|
||||
state = dismissFlow(state);
|
||||
assert.equal(state.cancelled, true);
|
||||
assert.equal(state.completed, true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user