From 425fe17be38b61768deb7b62c55cb810eef7d0db Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Tue, 27 Jan 2026 13:08:48 +0800 Subject: [PATCH] test: add comprehensive tests for chat-user-input component Coverage: 97.36% statements, 93.47% branches, 100% functions --- .../debug/chat-user-input.spec.tsx | 710 ++++++++++++++++++ 1 file changed, 710 insertions(+) create mode 100644 web/app/components/app/configuration/debug/chat-user-input.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 + }) => ( +