diff --git a/admin-compliance/lib/sdk/__tests__/compliance-scope-engine.test.ts b/admin-compliance/lib/sdk/__tests__/compliance-scope-engine.test.ts index 872736f9..174cb04a 100644 --- a/admin-compliance/lib/sdk/__tests__/compliance-scope-engine.test.ts +++ b/admin-compliance/lib/sdk/__tests__/compliance-scope-engine.test.ts @@ -253,14 +253,18 @@ describe('buildDocumentScope', () => { }) }) - it('mandatory documents have high priority', () => { + it('trigger-mandated documents get high priority', () => { const t = trigger('HT-A01', 'L3', { category: 'art9', mandatoryDocuments: ['VVT'], }) const docs = complianceScopeEngine.buildDocumentScope('L3', [t], []) - const mandatoryDocs = docs.filter((d: any) => d.requirement === 'mandatory') - mandatoryDocs.forEach((doc: any) => { + // A document required only by the level matrix is mandatory but may be + // medium priority (getDocumentPriority); only trigger-mandated docs (those + // with a populated triggeredBy) are forced to high priority. + const triggerMandated = docs.filter((d: any) => (d.triggeredBy?.length ?? 0) > 0) + expect(triggerMandated.length).toBeGreaterThan(0) + triggerMandated.forEach((doc: any) => { expect(doc.priority).toBe('high') }) }) diff --git a/admin-compliance/lib/sdk/__tests__/types.test.ts b/admin-compliance/lib/sdk/__tests__/types.test.ts index 916ab554..d2aafc40 100644 --- a/admin-compliance/lib/sdk/__tests__/types.test.ts +++ b/admin-compliance/lib/sdk/__tests__/types.test.ts @@ -78,14 +78,20 @@ describe('getStepByUrl', () => { }) describe('getNextStep', () => { + // getNextStep walks the steps ordered by `seq` (not array order), so the + // expectations are derived from the seq-sorted sequence to stay correct when + // steps are reordered or inserted (e.g. ai-act seq 350 sits before import 400). + const bySeq = [...SDK_STEPS].sort((a, b) => a.seq - b.seq) + it('should return the next step in sequence', () => { + const idx = bySeq.findIndex(s => s.id === 'use-case-assessment') const nextStep = getNextStep('use-case-assessment') expect(nextStep).toBeDefined() - expect(nextStep?.id).toBe('import') + expect(nextStep?.id).toBe(bySeq[idx + 1].id) }) it('should return undefined for the last step', () => { - const lastStep = SDK_STEPS[SDK_STEPS.length - 1] + const lastStep = bySeq[bySeq.length - 1] const nextStep = getNextStep(lastStep.id) expect(nextStep).toBeUndefined() })