Assessor_2.0/tests/features/ai-overview-panel.test.tsx

28 lines
1.5 KiB
TypeScript

import { renderToStaticMarkup } from 'react-dom/server';
import { describe, expect, it } from 'vitest';
import { AiOverviewResultView } from '../../src/features/dashboard/AiOverviewPanel';
import { validAiOverviewResult } from '../fixtures/ai-overview';
import { readFileSync } from 'node:fs';
describe('Client Info AI Overview', () => {
it('renders every section of the validated output contract as text', () => {
const html = renderToStaticMarkup(<AiOverviewResultView
result={validAiOverviewResult()} generatedAt="2026-09-14T08:00:00.000Z" model="work-model" />);
for (const heading of ['Executive summary', 'Environment overview', 'Security themes', 'Priorities',
'Five-phase roadmap', 'Coverage gaps', 'Quick wins', 'Questions', 'Assumptions']) {
expect(html).toContain(heading);
}
expect(html).toContain('Synthetic executive summary.');
expect(html).toContain('RULE-1');
expect(html).toContain('Advisory AI output');
});
it('adds the AI tab to standard, Defender-only, and mixed Client Info compositions', () => {
const dashboard = readFileSync(new URL('../../src/features/dashboard/DashboardPanel.tsx', import.meta.url), 'utf8');
expect(dashboard).toContain("...(pureDefender ? [] : [['overview', 'Overview'] as const])");
expect(dashboard).toContain("...(hasDefender ? [['defender', 'Microsoft Defender for IoT'] as const] : [])");
expect(dashboard).toContain("...(showAiOverview ? [['ai', 'AI Overview'] as const] : [])");
expect(dashboard).toContain("clientInfoView === 'ai'");
});
});