From 11259617fa64ec761a3134a9f1f46057f6cec139 Mon Sep 17 00:00:00 2001 From: Coding On Star <447357187@qq.com> Date: Tue, 27 Jan 2026 20:02:49 +0800 Subject: [PATCH] test: add comprehensive tests for chat-user-input component (#31595) Co-authored-by: CodingOnStar Co-authored-by: CodingOnStar --- .../debug/chat-user-input.spec.tsx | 710 +++++++++++++++++ .../chat-item.spec.tsx | 641 ++++++++++++++++ .../context.spec.tsx | 224 ++++++ .../debug-item.spec.tsx | 552 ++++++++++++++ .../model-parameter-trigger.spec.tsx | 405 ++++++++++ .../text-generation-item.spec.tsx | 721 ++++++++++++++++++ .../create/website/watercrawl/index.spec.tsx | 6 + 7 files changed, 3259 insertions(+) create mode 100644 web/app/components/app/configuration/debug/chat-user-input.spec.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/chat-item.spec.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/context.spec.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/debug-item.spec.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/model-parameter-trigger.spec.tsx create mode 100644 web/app/components/app/configuration/debug/debug-with-multiple-model/text-generation-item.spec.tsx diff --git a/web/app/components/app/configuration/debug/chat-user-input.spec.tsx b/web/app/components/app/configuration/debug/chat-user-input.spec.tsx new file mode 100644 index 0000000000..e6678ebf29 --- /dev/null +++ b/web/app/components/app/configuration/debug/chat-user-input.spec.tsx @@ -0,0 +1,710 @@ +import type { Inputs, ModelConfig } from '@/models/debug' +import type { PromptVariable } from '@/types/app' +import { fireEvent, render, screen } from '@testing-library/react' +import ChatUserInput from './chat-user-input' + +const mockSetInputs = vi.fn() +const mockUseContext = vi.fn() + +vi.mock('react-i18next', () => ({ + useTranslation: () => ({ + t: (key: string) => key, + }), +})) + +vi.mock('use-context-selector', () => ({ + useContext: () => mockUseContext(), + createContext: vi.fn(() => ({})), +})) + +vi.mock('@/app/components/base/input', () => ({ + default: ({ value, onChange, placeholder, autoFocus, maxLength, readOnly, type }: { + value: string + onChange: (e: { target: { value: string } }) => void + placeholder?: string + autoFocus?: boolean + maxLength?: number + readOnly?: boolean + type?: string + }) => ( + + ), +})) + +vi.mock('@/app/components/base/select', () => ({ + default: ({ defaultValue, onSelect, items, disabled, className }: { + defaultValue: string + onSelect: (item: { value: string }) => void + items: { name: string, value: string }[] + allowSearch?: boolean + disabled?: boolean + className?: string + }) => ( + + ), +})) + +vi.mock('@/app/components/base/textarea', () => ({ + default: ({ value, onChange, placeholder, readOnly, className }: { + value: string + onChange: (e: { target: { value: string } }) => void + placeholder?: string + readOnly?: boolean + className?: string + }) => ( +