Rubas

Rubas

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_patch and then assert on async data that loads after navigation
  • We can’t use render_click on elements that appear in async-loaded content

Solution

I’m not sure yet what the most elegant way to solve this is …

Showing Posts 1 to 2

LostKobrakai

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.

Rubas

Rubas OP

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"
— All posts loaded —

Where Next? Top

Trending in Proposals: Ideas Top

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews