From b5c0a7ebe2c97179f784d285f1927cac9fe0e2bb Mon Sep 17 00:00:00 2001 From: brooklyn! Date: Wed, 9 Sep 2026 21:53:45 -0500 Subject: [PATCH] test(desktop): cover clarify submit shortcuts and input guards --- .../assistant-ui/clarify-tool.test.tsx | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx index a877933679..4336cb127b 100644 --- a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx +++ b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx @@ -608,6 +608,47 @@ describe('readClarifyBatchResult', () => { }) }) +describe('ClarifyTool submit shortcut', () => { + it('submits selected choices with Cmd/Ctrl+Enter without toggling the focused option', async () => { + for (const modifier of [{ metaKey: true }, { ctrlKey: true }]) { + const { request } = renderLiveClarify({ multiSelect: true }) + const choice = screen.getByRole('button', { name: /staging/ }) + fireEvent.click(choice) + choice.focus() + fireEvent.keyDown(choice, { key: 'Enter', ...modifier }) + await waitFor(() => expect(request).toHaveBeenCalledTimes(1)) + expect(request).toHaveBeenCalledWith('clarify.respond', { + request_id: 'request-1', + answer: '["staging"]' + }) + cleanup() + } + }) + + it('submits a complete batch from its text field while preserving incomplete and multiline input', async () => { + for (const modifier of [{ metaKey: true }, { ctrlKey: true }]) { + const request = renderLiveBatch() + const field = screen.getByPlaceholderText('Type your answer…') + fireEvent.change(field, { target: { value: 'packet' } }) + field.focus() + fireEvent.keyDown(field, { key: 'Enter', ...modifier }) + expect(request).not.toHaveBeenCalled() + fireEvent.click(screen.getByRole('button', { name: /red/ })) + fireEvent.keyDown(field, { key: 'Enter', shiftKey: true }) + fireEvent.keyDown(field, { key: 'Enter', isComposing: true, ...modifier }) + expect(request).not.toHaveBeenCalled() + fireEvent.keyDown(field, { key: 'Enter', ...modifier }) + await waitFor(() => expect(request).toHaveBeenCalledTimes(2)) + expect(request).toHaveBeenNthCalledWith(2, 'clarify.respond', { + answer: 'packet', + question_id: 'q1', + request_id: 'request-batch' + }) + cleanup() + } + }) +}) + describe('ClarifyTool batch card', () => { it('renders every question at once', () => { renderLiveBatch()