80 lines
4.4 KiB
TypeScript
80 lines
4.4 KiB
TypeScript
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { PolicyAnalysisPanelView } from '../../src/features/project-import/PolicyAnalysisPanel';
|
|
import type { PolicyAnalysisOverview } from '../../src/domain/policy-analysis-overview';
|
|
|
|
const overview: PolicyAnalysisOverview = {
|
|
version: 1,
|
|
projectId: 'synthetic-project',
|
|
generatedAt: '2026-08-04T15:00:00.000Z',
|
|
summary: {
|
|
identityAnalysisRuns: 1, aggregationRuns: 1, evaluationRuns: 1, findingRuns: 1,
|
|
configuredMatches: 0, confirmedDeviations: 1, notApplicable: 0, policyFindings: 0,
|
|
reviewItems: 2, conflicts: 1, unresolvedIdentities: 0, catalogGaps: 1, parserGaps: 0, partialRuns: 1
|
|
},
|
|
current: {
|
|
version: 1,
|
|
summary: {
|
|
identityAnalysisRuns: 1, aggregationRuns: 1, evaluationRuns: 1, findingRuns: 1,
|
|
configuredMatches: 0, confirmedDeviations: 1, notApplicable: 0, policyFindings: 0,
|
|
reviewItems: 2, conflicts: 1, unresolvedIdentities: 0, catalogGaps: 1, parserGaps: 0, partialRuns: 1
|
|
},
|
|
evaluationRunIds: ['evaluation-1'], findingRunIds: ['finding-run-1'], reviewItems: [{
|
|
version: 1, id: 'review-1', category: 'conflict', source: 'snapshot-aggregation', sourceRunId: 'aggregation-1',
|
|
identityId: 'technical-identity-1', codes: ['policy-snapshot-customer-conflict'], observationCount: 2, backupCount: 2
|
|
}, {
|
|
version: 1, id: 'review-2', category: 'catalog-gap', source: 'policy-evaluation', sourceRunId: 'evaluation-1',
|
|
codes: ['policy-evaluation-baseline-missing'], observationCount: 1, backupCount: 1
|
|
}]
|
|
},
|
|
actions: { version: 1, reprocess: [], aggregate: [], evaluate: [], createFindings: [] },
|
|
profiles: [{ version: 1, id: 'profile-1', name: 'Synthetic Windows', revision: 1, active: true, contextCount: 1 }],
|
|
evaluations: [{
|
|
version: 1, evaluationRunId: 'evaluation-1', environmentProfileId: 'profile-1', status: 'partial',
|
|
completedAt: '2026-08-04T15:00:00.000Z', matchCount: 0, deviationCount: 1,
|
|
notApplicableCount: 0, reviewCount: 2, findingCount: 0, rejectedFindingCount: 0
|
|
}],
|
|
reviewItems: [{
|
|
version: 1, id: 'review-1', category: 'conflict', source: 'snapshot-aggregation', sourceRunId: 'aggregation-1',
|
|
identityId: 'technical-identity-1', codes: ['policy-snapshot-customer-conflict'], observationCount: 2, backupCount: 2
|
|
}, {
|
|
version: 1, id: 'review-2', category: 'catalog-gap', source: 'policy-evaluation', sourceRunId: 'evaluation-1',
|
|
codes: ['policy-evaluation-baseline-missing'], observationCount: 1, backupCount: 1
|
|
}]
|
|
};
|
|
|
|
describe('PolicyAnalysisPanelView', () => {
|
|
it('shows absent settings separately without inflating misconfiguration or GPO impact counts', () => {
|
|
const html = renderToStaticMarkup(<PolicyAnalysisPanelView overview={overview}
|
|
counts={{ Fail: 2, Pass: 4, Conflicts: 1, Duplicates: 1, 'Not configured': 3000 }}
|
|
impact={{ settings: 1, backups: 2 }}/>);
|
|
expect(html).toContain('<span>Misconfigured</span><strong>2</strong>');
|
|
expect(html).toContain('<span>Not configured</span><strong>3000</strong>');
|
|
expect(html).toContain('<span>Misconfigured settings</span><strong>1</strong>');
|
|
expect(html).toContain('<span>Affected GPO backups</span><strong>2</strong>');
|
|
});
|
|
|
|
it('leads with concise import, baseline-result, and issue summaries while keeping diagnostics optional', () => {
|
|
const html = renderToStaticMarkup(<PolicyAnalysisPanelView overview={overview}/>);
|
|
|
|
expect(html).toContain('Effective application requires RSoP or GP Results');
|
|
expect(html).toContain('GPO sources');
|
|
expect(html).toContain('Baseline results');
|
|
expect(html).toContain('Misconfigured');
|
|
expect(html).toContain('Not configured');
|
|
expect(html).toContain('Duplicates');
|
|
expect(html).toContain('Baseline comparisons');
|
|
expect(html).toContain('Affected GPO backups');
|
|
expect(html).toContain('Import issues');
|
|
expect(html).toContain('Different customer values for the same setting');
|
|
expect(html).toContain('<details class="policy-analysis-technical"><summary>Technical details</summary>');
|
|
expect(html).toContain('Evaluation history');
|
|
expect(html).toContain('Current review queue');
|
|
expect(html).toContain('Conflict');
|
|
expect(html).toContain('Baseline mapping unavailable');
|
|
expect(html).toContain('policy-evaluation-baseline-missing');
|
|
expect(html).not.toContain('Confirmed policy findings');
|
|
expect(html).not.toContain('Severity');
|
|
});
|
|
});
|