In the Phoenix.LiveViewTest
module, we can get the structured Flash after certain actions like assert_redirected
:
flash = assert_redirect(view, ~p"/user/search")
assert_single_flash(flash, "This user was deleted", type: :warning)
We use the Flashy library for more fancy flashes in our code, so this home-made assert_single_flash
helper can assert on many things like the type of flash, whether or not it is closable, etc.
I’d like to get this same structured flash response after render_submit
, but it does not seem possible to do:
html =
view
|> element("#name-modal form")
|> render_submit(%{"first_name" => "NewName"})
assert html =~ "Success."
All I seem to be able to do is assert on the returned HTML, which should contain the flash message. This does not allow for fine-grained assertions though.
Is there a way to get the current flash after the render_submit
has completed?