Rubas
Enhancing LiveViewTest API for better async testing
Current Challenge
When testing LiveViews that use assign_async, we can’t really operate on the async data.
-
render_async(view)waits for async operations but only returns the html -
All the other render_* test functions (
render_click,render_patch, etc.) can not be used in combination with async content
Problem
- We can’t use
render_patchand then assert on async data that loads after navigation - We can’t use
render_clickon elements that appear in async-loaded content
…
Solution
I’m not sure yet what the most elegant way to solve this is …
Marked As Solved
LostKobrakai
What’s the problem with just returning HTML? The LV test api is not a functional API. view includes a pid, which is what most apis talk to, so you don’t need to get a new view back everywhere.
1
Last Post!
Rubas
You are right. I missed something here.
This works
# Navigate to appointments list
{:ok, view, _html} = live(conn, ~q"/:locale/user/appointments")
# Navigate to first appointment
render_patch(view, ~q"/:locale/user/appointments/123")
# Wait for async data to load and render
html1 = render_async(view)
# Verify first appointment data
assert html1 =~ "Location One"
assert html1 =~ "123-456"
assert html1 =~ "John Doe"
# Navigate directly to second appointment
render_patch(view, ~q"/:locale/user/appointments/456")
# Wait for async data to load and render
html2 = render_async(view)
# Verify second appointment data
assert html2 =~ "Location Two"
assert html2 =~ "789-012"
assert html2 =~ "Jane Smith"
# Ensure first appointment data is no longer present
refute html2 =~ "Location One"
0
Popular in Proposals: Ideas
This is a proposal to make the map key mismatch errors a bit better:
Every time I have a typo It’s very challenging for me even when I u...
New
IEx is a very powerfull shell and it would be awesome to have all this power integrated inside a code editor. Clojure enables something l...
New
I propose adding compact_map/2 to the Enum module.
What is it?
Sometimes you want to map over a collection, but sometimes you want to ma...
New
Each time i use phx.gen I end up adding dark mode to it.
I’m offering to add this to the default phx gen templates.
This would
use ta...
New
Hi Phoenix community!
First off, huge thanks for an amazing framework - Phoenix has been a joy to work with. I have a small UX suggestio...
New
In the current Auth code, the email must change to be valid. This may be true for the two situations the author has in mind: Registering ...
New
The Problem
Phoenix 1.8 comes aggressively coupled with Daisy UI, a decision which many developers in the community have had mixed feelin...
New
Other popular topics
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









