Skip to content

refactor(tests): split every oversized test file off the max-lines suppression list - #14728

Merged
nwparker merged 5 commits into
mainfrom
nwparker/baby-test-tube-Small-Tests
Aug 15, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/baby-test-tube-Small-Tests

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

What

Every *.test.ts / *.spec.ts carrying an eslint/oxlint-disable max-lines directive is split into focused, behavior-scoped suites that fit the 800-line test budget. Shared setup moves into co-located *-test-harness.ts / *-test-fixtures.ts modules (300-line budget).

83 files → ~930. Largest output is 797 effective lines. src/main/runtime/orca-runtime.test.ts is intentionally excluded per the request.

Registries that enumerate test files were updated in lockstep:

  • config/max-lines-baseline.txt — pruned to 257; all 83 entries removed.
  • config/reliability-gates.jsonc — 34 gates repointed, with assertionRefs split per file where a gate's coverage now spans several.
  • .github/workflows/pr.yml — the real-zsh lane now lists the 4 split files that actually exercise zsh, so they keep running in the dedicated shell lane instead of falling into the general shards.

Two incidental fixes the split forced: agent-hooks/server-test-fixtures.ts → server.test-fixtures.ts (so the global-fetch call-site audit keeps skipping it), and .js extensions on the CLI suites' dynamic harness imports (node16 resolution) to unbreak build:cli.

Verification

Gate Result
Full suite 52,761 passing, 0 assertions lost
pnpm lint (full chain) exit 0
pnpm typecheck exit 0
pnpm build:cli exit 0
terminal-pane e2e 31/31 headless executed and passed

Test bodies were moved by scripted line-range slicing rather than retyped, so assertions are byte-identical. The only permitted body edits were mechanical rebinding where a shared value moved into a harness (e.g. tmpHome → homes.tmpHome). A body-parity check compared every it()/test() block against HEAD per file to enforce this.

The suite diff versus the pre-rebase baseline is 12 tests main itself removed and 3 that moved skipped → passing (they need a built CLI, which now succeeds).

Reviewer notes

1. A latent product bug in pty-connection.ts, not fixed here. At pty-connection.ts:7658, the .finally handler calls requestHiddenOutputRestoreIfNeeded(), which after dispose re-settles immediately and re-arms the same chain — an unbounded self-feeding promise chain that consumes ~4GB in ~12s. The 25k-line original test file was accidentally masking it: a later test happened to kill the loop. The split preserves that relative ordering to stay green, so those files can't be freely reordered until the source is fixed. Worth addressing independently.

2. pty-subprocess.test.ts chdir tests are now flakier. They process.chdir into a temp dir and delete it, and cwd is process-global. Splitting one file into ten means that window overlaps concurrent files more often. The tests are unchanged; their odds aren't. They pass in isolation consistently. The real fix is to stop mutating process-global cwd, which is a behavior change I left for a follow-up.

3. Upstream tests ported through the rebase. main added 27 tests to files this branch deletes. Taking the deletion side of those modify/delete conflicts would have dropped them silently; each is ported into the split file that owns the behavior, and all 27 titles are verified present.

…sion list

Every `*.test.ts`/`*.spec.ts` that carried an `eslint/oxlint-disable max-lines`
directive is now split into focused, behavior-scoped suites that fit the 800-line
test budget, with shared setup extracted into co-located `*-test-harness.ts` /
`*-test-fixtures.ts` modules (300-line budget). 83 files became ~930; the largest
output is 797 effective lines. `orca-runtime.test.ts` is intentionally untouched.

Test bodies were moved by scripted line-range slicing rather than retyped, so
assertions are byte-identical. The only permitted body edits were mechanical
rebinding where a shared value moved into a harness (e.g. `tmpHome` ->
`homes.tmpHome`).

Registries that enumerate test files were updated in lockstep:
- config/max-lines-baseline.txt: pruned 341 -> 258 entries (all 83 removed).
- config/reliability-gates.jsonc: 33 gates repointed at the split files, with
  assertionRefs split per file where a gate's coverage now spans several.
- .github/workflows/pr.yml: the real-zsh lane now lists the 4 split files that
  actually exercise zsh, so they keep running in the dedicated shell lane.

Also renamed agent-hooks `server-test-fixtures.ts` to `server.test-fixtures.ts`
so the global-fetch call-site audit keeps skipping it, and added `.js` extensions
to the CLI suites' dynamic harness imports (node16 resolution) to unbreak
`build:cli`.

Verification: full suite 52,449 passing vs 52,448 at baseline with zero
assertions lost; `pnpm lint`, `pnpm typecheck`, and `pnpm build:cli` all exit 0;
the terminal-pane e2e spec runs 31/31 headless.
…over budget

The pre-commit oxfmt pass reflowed pty-connection-hook-idle-arbitration.test.ts
to 811 effective lines, 11 over the test budget. Split the hook-completion side
effect and replacement-agent veto cases into their own suite; both files now sit
well under the cap and the 15 tests are unchanged.
Rebasing onto main surfaced 27 tests that main had added to files this branch
deleted, plus edits to tests that had already moved. Taking the deletion side of
those modify/delete conflicts would have dropped that coverage silently, so each
upstream change is ported into the split file that now owns the behavior — for
example main's six orchestration mailbox tests land across orchestration-runs,
-send, and -check.

Also repoints `orchestration.notification-mailbox-consistency`, a gate main added
after this branch's gate remap, at those same three split files, and re-prunes
the max-lines baseline against main's (257 entries).

Verified: all 27 upstream test titles present; full suite 52,761 passing with the
only diff vs baseline being 12 tests main itself removed and 3 that moved from
skipped to passing; lint and typecheck exit 0.
@greptile-apps

greptile-apps Bot commented Aug 15, 2026

Copy link
Copy Markdown

Too many files changed for review (1015 files, 100 file limit).

…est globals

CI shard 5/16 failed on both Node 24 and 26 with `ReferenceError: window is not
defined` from pty-connection.ts, surfacing through
pty-connection-daemon-snapshot-replay.test.ts.

The reattach/settle chains `await` a real promise and then touch `window.api`.
Under fake timers those continuations cannot run, so they only become schedulable
once restoreTerminalTestGlobals() switches back to real timers — which previously
happened immediately before `delete globalThis.window`, so a late continuation
threw and failed the whole file. Flush async ticks in that window instead.

This is latent in the source rather than new: the pre-split 25k-line file kept
running other tests after these, which gave the chains time to settle before
teardown. Splitting the file moved teardown directly behind them.
…of deleting it

The async-tick flush was not enough: the reattach/settle chain can resolve after
teardown regardless of how long we drain, so CI shard 5/16 still failed with
`ReferenceError: window is not defined` from pty-connection.ts.

A real renderer never loses `window`, so deleting it was the artificial part.
Swap in an inert proxy whose properties resolve to callables and whose calls
resolve to undefined, making a late `window.api.pty.*` call a harmless no-op.
The next test replaces it wholesale via installTerminalTestGlobals(), and no test
asserts that `window` is absent.
@nwparker
nwparker merged commit 9367169 into main Aug 15, 2026
53 checks passed
nwparker added a commit that referenced this pull request Aug 15, 2026
The read owner imported the shared/types barrel deleted by #14447, and its
push-target key hand-enumerated fields, so a new GitPushTarget field would
silently share a lease between two different targets. The destructure now
fails to compile if a field is added. Lease tests moved into their own file
after #14728 split ssh-git-provider.test.ts.
nwparker added a commit that referenced this pull request Aug 15, 2026
Bound cross-host runtime project refreshes behind a scheduler with a reserved
lane for the foreground workspace, so N remote hosts no longer fan out N x ~7
concurrent RPCs on startup and reconnect.

Sets the cap to 3 rather than 2: the reserved foreground slot is never lent
out, so a cap of 2 left exactly one background lane and serialized host
discovery. Tests that assert reservation semantics pin the cap explicitly.

Lease tests moved to a focused file after #14728 split useIpcEvents.test.ts.
nwparker added a commit that referenced this pull request Aug 15, 2026
Bound cross-host runtime project refreshes behind a scheduler with a reserved
lane for the foreground workspace, so N remote hosts no longer fan out N x ~7
concurrent RPCs on startup and reconnect.

Sets the cap to 3 rather than 2: the reserved foreground slot is never lent
out, so a cap of 2 left exactly one background lane and serialized host
discovery. Tests that assert reservation semantics pin the cap explicitly.

Lease tests moved to a focused file after #14728 split useIpcEvents.test.ts.
kunsanglee added a commit to kunsanglee/orca that referenced this pull request Aug 15, 2026
Two things main moved under this branch.

`src/main/agent-hooks/server.test.ts` was split across many `server-*.test.ts`
files (stablyai#14728). This branch's only edit to it was one last-status test, which now
lives in `server-last-status-write.test.ts` — moved there verbatim, including the
`cwd` field and the `sourceCwd` assertion.

`src/shared/worktree-id.ts` became `src/shared/worktree/id.ts` (stablyai#14437). The two
files this branch adds import three symbols from it and were the only references
the merge did not resolve; nothing else about them changed.

Verified in this worktree after installing against the branch lockfile: tsc clean
on all three projects, oxlint clean, and `src/main` plus `src/shared` at 2551
files / 26541 tests passing.
nwparker added a commit that referenced this pull request Aug 15, 2026
The read owner imported the shared/types barrel deleted by #14447, and its
push-target key hand-enumerated fields, so a new GitPushTarget field would
silently share a lease between two different targets. The destructure now
fails to compile if a field is added. Lease tests moved into their own file
after #14728 split ssh-git-provider.test.ts.
AmethystLiang added a commit that referenced this pull request Aug 16, 2026
…dispose (#14749)

Cherry-pick production hunk only from c0a7754. Omit the new test file:
it imports #14728 fixtures that are not on this cut.

(cherry picked from commit c0a7754)
nwparker added a commit that referenced this pull request Aug 16, 2026
One conflict, and it was structural rather than textual: main split
ssh-connection.test.ts from 2904 lines into seventeen files with a shared harness
and fixtures (#14728), taking it off the max-lines suppression list, while this
branch had added host key verification tests to the old monolith.

Resolved by adopting main's split rather than reinstating the big file, since
restoring it would put back the suppression the refactor just removed. The seven
host key tests move to ssh-connection-host-key-verification.test.ts unchanged,
including their comments — they are the reasoning, not decoration.

The load-bearing piece was the ssh2 mock, which now lives in the shared harness
and is therefore used by all seventeen files. It has to keep the callback form:
ssh2 calls hostVerifier(key, verify) and only accepts synchronously when the
return is not undefined, so the old single-argument mock would pass against a
verifier that never decides — exactly the regression this work exists to prevent.
It also has to abort on denial, or a refused key looks like a successful connect.
Defaulting the presented key to a valid ed25519 blob keeps the other sixteen
files unaffected, which the full run confirms: 1549 passed, 13 skipped, zero
failures, typecheck clean.

The one remaining caller of the old signature — the obsolete-generation
fingerprint test — moved to real key blobs, because the verifier now identifies a
key before recording a fingerprint and a placeholder string would be refused
before reaching the generation check that test covers.
nwparker added a commit that referenced this pull request Aug 16, 2026
* perf: coalesce git upstream status reads

* fix(git): repair upstream lease key imports and guard its field list

The read owner imported the shared/types barrel deleted by #14447, and its
push-target key hand-enumerated fields, so a new GitPushTarget field would
silently share a lease between two different targets. The destructure now
fails to compile if a field is added. Lease tests moved into their own file
after #14728 split ssh-git-provider.test.ts.

* test(git): enforce native upstream coalescing in CI

The 10-caller benchmark only runs under ORCA_GIT_UPSTREAM_COALESCING_BENCH_JSON,
so nothing in CI failed when the native/WSL lease was bypassed. Route status.ts
through invalidateGitUpstreamStatusReads so the export has a production caller.
luisgonzaleznf added a commit to luisgonzaleznf/orca that referenced this pull request Aug 24, 2026
Ports the collections feature across three upstream refactors: the
shared/types barrel drop (stablyai#14447) — Collection type now lives in
shared/collection-types.ts; the worktree-list decomposition (stablyai#14486) —
sidebar integration re-woven into worktree-list/{drag,grouping,listing,
rows,viewport} modules; and the per-domain test split (stablyai#14728) —
web-preload collections coverage moved to its own domain test file.
Splits collection RPC methods out of repo.ts to respect max-lines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013SqQZ3Ssc7LJnAvacUkVhx
trs-80 added a commit to trs-80/orca that referenced this pull request Sep 2, 2026
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted
1102 commits since the original merge base. Agent behavior is unchanged
from the original PR; only the landing sites moved.

Relocations forced by two refactors on main:

- stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union
  member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated
  moves to src/shared/global-settings-types.ts.
- src/main/persistence.ts is now an 8-line barrel; the three opt-in
  migration hunks move to persistence/loading-store/store.ts.
- stablyai#14728 split the oversized test files, so the Bob detection test moves
  to preflight-agent-detection.test.ts and the disabledTuiAgents tests
  move to persistence-settings-update.test.ts.
- i18n locales and agent-headless-command.ts took both sides of the
  collision with Prime Agent (stablyai#12935).

Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Shimakaze514 added a commit to Shimakaze514/orca that referenced this pull request Sep 7, 2026
Conflicts (both sides appended to the same lists):
  src/shared/agent-session-resume.ts       keep main's copilot/kimi entries, add hermes
  src/shared/agent-session-resume.test.ts  same
  src/main/agent-hooks/server.test.ts      split by stablyai#14728; the /hook/hermes assertions
                                           now live in server-hook-http-ingest.test.ts
trs-80 added a commit to trs-80/orca that referenced this pull request Sep 15, 2026
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted
1102 commits since the original merge base. Agent behavior is unchanged
from the original PR; only the landing sites moved.

Relocations forced by two refactors on main:

- stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union
  member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated
  moves to src/shared/global-settings-types.ts.
- src/main/persistence.ts is now an 8-line barrel; the three opt-in
  migration hunks move to persistence/loading-store/store.ts.
- stablyai#14728 split the oversized test files, so the Bob detection test moves
  to preflight-agent-detection.test.ts and the disabledTuiAgents tests
  move to persistence-settings-update.test.ts.
- i18n locales and agent-headless-command.ts took both sides of the
  collision with Prime Agent (stablyai#12935).

Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
trs-80 added a commit to trs-80/orca that referenced this pull request Oct 8, 2026
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted
1102 commits since the original merge base. Agent behavior is unchanged
from the original PR; only the landing sites moved.

Relocations forced by two refactors on main:

- stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union
  member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated
  moves to src/shared/global-settings-types.ts.
- src/main/persistence.ts is now an 8-line barrel; the three opt-in
  migration hunks move to persistence/loading-store/store.ts.
- stablyai#14728 split the oversized test files, so the Bob detection test moves
  to preflight-agent-detection.test.ts and the disabledTuiAgents tests
  move to persistence-settings-update.test.ts.
- i18n locales and agent-headless-command.ts took both sides of the
  collision with Prime Agent (stablyai#12935).

Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…ppression list (stablyai#14728)

* refactor(tests): split oversized test files off the max-lines suppression list

Every `*.test.ts`/`*.spec.ts` that carried an `eslint/oxlint-disable max-lines`
directive is now split into focused, behavior-scoped suites that fit the 800-line
test budget, with shared setup extracted into co-located `*-test-harness.ts` /
`*-test-fixtures.ts` modules (300-line budget). 83 files became ~930; the largest
output is 797 effective lines. `orca-runtime.test.ts` is intentionally untouched.

Test bodies were moved by scripted line-range slicing rather than retyped, so
assertions are byte-identical. The only permitted body edits were mechanical
rebinding where a shared value moved into a harness (e.g. `tmpHome` ->
`homes.tmpHome`).

Registries that enumerate test files were updated in lockstep:
- config/max-lines-baseline.txt: pruned 341 -> 258 entries (all 83 removed).
- config/reliability-gates.jsonc: 33 gates repointed at the split files, with
  assertionRefs split per file where a gate's coverage now spans several.
- .github/workflows/pr.yml: the real-zsh lane now lists the 4 split files that
  actually exercise zsh, so they keep running in the dedicated shell lane.

Also renamed agent-hooks `server-test-fixtures.ts` to `server.test-fixtures.ts`
so the global-fetch call-site audit keeps skipping it, and added `.js` extensions
to the CLI suites' dynamic harness imports (node16 resolution) to unbreak
`build:cli`.

Verification: full suite 52,449 passing vs 52,448 at baseline with zero
assertions lost; `pnpm lint`, `pnpm typecheck`, and `pnpm build:cli` all exit 0;
the terminal-pane e2e spec runs 31/31 headless.

* refactor(tests): split hook-idle arbitration suite that oxfmt pushed over budget

The pre-commit oxfmt pass reflowed pty-connection-hook-idle-arbitration.test.ts
to 811 effective lines, 11 over the test budget. Split the hook-completion side
effect and replacement-agent veto cases into their own suite; both files now sit
well under the cap and the 15 tests are unchanged.

* test: port upstream test changes into the split files after rebase

Rebasing onto main surfaced 27 tests that main had added to files this branch
deleted, plus edits to tests that had already moved. Taking the deletion side of
those modify/delete conflicts would have dropped that coverage silently, so each
upstream change is ported into the split file that now owns the behavior — for
example main's six orchestration mailbox tests land across orchestration-runs,
-send, and -check.

Also repoints `orchestration.notification-mailbox-consistency`, a gate main added
after this branch's gate remap, at those same three split files, and re-prunes
the max-lines baseline against main's (257 entries).

Verified: all 27 upstream test titles present; full suite 52,761 passing with the
only diff vs baseline being 12 tests main itself removed and 3 that moved from
skipped to passing; lint and typecheck exit 0.

* fix(test): flush pending continuations before tearing down terminal test globals

CI shard 5/16 failed on both Node 24 and 26 with `ReferenceError: window is not
defined` from pty-connection.ts, surfacing through
pty-connection-daemon-snapshot-replay.test.ts.

The reattach/settle chains `await` a real promise and then touch `window.api`.
Under fake timers those continuations cannot run, so they only become schedulable
once restoreTerminalTestGlobals() switches back to real timers — which previously
happened immediately before `delete globalThis.window`, so a late continuation
threw and failed the whole file. Flush async ticks in that window instead.

This is latent in the source rather than new: the pre-split 25k-line file kept
running other tests after these, which gave the chains time to settle before
teardown. Splitting the file moved teardown directly behind them.

* fix(test): keep an inert window after terminal test teardown instead of deleting it

The async-tick flush was not enough: the reattach/settle chain can resolve after
teardown regardless of how long we drain, so CI shard 5/16 still failed with
`ReferenceError: window is not defined` from pty-connection.ts.

A real renderer never loses `window`, so deleting it was the artificial part.
Swap in an inert proxy whose properties resolve to callables and whose calls
resolve to undefined, making a late `window.api.pty.*` call a harmless no-op.
The next test replaces it wholesale via installTerminalTestGlobals(), and no test
asserts that `window` is absent.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* perf: coalesce git upstream status reads

* fix(git): repair upstream lease key imports and guard its field list

The read owner imported the shared/types barrel deleted by stablyai#14447, and its
push-target key hand-enumerated fields, so a new GitPushTarget field would
silently share a lease between two different targets. The destructure now
fails to compile if a field is added. Lease tests moved into their own file
after stablyai#14728 split ssh-git-provider.test.ts.

* test(git): enforce native upstream coalescing in CI

The 10-caller benchmark only runs under ORCA_GIT_UPSTREAM_COALESCING_BENCH_JSON,
so nothing in CI failed when the native/WSL lease was bypassed. Route status.ts
through invalidateGitUpstreamStatusReads so the export has a production caller.
trs-80 added a commit to trs-80/orca that referenced this pull request Oct 21, 2026
Rebase of stablyai#7698 (by @kiyeonjeon21) onto current main, which had drifted
1102 commits since the original merge base. Agent behavior is unchanged
from the original PR; only the landing sites moved.

Relocations forced by two refactors on main:

- stablyai#14447 dropped the src/shared/types.ts barrel, so the TuiAgent union
  member moves to src/shared/tui-agent.ts and bobDefaultDisabledMigrated
  moves to src/shared/global-settings-types.ts.
- src/main/persistence.ts is now an 8-line barrel; the three opt-in
  migration hunks move to persistence/loading-store/store.ts.
- stablyai#14728 split the oversized test files, so the Bob detection test moves
  to preflight-agent-detection.test.ts and the disabledTuiAgents tests
  move to persistence-settings-update.test.ts.
- i18n locales and agent-headless-command.ts took both sides of the
  collision with Prime Agent (stablyai#12935).

Co-Authored-By: Kiyeon Jeon <kiyeon.jeon.21@gmail.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant