From b914e48a41f1a47086f8b792f58724f83462ba36 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 30 Apr 2026 12:30:22 +0800 Subject: [PATCH] fix(web): add toast for workflow switch --- .../components/app/app-publisher/__tests__/index.spec.tsx | 6 ++++++ .../app/app-publisher/use-workflow-type-switch.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/web/app/components/app/app-publisher/__tests__/index.spec.tsx b/web/app/components/app/app-publisher/__tests__/index.spec.tsx index cae41f7005..f33404efc3 100644 --- a/web/app/components/app/app-publisher/__tests__/index.spec.tsx +++ b/web/app/components/app/app-publisher/__tests__/index.spec.tsx @@ -20,6 +20,7 @@ const mockOpenAsyncWindow = vi.fn() const mockFetchInstalledAppList = vi.fn() const mockFetchAppDetailDirect = vi.fn() const mockToastError = vi.fn() +const mockToastSuccess = vi.fn() const mockConvertWorkflowType = vi.fn() const mockRefetchEvaluationWorkflowAssociatedTargets = vi.fn() const mockInvalidateAppWorkflow = vi.fn() @@ -120,6 +121,7 @@ vi.mock('@/service/use-workflow', () => ({ vi.mock('@langgenius/dify-ui/toast', () => ({ toast: { error: (...args: unknown[]) => mockToastError(...args), + success: (...args: unknown[]) => mockToastSuccess(...args), }, })) @@ -586,6 +588,7 @@ describe('AppPublisher', () => { id: 'app-1', workflow_kind: AppTypeEnum.EVALUATION, }) + expect(mockToastSuccess).toHaveBeenCalledWith('api.actionSuccess') }) await waitFor(() => { expect(screen.queryByText('publisher-summary-publish')).not.toBeInTheDocument() @@ -620,6 +623,7 @@ describe('AppPublisher', () => { id: 'app-1', workflow_kind: AppTypeEnum.EVALUATION, }) + expect(mockToastSuccess).toHaveBeenCalledWith('api.actionSuccess') }) }) @@ -695,6 +699,7 @@ describe('AppPublisher', () => { params: { appId: 'app-1' }, query: { target_type: AppTypeEnum.WORKFLOW }, }) + expect(mockToastSuccess).toHaveBeenCalledWith('api.actionSuccess') }) }) @@ -719,6 +724,7 @@ describe('AppPublisher', () => { params: { appId: 'app-1' }, query: { target_type: AppTypeEnum.WORKFLOW }, }) + expect(mockToastSuccess).toHaveBeenCalledWith('api.actionSuccess') }) expect(screen.queryByText('common.switchToStandardWorkflowConfirm.title')).not.toBeInTheDocument() }) diff --git a/web/app/components/app/app-publisher/use-workflow-type-switch.ts b/web/app/components/app/app-publisher/use-workflow-type-switch.ts index db5c37d73f..25e633877a 100644 --- a/web/app/components/app/app-publisher/use-workflow-type-switch.ts +++ b/web/app/components/app/app-publisher/use-workflow-type-switch.ts @@ -131,6 +131,7 @@ export const useWorkflowTypeSwitch = ({ }) setAppDetail(latestAppDetail) resetEvaluationWorkflowSwitchConfirm() + toast.success(t('api.actionSuccess', { ns: 'common' })) return true } @@ -150,6 +151,7 @@ export const useWorkflowTypeSwitch = ({ setAppDetail(latestAppDetail) onPublishedSwitch() resetEvaluationWorkflowSwitchConfirm() + toast.success(t('api.actionSuccess', { ns: 'common' })) return true } catch { @@ -164,6 +166,7 @@ export const useWorkflowTypeSwitch = ({ publishedAt, resetEvaluationWorkflowSwitchConfirm, setAppDetail, + t, workflowTypeSwitchConfig, ])