import { describe, expect, it } from 'vitest' import { buildAdjudicationPresentation, resolvePoseAssetId } from './narrativeRepository.js' describe('resolvePoseAssetId', () => { const poses = { neutral: 'asset-neutral', concerned: 'asset-concerned', missing: null } it('returns the requested pose asset when present', () => { expect(resolvePoseAssetId(poses, 'concerned', 'neutral')).toBe('asset-concerned') }) it('falls back to the NPC default pose when the requested pose is absent', () => { expect(resolvePoseAssetId(poses, 'pointing', 'neutral')).toBe('asset-neutral') }) it('falls back to the default when the requested pose exists but has no artwork', () => { expect(resolvePoseAssetId(poses, 'missing', 'neutral')).toBe('asset-neutral') }) it('returns null (no artwork) when neither requested nor default resolves', () => { expect(resolvePoseAssetId(poses, 'pointing', 'also-missing')).toBeNull() expect(resolvePoseAssetId(poses, null, null)).toBeNull() expect(resolvePoseAssetId({}, 'neutral', 'neutral')).toBeNull() }) }) describe('buildAdjudicationPresentation', () => { it('presents only evidence accepted by the submitted report', () => { const presentation = buildAdjudicationPresentation({ title: 'Barricelli Inventor Finding', investigatorName: 'Mutable byline', requiredForCompletion: true, status: 'accepted', issues: [], claims: [{ claimExhibitId: 'claim-1', statement: 'Nils Aall Barricelli was an inventor.', evidence: [ { connectionId: 'connection-1', documentExhibitId: 'document-1', displayNumber: 1, documentTitle: 'Patent record', fileType: 'image', relationText: 'Proves that Barricelli filed a patent.', publishedAt: '1953-08-19T00:00:00.000Z', sourceCitation: 'Google Patents', sourceUri: 'https://patents.example/1', evidenceAccepted: true, verification: { status: 'accepted', detail: 'Matched.' } }, { connectionId: 'connection-2', documentExhibitId: 'document-2', displayNumber: 2, documentTitle: 'Unverified image', fileType: 'image', relationText: 'Maybe related.', evidenceAccepted: false, verification: { status: 'not_evaluated', detail: 'Not checked.' } }, ] }], }, { investigatorName: 'Ada Investigator', submittedAt: new Date('2026-08-23T12:00:00.000Z') }) expect(presentation).toMatchObject({ kind: 'case-adjudication', investigatorName: 'Ada Investigator', submittedAt: '2026-08-23T12:00:00.000Z', finding: 'SUPPORTED BY THE SUBMITTED EVIDENCE', stampText: 'CASE VERIFIED', claims: [{ statement: 'Nils Aall Barricelli was an inventor.', evidence: [{ displayNumber: 1, title: 'Patent record' }] }], }) expect(presentation.claims[0].evidence).toHaveLength(1) }) })