import { expect, it } from 'vitest' import { renderToStaticMarkup } from 'react-dom/server' import { parseAIEvidence } from './qaAITypes' import { QAAIEvidenceView } from './QAAI' const wire = { id: 'fixture-local-proof', record_id: 'fixture-record', kind: 'evaluation', state: 'succeeded', stage: 'local_imported', attempt: 1, error_code: '', skip_reason: '', started_at: null, updated_at: '2026-10-20T00:00:00Z', input_hash: 'a'.repeat(64), config_revision: 0, prompt_version: 'qa-local-derivation-v1', dictionary_version: 'qa-approved-labels-v1', actual_model: 'local-rule-history-v1', result: { local_derivations: { language: { value: '中文', kind: 'local_rule', reason: '原问题本地语言规则,不调用模型' }, question_chinese: { value: 'MG400如何连接?', kind: 'original_chinese_copy', reason: '原始中文逐字保留' }, product_category: { value: 'MG400', kind: 'unique_history_question_label', reason: '历史同问题标签唯一一致' }, }, }, applied_fields: { language: '中文', question_chinese: 'MG400如何连接?', product_category: 'MG400' }, skipped_fields: {}, } it('renders field-level local and history provenance without pretending it is model output', () => { const result = parseAIEvidence(wire) expect(result.result).toHaveProperty('local_derivations') const html = renderToStaticMarkup() for (const text of [ '本地规则/历史复用(非模型)', '原问题本地语言规则,不调用模型', '原始中文逐字保留', '历史同问题标签唯一一致', '中文', 'MG400', ]) expect(html).toContain(text) expect(html).not.toContain('实际返回模型') }) it('rejects local provenance falsely attached to a GPT response', () => { expect(() => parseAIEvidence({ ...wire, actual_model: 'gpt-6.1-sol' })).toThrow() })