Skip to content

uiux/testing: better test coverage and visual testing integration - #133

Merged
lukebuehler merged 3 commits into
mainfrom
uiux/testing
Nov 5, 2026
Merged

lukebuehler merged 3 commits into
mainfrom
uiux/testing

Conversation

@dankrusi

@dankrusi dankrusi commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Hi luke,

To prepare for my changes on the web frontend I have added some missing test coverage, fixed failing tests on machines with different region settings, and added a lightweight visual testing system. npm run screenshots:demo is maybe also interesting for you to get latest screenshots.

Only affects platform/web, but doesn't change anything on the frontend.

Cover AccountPage, AdminChannelsPage, AdminEnvironmentProvidersPage,
AdminUniversesPage, BotCreatePage, GeneralSettingsPage, and HomeRedirect
with jsdom component tests in the existing createRoot/act style.

Make the session config editor capability test locale-independent: the
editor formats token counts with toLocaleString, so the expectation does
too. It failed on machines whose locale does not group digits with commas
(e.g. en-CH renders 1’000’000).
Add two review commands that capture the demo build in a real browser and
compare versions with screendiff-js:

  npm run screenshots:demo   capture the working tree
  npm run screendiff:demo    compare two versions (default: the working
                             tree against where the branch left main)

screendiff:demo takes optional [base] [head] refs plus --theme <light|dark>,
--no-cache, and --keep-screenshots. The default base is the merge-base with
main, not main's tip, so later changes on main stay out of the report.

Capture (platform/web/e2e/, playwright.config.ts):
- 27 demo routes in light and dark at 1440x900, 2x device scale.
- Pins clock, randomness, animations, locale, and timezone from outside
  the app, so it works on any commit; repeated captures of one build match
  pixel for pixel.
- The harness always comes from the working tree, so both sides capture
  the same screens. Specs use *.pw.ts so Vitest skips them.

Runner (platform/web/scripts/screendiff.mjs):
- Builds committed refs in a git worktree in the OS temp folder (outside
  the repo, so module resolution cannot fall back to this checkout's
  node_modules) and caches builds by SHA in node_modules/.cache.
- Writes a self-contained report.html and results.json per comparison to
  platform/web/test-results/screendiff/<base>_vs_<head>/; captured PNGs are
  removed afterwards unless --keep-screenshots is given or the run failed.

Visual tests are a review tool for UI/UX changes, deliberately not part of
npm test, npm run check, or CI. platform/README.md gains a "Testing &
Visual Tests" section.

Dependencies: @playwright/test 1.64.1, screendiff-js 0.1.2, and @types/node
as platform/web devDependencies. screendiff-js's peer dependency moves
Vitest from 5.0.3 to 5.1.0 in the lockfile; the web suite passes.
@dankrusi
dankrusi requested a review from lukebuehler November 5, 2026 11:49
@lukebuehler
lukebuehler enabled auto-merge November 5, 2026 16:48
@lukebuehler

Copy link
Copy Markdown
Contributor

super, thanks!

@lukebuehler lukebuehler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lukebuehler
lukebuehler merged commit e6558e3 into main Nov 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants