feat(plan): add 'All the above' option to multi-select AskUser questions (#22365)

Co-authored-by: jacob314 <jacob314@gmail.com>
This commit is contained in:
Adib234
2026-03-17 15:17:34 -04:00
committed by GitHub
parent b211f30d95
commit 77a874cf65
4 changed files with 126 additions and 5 deletions

View File

@@ -87,6 +87,31 @@ describe('AskUserDialog', () => {
writeKey(stdin, '\r'); // Toggle TS
writeKey(stdin, '\x1b[B'); // Down
writeKey(stdin, '\r'); // Toggle ESLint
writeKey(stdin, '\x1b[B'); // Down to All of the above
writeKey(stdin, '\x1b[B'); // Down to Other
writeKey(stdin, '\x1b[B'); // Down to Done
writeKey(stdin, '\r'); // Done
},
expectedSubmit: { '0': 'TypeScript, ESLint' },
},
{
name: 'All of the above',
questions: [
{
question: 'Which features?',
header: 'Features',
type: QuestionType.CHOICE,
options: [
{ label: 'TypeScript', description: '' },
{ label: 'ESLint', description: '' },
],
multiSelect: true,
},
] as Question[],
actions: (stdin: { write: (data: string) => void }) => {
writeKey(stdin, '\x1b[B'); // Down to ESLint
writeKey(stdin, '\x1b[B'); // Down to All of the above
writeKey(stdin, '\r'); // Toggle All of the above
writeKey(stdin, '\x1b[B'); // Down to Other
writeKey(stdin, '\x1b[B'); // Down to Done
writeKey(stdin, '\r'); // Done
@@ -131,6 +156,42 @@ describe('AskUserDialog', () => {
});
});
it('verifies "All of the above" visual state with snapshot', async () => {
const questions = [
{
question: 'Which features?',
header: 'Features',
type: QuestionType.CHOICE,
options: [
{ label: 'TypeScript', description: '' },
{ label: 'ESLint', description: '' },
],
multiSelect: true,
},
] as Question[];
const { stdin, lastFrame, waitUntilReady } = renderWithProviders(
<AskUserDialog
questions={questions}
onSubmit={vi.fn()}
onCancel={vi.fn()}
width={120}
/>,
{ width: 120 },
);
// Navigate to "All of the above" and toggle it
writeKey(stdin, '\x1b[B'); // Down to ESLint
writeKey(stdin, '\x1b[B'); // Down to All of the above
writeKey(stdin, '\r'); // Toggle All of the above
await waitFor(async () => {
await waitUntilReady();
// Verify visual state (checkmarks on all options)
expect(lastFrame()).toMatchSnapshot();
});
});
it('handles custom option in single select with inline typing', async () => {
const onSubmit = vi.fn();
const { stdin, lastFrame, waitUntilReady } = renderWithProviders(