Assessor_2.0/tests/features/record-title.test.ts

29 lines
1.1 KiB
TypeScript

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 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');
});
});