Files
music_library/backlog/completed/ml-182.5 - Wave-5-Files-with-sendview.pid-and-live_isolated-blockers-4-files.md
Claudio Ortolina 0881971635 Backlog cleanup
2026-05-19 09:48:55 +01:00

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
Codex
2026-05-14 22:15 2026-05-17 20:18
testing
refactoring
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
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 use live/2 with nested render_change/2 params. 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/2 for synchronous import flow.
  • record_actions_test.exs: One test uses send(view.pid, {Chat, :chats_changed}). Rest are standard live/2+render_click/3.
  • components/release_test.exs: render_change/2 with nested LiveComponent form data (%{"release" => %{"finished_at" => ...}}). ShowPrintTest sub-module uses live_isolated/3. Workaround: test through parent LiveView page.

Blocking patterns:

  1. send(view.pid, message) — PhoenixTest sessions don't expose LiveView PIDs
  2. live_isolated/3 — no PhoenixTest equivalent; test through parent page
  3. render_change/2 with nested params — fill_in works for individual fields but not bulk nested changes

Implementation Plan

Approved implementation plan:

  1. Convert index PubSub tests in collection_live/index_test.exs and wishlist_live/index_test.exs from raw LiveViewTest.live/2 plus send(view.pid, :records_index_changed) to PhoenixTest visit/2 sessions plus the real MusicLibrary.Records.broadcast_index_changed/0. Assert the newly-created record appears on :index pages and remains absent while the import modal action ignores the message.
  2. Convert remaining raw live/2 import-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.
  3. For cart format-change and Release component nested-form interactions, use PhoenixTest as the outer session and keep the smallest unwrap/2 bridge only for the label-less/nested LiveComponent form change that PhoenixTest cannot express directly.
  4. Replace release_test.exs live_isolated/3 coverage with parent LiveView coverage: CollectionLive.Show for show_print?: true and ScrobbleLive.ReleaseShow for show_print?: false.
  5. Convert record_actions_test.exs to PhoenixTest visit/2 where practical; for the chat-count test, trigger the real Chat component send_message flow instead of directly sending {Chat, :chats_changed} to the LiveView PID.
  6. Run focused tests for the four task files, then mix format on 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 use Records.broadcast_index_changed/0; import flows use PhoenixTest session pipelines; cart format changes keep a narrow unwrap/2 helper 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 with visit/2; the chat-count test triggers the real Chat component submit flow instead of send(view.pid, ...).
  • components/release_test.exs: removed the isolated host LiveView and replaced show_print? coverage with CollectionLive.Show and ScrobbleLive.ReleaseShow parent 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.exs
  • mix 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), raw LiveViewTest.live, assert_redirect, and LVT returned no matches in the scoped files.
  • git diff --check passed.