Files
orca/config/scripts/check-changed-selection.test.mjs
T
Neil d08774d336 feat(devex): pnpm check:changed as the single pre-handoff gate (#33432)
* feat(devex): add pnpm check:changed as the single pre-handoff gate

Runs format, oxlint, the changed-code gate, affected typecheck projects,
affected unit tests, and the ratchets/verifiers whose inputs changed, in
parallel against the origin/main merge base plus local edits. Printing is
limited to failures, and a pass is cached by a hash of the diff, untracked
files, lockfile, and config so an unchanged rerun exits immediately.

* fix(devex): keep the check:changed pass valid across staging and commits

* docs(agents): slim Useful Commands to the commands agents need
2026-10-24 23:50:26 -07:00

56 lines
2.0 KiB
JavaScript

import { join } from 'node:path'
import { expect, it } from 'vitest'
import { planChangedChecks, splitUnitTestInputs } from './check-changed-selection.mjs'
const scriptsDir = join(import.meta.dirname)
const plan = (files) => planChangedChecks(files, { scriptsDir })
const checkNames = (files) => plan(files).checks.map((check) => check.name)
it('skips typecheck, tests, and verifiers for a docs-only change but keeps the format gate', () => {
expect(plan(['docs/reference/git-workflow.md'])).toEqual({
staticAnalysis: true,
typecheckProjects: [],
unitTests: { related: [], colocated: [] },
checks: []
})
})
it('routes generated-artifact inputs to their verifiers', () => {
expect(checkNames(['src/renderer/src/i18n/locales/fr.json'])).toEqual(
expect.arrayContaining(['localization catalogs', 'localization coverage'])
)
expect(checkNames(['src/main/runtime/rpc/methods/worktree.ts'])).toContain('rpc params catalog')
expect(checkNames(['skills/orca-cli/SKILL.md'])).toEqual([
'bundled skill guides',
'skill bundle manifest'
])
})
it('limits typecheck to the projects a tree reaches', () => {
expect(plan(['src/renderer/src/App.tsx']).typecheckProjects).toEqual([
'config/tsconfig.node.json',
'config/tsconfig.tc.web.json'
])
expect(plan(['src/packages/process-host/src/run-process.ts']).typecheckProjects).toHaveLength(4)
})
it('keeps Vitest full-run triggers out of the related set and runs their colocated tests', () => {
const listDirectory = (directory) =>
directory === 'config/scripts/'
? ['foo.mjs', 'foo.test.mjs', 'foo.windows.test.mjs', 'foobar.test.mjs']
: []
expect(
splitUnitTestInputs(
['package.json', 'config/scripts/foo.mjs', 'config/scripts/bar.test.mjs', 'src/main/a.ts'],
listDirectory
)
).toEqual({
related: ['src/main/a.ts'],
colocated: [
'config/scripts/bar.test.mjs',
'config/scripts/foo.test.mjs',
'config/scripts/foo.windows.test.mjs'
]
})
})