mirror of
https://github.com/langgenius/dify.git
synced 2026-05-09 21:28:25 +08:00
test(plugins): mock stop all task hook
Update the new plugin task hook spec so CI web tests include the Stop All mutation mock.
This commit is contained in:
parent
a4c68ee1fa
commit
6acafc3f52
@ -4,6 +4,7 @@ import { TaskStatus } from '@/app/components/plugins/types'
|
||||
import { usePluginTaskStatus } from '../hooks'
|
||||
|
||||
const mockClearTask = vi.fn().mockResolvedValue({})
|
||||
const mockStopAllTask = vi.fn().mockResolvedValue({})
|
||||
const mockRefetch = vi.fn()
|
||||
|
||||
vi.mock('@/service/use-plugins', () => ({
|
||||
@ -28,6 +29,9 @@ vi.mock('@/service/use-plugins', () => ({
|
||||
useMutationClearTaskPlugin: () => ({
|
||||
mutateAsync: mockClearTask,
|
||||
}),
|
||||
useMutationStopAllTaskPlugins: () => ({
|
||||
mutateAsync: mockStopAllTask,
|
||||
}),
|
||||
}))
|
||||
|
||||
describe('usePluginTaskStatus', () => {
|
||||
@ -74,4 +78,13 @@ describe('usePluginTaskStatus', () => {
|
||||
})
|
||||
expect(mockRefetch).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should handle stop all plugins', async () => {
|
||||
const { result } = renderHook(() => usePluginTaskStatus())
|
||||
|
||||
await result.current.handleStopAllPlugins()
|
||||
|
||||
expect(mockStopAllTask).toHaveBeenCalled()
|
||||
expect(mockRefetch).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user