From 9811c6923108c06d097df28dd1a87f1ec1e873b4 Mon Sep 17 00:00:00 2001 From: slhx agent Date: Mon, 25 May 2026 23:03:40 +0200 Subject: [PATCH] test(js): cover sse root dispatch Cover data-slhx-sse EventSource setup, slhx/message event handling, root-scoped EffectBatch application, and SSE error emission. req: push/001 req: push/003 req: runtime/001 --- slhx-js/tests/runtime.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/slhx-js/tests/runtime.rs b/slhx-js/tests/runtime.rs index c0b1d15..0471c84 100644 --- a/slhx-js/tests/runtime.rs +++ b/slhx-js/tests/runtime.rs @@ -128,6 +128,20 @@ fn runtime_refuses_partial_updates_on_fingerprint_mismatch() { assert!(source.contains("if (expected && String(batch.fingerprint) !== expected)")); } +#[test] +fn runtime_applies_sse_effect_batches_inside_roots() { + // req: push/001 req: push/003 req: runtime/001 + let source = slhx_js::RUNTIME_JS; + + assert!(source.contains("const sseSources = new WeakMap()")); + assert!(source.contains("const url = root.getAttribute(\"data-slhx-sse\")")); + assert!(source.contains("new EventSource(new URL(url, location.href).href)")); + assert!(source.contains("source.addEventListener(\"slhx\", (event) => applySseMessage(root, event))")); + assert!(source.contains("source.addEventListener(\"message\", (event) => applySseMessage(root, event))")); + assert!(source.contains("applyBatch(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength), root)")); + assert!(source.contains("emit(root, \"slhx:sse-error\", url)")); +} + #[test] fn runtime_page_swaps_lowered_slot_ids() { // req: wire/001