Skip to content

fix(test): update TerminalView write assertions and harden opencode serve port#388

Merged
danshapiro merged 1 commit into
mainfrom
fix/terminal-test-assertions-and-opencode-serve-port
Jun 4, 2026
Merged

fix(test): update TerminalView write assertions and harden opencode serve port#388
danshapiro merged 1 commit into
mainfrom
fix/terminal-test-assertions-and-opencode-serve-port

Conversation

@danshapiro
Copy link
Copy Markdown
Owner

Summary

Two test-only fixes that bring the suite back to green.

1. TerminalView stale write() assertions (3 assertions)

The backpressure fix (dd12912b) made TerminalView always pass a completeRenderedFrame callback as the second argument to term.write(). That commit updated lifecycle.test.tsx but missed TerminalView.osc52.test.tsx (×2) and TerminalView.renderer.test.tsx (×1), which still asserted write() was called with undefined. Switched them to the established write.mock.calls.some((call) => call[0] === '…') idiom that verifies the written data without pinning the now-present callback argument.

2. OpenCode real-provider contract test hardcoded serve port

coding-cli-session-contract.test.ts hardcoded serve port 46123. A leaked orphan opencode serve holding that port let the --attach run silently connect to the stranger (different XDG_DATA_HOME → wrong DB), so the session never landed in the watched DB and the test timed out.

Fix: allocate a free ephemeral port via allocateLocalhostPort() and fail fast on serve startup errors, through a new startOpencodeServe harness helper that mirrors the existing startCodexAppServer pattern.

Test plan

  • Full coordinated suite green (npm test): full-suite success exit=0.
  • npm run typecheck (client + server): clean.
  • OpenCode contract test passes (~23s); full real-contract file: 7 passed / 2 skipped (binary-gated).

🤖 Generated with Claude Code

…erve port

The backpressure fix (dd12912) made TerminalView always pass a
completeRenderedFrame callback as the second argument to term.write().
It updated lifecycle.test.tsx but missed the osc52 and renderer tests,
which still asserted write() was called with `undefined`. Switch them to
the established write.mock.calls.some(...) idiom that verifies the written
data without pinning the now-present callback argument.

The opencode real-provider contract test hardcoded serve port 46123. A
leaked orphan `opencode serve` holding that port let the `--attach` run
silently connect to the stranger (different XDG_DATA_HOME -> wrong DB), so
the session never landed in the watched DB and the test timed out. Allocate
a free ephemeral port via allocateLocalhostPort() and fail fast on serve
startup errors through a new startOpencodeServe harness helper that mirrors
startCodexAppServer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@glowforgedan glowforgedan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test-only fixes verified green (full coordinated suite + typecheck). Stale write() assertions updated to match the backpressure callback change; opencode contract test moved off the hardcoded port to a free ephemeral port with fast-fail. LGTM.

@danshapiro danshapiro merged commit 1f5839e into main Jun 4, 2026
1 check passed
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.

3 participants