Problem
fill_in calls clear() then set_value(). Both trigger phx-change on the form:
clear() → empties input → phx-change fires with email: ""
set_value() → types characters → phx-change fires with email: "user@test.com"
with_patch_await wraps fill_in and resolves after the FIRST patch (from clear). The test continues, click("Submit") fires before the server has processed set_value's change event. The server state still has an empty email.
Evidence
Screenshot shows the sign-in form with an empty email field after fill_in + click sequence. Intermittent under concurrent load.
Fix options
fill_in should await patch after set_value, not after clear — move with_patch_await to wrap only set_value, or await twice
clear should not trigger phx-change — use JS to clear without dispatching input/change events
- Debounce-aware fill_in — after typing, wait for the debounce period + patch before returning
Problem
fill_incallsclear()thenset_value(). Both triggerphx-changeon the form:clear()→ empties input →phx-changefires withemail: ""set_value()→ types characters →phx-changefires withemail: "user@test.com"with_patch_awaitwrapsfill_inand resolves after the FIRST patch (fromclear). The test continues,click("Submit")fires before the server has processedset_value's change event. The server state still has an empty email.Evidence
Screenshot shows the sign-in form with an empty email field after
fill_in+clicksequence. Intermittent under concurrent load.Fix options
fill_inshould await patch afterset_value, not afterclear— movewith_patch_awaitto wrap onlyset_value, or await twiceclearshould not trigger phx-change — use JS to clear without dispatching input/change events