Skip to content

dev:web: browser end-to-end tests for the web UI - #2697

Open
acinader wants to merge 1 commit into
simonmichael:mainfrom
acinader:web-e2e-tests
Open

dev:web: browser end-to-end tests for the web UI#2697
acinader wants to merge 1 commit into
simonmichael:mainfrom
acinader:web-e2e-tests

Conversation

@acinader

@acinader acinader commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

See #200

Why

Hledger/Web/Test.hs (yesod-test) never runs JavaScript, so nothing currently covers the parts of the web UI that only exist in a browser: the add form's posting rows, autocomplete, the date picker, keyboard shortcuts, sidebar show/hide, scroll state, and hash highlighting.

What is here

  • webui.spec.js — the current behavior of page startup, the add form, the edit form, search, keyboard shortcuts, and the sidebar. It includes a regression test for web: keep the account sidebar's scroll position when switching accounts #2651 (sidebar scroll position) and one for register?...#N.
  • security.spec.js — journal data (descriptions, account names) renders as text and not markup, including the data handed to the autocomplete's javascript. fixture.journal deliberately carries html/javascript payloads for this. Only a browser can show that nothing executes.
  • Hledger/Web/Test.hs — CSRF tokens and restricting file access to the journal's own files. These need no browser, so they belong here, where they already run in CI. Each negative test has a positive control posting the same request with a valid token; without one they pass whether or not the protection exists.

24 browser tests, ~8s. 15 server tests, ~0.05s.

Notes / questions

  • The browser tests are not part of the build. Nothing in test/e2e touches stack build or stack test; node is needed only to run that suite. The Test.hs additions are ordinary stack test tests.
  • CI is a separate question. Running the browser suite in CI means installing node and a browser, which costs time on every run. Not wired up in this PR.
  • Selectors depend on current markup, so this will conflict with UI PRs in flight. I am happy to rebase around web: many improvements for 2.0 #2671 rather than the other way round.

AI usage: Claude Fable 5, ~70k output tokens

Comment thread hledger-web/test/e2e/security.spec.js Outdated
Comment thread hledger-web/test/e2e/security.spec.js Outdated
@acinader acinader closed this Aug 23, 2026
@acinader acinader reopened this Aug 23, 2026
@simonmichael simonmichael added A-WISH Some kind of improvement request or proposal. web The hledger-web tool. labels Aug 23, 2026
@acinader
acinader force-pushed the web-e2e-tests branch 3 times, most recently from 5a0c787 to bc23d8f Compare August 23, 2026 22:14
@acinader
acinader marked this pull request as ready for review August 23, 2026 22:18
@acinader
acinader marked this pull request as draft August 24, 2026 02:00
@simonmichael

Copy link
Copy Markdown
Owner

I'm nervous about using npm on a trusted machine these days. But that aside, this sounds great and I'll merge when it's ready.

@acinader

acinader commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Very interesting. Hadn't considered. Will research.

@acinader

Copy link
Copy Markdown
Contributor Author

Thanks for feedback @simonmichael

Hardened. See 11c5497.

@acinader
acinader marked this pull request as ready for review August 24, 2026 21:48
@acinader
acinader marked this pull request as draft August 24, 2026 21:57
These Playwright tests drive a browser to cover the parts of the web UI
implemented client side in javascript: add form, autocomplete, date
picker, keyboard shortcuts, sidebar state, and hash highlighting. This suite
is a complement to the yesod-test suite.

The security suite also confirms journal data renders as text and not markup.

The suite is available for on demand use and is not part of stack build or stack test.

CSRF tokens and restricting file access to the journal's own files need no
browser, so this PR adds those tests to Hledger/Web/Test.hs, which already runs in CI.
Each negative test there has a positive control posting the same request with
a valid token.

The suite runs with pnpm (>= 10) to reduce supply-chain
exposure: pnpm does not run dependency install scripts by default,
pnpm-workspace.yaml adds a 24h release-age gate, and pnpm-lock.yaml is
committed with integrity hashes. The one dependency is @playwright/test.

AI usage: Claude Opus 5, ~90k output tokens
@acinader
acinader marked this pull request as ready for review August 24, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-WISH Some kind of improvement request or proposal. web The hledger-web tool.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants