diff --git a/web/app/components/base/prompt-editor/plugins/hitl-input-block/__tests__/component-ui.spec.tsx b/web/app/components/base/prompt-editor/plugins/hitl-input-block/__tests__/component-ui.spec.tsx index c1c891a5f4..aa97e32509 100644 --- a/web/app/components/base/prompt-editor/plugins/hitl-input-block/__tests__/component-ui.spec.tsx +++ b/web/app/components/base/prompt-editor/plugins/hitl-input-block/__tests__/component-ui.spec.tsx @@ -5,7 +5,8 @@ import type { ValueSelector } from '@/app/components/workflow/types' import { LexicalComposer } from '@lexical/react/LexicalComposer' import { cleanup, fireEvent, render, screen } from '@testing-library/react' -import { BlockEnum, InputVarType } from '@/app/components/workflow/types' +import { BlockEnum, InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types' +import { TransferMethod } from '@/types/app' import HITLInputComponentUI from '../component-ui' import { HITLInputNode } from '../node' @@ -215,7 +216,7 @@ describe('HITLInputComponentUI', () => { }) describe('Default formInput', () => { - it('should pass default payload to InputField when formInput is undefined', async () => { + it('should open an empty default editor when formInput is undefined', async () => { const { findByRole } = renderComponent({ formInput: undefined, }) @@ -223,10 +224,10 @@ describe('HITLInputComponentUI', () => { fireEvent.click(await screen.findByRole('button', { name: 'common.operation.edit' })) const textbox = await findByRole('textbox') + const saveButton = await screen.findByRole('button', { name: 'common.operation.save' }) - fireEvent.click(await screen.findByRole('button', { name: 'common.operation.save' })) - - expect(textbox).toHaveValue('customer_name') + expect(textbox).toHaveValue('') + expect(saveButton).toBeDisabled() }) it('should render variable selector when workflowNodesMap fallback is used', () => { diff --git a/web/app/components/workflow/nodes/human-input/components/__tests__/single-run-form.spec.tsx b/web/app/components/workflow/nodes/human-input/components/__tests__/single-run-form.spec.tsx index 13ec9b346d..0c477a9160 100644 --- a/web/app/components/workflow/nodes/human-input/components/__tests__/single-run-form.spec.tsx +++ b/web/app/components/workflow/nodes/human-input/components/__tests__/single-run-form.spec.tsx @@ -1,4 +1,5 @@ -import type { ReactNode } from 'react' +import type { HumanInputFieldValue } from '@/app/components/base/chat/chat/answer/human-input-content/field-renderer' +import type { FormInputItem } from '@/app/components/workflow/nodes/human-input/types' import type { HumanInputFormData } from '@/types/workflow' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' @@ -12,25 +13,54 @@ vi.mock('react-i18next', () => ({ }), })) -vi.mock('@langgenius/dify-ui/button', () => ({ - Button: ({ - children, - disabled, - onClick, - }: { - children?: ReactNode - disabled?: boolean - onClick?: () => void - }) => ( - - ), -})) - vi.mock('@/app/components/base/chat/chat/answer/human-input-content/content-item', () => ({ __esModule: true, - default: ({ content }: { content: string }) =>
{content}
, + default: ({ + content, + formInputFields, + inputs, + onInputChange, + }: { + content: string + formInputFields: FormInputItem[] + inputs: Record + onInputChange: (name: string, value: HumanInputFieldValue) => void + }) => { + const fieldName = /\{\{#\$output\.([^#]+)#\}\}/.exec(content)?.[1] + if (!fieldName) + return
{content}
+ + const field = formInputFields.find(field => field.output_variable_name === fieldName) + if (!field) + return null + + if (field.type === 'select') { + return ( + + ) + } + + if (field.type === 'paragraph') { + return ( +