41 lines
2.9 KiB
TypeScript
41 lines
2.9 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { createElement } from 'react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { DatahubHistoryOverview } from '../../src/features/project-import/DatahubHistoryOverview';
|
|
const app = readFileSync(new URL('../../src/app/App.tsx', import.meta.url), 'utf8');
|
|
|
|
describe('Datahub client quick open', () => {
|
|
it('opens a selected client in Client Info by default', () => {
|
|
expect(app).toMatch(/if \(project\)\s*\{\s*setActiveArea\('dashboard'\);\s*void app\.openProject\(project\.id, scanRunIds, assessmentIds\);\s*\}/);
|
|
expect(app).not.toMatch(/if \(project\)\s*\{\s*setActiveArea\('work'\)/);
|
|
});
|
|
|
|
it('offers the latest scanner-backed timeslot on each client card', () => {
|
|
const project = { id: 'project-a', name: 'Client A', description: '', createdAt: '2026-08-22T08:00:00.000Z', updatedAt: '2026-08-22T08:00:00.000Z', attributes: {} };
|
|
const markup = renderToStaticMarkup(createElement(DatahubHistoryOverview, {
|
|
projects: [project],
|
|
projectData: { 'project-a': [{ id: 'file-a', scanRunId: 'run-a', fileName: 'synthetic.csv', format: 'CSV', sizeBytes: 10, importedAt: '2026-08-22T08:00:00.000Z', detectedTool: { id: 'generic', name: 'Generic' }, detection: { level: 'high', score: 1, reasons: [] }, processedWith: { parserId: 'csv', parserVersion: '1.0.0', profileId: 'generic', profileVersion: '1.0.0', mappingVersion: '1.0.0', normalizationVersion: '1.0.0', presentationVersion: '1.0.0', compatibilityKey: 'generic-canonical-v1' }, sourceArtifact: { kind: 'not-retained', reason: 'synthetic' } }] },
|
|
projectHistory: { 'project-a': { version: 1, projectId: 'project-a', assessments: [{ id: 'assessment-a', projectId: 'project-a', name: 'Assessment', createdAt: '2026-08-22T08:00:00.000Z', updatedAt: '2026-08-22T08:00:00.000Z', effectiveAt: '2026-08-22T08:00:00.000Z' }], scanRuns: [{ id: 'run-a', assessmentId: 'assessment-a', sequence: 1, label: 'Run', tool: { id: 'generic', name: 'Generic' }, importedAt: '2026-08-22T08:00:00.000Z' }] } },
|
|
projectGpoData: {},
|
|
projectOpenReadiness: { 'project-a': { 'timeslot-2026-08-22': { canOpen: true, hasPolicyResults: false } } },
|
|
selection: null,
|
|
timeslotMetrics: null,
|
|
loading: false,
|
|
comparisonBusy: false,
|
|
comparisonError: null,
|
|
onCreate: () => undefined,
|
|
onShow: () => undefined,
|
|
onOpen: () => undefined,
|
|
onSelectProject: () => undefined
|
|
}));
|
|
|
|
expect(markup).toContain('class="btn primary datahub-tenant-open"');
|
|
expect(markup).toContain('title="Open latest timeslot"');
|
|
expect(markup).not.toContain('datahub-tenant-open" type="button" disabled');
|
|
expect(markup).toContain('class="datahub-tenant-processing-dot" data-status="review"');
|
|
expect(markup).toContain('aria-label="A client timeslot requires review or a future reimport."');
|
|
expect(markup).toContain('>Manage</button>');
|
|
});
|
|
});
|