TLDR: I have a page that is partly rendered on the server and partly on the client. I am looking for a good way to test this page. Can I somehow end-to-end test the page, while using test environment-only data fixtures?
Playwright is a framework for testing web applications end-to-end. There is a part of one of my live views that I cannot test with LiveView’s built-in tests only. At least, that’s my suspicion.
Here’s a dumbed down version of the behaviour that I am testing.
A live view renders a large text as pages on the client. The client renders one page at a time. Scrolling is not possible, because the rendered page adjusts to the dimensions of the containing
Currently, I have a fully functional live view. But… I took the “build first, test later” approach. There is one part of the live view that I want to test from “end to end”. That’s the following part of the implementation:
A live view sends a text to the client. This text might overflow it’s containing
div. The client adjusts the text to render the UI properly and sends back a short report to the live view. The live view needs this report to handle a certain client event.
I am looking for a good way to test this behaviour/implementation. Testing with Playwright across many real browsers works well. But how can I use a fixed test environment-only dataset to use alongside the Playwright framework?
As the title of my post suggests, I have considered that maybe I can use LiveView’s DataCase somehow? I am, however, not sure how. And whether that is a good way to approach the problem.
The implementation of the desired behaviour might seem a bit odd, considering alternatives (in case you can tell from the little information in this post). I case you are interested, I am indeed looking for better implementations. Currently, I am not using LiveView’s
streams. However, that might very well be a better way forward.