ML-182.5: migrate blocked LiveView tests
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
This commit is contained in:
+47
-2
@@ -1,9 +1,11 @@
|
||||
---
|
||||
id: ML-182.5
|
||||
title: "Wave 5: Files with send(view.pid) and live_isolated blockers (4 files)"
|
||||
status: To Do
|
||||
assignee: []
|
||||
status: Done
|
||||
assignee:
|
||||
- Codex
|
||||
created_date: "2026-05-14 22:15"
|
||||
updated_date: "2026-05-17 20:18"
|
||||
labels:
|
||||
- testing
|
||||
- refactoring
|
||||
@@ -35,3 +37,46 @@ Blocking patterns:
|
||||
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
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
<!-- SECTION:PLAN:BEGIN -->
|
||||
|
||||
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.
|
||||
<!-- SECTION:PLAN:END -->
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
<!-- SECTION:NOTES:BEGIN -->
|
||||
|
||||
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.
|
||||
|
||||
<!-- SECTION:NOTES:END -->
|
||||
|
||||
## Final Summary
|
||||
|
||||
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
|
||||
|
||||
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.
|
||||
<!-- SECTION:FINAL_SUMMARY:END -->
|
||||
|
||||
Reference in New Issue
Block a user