import { acceptingModels, validateLegalApproval } from './legal-validation' const review = (model: string, verdict = 'approve', reviewedAt = '2026-09-29', result = '| Section | … |') => ({ model, verdict, reviewedAt, result, }) const approve = (reviews: ReturnType[]) => validateLegalApproval('approved', { siblingData: { legalValidation: { reviews } } }) describe('legal approval rule (MITHOME-113)', () => { it('should accept two distinct models with complete, non-rejecting reviews', () => { expect(approve([review('Claude Opus 5.5'), review('GPT-5', 'approve-with-changes')])).toBe(true) }) it('should not count the same model twice (case- and space-insensitive)', () => { expect(approve([review('Claude Opus 5.5'), review(' claude opus 5.5 ')])).toEqual(expect.stringContaining('Jelenleg: 1')) }) it('should ignore incomplete reviews (no pasted answer)', () => { expect(approve([review('Claude Opus 5.5'), review('GPT-5', 'approve', '2026-09-29', ' ')])).toEqual(expect.any(String)) }) it('should not count a model whose latest verdict is reject', () => { expect(approve([review('Claude Opus 5.5'), review('GPT-5', 'reject')])).toEqual(expect.any(String)) }) it('should let a newer review of the same model supersede its rejection', () => { const reviews = [review('GPT-5', 'reject', '2026-09-28'), review('GPT-5', 'approve', '2026-09-30'), review('Claude Opus 5.5')] expect(acceptingModels({ reviews })).toEqual(['GPT-5', 'Claude Opus 5.5']) expect(approve(reviews)).toBe(true) }) it('should keep an older approval superseded by a newer rejection out', () => { expect(acceptingModels({ reviews: [review('GPT-5', 'approve', '2026-09-28'), review('GPT-5', 'reject', '2026-09-30')] })).toEqual([]) }) it.each(['none', 'ai-draft', undefined])('should not require reviews for status %s', (status) => { expect(validateLegalApproval(status, { siblingData: {} })).toBe(true) }) it('should handle a missing record', () => { expect(acceptingModels(undefined)).toEqual([]) }) })