diff --git a/src/components/WikilinkChatInput.test.tsx b/src/components/WikilinkChatInput.test.tsx index 5016efba..89ffafc2 100644 --- a/src/components/WikilinkChatInput.test.tsx +++ b/src/components/WikilinkChatInput.test.tsx @@ -130,6 +130,12 @@ function updateEditorText(text: string) { fireEvent.input(editor) } +async function waitForCompositionFlush() { + await act(async () => { + await Promise.resolve() + }) +} + function clickFirstSuggestion() { const rows = screen.getByTestId('wikilink-menu').querySelectorAll('[class*="cursor-pointer"]') expect(rows.length).toBeGreaterThan(0) @@ -336,10 +342,14 @@ describe('WikilinkChatInput', () => { firstEditor.appendChild(document.createTextNode('안')) fireEvent.input(firstEditor) fireEvent.compositionEnd(firstEditor) + await waitForCompositionFlush() await waitFor(() => { expect(onDraftChange).toHaveBeenLastCalledWith('안') }) + await waitFor(() => { + expect(screen.getByTestId('agent-input').textContent).toBe('안') + }) const secondEditor = screen.getByTestId('agent-input') as HTMLDivElement secondEditor.focus() @@ -347,6 +357,7 @@ describe('WikilinkChatInput', () => { secondEditor.appendChild(document.createTextNode('녕')) fireEvent.input(secondEditor) fireEvent.compositionEnd(secondEditor) + await waitForCompositionFlush() await waitFor(() => { expect(onDraftChange).toHaveBeenLastCalledWith('안녕')