mirror of
https://github.com/langgenius/dify.git
synced 2026-10-28 03:35:04 +08:00
test: use happy dom (#34154)
This commit is contained in:
@@ -142,7 +142,7 @@ describe('EndpointCard', () => {
|
||||
failureFlags.disable = false
|
||||
failureFlags.delete = false
|
||||
failureFlags.update = false
|
||||
// Polyfill document.execCommand for copy-to-clipboard in jsdom
|
||||
// Polyfill document.execCommand for copy-to-clipboard in the test DOM runtime
|
||||
if (typeof document.execCommand !== 'function') {
|
||||
document.execCommand = vi.fn().mockReturnValue(true)
|
||||
}
|
||||
|
||||
+11
-2
@@ -102,10 +102,12 @@ vi.mock('@/app/components/base/ui/toast', () => ({
|
||||
}))
|
||||
|
||||
const mockClipboardWriteText = vi.fn()
|
||||
Object.assign(navigator, {
|
||||
clipboard: {
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: mockClipboardWriteText,
|
||||
},
|
||||
configurable: true,
|
||||
writable: true,
|
||||
})
|
||||
|
||||
vi.mock('@/app/components/base/modal/modal', () => ({
|
||||
@@ -192,6 +194,13 @@ describe('OAuthClientSettingsModal', () => {
|
||||
vi.clearAllMocks()
|
||||
mockUsePluginStore.mockReturnValue(mockPluginDetail)
|
||||
mockClipboardWriteText.mockResolvedValue(undefined)
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
value: {
|
||||
writeText: mockClipboardWriteText,
|
||||
},
|
||||
configurable: true,
|
||||
writable: true,
|
||||
})
|
||||
setMockFormValues({
|
||||
values: { client_id: 'test-client-id', client_secret: 'test-client-secret' },
|
||||
isCheckValidated: true,
|
||||
|
||||
Reference in New Issue
Block a user