/* @vitest-environment jsdom */ import { fireEvent, render, screen } from '@testing-library/react'; import { expect, test, vi } from 'vitest'; import { PlatformSelectField, PlatformTextField } from './PlatformTextField'; test('renders shared platform input chrome', () => { const onChange = vi.fn(); render( , ); const input = screen.getByLabelText('作品名称'); fireEvent.change(input, { target: { value: '水果乐园' } }); expect(input.tagName).toBe('INPUT'); expect(input.className).toContain('bg-white/86'); expect(input.className).toContain('text-base'); expect(input.className).toContain( 'focus:border-[var(--platform-surface-hover-border)]', ); expect(input.className).toContain('focus:ring-2'); expect(input.className).toContain('focus:ring-[var(--platform-warm-border)]'); expect(onChange).toHaveBeenCalledTimes(1); }); test('renders shared platform textarea chrome', () => { render( , ); const textarea = screen.getByLabelText('作品描述'); expect(textarea.tagName).toBe('TEXTAREA'); expect(textarea.getAttribute('rows')).toBe('5'); expect(textarea.className).toContain('resize-none'); expect(textarea.className).toContain('leading-6'); }); test('keeps local classes and disabled state', () => { render( , ); const input = screen.getByLabelText('物品名称'); expect(input).toHaveProperty('disabled', true); expect(input.className).toContain('mt-2'); expect(input.className).toContain('disabled:cursor-not-allowed'); }); test('renders compact field chrome', () => { render( , ); const input = screen.getByLabelText('形状名称'); expect(input.className).toContain('rounded-[0.85rem]'); expect(input.className).toContain('bg-white/90'); expect(input.className).toContain('py-2'); }); test('renders roomy textarea chrome', () => { render( , ); const textarea = screen.getByLabelText('作品简介'); expect(textarea.className).toContain('bg-white/90'); expect(textarea.className).toContain('px-4'); expect(textarea.className).toContain('py-3'); expect(textarea.className).toContain('leading-6'); }); test('renders focused field tone variants', () => { render( <> , ); expect(screen.getByLabelText('主题').className).toContain( 'focus:border-rose-200 focus:ring-rose-100', ); expect(screen.getByLabelText('物品').className).toContain( 'focus:border-emerald-200 focus:ring-emerald-100', ); }); test('renders shared platform select chrome', () => { render( , ); const select = screen.getByLabelText('目标洞口'); expect(select.tagName).toBe('SELECT'); expect(select.className).toContain('rounded-[0.85rem]'); expect(select.className).toContain('text-sm'); }); test('renders editor dark input textarea and select chrome', () => { render( <> , ); const input = screen.getByLabelText('角色名字'); const textarea = screen.getByLabelText('聊天草稿'); const select = screen.getByLabelText('生成模式'); expect(input.className).toContain('platform-text-field--editor-dark'); expect(input.className).toContain('bg-black/30'); expect(input.className).toContain('focus:border-emerald-400/40'); expect(textarea.className).toContain('resize-none'); expect(textarea.className).toContain('focus:border-sky-400/40'); expect(select.className).toContain('platform-text-field--editor-dark'); expect(select.className).toContain('focus:border-sky-400/40'); });