I am trying to add end-to-end browser tests to my Phoenix application with PhoenixTest.Playwright, and I can only get it to work if I run the cases synchronously (use PhoenixTest.Playwright.Case
instead of use PhoenixTest.Playwright.Case, async: true
). I have a test that creates a user through the AshAuthentication regsiter LiveView, and if I slow down the test, I can see that my LiveView (after completing user registration) has current_user
set in the assigns, as expected (and not nil
), and then shortly after updates to have current_user: nil
.
From the application log, the following happens:
- The user-registration form submission triggers a
302
redirect to the expected route - This route’s LiveView is mounted
current_user
is set (notnil
)- With the same
request_id
as the302
just before, a200
request is sent - The LiveView socket is reconnected, and the same LiveView is mounted again
- This time the logged SQL query (from Ash) on the users table returns no records
current_user
is nownil
In my on_mount
hook to allow the SQL sandbox for LiveViews, described here, I have added a line to log metadata
, and I can see that it always the same value throughout the sequence outlined above. But I also notice that it is the exact same value across all runs, so I am unsure whether this is working correctly.
I have at this point gone over the setup instructions for PhoenixTest and PhoenixTest.Playwright several times, and I am now quite sure I have not missed anything from there, so I am wondering whether some additional steps are required because I am using Ash, and this combination (PhoenixTest.Playwright with Ash instead of bare Ecto) has just not been documented anywhere yet.