Replace direct LiveView PID and isolated component test patterns with PhoenixTest-backed page flows while keeping narrow unwrap bridges where PhoenixTest cannot express the component interaction. Precommit: mise run dev:precommit
5.7 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, modified_files, parent_task_id, priority, ordinal
| id | title | status | assignee | created_date | updated_date | labels | dependencies | modified_files | parent_task_id | priority | ordinal | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ML-182.5 | Wave 5: Files with send(view.pid) and live_isolated blockers (4 files) | Done |
|
2026-05-14 22:15 | 2026-05-17 20:18 |
|
|
ML-182 | medium | 15000 |
Description
Files blocked by send(view.pid, message) pattern for testing internal handle_info/2 callbacks, plus live_isolated/3 and render_change/2 with nested LiveComponent form data.
- collection_live/index_test.exs: 2 PubSub tests use
send(view.pid, :records_index_changed). 3 cart format-change tests uselive/2with nestedrender_change/2params. Workaround needed: trigger actual PubSub broadcasts or use alternative approach for PID message testing. - wishlist_live/index_test.exs: Same PubSub pattern (2 tests). Single-item import test uses
live/2for synchronous import flow. - record_actions_test.exs: One test uses
send(view.pid, {Chat, :chats_changed}). Rest are standardlive/2+render_click/3. - components/release_test.exs:
render_change/2with nested LiveComponent form data (%{"release" => %{"finished_at" => ...}}).ShowPrintTestsub-module useslive_isolated/3. Workaround: test through parent LiveView page.
Blocking patterns:
send(view.pid, message)— PhoenixTest sessions don't expose LiveView PIDslive_isolated/3— no PhoenixTest equivalent; test through parent pagerender_change/2with nested params —fill_inworks for individual fields but not bulk nested changes
Implementation Plan
Approved implementation plan:
- Convert index PubSub tests in
collection_live/index_test.exsandwishlist_live/index_test.exsfrom rawLiveViewTest.live/2plussend(view.pid, :records_index_changed)to PhoenixTestvisit/2sessions plus the realMusicLibrary.Records.broadcast_index_changed/0. Assert the newly-created record appears on:indexpages and remains absent while the import modal action ignores the message. - Convert remaining raw
live/2import-flow tests in collection/wishlist to PhoenixTest pipelines (visit,fill_in,click_link,click_button,assert_path) and use DB assertions for the dynamically-created redirected record. - For cart format-change and Release component nested-form interactions, use PhoenixTest as the outer session and keep the smallest
unwrap/2bridge only for the label-less/nested LiveComponent form change that PhoenixTest cannot express directly. - Replace
release_test.exslive_isolated/3coverage with parent LiveView coverage:CollectionLive.Showforshow_print?: trueandScrobbleLive.ReleaseShowforshow_print?: false. - Convert
record_actions_test.exsto PhoenixTestvisit/2where practical; for the chat-count test, trigger the real Chat componentsend_messageflow instead of directly sending{Chat, :chats_changed}to the LiveView PID. - Run focused tests for the four task files, then
mix formaton changed files. Update the task notes/final summary and check any acceptance-style completion evidence even though this task has no explicit acceptance criteria.
Implementation Notes
Implemented the approved PhoenixTest migration plan for the four scoped files. Direct LiveView PID messaging was replaced with real PubSub broadcasts or UI/component flows; live_isolated/3 Release coverage was replaced with routed parent LiveViews; raw live/2 import flows were converted to PhoenixTest session pipelines. Kept small unwrap/2 bridges only for interactions PhoenixTest cannot express directly: cart native-select phx-change, Release component nested form changes, record action event dispatches, and Chat component form submit.
Final Summary
Converted the ML-182.5 test files away from raw LiveView PID/isolation patterns while preserving the existing behavioral coverage.
Changed:
collection_live/index_test.exs: PubSub tests now useRecords.broadcast_index_changed/0; import flows use PhoenixTest session pipelines; cart format changes keep a narrowunwrap/2helper for the component form change.wishlist_live/index_test.exs: PubSub and single-item import tests now use PhoenixTest-style navigation and async path assertions.record_actions_test.exs: page-level tests now mount withvisit/2; the chat-count test triggers the real Chat component submit flow instead ofsend(view.pid, ...).components/release_test.exs: removed the isolated host LiveView and replacedshow_print?coverage withCollectionLive.ShowandScrobbleLive.ReleaseShowparent pages.
Validation:
mix format test/music_library_web/live/collection_live/index_test.exs test/music_library_web/live/wishlist_live/index_test.exs test/music_library_web/live_helpers/record_actions_test.exs test/music_library_web/components/release_test.exsmix test test/music_library_web/live/collection_live/index_test.exs test/music_library_web/live/wishlist_live/index_test.exs test/music_library_web/live_helpers/record_actions_test.exs test/music_library_web/components/release_test.exs --max-failures 5-> 52 passed- Blocker scan for
live_isolated,send(view.pid), rawLiveViewTest.live,assert_redirect, andLVTreturned no matches in the scoped files. git diff --checkpassed.