test: stabilize wikilink ime composition test

This commit is contained in:
lucaronin
2026-06-06 03:50:51 +02:00
parent 8d47b8d7d2
commit e3ef3f6073

View File

@@ -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('안녕')