51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { buildScopedResultDbQuery, resultDbBatchFilters } from '../../src/domain/result-db-query';
|
|
import type { UnifiedResultQuery } from '../../src/domain/unified-result';
|
|
|
|
describe('Result DB scoped query', () => {
|
|
it('uses one pagination-free query for export and regulatory batch filters', () => {
|
|
const filters: UnifiedResultQuery = {
|
|
evaluationRunId: 'evaluation-1',
|
|
sourceKind: ['scanner-finding'],
|
|
deviation: true,
|
|
isIoe: false,
|
|
severity: ['high'],
|
|
outcome: ['fail'],
|
|
technicalExecutionState: ['completed'],
|
|
resultType: ['compliance_check'],
|
|
policyClassification: ['misconfigured'],
|
|
sourceTool: ['purple-knight'],
|
|
mappingRuleVersion: ['mapping-1'],
|
|
sourceProfileVersion: ['profile-1'],
|
|
processingStatus: ['current'],
|
|
reviewDisposition: ['accepted'],
|
|
lifecycleState: ['new'],
|
|
categoryNamespace: ['framework'],
|
|
categoryValue: ['iso'],
|
|
affectedAsset: 'synthetic asset',
|
|
environmentState: ['observed'],
|
|
environmentProperty: ['domain.count'],
|
|
environmentSubjectType: ['domain'],
|
|
search: 'synthetic',
|
|
observedFrom: '2026-09-01T00:00:00.000Z',
|
|
observedTo: '2026-09-16T00:00:00.000Z'
|
|
};
|
|
const query = buildScopedResultDbQuery({
|
|
...filters,
|
|
offset: 100,
|
|
limit: 50,
|
|
projectId: 'untrusted-project',
|
|
scanRunIds: ['untrusted-run']
|
|
}, 'project-1', ['run-1'], ['assessment-1']);
|
|
|
|
expect(query).toEqual({
|
|
audience: 'result-db',
|
|
projectId: 'project-1',
|
|
assessmentIds: ['assessment-1'],
|
|
scanRunIds: ['run-1'],
|
|
...filters
|
|
});
|
|
expect(resultDbBatchFilters(query)).toEqual(filters);
|
|
});
|
|
});
|