Files
orca/src/shared/quick-open-listing-limits.test.ts
T
Neil 70475e0228 test: stop testing private internals through exports no caller needs (#23829)
Third audit wave. The detector looked for production modules exporting three
or more symbols that no production file imports — only tests do. That shape is
the authoring gate's fourth question failing: a test needing a production seam
no caller needs belongs at the real boundary instead.

Most hits were detector false positives and were left alone; the scanner misses
re-export barrels and dynamic imports, so every module was re-verified with rg
before any edit. Where a private predicate's behavior was already covered
through the module's real entry point, the duplicate cases are gone and the
symbol is module-private again. Where it was NOT covered anywhere else, the test
stays — this audit removes tests, it does not author replacements.

Production code deleted where tests were its only callers: the superseded
`filesystem-directory-listing-limit` module, the unused
`format{Hourly,Daily,Adhoc}Version` helpers and their orphaned prerelease
identifiers, the dead `filterByAutomationListSearch*` family superseded by
`matchAutomationListSearchRowKeys`, and the dead
`getAiVaultResumeWorktreeTargetStatus` copy of the live workspace branch.

Also drops two call-shape source greps in `relay-sweep-schedule.test.ts` that
asserted `index.ts` spells `jitteredSweepIntervalMs(30_000)`; the jitter math
has a behavioral owner at the top of the same file. The structural census that
counts role-gated vs total `setInterval(` calls stays — an ungated sweep runs in
every cell, and nothing else can catch that.
2026-09-29 15:53:18 -07:00

42 lines
1.5 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import {
QuickOpenSubprocessPathAccumulator,
resolveQuickOpenResultLimit,
QUICK_OPEN_LISTING_MAX_RESULTS
} from './quick-open-listing-limits'
describe('Quick Open listing limits', () => {
it('uses one hard result cap while preserving smaller requested limits', () => {
expect(resolveQuickOpenResultLimit()).toBe(QUICK_OPEN_LISTING_MAX_RESULTS)
expect(resolveQuickOpenResultLimit(17)).toBe(17)
expect(resolveQuickOpenResultLimit(QUICK_OPEN_LISTING_MAX_RESULTS + 1)).toBe(
QUICK_OPEN_LISTING_MAX_RESULTS
)
expect(resolveQuickOpenResultLimit(0)).toBe(0)
})
it('bounds one fragmented subprocess path and recovers after overflow', () => {
const onPath = vi.fn(() => true)
const fields = new QuickOpenSubprocessPathAccumulator(0, 3)
expect(fields.push(Buffer.from('ab'), onPath)).toBe('continue')
expect(fields.push(Buffer.from('cd'), onPath)).toBe('path-too-large')
expect(fields.push(Buffer.from('ok\0'), onPath)).toBe('continue')
expect(onPath).toHaveBeenCalledTimes(1)
expect(onPath).toHaveBeenCalledWith('ok')
})
it('stops within a multi-path chunk without visiting later fields', () => {
const visited: string[] = []
const fields = new QuickOpenSubprocessPathAccumulator(0, 16)
expect(
fields.push(Buffer.from('one\0two\0three\0'), (path) => {
visited.push(path)
return path !== 'two'
})
).toBe('stopped')
expect(visited).toEqual(['one', 'two'])
})
})