You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces a shared tests/e2e/testUtils.ts with browser-context sign-in helpers (guest, pending-join, member, admin) and reusable redirect-assertion helpers, then wires them into new e2e specs for the home, login, members, and profile routes.
expectPageRedirectsUnlessApprovedMember (used by home.spec.ts) never asserts that an approved member can access the page — unlike the analogous helpers expectPageRedirectsUnlessAdmin and expectPageDoesNotRedirect which both include the positive case. A regression that blocks approved members would silently pass.
The three sign-in helpers still call signUpAndGetHeaders, which is marked @deprecated in tests/unit/testUtils.ts in favour of signUpAndGetSession.
Confidence Score: 4/5
Safe to merge after fixing the missing positive-case assertion in expectPageRedirectsUnlessApprovedMember.
One P1 finding: expectPageRedirectsUnlessApprovedMember skips the positive assertion that approved members can access the route, meaning a regression blocking approved members would go undetected. The remaining findings are P2 (deprecated helper usage, redundant await). Score is 4 pending the P1 fix.
tests/e2e/testUtils.ts — specifically the expectPageRedirectsUnlessApprovedMember function.
Important Files Changed
Filename
Overview
tests/e2e/testUtils.ts
New e2e test utility file with sign-in helpers and redirect-assertion helpers; uses deprecated signUpAndGetHeaders, and expectPageRedirectsUnlessApprovedMember is missing the positive-case assertion for approved members.
tests/e2e/home.spec.ts
New e2e tests for the home route using the shared helpers; positive admin-access case covered by a separate test.
tests/e2e/login.spec.ts
New e2e login tests; contains a redundant await on the synchronous buildTestUser() call at line 10.
tests/e2e/members.spec.ts
Comprehensive e2e tests for the members page covering RBAC, column headers, pagination, and feature-flag disable; no issues found.
tests/e2e/profile.spec.ts
e2e tests for the profile page covering auth gates, UI elements, tab navigation, and conditional event navigation; no issues found.
app/members/page.tsx
Members page with admin-only guard, pagination, and server action for direct member addition; no issues found in this PR's changes.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Test starts] --> B{User state}
B -->|No cookies / guest| C[goto path]
C --> D[expect redirect to /login]
B -->|Pending join request| E[createTestUserWithPendingJoinRequestAndSignIn]
E --> F[goto path]
F --> G[expect redirect to /joinrequeststatus]
B -->|Approved member| H[createTestMemberAndSignIn]
H --> I[goto path]
I --> J{helper used?}
J -->|expectPageRedirectsUnlessAdmin| K[expect redirect to /]
J -->|expectPageDoesNotRedirect| L[expect stay on path]
J -->|expectPageRedirectsUnlessApprovedMember| M[NOT TESTED]
B -->|Admin| N[createTestAdminAndSignIn]
N --> O[goto path]
O --> P[expect stay on path]
buildTestUser is a synchronous function (returns a plain object, not a Promise), so adding await is incorrect. While JavaScript silently coerces the result, TypeScript may produce a lint warning, and it signals to readers that the function is async when it isn't.
signUpAndGetHeaders is marked @deprecated in tests/unit/testUtils.ts with a note to use signUpAndGetSession instead. It's called in three of the helpers defined here (createTestUserAndSignIn, createTestUserWithPendingJoinRequestAndSignIn, and elsewhere). Consider migrating to signUpAndGetSession, which already returns headers alongside the session, to keep the test utilities consistent with the guidance in the shared utils file.
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
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 #
Checklist: