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