feat(redis): add channel prefix and error handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
---
|
||||
id: redis-adapter-tests
|
||||
name: Write tests for Redis event target adapter
|
||||
status: pending
|
||||
status: completed
|
||||
depends_on: [core-pubsub-tests]
|
||||
scope: moderate
|
||||
risk: medium
|
||||
@@ -26,15 +26,15 @@ Note: test 7 (error propagation) is partially blocked by the missing error handl
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] `test/event-target-redis.test.ts` exists and passes
|
||||
- [ ] Test approach for Redis dependency is decided (mock, container, or ioredis-mock)
|
||||
- [ ] Test: dispatchEvent publishes correct channel and serialized envelope
|
||||
- [ ] Test: addEventListener subscribes to Redis and dispatches to local listeners
|
||||
- [ ] Test: removeEventListener unsubscribes from Redis when no listeners remain
|
||||
- [ ] Test: type:id topic scoping works correctly
|
||||
- [ ] Test: EventEnvelope round-trips through JSON serialization
|
||||
- [ ] Test: multiple listeners on same topic result in single Redis subscribe
|
||||
- [ ] Test: custom serializer option works
|
||||
- [x] `test/event-target-redis.test.ts` exists and passes
|
||||
- [x] Test approach for Redis dependency is decided (mock, container, or ioredis-mock)
|
||||
- [x] Test: dispatchEvent publishes correct channel and serialized envelope
|
||||
- [x] Test: addEventListener subscribes to Redis and dispatches to local listeners
|
||||
- [x] Test: removeEventListener unsubscribes from Redis when no listeners remain
|
||||
- [x] Test: type:id topic scoping works correctly
|
||||
- [x] Test: EventEnvelope round-trips through JSON serialization
|
||||
- [x] Test: multiple listeners on same topic result in single Redis subscribe
|
||||
- [x] Test: custom serializer option works
|
||||
|
||||
## References
|
||||
|
||||
@@ -43,8 +43,14 @@ Note: test 7 (error propagation) is partially blocked by the missing error handl
|
||||
|
||||
## Notes
|
||||
|
||||
> To be filled by implementation agent
|
||||
Test approach: Manual Redis mock (no external dependencies). The `createMockRedis()` helper creates a lightweight mock that tracks `publish`/`subscribe`/`unsubscribe` calls and provides `simulateMessage()` to trigger the `message` event handler. This avoids needing `ioredis-mock` or a running Redis instance.
|
||||
|
||||
Test 7 (error propagation) is not included because the current implementation lacks error handling — tracked in `redis-channel-prefix-and-error-handling` task.
|
||||
|
||||
## Summary
|
||||
|
||||
> To be filled on completion
|
||||
Implemented comprehensive tests for the Redis event target adapter using a manual mock approach (no external dependencies needed).
|
||||
|
||||
- Created: `test/event-target-redis.test.ts` (17 tests across 7 describe blocks)
|
||||
- Tests: 17, all passing
|
||||
- Coverage: dispatchEvent/publish path, addEventListener/subscribe path, removeEventListener/unsubscribe path, topic scoping, envelope round-trip serialization, multiple listeners (single Redis subscribe), custom serializer, EventListenerObject support
|
||||
Reference in New Issue
Block a user