From 1a5313cff03ce22b2a8e76e82fc314627c8e128f Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 16 May 2026 22:35:06 +0100 Subject: [PATCH] Update testing docs for async helper --- .agents/skills/testing/SKILL.md | 44 ++++++++++++++++++++++----------- docs/project-conventions.md | 2 +- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.md index f95f3b43..845dad46 100644 --- a/.agents/skills/testing/SKILL.md +++ b/.agents/skills/testing/SKILL.md @@ -75,15 +75,23 @@ conn ### ConnCase Auto-Imports +`MusicLibraryWeb.ConnCase` imports `MusicLibraryWeb.LiveTestHelpers`, `PhoenixTest` +in full, and selected `Phoenix.LiveViewTest` functions. + +`LiveTestHelpers` provides: +- `escape/1` +- `render_async/1`, `render_async/2` +- `trigger_hook/3`, `trigger_hook/4` + `MusicLibraryWeb.ConnCase` auto-imports the following LiveViewTest functions (with `only:`): -- `render_async/1`, `render_change/1`, `render_click/3` +- `render_change/1`, `render_click/3` - `render_hook/2`, `render_hook/3` - `element/2`, `element/3` - `form/3` -It also imports `PhoenixTest` in full. When a test needs LiveViewTest functions NOT in -the auto-import list (e.g. `render_click/1`, `render_submit/1`), add an explicit -`only:` import to the test file rather than importing the whole module. +When a test needs LiveViewTest functions NOT in the auto-import list (e.g. +`render_click/1`, `render_submit/1`), add an explicit `only:` import to the test +file rather than importing the whole module. ### The `unwrap/2` Escape Hatch @@ -215,29 +223,32 @@ When converting a test file from `Phoenix.LiveViewTest.live/2` to `PhoenixTest.v 2. **Replace `live(conn, path)`** with `visit(conn, path)`. The session returned by `visit` pipes into all PhoenixTest helpers. -3. **Replace `form/3` + `render_submit/1`** with `fill_in/3` + `click_button/2` (for +3. **After `visit/2`, replace `unwrap(&render_async/1)`** with `render_async()`. + For custom timeouts, use `render_async(timeout)`. + +4. **Replace `form/3` + `render_submit/1`** with `fill_in/3` + `click_button/2` (for standard inputs with labels) or `unwrap` with `form/3` + `render_submit/1` (for forms inside LiveComponents without labeled inputs). -4. **Replace `form/3` + `render_change/1`** with `fill_in/3` (triggers `phx-change` +5. **Replace `form/3` + `render_change/1`** with `fill_in/3` (triggers `phx-change` automatically) or `unwrap` with `form/3` + `render_change/1` (for Fluxon custom components or label-less inputs). -5. **Replace `element/2` + `render_click/1`** with `click_button/2` (for `