test(auth): E2E-AUTH-005 — Invite Request CTA#408
Conversation
|
@Sakshamk17 is attempting to deploy a commit to the Louis Girifalco's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds Playwright E2E coverage for the invite request CTA flow at /auths/request-access, and updates the request-access UI to be more semantic/testable via stable data-testid selectors. It also adjusts Jest versions to restore unit test compatibility after an upstream Jest major bump.
Changes:
- Refactors the request-access CTA from a
div-driven submit to a semantic<form onSubmit>and addsdata-testidselectors for E2E targeting. - Introduces Playwright E2E scenarios for invite request success + duplicate handling, with GraphQL operation mocking by operation name.
- Downgrades Jest to 29.x (and updates
ts-jest) to address a Jest/ts-jest compatibility break.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| quotevote-frontend/src/components/RequestAccess/PersonalForm/PersonalForm.tsx | Adds invite-success-message selector to support success-state assertions. |
| quotevote-frontend/src/app/auths/request-access/PageContent.tsx | Converts CTA into a form and adds test ids for form/input/button and error message. |
| quotevote-frontend/e2e/auth.spec.ts | Adds E2E-AUTH-005 invite request tests and a GraphQL operation mocking helper. |
| quotevote-frontend/package.json | Downgrades Jest and bumps ts-jest to restore unit test compatibility. |
| quotevote-frontend/pnpm-lock.yaml | Updates lockfile to reflect Jest/ts-jest dependency changes. |
Files not reviewed (1)
- quotevote-frontend/pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <form | ||
| data-testid="invite-request-form" | ||
| onSubmit={(e) => { e.preventDefault(); onSubmit(); }} | ||
| style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: 8, marginBottom: 8 }} | ||
| > |
| <button | ||
| data-testid="invite-submit-button" | ||
| onClick={onSubmit} | ||
| disabled={loading} |
| {errorMessage && ( | ||
| <p style={{ color: '#fff', margin: '4px 0 12px', fontSize: 14 }}>{errorMessage}</p> | ||
| <p data-testid="invite-duplicate-message" style={{ color: '#fff', margin: '4px 0 12px', fontSize: 14 }}>{errorMessage}</p> | ||
| )} |
| <div className="flex flex-col items-center justify-center min-h-screen py-12 px-4"> | ||
| <div className="w-full max-w-6xl"> | ||
| <h1 className="text-center text-2xl md:text-4xl font-bold mb-4 md:mb-8"> | ||
| <h1 data-testid="invite-success-message" className="text-center text-2xl md:text-4xl font-bold mb-4 md:mb-8"> |
| * password setup, admin invite management, email delivery. | ||
| */ | ||
|
|
||
| const GRAPHQL_URL = "http://localhost:4000/graphql"; |
| // 2. Email input accepts a registered email address | ||
| await emailInput.fill(registeredUser.email); | ||
| await emailInput.dispatchEvent("input"); | ||
|
|
| await emailInput.fill(visitorEmail); | ||
| await submitButton.click(); |
| "jest": "^29.7.0", | ||
| "jest-environment-jsdom": "^29.7.0", | ||
| "next-test-api-route-handler": "^5.0.3", | ||
| "prettier": "^3.7.1", | ||
| "tailwindcss": "^4", | ||
| "ts-jest": "^29.4.5", | ||
| "ts-jest": "^29.4.11", | ||
| "tw-animate-css": "^1.4.0", |
| ts-jest: | ||
| specifier: ^29.4.5 | ||
| version: 29.4.5(@babel/core@7.28.5)(@jest/transform@30.2.0)(@jest/types@30.2.0)(babel-jest@30.2.0(@babel/core@7.28.5))(jest-util@30.2.0)(jest@30.2.0(@types/node@20.19.25))(typescript@5.9.3) | ||
| specifier: ^29.4.11 | ||
| version: 29.4.11(@babel/core@7.28.5)(@jest/transform@30.2.0)(@jest/types@30.2.0)(babel-jest@30.2.0(@babel/core@7.28.5))(jest-util@30.2.0)(jest@29.7.0(@types/node@20.19.25))(typescript@5.9.3) | ||
| tw-animate-css: |
Note on CI Failure —
|
There was a problem hiding this comment.
Nice work @Sakshamk17. Clean and well-scoped -- the E2E spec covers both the happy path and the duplicate handling path, the mockGraphQLOperation helper is reusable, and the <form onSubmit> refactor in PageContent.tsx is a good accessibility improvement. The note about page.keyboard.type() vs fill() for react-hook-form compatibility is a helpful detail for future contributors.
The Jest 30 → 29 downgrade to fix the ts-jest incompatibility is the right call given the broken state on main. Good catch documenting that in the PR description.
One minor thing: the <button onClick={onSubmit}> in PageContent.tsx still has the old onClick handler alongside the new <form onSubmit>. Since the form's onSubmit already calls onSubmit(), the button's onClick is redundant and will fire the submission twice if someone clicks (once from onClick, once from the form submit event). You should remove the onClick from the button and just keep type="submit".
One a last thing make sure the frontend pnpm lint, type-check and test are passing.
Verdict: Will be merge after removing the redundant onClick={onSubmit} from the submit button and the pnpm lint, type-check and test are passed.
Thank you!!
Reviewer Feedback Addressed
|
|
Hey @Sakshamk17 the correct command for lint check is use these commands locally in frontend directory: Thank you!! |
f2084b6 to
1336516
Compare
Summary
Fixes issue #397 .
This PR introduces Playwright end-to-end test coverage for the invite request CTA at
/auths/request-access, covering both the happy path (successful submission) and the duplicate handling path. It also resolves a blocking semantic issue inPageContent.tsxwhere the form lacked a proper<form>element, and adds thedata-testidselectors required for stable test targeting.Changes Implemented
Fixes & Enhancements
PageContent.tsxfrom an unstablediv + onClicksetup to a semantic<form onSubmit>, enabling native Enter key submission and proper form accessibilitydata-testidattributes acrossPageContent.tsxandPersonalForm.tsxper the selectors specified in the issue:invite-request-forminvite-email-inputinvite-submit-buttoninvite-duplicate-messageinvite-success-messageTest Implementation
e2e/auth.spec.tsunder theInvite Request CTA (E2E-AUTH-005)describe block:checkDuplicateEmail(empty) andrequestUserAccess(success), verifies the "Thank you for joining us" confirmation renderscheckDuplicateEmail(existing record), verifies "This email already exists" message appears and the success state does not rendermockGraphQLOperation()helper to intercept Apollo GraphQL requests by operation name, avoiding any dependency on a live backendBug Fix — Jest/ts-jest version mismatch
jest@30whilets-jestis still onv29— these are incompatible and caused Jest's globals (describe,jest,it) to stop being injected, breaking the entire unit test suitejestandjest-environment-jsdomfrom30.x→29.7.0to restore compatibility withts-jest@29.4.11Verification
Notes for Reviewers
Both GraphQL operations (
checkDuplicateEmailquery andrequestUserAccessmutation) are mocked at the network layer viapage.route()since no real backend is required for this test to be meaningful. Operation names match the camelCase definitions insrc/graphql/queries.tsandsrc/graphql/mutations.tsexactly.page.keyboard.type()is used instead of Playwright'sfill()for the email input. This is intentional —react-hook-formwithzodResolverrequires real keyboard events to trigger validation and enable the submit button.fill()bypasses React's synthetic event system and leaves the button permanently disabled.The
SettingsContenttimeout flake andProfileHeaderCoverassertion failure are both pre-existing upstream issues introduced before this branch and are not caused by these changes.