mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 09:28:04 +08:00
add @testing-library/user-event and create tests for external-knowledge-base/ (#29323)
Co-authored-by: CodingOnStar <hanxujiang@dify.ai> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,19 @@
|
||||
import '@testing-library/jest-dom'
|
||||
import { cleanup } from '@testing-library/react'
|
||||
|
||||
// Fix for @headlessui/react compatibility with happy-dom
|
||||
// headlessui tries to set focus property which is read-only in happy-dom
|
||||
if (typeof window !== 'undefined') {
|
||||
// Ensure window.focus is writable for headlessui
|
||||
if (!Object.getOwnPropertyDescriptor(window, 'focus')?.writable) {
|
||||
Object.defineProperty(window, 'focus', {
|
||||
value: jest.fn(),
|
||||
writable: true,
|
||||
configurable: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user