From 1ccd9ccc918723d0969f9ad73f2aed06e803744c Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 23 May 2026 07:18:25 +0100 Subject: [PATCH] ML-182: finish audit and subsequent improvements --- ...t-streaming-tests-send_update-3-blocker.md | 37 +++++++++++++++++++ ...eViewTest-usage-in-favor-of-PhoenixTest.md | 4 +- ...t-streaming-tests-send_update-3-blocker.md | 34 ----------------- 3 files changed, 39 insertions(+), 36 deletions(-) create mode 100644 backlog/archive/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md delete mode 100644 backlog/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md diff --git a/backlog/archive/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md b/backlog/archive/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md new file mode 100644 index 00000000..a91ab51d --- /dev/null +++ b/backlog/archive/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md @@ -0,0 +1,37 @@ +--- +id: ML-182.6 +title: "Wave 6: Chat component streaming tests (send_update/3 blocker)" +status: To Do +assignee: [] +created_date: "2026-05-14 22:15" +updated_date: "2026-05-23 06:16" +labels: + - testing + - refactoring +dependencies: [] +modified_files: + - test/music_library_web/components/chat_test.exs +parent_task_id: ML-182 +priority: medium +ordinal: 16000 +--- + +## Description + + + +## Decision: Keep send_update/3 (Accepted Blocker) + +After reviewing the implementation plan against the project's testing conventions, the decision is to **keep `send_update/3`** rather than rewrite the three streaming state-transition tests as SSE pipeline integration tests. + +### Rationale + +The testing skill at `.agents/skills/testing/SKILL.md` already documents `send_update/3` in the "Known Blockers for Full PhoenixTest Migration" table with the workaround: **"Keep `send_update` for these tests."** This is the project's documented convention — `send_update/3` is an accepted escape hatch for unit-level LiveComponent streaming-state testing. + +The proposed SSE integration approach would work technically but carries disproportionate cost (4-6h estimated) for three tests, introduces async timing fragility, requires new DOM selectors in the template, and masks the unit-level coverage of `update/2` clause logic behind a full-pipeline integration test. + +### Action + +Import `send_update/3` explicitly in `chat_test.exs`, keep the three streaming state-transition tests as-is, and close this task. No other changes needed. + + diff --git a/backlog/tasks/ml-182 - Analyze-and-plan-elimination-of-LiveViewTest-usage-in-favor-of-PhoenixTest.md b/backlog/tasks/ml-182 - Analyze-and-plan-elimination-of-LiveViewTest-usage-in-favor-of-PhoenixTest.md index 33e4bbf7..fff3df5f 100644 --- a/backlog/tasks/ml-182 - Analyze-and-plan-elimination-of-LiveViewTest-usage-in-favor-of-PhoenixTest.md +++ b/backlog/tasks/ml-182 - Analyze-and-plan-elimination-of-LiveViewTest-usage-in-favor-of-PhoenixTest.md @@ -1,10 +1,10 @@ --- id: ML-182 title: Analyze and plan elimination of LiveViewTest usage in favor of PhoenixTest -status: In Progress +status: Done assignee: [] created_date: "2026-05-14 21:40" -updated_date: "2026-05-14 22:15" +updated_date: "2026-05-23 06:17" labels: - testing - refactoring diff --git a/backlog/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md b/backlog/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md deleted file mode 100644 index 0bcae32d..00000000 --- a/backlog/tasks/ml-182.6 - Wave-6-Chat-component-streaming-tests-send_update-3-blocker.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -id: ML-182.6 -title: "Wave 6: Chat component streaming tests (send_update/3 blocker)" -status: To Do -assignee: [] -created_date: "2026-05-14 22:15" -labels: - - testing - - refactoring -dependencies: [] -modified_files: - - test/music_library_web/components/chat_test.exs -parent_task_id: ML-182 -priority: medium -ordinal: 16000 ---- - -## Description - - - -The hardest file — `components/chat_test.exs` uses `Phoenix.LiveView.send_update(view.pid, Chat, [chunk: ..., done: ..., error: ...])` to drive the Chat component's internal `update/2` callback directly with streaming state tuples. This is unit-level LiveComponent testing with no PhoenixTest equivalent — PhoenixTest has no concept of LiveComponent PIDs. - -3 tests affected in "update/2 streaming state transitions" describe block: - -- "chunk clause appends to the streaming doc" -- "done clause finalizes the assistant message and clears loading" -- "error clause surfaces the error and a retry button" - -Workaround: Rewrite as integration tests through the actual SSE streaming pipeline (stub OpenAI.API to emit controlled SSE events, use `visit/2` + `assert_has/3`). - -Effort: High (4-6h). Requires understanding the SSE streaming protocol and Chat component internals. - -