Assessor_2.0/tests/features/datahub-client-open.test.ts

32 lines
2.3 KiB
TypeScript

import { createElement } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { describe, expect, it } from 'vitest';
import { DatahubHistoryOverview } from '../../src/features/project-import/DatahubHistoryOverview';
describe('Datahub client quick open', () => {
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: {},
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="ready"');
expect(markup).toContain('aria-label="Processing ready across all client timeslots."');
});
});