Mutare.Phoenix.LiveView.Navigation (mutare_phoenix_live_view v0.1.0)

Copy Markdown View Source

:lv_nav — swaps a LiveView's socket-navigation call between its two patch/navigate forms:

push_navigate(socket, to: p)  <->  push_patch(socket, to: p)

push_navigate dismounts the current LiveView and mounts a new one (state discarded); push_patch keeps the process and only re-invokes handle_params/3. Phoenix.LiveViewTest separates them (assert_patch vs assert_redirect), so a test that asserts how navigation happened kills the mutant.

One caveat on the push_navigate → push_patch direction: push_patch is only valid to the same LiveView, so patching to a route backed by a different LiveView raises at runtime — an uninformative kill (any test exercising the line dies) rather than a survivor. The common same-LiveView case is a genuine seam, and the push_patch → push_navigate direction is always valid.

Matches direct (Phoenix.LiveView.push_navigate(...)), aliased, and bare-imported (use-injected) calls. Silence a site with # mutare:ignore[lv_nav].

Also routes the LiveView compile-time DSL :skip — the Phoenix.LiveView.Router route declarations (live/live_session), on_mount hook declarations, and Phoenix.Component's declarative assigns and template embedding (attr/slot/ embed_templates) — so each of those calls is an inert leaf: Mutare neither descends into the declaration nor rewrites the call.