--- id: worker-adapter-tests name: Write tests for Worker event target adapter status: completed depends_on: [worker-adapter-implementation] scope: moderate risk: medium impact: component level: 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