68 lines
3.0 KiB
TypeScript
68 lines
3.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { readFileSync } from 'node:fs';
|
|
import { resolve } from 'node:path';
|
|
import { act } from 'react';
|
|
import { createRoot } from 'react-dom/client';
|
|
import { describe, expect, it, vi } from 'vitest';
|
|
import { RegulatoryMappingBatchDialog } from '../../src/compliance/ui/RegulatoryMappingBatchDialog';
|
|
|
|
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
|
|
describe('Result DB regulatory mapping batch', () => {
|
|
it('places the action with the Result DB page actions and shares its scoped query with export', () => {
|
|
const source = readFileSync(resolve(process.cwd(), 'src/features/results-browser/ResultsBrowser.tsx'), 'utf8');
|
|
expect(source.indexOf('Map all ISO controls')).toBeGreaterThan(source.indexOf("'Refresh'"));
|
|
expect(source.indexOf('Map all ISO controls')).toBeLessThan(source.indexOf("'Exporting …'"));
|
|
expect(source).toContain('buildScopedResultDbQuery');
|
|
expect(source).toContain('queryAllUnifiedResults');
|
|
expect(source).toContain('resultDbBatchFilters(scopedQuery)');
|
|
});
|
|
|
|
it('explains complete filtered membership and displays durable progress counts', async () => {
|
|
const container = document.createElement('div');
|
|
document.body.appendChild(container);
|
|
const root = createRoot(container);
|
|
await act(async () => root.render(<RegulatoryMappingBatchDialog filteredResultCount={75} onClose={() => {}} controller={{
|
|
available: true,
|
|
loading: false,
|
|
starting: false,
|
|
start: vi.fn(),
|
|
response: {
|
|
version: 1,
|
|
projectId: 'project-1',
|
|
scope: { assessmentIds: ['assessment-1'], scanRunIds: ['run-1'], filters: { deviation: true } },
|
|
generationEnabled: true,
|
|
state: 'running',
|
|
pollAfterMs: 1_500,
|
|
run: {
|
|
version: 1,
|
|
id: 'batch-1',
|
|
projectId: 'project-1',
|
|
scopeKey: 'scope-1',
|
|
filterHash: 'a'.repeat(64),
|
|
idempotencyKey: 'batch-request-1',
|
|
assessmentIds: ['assessment-1'],
|
|
scanRunIds: ['run-1'],
|
|
filters: { deviation: true },
|
|
status: 'running',
|
|
counts: {
|
|
filteredResultCount: 75, excludedNonScannerCount: 5, eligibleFindingCount: 68, unsupportedFindingCount: 2,
|
|
distinctRuleCount: 20, reusedSucceededRuleCount: 8, reusedActiveRuleCount: 1, scheduledRuleCount: 11,
|
|
succeededRuleCount: 4, failedRuleCount: 1
|
|
},
|
|
createdAt: '2026-09-16T08:00:00.000Z',
|
|
updatedAt: '2026-09-16T08:01:00.000Z'
|
|
}
|
|
}
|
|
}}/>));
|
|
const text = document.body.textContent ?? '';
|
|
expect(text).toContain('all 75 results matching the current Result DB filters');
|
|
expect(text).toContain('Pagination, “Load more,” and loaded-row limits do not restrict this batch.');
|
|
expect(text).toContain('Distinct rules20');
|
|
expect(text).toContain('Completed4');
|
|
expect(text).toContain('Failed1');
|
|
await act(async () => root.unmount());
|
|
container.remove();
|
|
});
|
|
});
|