Mutare.Phoenix.ChannelMessage (mutare_phoenix v0.3.1)

Copy Markdown View Source

:channel_message — removes a Phoenix.Channel outbound-message call, collapsing it to the :ok it returns on success. Three kinds, each a variant label:

broadcast(socket, "new_msg", %{body: body})        ->  :ok     # broadcast
broadcast!(socket, "new_msg", %{body: body})       ->  :ok     # broadcast
broadcast_from(socket, "typing", %{})              ->  :ok     # broadcast
broadcast_from!(socket, "typing", %{})             ->  :ok     # broadcast
push(socket, "presence_state", state)              ->  :ok     # push
reply(ref, {:ok, %{status: "done"}})               ->  :ok     # reply

A broadcast survivor means no test asserts the message reached the topic's subscribers (Phoenix.ChannelTest.assert_broadcast/3); a push survivor, that nothing asserts the client received the event (assert_push/3); a reply survivor, that nothing asserts the deferred reply arrived (assert_reply/4). Suppress one kind with # mutare:ignore[channel_message:push], or the whole family with # mutare:ignore[channel_message].

The :channel_reply family mutates inline replies — the {:reply, reply, socket} tuples returned by handle_in/3; this family mutates only outbound-message calls. Mutare's built-in :convention family mutates the :ok / :error status inside a reply payload, and :string mutates the event string. Enable them alongside this family to mutate each part independently.

Only the defined arities match — broadcast/3 and its three siblings, push/3, reply/2 — so a name-matched call of any other arity (reachable only by an explicit qualifier) is left alone, keeping every metamutant compiling. A call written as a pipe stage (socket |> push("event", payload)) gets the same mutant, reported over the whole pipe. Matches direct (Phoenix.Channel.broadcast(...)), aliased, and bare-imported (use Phoenix.Channel-injected) calls.