e2e: cover logged-in state; fix rating-button contrast and login-page JS error - #13366
Draft
lokesh wants to merge 1 commit into
Draft
e2e: cover logged-in state; fix rating-button contrast and login-page JS error#13366lokesh wants to merge 1 commit into
lokesh wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #
The Playwright e2e suite only ever ran anonymously — no test logged in. This adds logged-in coverage alongside the existing anonymous checks, and fixes two bugs that coverage exposed:
.star-messaging) used--mid-grey, a non-text token, and failed WCAG AA at 2.48:1. Now--color-text-muted. Only visible once a patron has rated the book, which is why the anonymous a11y scan never saw it./account/loginfor logged-in users (dev only): theLOCAL_DEVcredential-autofill hint rendered even when the login form didn't, soindex.jsthrew on a null#username.Technical
tests/e2e/helpers.tsgainslogin(page), which POSTs/account/login.jsonthroughpage.request— that shares the context's cookie jar, so the nextpage.goto()is authenticated without driving the form. Specs use it astest.beforeEach(({ page }) => login(page))inside atest.describe('when logged in')block; this is the pattern for any future logged-in e2e test. Dev defaults to the seededopenlibrarypatron; elsewhereOL_E2E_USERNAME/PASSWORD,OL_E2E_S3_ACCESS/SECRET, orOL_E2E_EMAIL(form path), otherwise logged-in tests skip. Documented intests/e2e/README.md./account/loginwith no console errors; axe scans of home + work page while logged in; newmy-books.spec.ts(anon → redirect to login, logged in →/people/<user>/booksand shelves).docker/mockservicesaccepts any non-empty password, sowrongpassword123was actually logging in and its only assertion wasurl.not.toContain('500'). The mock now rejects the sentinel passwordbad_password(with a unit test), and the e2e test asserts an error message renders and the page stays on/account/login. Also added a real form-login happy path (form istype=email, so it needs an email rather than a username).Not addressed here:
/people/<user>/bookshas several axe violations (cover images without alt, invalid list structure, unlabeled<select>), so no full-page a11y assertion was added for it — that's its own fix PR. The suite is still local-only, not in CI.Testing
Locally: 36 passed, 7 skipped (opt-in
OL_VISUALsnapshots). Both app fixes were observed failing before and passing after: the pageerror on/account/loginand thecolor-contrastviolation on the work page each appear in a pre-fix logged-in run and are gone post-fix.pytest docker/mockservices/tests/test_e2e.py -k Xauthnpasses in thehomecontainer.Screenshot
n/a — the only visual change is the "Clear my rating" button going from
neutral-400toneutral-500grey.Stakeholders