Assessor_2.0/tests/features/datahub-gpo-report-visibili...

36 lines
2.5 KiB
TypeScript

import { readFileSync } from 'node:fs';
import { describe, expect, it } from 'vitest';
const dataHubSource = readFileSync(new URL('../../src/features/project-import/DataHub.tsx', import.meta.url), 'utf8');
const historyOverviewSource = readFileSync(new URL('../../src/features/project-import/DatahubHistoryOverview.tsx', import.meta.url), 'utf8');
const gpoImportSource = readFileSync(new URL('../../src/features/project-import/GpoFolderImport.tsx', import.meta.url), 'utf8');
describe('Datahub assessment timeslot composition', () => {
it('keeps GPO as a source in the timeslot without pretending it is a scanner run', () => {
expect(dataHubSource).toContain('listProjectGpoBackupStatus');
expect(dataHubSource).toContain('projectGpoData');
expect(dataHubSource).not.toContain('tenant-file-gpo');
expect(historyOverviewSource).not.toContain('listProjectGpoBackupStatus');
expect(historyOverviewSource).not.toContain('tenant-file-gpo');
expect(historyOverviewSource).toContain('groupProjectImportFiles(');
expect(historyOverviewSource).toContain('projectGpoData[project.id] ?? []');
expect(historyOverviewSource).toContain('aria-pressed={selected}');
expect(historyOverviewSource).toContain('onClick={() => onSelectProject(project.id)}');
expect(dataHubSource).toContain('const latest = groupsForProject(projectId).find(group => group.scanRunIds.length)');
expect(dataHubSource).toContain('runIds: latest.scanRunIds');
expect(historyOverviewSource).toContain('DonutMetricCard className="datahub-reference-knob" label="Results All"');
expect(historyOverviewSource).toContain('DonutMetricCard className="datahub-reference-knob" label="Deviation"');
expect(historyOverviewSource).toContain('DonutMetricCard className="datahub-reference-knob" label="Passed"');
expect(historyOverviewSource).toContain('DonutMetricCard className="datahub-reference-knob" label="Not Applicable"');
expect(historyOverviewSource).toContain('DonutMetricCard className="datahub-reference-knob" label="Not Run"');
expect(historyOverviewSource).toContain('DonutMetricCard className="datahub-reference-knob" label="Error"');
});
it('keeps the detailed GPO processing status available in the selected timeslot', () => {
expect(gpoImportSource).toContain('aria-label="GPO processing status"');
expect(gpoImportSource).toContain('GPO Processing');
expect(gpoImportSource).toContain('1 tenant GPO backup');
expect(gpoImportSource).toContain('GPO{record.gpoCount === 1');
});
});