mirror of
https://github.com/langgenius/dify.git
synced 2026-08-29 00:16:50 +08:00
broadcast workflow updates after DSL import
This commit is contained in:
parent
5e0e0982bc
commit
df5d3a6dbc
@ -17,6 +17,7 @@ class MockFileReader {
|
||||
|
||||
vi.stubGlobal('FileReader', MockFileReader as unknown as typeof FileReader)
|
||||
const mockEmit = vi.fn()
|
||||
const mockEmitWorkflowUpdate = vi.hoisted(() => vi.fn())
|
||||
|
||||
vi.mock('@/app/components/base/ui/toast', () => ({
|
||||
toast: {
|
||||
@ -39,6 +40,12 @@ vi.mock('@/service/workflow', () => ({
|
||||
fetchWorkflowDraft: (path: string) => mockFetchWorkflowDraft(path),
|
||||
}))
|
||||
|
||||
vi.mock('../collaboration/core/collaboration-manager', () => ({
|
||||
collaborationManager: {
|
||||
emitWorkflowUpdate: mockEmitWorkflowUpdate,
|
||||
},
|
||||
}))
|
||||
|
||||
const mockHandleCheckPluginDependencies = vi.fn()
|
||||
vi.mock('@/app/components/workflow/plugin-dependency/hooks', () => ({
|
||||
usePluginDependencies: () => ({
|
||||
@ -138,6 +145,7 @@ describe('UpdateDSLModal', () => {
|
||||
expect(mockEmit).toHaveBeenCalledWith(expect.objectContaining({
|
||||
type: 'WORKFLOW_DATA_UPDATE',
|
||||
}))
|
||||
expect(mockEmitWorkflowUpdate).toHaveBeenCalledWith('app-1')
|
||||
expect(defaultProps.onImport).toHaveBeenCalledTimes(1)
|
||||
expect(defaultProps.onCancel).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
@ -187,6 +195,7 @@ describe('UpdateDSLModal', () => {
|
||||
await waitFor(() => {
|
||||
expect(mockImportDSLConfirm).toHaveBeenCalledWith({ import_id: 'import-2' })
|
||||
})
|
||||
expect(mockEmitWorkflowUpdate).toHaveBeenCalledWith('app-1')
|
||||
})
|
||||
|
||||
it('should open the pending modal after the timeout and allow dismissing it', async () => {
|
||||
|
||||
@ -114,6 +114,7 @@ const UpdateDSLModal = ({
|
||||
}
|
||||
|
||||
await handleWorkflowUpdate(appId)
|
||||
collaborationManager.emitWorkflowUpdate(appId)
|
||||
onImport?.()
|
||||
const payload = getImportNotificationPayload(status, t)
|
||||
toast[payload.type](payload.message, payload.children ? { description: payload.children } : undefined)
|
||||
@ -183,9 +184,6 @@ const UpdateDSLModal = ({
|
||||
|
||||
if (isImportCompleted(status)) {
|
||||
await handleCompletedImport(status, app_id)
|
||||
// Notify other collaboration clients about the workflow update
|
||||
if (app_id)
|
||||
collaborationManager.emitWorkflowUpdate(app_id)
|
||||
}
|
||||
else if (status === DSLImportStatus.FAILED) {
|
||||
setLoading(false)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user