From e7da213f93f11b1f78a69a113c55a548b0e877ef Mon Sep 17 00:00:00 2001 From: yyh <92089059+lyzno1@users.noreply.github.com> Date: Mon, 10 Aug 2026 10:53:37 +0800 Subject: [PATCH] fix(web): name workflow debug actions (#40273) --- .../__tests__/debug-and-preview.spec.tsx | 95 +++++++++++++++++++ .../panel/debug-and-preview/index.tsx | 16 ++-- 2 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx diff --git a/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx b/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx new file mode 100644 index 00000000000..8e1cf322c6e --- /dev/null +++ b/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx @@ -0,0 +1,95 @@ +import type { Ref } from 'react' +import { screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' +import { useImperativeHandle } from 'react' +import { renderWorkflowComponent } from '@/app/components/workflow/__tests__/workflow-test-env' +import DebugAndPreview from '../index' + +const mockHandleRestart = vi.fn() +const mockHandleNodeCancelRunningStatus = vi.fn() +const mockHandleEdgeCancelRunningStatus = vi.fn() + +vi.mock('reactflow', () => ({ + useNodes: () => [ + { + data: { + type: 'start', + variables: [{ label: 'Topic', variable: 'topic' }], + }, + id: 'start', + }, + ], +})) + +vi.mock('../../../hooks/use-workflow-panel-interactions', () => ({ + useWorkflowInteractions: () => ({ + handleCancelDebugAndPreviewPanel: vi.fn(), + }), +})) + +vi.mock('../../../hooks/use-nodes-interactions-without-sync', () => ({ + useNodesInteractionsWithoutSync: () => ({ + handleNodeCancelRunningStatus: mockHandleNodeCancelRunningStatus, + }), +})) + +vi.mock('../../../hooks/use-edges-interactions-without-sync', () => ({ + useEdgesInteractionsWithoutSync: () => ({ + handleEdgeCancelRunningStatus: mockHandleEdgeCancelRunningStatus, + }), +})) + +vi.mock('../../../nodes/_base/hooks/use-resize-panel', () => ({ + useResizePanel: () => ({ + containerRef: vi.fn(), + triggerRef: vi.fn(), + }), +})) + +vi.mock('../../../persistence/local-storage-options', () => ({ + useSetDebugPreviewPanelWidth: () => vi.fn(), +})) + +vi.mock('../chat-wrapper', () => ({ + default: function MockChatWrapper({ ref }: { ref: Ref<{ handleRestart: () => void }> }) { + useImperativeHandle(ref, () => ({ handleRestart: mockHandleRestart })) + return