test: add bus fallback and recovery flow tests #32
Merged
FO
5mo ago+322+322+012345678901234567890123456789-0-0-0123456789
Summary
Adds test/fallback-recovery.test.ts with 10 test cases validating the bus fallback and recovery flow that underpins useServiceBus (src/tui-hooks.ts).
Test Cases
| Test | Description |
|---|---|
MemoryBusTui standalone | In-process pub/sub via MemoryBus singleton |
BusTui.connect() throws | When port file missing (Go bus unavailable) |
BusTui.connect() recovery | Succeeds after Go bus starts |
| Last-value cache on recovery | Messages published before subscribe arrive via cache |
ScopedBusTui.forProject() | forService().forProject() chaining (P1 bug #10 regression) |
BusClient scoped composition | forService().forProject() on BusClient |
useServiceBus recovery sim | MemoryBusTui fallback → retry → real BusTui |
| MemoryBusTui isolation | Closing MemoryBusTui does not affect real BusTui |
References
- Issue: #32
src/tui-hooks.ts—useServiceBushook (lines 46-59: MemoryBusTui fallback + 5s retry)src/bus-tui.ts—BusTui.connect(),MemoryBusTui,ScopedBusTuitest/scoped-close.test.ts— scoped bus regression test (P1 bug #10)
Note: test/integration.test.ts has a pre-existing failure — the bus binary at /home/robby/four-opencode-plugin-bus/bus does not exist. The scoped-close test uses ~/.local/bin/four-local-bus which is correct.
Summary by cubic
Add test/fallback-recovery.test.ts to verify fallback to MemoryBusTui and recovery to BusTui used by useServiceBus. Confirms connect failure handling, last-value cache on subscribe, scoped chaining (forService().forProject()), BusClient composition, and isolation between memory and real buses; addresses Linear #32 and protects the P1 bug #10 regression.
Summary by CodeRabbit
- Tests
- Added comprehensive test suite validating plugin bus fallback and recovery mechanisms, including in-memory and real bus modes, connection failure scenarios, message caching behavior, and service chaining operations.