diff --git a/web/app/components/base/chat/chat/answer/__tests__/human-input-filled-form-list.spec.tsx b/web/app/components/base/chat/chat/answer/__tests__/human-input-filled-form-list.spec.tsx index 37556550ca..7f874f5e74 100644 --- a/web/app/components/base/chat/chat/answer/__tests__/human-input-filled-form-list.spec.tsx +++ b/web/app/components/base/chat/chat/answer/__tests__/human-input-filled-form-list.spec.tsx @@ -1,5 +1,6 @@ import type { HumanInputFilledFormData } from '@/types/workflow' import { render, screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' import { describe, expect, it } from 'vitest' import HumanInputFilledFormList from '../human-input-filled-form-list' @@ -12,13 +13,15 @@ const createFormData = ( ): HumanInputFilledFormData => ({ node_id: 'node-1', node_title: 'Node Title', + rendered_content: 'fallback content', + action_id: 'approve', + action_text: 'Approve', + form_data: { + summary: 'Approved', + }, - // 👇 IMPORTANT - // DO NOT guess properties like `inputs` - // Only include fields that actually exist in your project type. - // Leave everything else empty via spread. ...overrides, -} as HumanInputFilledFormData) +}) describe('HumanInputFilledFormList', () => { it('renders nothing when list is empty', () => { @@ -27,12 +30,15 @@ describe('HumanInputFilledFormList', () => { expect(screen.queryByText('Node Title')).not.toBeInTheDocument() }) - it('renders one form item', () => { + it('renders one form item', async () => { + const user = userEvent.setup() const data = [createFormData()] render() expect(screen.getByText('Node Title')).toBeInTheDocument() + await user.click(screen.getByTestId('expand-icon')) + expect(screen.getByTestId('submitted-field-summary')).toHaveTextContent('Approved') }) it('renders multiple form items', () => { diff --git a/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx b/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx index e3d0557180..53e7e87b74 100644 --- a/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx +++ b/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx @@ -9,6 +9,9 @@ const createFilledForm = (overrides: Partial = {}): Hu rendered_content: 'Approved by Alice', action_id: 'approve', action_text: 'Approve', + form_data: { + summary: 'Approved by Alice', + }, ...overrides, }) @@ -33,11 +36,13 @@ describe('HumanInputFilledFormList', () => { expect(screen.getByText('Approval'))!.toBeInTheDocument() expect(screen.getByText('Review'))!.toBeInTheDocument() - expect(screen.getAllByTestId('submitted-content')).toHaveLength(2) + expect(screen.getAllByTestId('submitted-field-values')).toHaveLength(2) expect(screen.getAllByTestId('executed-action')).toHaveLength(2) + expect(screen.getAllByTestId('submitted-field-summary')).toHaveLength(2) + expect(screen.getAllByTestId('submitted-field-summary')[0]).toHaveTextContent('Approved by Alice') await user.click(screen.getAllByTestId('expand-icon')[0]!) - expect(screen.getAllByTestId('submitted-content')).toHaveLength(1) + expect(screen.getAllByTestId('submitted-field-values')).toHaveLength(1) }) }) diff --git a/web/app/components/workflow/panel/__tests__/workflow-preview.spec.tsx b/web/app/components/workflow/panel/__tests__/workflow-preview.spec.tsx index 9b5f89ebd0..87c78cabc7 100644 --- a/web/app/components/workflow/panel/__tests__/workflow-preview.spec.tsx +++ b/web/app/components/workflow/panel/__tests__/workflow-preview.spec.tsx @@ -1,4 +1,5 @@ import type { Shape } from '../../store/workflow' +import type { HumanInputFieldValue } from '@/app/components/base/chat/chat/answer/human-input-content/field-renderer' import type { HumanInputFilledFormData, HumanInputFormData } from '@/types/workflow' import { toast } from '@langgenius/dify-ui/toast' import { fireEvent, screen, waitFor } from '@testing-library/react' @@ -84,11 +85,11 @@ vi.mock('@/app/components/workflow/panel/human-input-form-list', () => ({ onHumanInputFormSubmit, }: { humanInputFormDataList: unknown[] - onHumanInputFormSubmit?: (token: string, formData: Record) => Promise + onHumanInputFormSubmit?: (token: string, formData: { inputs: Record, action: string }) => Promise }) => (
{humanInputFormDataList.length}
-
@@ -236,7 +237,7 @@ describe('WorkflowPreview', () => { expect(screen.getByTestId('filled-form-list')).toHaveTextContent('1') await user.click(screen.getByRole('button', { name: 'submit-human-form' })) - expect(mockSubmitHumanInputForm).toHaveBeenCalledWith('form-token', { answer: 'ok' }) + expect(mockSubmitHumanInputForm).toHaveBeenCalledWith('form-token', { inputs: { answer: 'ok' }, action: 'approve' }) }) it('should copy successful string output and show a success toast', async () => {