import { it, expect } from 'vitest' import { renderToStaticMarkup } from 'react-dom/server' import { QAModelSettings, qaAIKeyEntryAllowed } from './QAModelSettings' it('provides independent write-only model settings and does not equate save with bulk execution', () => { const html = renderToStaticMarkup( ) for (const text of [ '问答评估模型', 'API 基础地址', '模型名称', 'API Key', 'type="password"', '测试连接', '保存配置', '保留现有密钥', '更换密钥', '清除密钥', '保存不会启动全量评估', ]) expect(html).toContain(text) expect(html).not.toContain('value="fixture-only-api-key"') }) it('permits new-key entry only on HTTPS or browser-local loopback origins', () => { expect(qaAIKeyEntryAllowed({ protocol: 'https:', hostname: 'kg.example.invalid' })).toBe(true) expect(qaAIKeyEntryAllowed({ protocol: 'http:', hostname: 'localhost' })).toBe(true) expect(qaAIKeyEntryAllowed({ protocol: 'http:', hostname: '192.168.1.2' })).toBe(false) })