Files
pubsub/tasks/013-worker-adapter-tests.md
glm-5.1 1306716897 Decompose architecture into atomic, dependency-ordered tasks
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.
2026-05-08 05:50:43 +00:00

1.6 KiB

id, name, status, depends_on, scope, risk, impact, level
id name status depends_on scope risk impact level
worker-adapter-tests Write tests for Worker event target adapter pending
worker-adapter-implementation
moderate medium component implementation

Description

Write tests for the Worker event target adapter(s). Testing Workers is non-trivial because it requires creating actual Worker instances or mocking the postMessage/onmessage API.

Test scenarios from the architecture doc:

  1. Main → Worker send — dispatchEvent from main posts message to worker
  2. Worker → Main send — dispatchEvent from worker posts message to main
  3. Bidirectional — both sides can subscribe and publish
  4. Topic scoping — type:id topics correctly formed
  5. Envelope round-trip — full envelope survives serialization
  6. Worker termination — cleanup when worker exits

Acceptance Criteria

  • test/event-target-worker.test.ts exists and passes
  • Mock strategy for Worker environment established (actual workers, vitest worker threads, or mocked postMessage)
  • Test: host dispatchEvent posts message to worker via postMessage
  • Test: worker thread dispatchEvent posts message to parent
  • Test: bidirectional communication works
  • Test: type:id topic scoping works correctly
  • Test: EventEnvelope round-trips through serialization
  • Test: addEventListener and removeEventListener work on both sides

References

  • docs/architecture/event-targets/worker.md (Test Plan section)
  • src/event-target-worker.ts

Notes

To be filled by implementation agent

Summary

To be filled on completion