import { describe, expect, it } from 'vitest'; import type { FindingRecord } from '../../src/domain/finding'; import { recordTitleFor } from '../../src/features/dataset-viewer/record-title'; function record(fields: Array<[string, string]>, title = 'fallback'): FindingRecord { return { id: 'synthetic-record', index: 0, title, fields: fields.map(([label, value], index) => ({ label, value, index })), filled: [], meta: [] }; } describe('mixed Work record titles', () => { it('uses the Defender CVE instead of the device name selected by the generic aggregate profile', () => { const defender = record([ ['Source: Scan', 'Microsoft Defender for IoT · 2026-09-10T08:00:00.000Z'], ['Name', '10.0.0.42'], ['CVE', 'CVE-2026-4242'] ]); expect(recordTitleFor(defender, 'Name', 'generic')).toBe('CVE-2026-4242'); }); it('keeps the GPO title when the aggregate title column is empty on the GPO row', () => { const gpo = record([ ['Source: Scan', 'GPOs · 2026-09-10T08:00:00.000Z'], ['Name', ''], ['Title', 'Synthetic policy setting'] ], 'Synthetic policy setting'); expect(recordTitleFor(gpo, 'Name', 'generic')).toBe('Synthetic policy setting'); }); it('keeps the selected title column for records without a tool-specific title field', () => { const generic = record([['Name', 'Synthetic finding'], ['Value', '42']]); expect(recordTitleFor(generic, 'Name', 'generic')).toBe('Synthetic finding'); }); });