Skip to content

refactor(test): compress repetitive fixtures in worst mega-tests with builders - #120055

Merged
steipete merged 5 commits into
mainfrom
steipete/loc2-fixture-builders-9d3b
Aug 6, 2026
Merged

steipete merged 5 commits into
mainfrom
steipete/loc2-fixture-builders-9d3b

Conversation

@steipete

@steipete steipete commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Five of the largest test files repeated dominant arrange objects dozens of times, obscuring the scenario-specific inputs and making fixture-wide updates risky. This refactor gives each scope one domain-named builder with Partial-based overrides, while preserving every test title, assertion, and runtime input.

Why This Change Was Made

  • run.incomplete-turn.test.ts: adds makeLastAssistant; the canonical makeAttemptResult was already present on this base and remains unchanged.
  • talk-realtime-relay.test.ts: adds makeRelayTransport while retaining the one deliberately method-absent fixture and preserving Vitest mock metadata.
  • subagent-registry.test.ts: keeps the already-landed shared run builders and compresses the remaining killed-run, running-task, completed-collector, and suspended-delivery clusters.
  • cli-runner.reliability.test.ts: adds builders for run exits, managed runs, Claude prepared contexts, and live Claude backends.
  • chat-send.test.ts: extracts its existing mature host/request fixture into chat-host.test-fixture.ts; adoption is intentionally limited to this test file.

Per-file physical LOC before → after:

  • src/agents/embedded-agent-runner/run.incomplete-turn.test.ts: 5,375 → 4,957
  • src/gateway/talk-realtime-relay.test.ts: 4,269 → 4,039
  • src/agents/subagent-registry.test.ts: 6,655 → 6,592
  • src/agents/cli-runner.reliability.test.ts: 5,060 → 4,426
  • ui/src/pages/chat/chat-send.test.ts: 9,240 → 9,058
  • ui/src/pages/chat/chat-host.test-fixture.ts: 0 → 195

User Impact

None. This is test-only fixture compression: no production code, behavior, public API, configuration, snapshots, inventories, or generated baselines changed.

Evidence

Focused Vitest counts are unchanged before → after:

  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.incomplete-turn.test.ts: 171 → 171 passed
  • node scripts/run-vitest.mjs src/gateway/talk-realtime-relay.test.ts: 63 → 63 passed
  • node scripts/run-vitest.mjs src/agents/subagent-registry.test.ts: 143 → 143 passed
  • node scripts/run-vitest.mjs src/agents/cli-runner.reliability.test.ts: 83 → 83 passed
  • node scripts/run-vitest.mjs ui/src/pages/chat/chat-send.test.ts: 268 → 268 passed

Checks:

  • pnpm format <six changed paths>: passed
  • node scripts/run-oxlint.mjs <six changed paths>: passed
  • git diff --check: passed
  • pnpm tsgo:ui: passed
  • pnpm tsgo:core:test: changed fixture errors cleared; blocked only by three untouched browser/server global errors in ui/src/e2e/appearance-settings-defaults.e2e.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode local --stream-engine-output: clean, no accepted/actionable findings

node scripts/check-changed.mjs delegated as required but the provider chain failed before running: Blacksmith doctor failed, Daytona timed out, and Azure rejected the configured image selector with admin_required. Its local fallback plan was run constituent-by-constituent; all guards, format, UI i18n, dead-code, dependency, boundary, and UI type lanes passed, with only the unrelated core-test diagnostics noted above.

Production vs test LOC from git diff origin/main...HEAD --numstat:

  • Production: +0 / -0 (net 0)
  • Tests and test fixtures: +1,618 / -2,950 (net -1,332)

@steipete
steipete marked this pull request as ready for review August 6, 2026 22:56
@steipete

steipete commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Incident-mode landing note (operator-directed).

GitHub's declared Actions incident prevented CI attachment and ClawSweeper review on this PR; the operator directed landing without waiting. Compensating gates, all satisfied:

  • Coordinator diff review: builder pattern verified across all five files (override-based make* fixtures with the file's dominant literals as defaults; e.g. makeRelayTransport replacing 32+ inline 10-field transport mocks); a mechanical check found zero describe/it title deltas across every touched test file.
  • Structured Codex autoreview: clean ("patch is correct, 0.99").
  • Focused tests: all five files green with unchanged test counts (171, 63, 143, 83, 268); format, lint, UI types, diff checks passed. The three tsgo errors the worker flagged in an untouched file were a pre-existing main breakage from refactor(ui): adopt shared control-ui e2e suite bootstrap #119978's incident-mode rebase — root-caused and fixed separately on main in dc0b995.
  • Merge verified clean against latest origin/main (git merge-tree).

Test LOC −1,332, production 0 (plus a new shared chat-host.test-fixture.ts for follow-up adoption by the other 8 chat test files). Landed via operator-authorized admin merge at the verified head because branch protection could not evaluate during the incident.

@steipete
steipete merged commit 65d2222 into main Aug 6, 2026
2 checks passed
@steipete
steipete deleted the steipete/loc2-fixture-builders-9d3b branch August 6, 2026 23:11
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 6, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
… builders (openclaw#120055)

* refactor(test): share incomplete-turn assistant fixtures

* refactor(test): share realtime relay transport fixtures

* refactor(test): share subagent registry fixtures

* refactor(test): share CLI reliability fixtures

* refactor(test): extract chat host fixture
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant