I have a button like this in my Liveview, and a corresponding modal defined with the CoreComponents.modal function:
<.button type="button" phx-click={show_modal("my_modal")}>
Do it
</.button>
and I want to test that clicking the button actually shows the modal, and I want to be able to test interacting with stuff inside the modal as well. Perhaps I’m missing something, but it doesn’t seem possible at the moment?
Here’s what I’ve tried:
{:ok, lv, html} =
lv
|> element("button", "Do it")
|> render_click()
But I get this error when I run my test:
** (ArgumentError) no push or navigation command found within JS commands: [["show",{"to":"#my_modal"}],["show",{"to":"#confirm_auto_assign_types-bg","transition":[["transition-all","transform","ease-out","duration-300"],["opacity-0"],["opacity-100"]]}],["show",{"to":"#my_modal-container","transition":[["transition-all","transform","ease-out","duration-300"],["opacity-0","translate-y-4","sm:translate-y-0","sm:scale-95"],["opacity-100","translate-y-0","sm:scale-100"]]}],["add_class",{"names":["overflow-hidden"],"to":"body"}],["focus_first",{"to":"#my_modal-content"}]]
Any ideas how I can go about testing my modal?






















