Files
orca/config/scripts/ci-unit-selection-review.test.mjs
T
92dfb4fda6 test: trim redundant coverage and fix vacuous assertions (#32305)
* test: remove redundant cases and repair behavioral assertions

* docs: reconcile audit records with current main

* fix(deps): apply security updates from #32101

Apply the six-file DOMPurify 3.4.17 and Next.js 16.4.1 patch from PR #32101 to resolve the dependency security gate for this test audit. Original patch by Brennan Benson.

* test: satisfy changed-line quality gates

Add required braces and replace filter indexing with find. Rerun both CI quality gates and the 27 affected relay tests; refresh audit hashes and record the corrections.

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
2026-10-23 03:52:51 -07:00

72 lines
2.3 KiB
JavaScript

import { expect, it } from 'vitest'
import { reviewUnitSelection } from './ci-unit-selection-review.mjs'
const plan = {
sourceSha: 'sha',
mode: 'shadow',
selectionAvailable: true,
files: ['a', 'b'],
candidateFiles: ['a']
}
it('does not present full fallback runs as selection-validation evidence', () => {
const records = [record(1, 'a', 'passed'), record(2, 'b', 'passed')].map((row) => ({
...row,
plan: { ...plan, selectionAvailable: false }
}))
expect(reviewUnitSelection(records)[0]).toMatchObject({
completeFullRun: true,
selectionEvaluated: false
})
})
const record = (index, file, state) => ({
plan,
timing: {
sourceSha: 'sha',
runId: '1',
runAttempt: '1',
nodeVersion: '24',
status: state,
unhandledErrors: 0,
shard: { index, count: 2 },
timings: { [file]: 100 },
results: { [file]: state }
}
})
it('finds omitted failures in a complete failing reference run', () => {
expect(
reviewUnitSelection([record(1, 'a', 'passed'), record(2, 'b', 'failed')])[0]
).toMatchObject({ completeFullRun: true, missedFailures: ['b'], potentiallyOmittedWorkerMs: 100 })
})
it('does not call incomplete, duplicate, interrupted or selected evidence a full reference', () => {
const a = record(1, 'a', 'passed'),
b = record(2, 'b', 'passed')
for (const rows of [
[a],
[a, a],
[a, { ...b, timing: { ...b.timing, unhandledErrors: 1 } }],
[a, { ...b, timing: { ...b.timing, status: 'interrupted' } }],
[a, b].map((row) => ({ ...row, plan: { ...plan, mode: 'selected' } }))
]) {
expect(reviewUnitSelection(rows).map((row) => row.completeFullRun)).toEqual([false])
}
})
it('requires all ten full assignments exactly once for complete evidence', () => {
const files = Array.from({ length: 10 }, (_, index) => `retained-${index}.test.ts`)
const tenPlan = { ...plan, files, candidateFiles: files }
const records = files.map((file, index) => {
const row = record(index + 1, file, 'passed')
return {
...row,
plan: tenPlan,
timing: { ...row.timing, shard: { index: index + 1, count: 10 } }
}
})
expect(reviewUnitSelection(records)[0].completeFullRun).toBe(true)
expect(reviewUnitSelection(records.slice(0, -1))[0].completeFullRun).toBe(false)
expect(reviewUnitSelection([...records.slice(0, -1), records[0]])[0].completeFullRun).toBe(false)
})