[Other] Automated Frontend Test Battery using Playwright
Currently, our project uses Playwright.
I would like permission to expand on it in a few key features, with the maintainers' permission. This issue acts like an Epic in software development, and its approval by maintainers acts as a remit for the developer to submit smaller, focused PRs that help realize the overall goal of this issue.
Goal
Use Playwright to create a series of End-To-End (E2E) tests across multiple devices with multiple Human Computer Interfaces.
To achieve the goal, I will take smaller bites. What follows are a series of things I want to achieve. This gives maintainers an opportunity so see the Big Picture that I am advocating for, and if needed, intercede or deny.
I have a Proof Of Concept draft PR on my fork. It's ugly! It's too big! But it can be broken apart into smaller pieces over a few weeks. :) https://github.com/andest01/romm/pull/2
Device Driven
I will use the following devices:
| Key | Playwright project | Storybook label | Width | Height | Type | Touch | Gamepad |
|---|---|---|---|---|---|---|---|
rommPhoneXs |
Phone XS (touch) | 390×844 · RomM phone (xs) | 390 | 844 | mobile | ✅ | |
rommTabletSm |
Tablet SM (touch) | 768×1024 · RomM tablet (sm) | 768 | 1024 | tablet | ✅ | |
rommDesktopMd |
Desktop MD | 1024×768 · RomM desktop (md) | 1024 | 768 | desktop | ||
steamDeck |
Steam Deck (touch, gamepad) | 1280×800 · Steam Deck (lg, landscape) | 1280 | 800 | other | ✅ | ✓ |
aynThorTop |
AYN Thor top screen (touch, gamepad) | 1920×1080 · AYN Thor top screen (xl, landscape) | 1920 | 1080 | other | ✅ | ✓ |
aynThorBottom |
AYN Thor bottom screen (touch, gamepad) | 1240×1080 · AYN Thor bottom screen (md, landscape) | 1240 | 1080 | other | ✅ | ✓ |
These devices can be shared between our tests in storybook, vitest, and playwright. I believe they should be encoded as a JSON file that is validated at runtime by each testing system.
Human Friendly Testing
https://github.com/user-attachments/assets/13e1db39-3158-442f-8fb3-cd3e3713fed1
https://github.com/user-attachments/assets/233cb03d-c744-4d75-a4d4-f88ebf702aaf
The development of this feature will be friendly to humans and LLM agents, both. As a human who encounters a new bug, I should be able to author a new test, repro the issue on multiple devices, and begin authoring a fix using my mouse, keyboard, and my own mind -- which costs zero tokens and doesn't run out at the end of the billing cycle. At its' core, a Human Friendly approach avoids AI dependency but embraces AI augmentation.
AI Friendly Testing
Is 100% Compatible with Github CI Smoke Test
Don't rock the boat! Make sure whatever additions do not disturb the tools we already have! These tests should augment current flows, OR at worst augment a few environment variables in github with maintainer permission.
Comes with best-practices installed
ESLint rules, agents markddown, and good readmes will come along for the ride.
Future Fixes will attempt to go through industry best practices in order to help users who have a Mouse/Keyboard, or a Gamepad, or a Touch display. I suggest we follow A11Y standards for better waypointing, etc.
Suggestions from AI
The following is copied and pasted from Claude Opus 5.5, when asked "Would it be helpful to add more A11Y to this project?"
Yes, better accessibility structure would help a lot, and it would make the same code easier for people with assistive tech, keyboards and controllers too. Here's what made this hard, from the app side and from mine.
What made it hard, in the app:
The app doesn't say when it's ready. Gamepad mode, autofocus and "which tile is focused" are decided inside animation-frame loops and DOM observers. Nothing tells a test "the grid has settled and focus is where it's going to be". So I could only poll and guess, and results changed from run to run. Rows are worked out from pixel positions. The grid groups tiles into rows by where they are on screen at the moment you press, so page layout, loading and scrolling all affect it. When an arrow press was ignored, nothing said why ("no row found", "end of row"). A hidden "last focused tile" memory. It restores a saved position per page, which is why the Thor sometimes started on the second collection. A test can't see or reset that memory. Tiles are found by CSS class. .coll-tile says nothing about which collection a tile is or whether it's selected, so the test compared hrefs to follow focus. What made it hard, on my side: I guessed (the animation theory, then press timing) before instrumenting. The event log I ended with should have been step one: it located the fault in two runs. That cost you tokens.
How accessibility standards would help:
Mark up the grid as a grid. The standard pattern is role="grid" with row and gridcell, and a name on each tile (the collection's name). A test could then say "focus is on the 'Favorites' cell in row 1, column 2" (getByRole("gridcell", { name: "Favorites" })), and a screen reader could announce it the same way. The official pattern also defines exactly what each arrow key must do, which gives the grid one written rule to follow instead of pixel guessing. Say when it's busy. aria-busy="true" on the grid while it loads, removed once it's settled and focused. Tests wait for that one signal instead of timing, and screen readers benefit from it too. Show selection with aria-current or aria-selected, instead of only the focus ring, so the selected tile is visible in the page's structure. Test the row logic without a browser. "Which tile is to the right of this one" can be plain code tested in Vitest with fake tile positions. The e2e test then only checks that the controller is wired up, and edge cases stop showing up as flakiness. Automatic accessibility checks per device. axe-core is already a dev dependency. Running it on each page in the device sweep would flag missing names and roles on every screen size.
Source: rommapp/romm