mirror of
https://github.com/langgenius/dify.git
synced 2026-04-05 11:11:12 +08:00
test: add onBlur behavior test for PromptEditor component
This commit is contained in:
@@ -272,6 +272,28 @@ describe('PromptEditor', () => {
|
||||
expect(onFocus).toHaveBeenCalledTimes(1)
|
||||
expect(onBlur).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should not call onBlur when blur target is var-search-input', () => {
|
||||
const onBlur = vi.fn()
|
||||
const onFocus = vi.fn()
|
||||
|
||||
render(
|
||||
<PromptEditor
|
||||
onFocus={onFocus}
|
||||
onBlur={onBlur}
|
||||
/>,
|
||||
)
|
||||
|
||||
const blurHandler = mocks.commandHandlers.get(BLUR_COMMAND)
|
||||
expect(blurHandler).toBeDefined()
|
||||
|
||||
const varInput = document.createElement('input')
|
||||
varInput.classList.add('var-search-input')
|
||||
|
||||
blurHandler?.({ relatedTarget: varInput } as unknown as ReactFocusEvent<Element>)
|
||||
|
||||
expect(onBlur).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
// Prop typing guard for shortcut popup shape without any-casts.
|
||||
|
||||
Reference in New Issue
Block a user