Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat(tests): add mock for useInvalidateWorkflowRunHistory in pipeline run tests (#32234)

Wu Tianwei5b4c7b2a4002
diff --git a/web/app/components/rag-pipeline/hooks/use-pipeline-run.spec.ts b/web/app/components/rag-pipeline/hooks/use-pipeline-run.spec.ts
index 2b210018395..c8a4a0ebb70 100644
--- a/web/app/components/rag-pipeline/hooks/use-pipeline-run.spec.ts
+++ b/web/app/components/rag-pipeline/hooks/use-pipeline-run.spec.ts
@@ -92,8 +92,10 @@ vi.mock('@/service/workflow', () => ({
}))
const mockInvalidAllLastRun = vi.fn()
+const mockInvalidateRunHistory = vi.fn()
vi.mock('@/service/use-workflow', () => ({
useInvalidAllLastRun: () => mockInvalidAllLastRun,
+ useInvalidateWorkflowRunHistory: () => mockInvalidateRunHistory,
}))
// Mock FlowType
@@ -472,6 +474,7 @@ describe('usePipelineRun', () => {
})
expect(onWorkflowStarted).toHaveBeenCalledWith({ task_id: 'task-1' })
+ expect(mockInvalidateRunHistory).toHaveBeenCalled()
})
it('should call onWorkflowFinished callback when provided', async () => {
@@ -493,6 +496,7 @@ describe('usePipelineRun', () => {
})
expect(onWorkflowFinished).toHaveBeenCalledWith({ status: 'succeeded' })
+ expect(mockInvalidateRunHistory).toHaveBeenCalled()
})
it('should call onError callback when provided', async () => {
@@ -514,6 +518,7 @@ describe('usePipelineRun', () => {
})
expect(onError).toHaveBeenCalledWith({ message: 'error' })
+ expect(mockInvalidateRunHistory).toHaveBeenCalled()
})
it('should call onNodeStarted callback when provided', async () => {
diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json
index 9293446c0c7..a939fd7d2f5 100644
--- a/web/eslint-suppressions.json
+++ b/web/eslint-suppressions.json
@@ -2299,7 +2299,7 @@
},
"app/components/base/markdown-blocks/code-block.tsx": {
"react-hooks-extra/no-direct-set-state-in-use-effect": {
- "count": 10
+ "count": 7
},
"tailwindcss/enforce-consistent-class-order": {
"count": 1