Skip to content

tests: raise claw-pilot coverage from 79.5% to 83.7%#1

Merged
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage
May 27, 2026
Merged

tests: raise claw-pilot coverage from 79.5% to 83.7%#1
TeoSlayer merged 1 commit into
mainfrom
add-test-coverage

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Summary

Adds 42 new tests across 5 files targeting coverage gaps in the TypeScript plugin. No production code modified.

File Before (lines) After (lines)
inbound.ts 79.6% 85.8%
lifecycle.ts 66.8% 82.5%
channel-plugin-api.ts 75.7% 98.1%
directory.ts 66.7% 100%
status.ts 83.3% 100%
wire.ts 96.9% 98.3%
All files 79.5% 83.7%

Branches went 84.7% → 87.7%, functions 81.7% → 86.9%.

New test files

  • inbound-coverage: ack send (happy + failure), onPeerProofOfLife (fires + throw-safe + control-frame trigger), HMAC port-strip, oversize media drop, filename sanitization, ext fallback, duplicate media, unknown envelope kind.
  • status-directory: every summarize state branch (missing / disabled / starting / ok), listEntries, resolveTarget rejection paths.
  • channel-plugin-api-coverage: config adapter (defaultAccountId / listAccountIds / resolveAccount), normalizeTarget whitespace handling, lifecycle hooks (onAccountConfigChanged, onAccountRemoved, runStartupMaintenance).
  • lifecycle-coverage: stopAll resilience when transport rejects, periodic outbox drain, drain failure path, onPeerProofOfLife wiring through to outbox.
  • wire-coverage: MediaReassembler.gc eviction, Reassembler.gc default args, verifyEnvelope malformed-base64 + length-mismatch defenses.

What was not covered (and why)

  • pilot-transport.ts / pilot-worker.ts (still 0%): require a live pilotprotocol.Driver plus a worker_threads.Worker. Need integration setup, not unit tests.
  • index.ts (still 46.9%): the register() setTimeout / fs.watch / ~/.openclaw/openclaw.json boot path needs a long-running fixture; the double-register guard is already tested.
  • iOS Swift: out of scope per plan — Sources/ is 90% SwiftUI/UIKit views. The unit-testable Swift modules (Wire, MessageStore, ProfileStore) already have high coverage from 146 existing Swift tests.

Findings (not fixed — flagged only)

  • channel-plugin-api.ts onAccountConfigChanged calls transport.stop() but does not remove the account from lifecycle.accounts before calling startAll(nextCfg). The subsequent startAccount throws "already running" and the new allowlist is silently ignored. Documented in the matching test as observed behavior.
  • inbound.ts sanitizeFilename strips / (preventing directory escape) but leaves literal .. sequences in the basename. Harmless in practice because no / remains, but the function name oversells what it does. Updated test asserts "no path escape" rather than "no .. substring."

Test plan

  • npx vitest run — 230 / 230 pass
  • npx vitest run --coverage — 83.7% lines, 87.7% branches, 86.9% functions
  • No production source files modified (git diff --stat shows only plugin/tests/*-coverage.test.ts and one tests/status-directory.test.ts)

Five new test files cover gaps in the inbound pipeline, lifecycle, channel
plugin API, status/directory adapters, and wire envelope GC + HMAC defenses:

- inbound-coverage: ack-send happy path + failure logging, onPeerProofOfLife
  fire-and-throw-handling, HMAC peer port-strip, oversize media drop,
  filename sanitization, ext fallback when sender omits filename, duplicate
  media drop, unknown envelope kind drop.
- status-directory: every state branch in summarize (missing/disabled/
  starting/ok), listEntries shape, resolveTarget rejection paths.
- channel-plugin-api-coverage: config adapter (defaultAccountId,
  listAccountIds, resolveAccount), normalizeTarget whitespace handling,
  lifecycle hooks (onAccountConfigChanged, onAccountRemoved,
  runStartupMaintenance).
- lifecycle-coverage: stopAll resilience when transport.stop rejects,
  periodic outbox drain, drain failure path, onPeerProofOfLife wiring.
- wire-coverage: MediaReassembler.gc eviction, Reassembler.gc default-args,
  verifyEnvelope malformed-base64 and length-mismatch rejection.

230 tests, all passing. No production code modified.
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@TeoSlayer TeoSlayer merged commit 526f35e into main May 27, 2026
4 checks passed
@TeoSlayer TeoSlayer deleted the add-test-coverage branch May 27, 2026 23:54
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.

2 participants