Skip to content

e2e: cover logged-in state; fix rating-button contrast and login-page JS error - #13366

Merged
lokesh merged 4 commits into
internetarchive:masterfrom
lokesh:e2e-fixes
Aug 28, 2026
Merged

e2e: cover logged-in state; fix rating-button contrast and login-page JS error#13366
lokesh merged 4 commits into
internetarchive:masterfrom
lokesh:e2e-fixes

Conversation

@lokesh

@lokesh lokesh commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Fixes tests

Our Playwright e2e suite only tested the site as a logged-out visitor. That means the logged-in experience — which is most of what an active patron actually sees — had no automated coverage at all. This PR adds a simple way for any e2e test to log in first, and then re-runs our key checks (page loads, console errors, accessibility scans) as a logged-in user.

That new coverage immediately surfaced a category of bug we were blind to before: problems that only exist for logged-in users. Two got fixed here:

  • An accessibility issue — a button that only appears after you've rated a book had text contrast below WCAG standards.
  • A JavaScript error on the login page when you visit it while already logged in (dev only).

It also exposed a test that was passing without testing anything: our "invalid credentials" login test was actually logging in successfully, because the dev-environment mock accepts any password. The mock now has a way to reject a bad password, so the test genuinely verifies login failure.

Testing

# One-time setup: rebuild mock services and install the Playwright browser
OL_MOUNT_DIR="$(pwd)" docker compose up -d --build mockservices
npx playwright install chromium chromium-headless-shell

# Run the full suite (headless)
npm run test:e2e

# Watch it run in a visible browser
npm run test:e2e -- --headed

# Interactive UI mode (pick tests, time-travel through steps)
npm run test:e2e -- --ui

# Run a single spec
npm run test:e2e -- tests/e2e/login.spec.ts

Locally: 36 passed, 7 skipped (opt-in visual snapshots). Both fixes were verified failing before and passing after.

Screenshot

image

Stakeholders

lokesh added 3 commits August 18, 2026 10:31
The Playwright suite only ever ran anonymously. Add a login() helper and
'when logged in' blocks (home, work, login, a11y, new my-books spec).

Running pages logged in surfaced:
- login.html rendered the LOCAL_DEV autofill hint for logged-in users,
  whose form isn't rendered, so index.js threw on a null #username.
- .star-messaging ("Clear my rating") used the non-text --mid-grey token
  and failed WCAG contrast (2.48:1).

The 'invalid credentials' login test was passing vacuously: the mock IA
auth accepts any non-empty password, so it was actually logging in.
Mock now rejects the sentinel 'bad_password' so the error path is real.

Claude-Session: https://claude.ai/code/session_01Vmhke1AR5VjcNKP7KnciCJ
The loading indicator is only rendered for authenticated patrons —
my_books/dropdown_content.html emits it under `$if async_load: $if ctx.user`
— but initLoadingAnimation always started its interval. For anonymous
visitors the callback dereferenced null every 1.5 seconds, throwing for as
long as the page stayed open, on every page carrying a dropper.

This showed up as an intermittent failure in edition.spec.ts, whose
console-error assertion only observes the error when the test happens to
outlive the first interval tick.

clearInterval(null) is a no-op, so returning null leaves updateReadingLists()
unchanged.
@lokesh
lokesh requested a review from mekarpeles August 26, 2026 05:22
@lokesh
lokesh marked this pull request as ready for review August 26, 2026 05:22
@lokesh
lokesh merged commit 12206af into internetarchive:master Aug 28, 2026
4 of 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.

1 participant