Assertions for StarView SSE responses in Plug.Test / Phoenix.ConnTest
tests. Chunked SSE bodies accumulate on the test adapter; these helpers
parse them back into events.
conn = Plug.Conn.put_req_header(conn, "content-type", "application/json")
conn = post(conn, "/ds/my_app_web-counter_controller/increment", StarView.JSON.encode!(%{count: 0}))
assert_patched_signals(conn, %{count: 1})
assert_patched_element(conn, "#history")
Summary
Functions
Asserts a datastar-patch-elements event targets target — either via
an explicit selector line or via an id attribute in the patched HTML
(pass the target as "#the-id" in both cases).
Returns the conn for piping.
Asserts a top-level subset of emitted signals. Nested values compare exactly. Keys may be atoms or strings; values compare against the JSON-decoded patch. Returns the conn for piping.
Combines all emitted signal patch documents, including null removals.
This inspects writes, not the browser's final state: it does not apply
onlyIfMissing against initial signals or remove null-valued keys.
Parses the SSE events from a conn (or raw body string) into a list of
%{type: String.t() | nil, data: [String.t()]}.
Functions
Asserts a datastar-patch-elements event targets target — either via
an explicit selector line or via an id attribute in the patched HTML
(pass the target as "#the-id" in both cases).
Returns the conn for piping.
Asserts a top-level subset of emitted signals. Nested values compare exactly. Keys may be atoms or strings; values compare against the JSON-decoded patch. Returns the conn for piping.
Combines all emitted signal patch documents, including null removals.
This inspects writes, not the browser's final state: it does not apply
onlyIfMissing against initial signals or remove null-valued keys.
Parses the SSE events from a conn (or raw body string) into a list of
%{type: String.t() | nil, data: [String.t()]}.
This parser understands StarView's own SSE output format (event: /
data: with a trailing space, LF line endings) — it is not a
general-purpose SSE parser.