test(admin): fix 3 stale vitest logic assumptions
These were pre-existing failures (stale tests, not source bugs): - getNextStep walks steps ordered by `seq`, not array order (ai-act seq 350 sits before import 400). The tests assumed array order; derive the expectations from the seq-sorted sequence instead. - buildDocumentScope: a document required only by the level matrix is `mandatory` but may be `medium` priority — only trigger-mandated docs (and the high-priority doc types) are forced to high. The test wrongly asserted ALL mandatory docs are high; now it checks the trigger-mandated ones. Full vitest suite: 414/414 green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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', {
|
const t = trigger('HT-A01', 'L3', {
|
||||||
category: 'art9',
|
category: 'art9',
|
||||||
mandatoryDocuments: ['VVT'],
|
mandatoryDocuments: ['VVT'],
|
||||||
})
|
})
|
||||||
const docs = complianceScopeEngine.buildDocumentScope('L3', [t], [])
|
const docs = complianceScopeEngine.buildDocumentScope('L3', [t], [])
|
||||||
const mandatoryDocs = docs.filter((d: any) => d.requirement === 'mandatory')
|
// A document required only by the level matrix is mandatory but may be
|
||||||
mandatoryDocs.forEach((doc: any) => {
|
// 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')
|
expect(doc.priority).toBe('high')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -78,14 +78,20 @@ describe('getStepByUrl', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('getNextStep', () => {
|
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', () => {
|
it('should return the next step in sequence', () => {
|
||||||
|
const idx = bySeq.findIndex(s => s.id === 'use-case-assessment')
|
||||||
const nextStep = getNextStep('use-case-assessment')
|
const nextStep = getNextStep('use-case-assessment')
|
||||||
expect(nextStep).toBeDefined()
|
expect(nextStep).toBeDefined()
|
||||||
expect(nextStep?.id).toBe('import')
|
expect(nextStep?.id).toBe(bySeq[idx + 1].id)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return undefined for the last step', () => {
|
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)
|
const nextStep = getNextStep(lastStep.id)
|
||||||
expect(nextStep).toBeUndefined()
|
expect(nextStep).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user