19 tasks covering core testing, Redis hardening, WebSocket client/server adapters, Worker adapter, and final review gates. Iroh adapters are tracked as a deferred placeholder blocked on the @alkdev/iroh fork. Phases: core validation → Redis hardening → review gate → WebSocket adapters → review gate → Worker adapter → review gate → final validation.
2.3 KiB
2.3 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | |
|---|---|---|---|---|---|---|---|---|
| websocket-client-tests | Write tests for WebSocket client event target adapter | pending |
|
moderate | medium | component | implementation |
Description
Write tests for createWebSocketClientEventTarget. Since WebSocket is a browser API, we need to mock WebSocket in tests. Use a lightweight mock or vitest mocking to simulate WebSocket behavior.
Test scenarios from the architecture doc:
- Send path — dispatchEvent serializes envelope and calls ws.send
- Receive path — ws.onmessage parses envelope, creates CustomEvent, dispatches to listeners
- Topic scoping — type:id topics correctly formed from envelope
- Subscription forwarding — addEventListener sends __subscribe on first listener for a topic
- Subscription dedup — multiple addEventListener for the same topic sends only one __subscribe
- Unsubscription forwarding — removeEventListener sends __unsubscribe when no listeners remain
- Connection close — ws.onclose behavior
- Reconnection — new connection + new event target + re-subscribe restores subscriptions
- Multiple listeners — multiple addEventListener on same topic receives events correctly
Acceptance Criteria
test/event-target-websocket-client.test.tsexists and passes- Mock strategy for WebSocket is established (vitest mock, mock WebSocket class, or similar)
- Test: dispatchEvent sends JSON-stringified envelope via ws.send
- Test: addEventListener with first listener for a topic sends
__subscribecontrol event - Test: multiple addEventListener for same topic sends only one
__subscribe - Test: removeEventListener with last listener sends
__unsubscribe - Test: removeEventListener with remaining listeners does NOT send
__unsubscribe - Test: malformed JSON from server is silently ignored
- Test: control events received from server are silently ignored
- Test: ws.onmessage correctly dispatches to local listeners with type:id topic
- Test: multiple listeners on same topic all receive events
References
- docs/architecture/event-targets/websocket-client.md (Test Plan section)
- src/event-target-websocket-client.ts
Notes
To be filled by implementation agent
Summary
To be filled on completion