import { describe, expect, it } from 'vitest'; import type { FindingRecord } from '../../src/domain/finding'; import { resultSheetRowToneFor } from '../../src/features/linked-results/result-message'; /** Synthetic result-table row with the given cells. */ function row(...cells: string[]): FindingRecord { const fields = cells.map((value, index) => ({ label: `Column ${index + 1}`, value, index })); return { id: cells.join('|'), index: 0, title: cells[0] ?? '', fields, filled: fields, meta: [] }; } describe('source-proven row status in Results', () => { it('colors Maester rows only from explicit per-row status markers', () => { expect(resultSheetRowToneFor('maester', row('Synthetic policy A', '✅ Enabled'))).toBe('match'); expect(resultSheetRowToneFor('maester', row('Synthetic policy B', '❌ Disabled'))).toBe('violation'); expect(resultSheetRowToneFor('maester', row('Synthetic policy C', 'Passed'))).toBe('match'); expect(resultSheetRowToneFor('maester', row('Synthetic policy D', 'Fail'))).toBe('violation'); expect(resultSheetRowToneFor('maester', row('Synthetic policy E', ':white_check_mark:'))).toBe('match'); // No marker, a marker inside prose, or contradicting markers prove nothing. expect(resultSheetRowToneFor('maester', row('Synthetic policy F', 'Enabled'))).toBeUndefined(); expect(resultSheetRowToneFor('maester', row('Synthetic Fail-safe policy', 'Report-only'))).toBeUndefined(); expect(resultSheetRowToneFor('maester', row('✅ Synthetic', '❌ Synthetic'))).toBeUndefined(); }); it('keeps other scanners unchanged', () => { expect(resultSheetRowToneFor('pingcastle', row('Synthetic object', '❌'))).toBeUndefined(); expect(resultSheetRowToneFor('purple-knight', row('Synthetic object', 'Failed'))).toBeUndefined(); const evaluated = { ...row('Synthetic item', 'Synthetic value'), highlighted: true }; expect(resultSheetRowToneFor('cis-cat', evaluated, 'pass')).toBe('match'); expect(resultSheetRowToneFor('cis-cat', evaluated, 'fail')).toBe('violation'); }); });