Compare commits

...
Author SHA1 Message Date
crazywoola fe676f6797 fix missing answer workflow preview 2026-07-21 10:49:09 +08:00
2 changed files with 10 additions and 3 deletions
@@ -1,5 +1,4 @@
'use client'
import type { FC } from 'react'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { VariableLabelInText } from '@/app/components/workflow/nodes/_base/components/variable/variable-label'
@@ -9,13 +8,13 @@ import { getNodeInfoById, isSystemVar } from './variable/utils'
type Props = Readonly<{
nodeId: string
value: string
value?: string
className?: string
}>
const VAR_PLACEHOLDER = '@#!@#!'
const ReadonlyInputWithSelectVar: FC<Props> = ({ nodeId, value, className }) => {
function ReadonlyInputWithSelectVar({ nodeId, value = '', className }: Props) {
const { getBeforeNodesInSameBranchIncludeParent } = useWorkflow()
const availableNodes = getBeforeNodesInSameBranchIncludeParent(nodeId)
const startNode = availableNodes.find((node: any) => {
@@ -61,4 +60,5 @@ const ReadonlyInputWithSelectVar: FC<Props> = ({ nodeId, value, className }) =>
return <div className={cn('text-xs break-all', className)}>{res}</div>
}
export default React.memo(ReadonlyInputWithSelectVar)
@@ -42,6 +42,13 @@ describe('AnswerNode', () => {
expect(screen.getByText('Plain answer')).toBeInTheDocument()
})
it('should render an empty panel when a saved answer is missing', () => {
renderNodeComponent(Node, createNodeData({ answer: undefined }))
expect(screen.getByText('workflow.nodes.answer.answer')).toBeInTheDocument()
expect(screen.queryByText('Plain answer')).not.toBeInTheDocument()
})
it('should render referenced variables inside the readonly content', () => {
mockUseWorkflow.mockReturnValue({
getBeforeNodesInSameBranchIncludeParent: () => [