ML-182.3; update more tests and findings
This commit is contained in:
+9
-12
@@ -4,7 +4,7 @@ title: "Wave 3: Convert live/2 → visit/2 for CRUD LiveViews (6 files)"
|
||||
status: In Progress
|
||||
assignee: []
|
||||
created_date: "2026-05-14 22:14"
|
||||
updated_date: "2026-05-15 05:46"
|
||||
updated_date: "2026-05-15 06:01"
|
||||
labels:
|
||||
- testing
|
||||
- refactoring
|
||||
@@ -27,20 +27,17 @@ ordinal: 13000
|
||||
|
||||
Convert `live/2` → `visit/2` for standard CRUD LiveViews. Files:
|
||||
|
||||
- **maintenance_live/index_test.exs** ✅ Done (14 tests pass) — all `live/2` → `visit/2`, `render_click/3` → `click_button/2` with scoped selectors for duplicate button texts. External redirect test simplified. Kept `unwrap(&render_async/1)` for async status tests.
|
||||
- **online_store_template_live/index_test.exs** ✅ Done (7 tests pass) — mixed `visit/2` and `live/2` eliminated. Field labels: "Template Name", "URL Template". Buttons: "Save Template", "Delete", "Disable/Enable template".
|
||||
- **record_set_live/index_test.exs** ✅ Done (7 tests pass) — removed `import Phoenix.LiveViewTest`. Create/Edit: `live/2` + `form/3` + `render_submit/1` → `visit/2` + `fill_in/3` + `click_button/2`. Validation: `live/2` + `form/3` + `render_change/1` → `visit/2` + `click_button/2` + `assert_has("[data-part='error']", ...)`. Ordering test: `live/2` → `visit/2` + `Phoenix.LiveViewTest.render(session.view)`. Button text: "Save Set", field label: "Name".
|
||||
- **record_set_live/show_test.exs** ✅ Done (15 tests pass) — removed `import Phoenix.LiveViewTest`, replaced with explicit `only:` for `render_click/1, render_hook/3, render_submit/1, element/2, form/3`. Remove record: `click_button("button[...]", "Remove")`. Delete set: `click_button("button[phx-click='delete_set']", "Delete")` + `assert_path`. Reorder: `unwrap(&render_hook/3)`. Picker search: `search_picker` helper uses `unwrap` with `form/3` + `render_submit/1`. Add record: `unwrap` with `element/2` + `render_click/1` on `<li phx-click='add_record'>`. Result checks use `assert_has`/`refute_has` instead of `=~` and `has_element?`.
|
||||
- **scrobble_rules_live/index_test.exs** ⏸️ Needs form label inspection — "Match Value", "Target MusicBrainz ID", "Type" select, "Save" button.
|
||||
- **maintenance_live/index_test.exs** ✅ Done (14 tests pass)
|
||||
- **online_store_template_live/index_test.exs** ✅ Done (7 tests pass)
|
||||
- **record_set_live/index_test.exs** ✅ Done (7 tests pass)
|
||||
- **record_set_live/show_test.exs** ✅ Done (15 tests pass)
|
||||
- **scrobble_rules_live/index_test.exs** ✅ Done (10 tests pass) — removed `import Phoenix.LiveViewTest`, added explicit `only:` for `render_change/1` and `form/3`. Fluxon `<.select>` component requires `unwrap` with `form/3` + `render_change/1` for type changes — standard `PhoenixTest.select/3` doesn't work with custom selects. Dynamic label ("Match Value"/"Album Title"/"Artist Name") handled via `set_rule_type` helper. Edit validation test uses `unwrap` with `render_change` to clear existing data before checking errors. Path assertions on patch links omit query params (not captured by PhoenixTest). Buttons: "Add" (link), "Save Rule", "Apply", "Apply rule", "Delete", "Disable rule"/"Enable rule".
|
||||
- **scrobbled_tracks_live/rule_picker_test.exs** ⏸️ Blocked: clicks `<span>` badges with `phx-click` (Fluxon). PhoenixTest only supports `<a>` and `<button>`.
|
||||
|
||||
Key learnings for remaining files:
|
||||
|
||||
- `click_button(session, "button[phx-click='...']", "text")` scoped selector works for duplicate button texts
|
||||
- Fluxon labels without separate visible text don't work with `fill_in` — visit with query params instead
|
||||
- `trigger_hook` in PhoenixTest expects JSON-encoded values
|
||||
- LiveComponent modals with `phx-target` need form interaction, not URL params
|
||||
- For position-based assertions (ordering), use `Phoenix.LiveViewTest.render(session.view)` to get raw HTML
|
||||
- Fluxon custom `<.select>` components are NOT native `<select>` elements — use `unwrap` with `form/3` + `render_change/1` instead of `PhoenixTest.select/3`
|
||||
- For edit-form validation tests where existing data would pass validation, `unwrap` with `render_change` clears fields first
|
||||
- `assert_path` on patch links doesn't capture query params — use path-only assertions
|
||||
- `<li phx-click>` needs `unwrap` with `element/2` + `render_click/1` since PhoenixTest only supports `<a>` and `<button>` natively
|
||||
- Forms inside LiveComponents (phx-target={@myself}) with no visible label on inputs need `unwrap` with `form/3` + `render_submit/1` for search/submit operations
|
||||
<!-- SECTION:DESCRIPTION:END -->
|
||||
|
||||
Reference in New Issue
Block a user