31 lines
2.4 KiB
TypeScript
31 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { dashboardEnvironmentDetail, dashboardMaesterTenantCount } from '../../src/features/dashboard/DashboardPanel';
|
|
import { maesterEnvironmentContext } from '../../src/importers/maester-environment-context';
|
|
import type { EnvironmentSnapshot } from '../../src/domain/environment-context';
|
|
|
|
describe('Maester context presentation', () => {
|
|
const context = maesterEnvironmentContext('synthetic.html', {
|
|
TenantId: 'tenant-1', TenantName: 'Synthetic tenant', CurrentVersion: '1.2', ExecutedAt: '2026-09-09T08:00:00Z',
|
|
TotalDuration: '00:00:05', Tests: [], SystemInfo: { OSDescription: 'Synthetic scanner OS', MachineName: 'Synthetic runner' }, PowerShellInfo: { Version: '7.4' }
|
|
}, '$', 0);
|
|
const snapshot: EnvironmentSnapshot = {
|
|
version: 1, projectId: 'project-1', scanRunIds: ['run-1'], generatedAt: '2026-09-09T08:00:00Z', sections: [],
|
|
observations: context.environmentObservations.map((observation, index) => ({ ...observation, id: `observation-${index}`, tool: { id: 'maester', name: 'Maester' }, scanRunId: 'run-1', importFileId: 'file-1', mappingVersion: '1.1.0' })),
|
|
coverage: { observed: 0, empty: 0, explicitlyAbsent: 0, restricted: 0, incomplete: 0 }
|
|
};
|
|
it('shows labelled tool and runtime facts without treating the scanner host as the assessed host', () => {
|
|
const detail = dashboardEnvironmentDetail(snapshot);
|
|
expect(detail.toolContext).toContainEqual({ label: 'Maester version', value: '1.2' });
|
|
expect(detail.toolContext).toContainEqual({ label: 'Maester Scanner operating system', value: 'Synthetic scanner OS' });
|
|
expect(detail.toolContext).toContainEqual({ label: 'Maester PowerShell version', value: '7.4' });
|
|
expect(detail.inventory).toContainEqual({ label: 'Assessed host', value: '—' });
|
|
});
|
|
it('counts distinct reported tenants and does not invent an absent tenant', () => {
|
|
expect(dashboardMaesterTenantCount(snapshot)).toBe(1);
|
|
const tenant = snapshot.observations.find(observation => observation.property === 'entra.tenant_id')!;
|
|
expect(dashboardMaesterTenantCount({ ...snapshot, observations: [...snapshot.observations, tenant, { ...tenant, normalizedValue: 'tenant-2' }] })).toBe(2);
|
|
expect(dashboardMaesterTenantCount()).toBeUndefined();
|
|
expect(dashboardEnvironmentDetail().toolContext.some(item => item.label.startsWith('Maester'))).toBe(false);
|
|
});
|
|
});
|