Skip to content

implement test utils - #178

Merged
krishpra2315 merged 2 commits into
mainfrom
krish/124-test-utils
Apr 4, 2026
Merged

krishpra2315 merged 2 commits into
mainfrom
krish/124-test-utils

Conversation

@krishpra2315

Copy link
Copy Markdown
Collaborator

Closes #

Checklist:

  • I have mentioned a ticket above
  • My changes meet the acceptance criteria of said ticket
  • I have self-reviewed my changes
  • I have requested a review from the appropriate team member(s)
  • I have fixed all merge conflicts
  • I have ensured CI checks pass

@netlify

netlify Bot commented Apr 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for servicestart ready!

Name Link
🔨 Latest commit 9f3ca9f
🔍 Latest deploy log https://app.netlify.com/projects/servicestart/deploys/69d165544a1156000852f5bf
😎 Deploy Preview https://deploy-preview-178--servicestart.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@renatodellosso renatodellosso linked an issue Apr 4, 2026 that may be closed by this pull request
5 tasks

@renatodellosso renatodellosso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@greptile-apps

greptile-apps Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

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]
Loading

Comments Outside Diff (2)

  1. tests/e2e/login.spec.ts, line 10 (link)

    P2 Redundant await on synchronous function

    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.

  2. tests/e2e/testUtils.ts, line 30-35 (link)

    P2 Using @deprecated helper signUpAndGetHeaders

    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.

Reviews (1): Last reviewed commit: "Merge branch 'main' into krish/124-test-..." | Re-trigger Greptile

Comment thread tests/e2e/testUtils.ts
@krishpra2315
krishpra2315 merged commit 1507f40 into main Apr 4, 2026
17 of 25 checks passed
@krishpra2315
krishpra2315 deleted the krish/124-test-utils branch April 4, 2026 19:42

This branch was previously deployed

1 inactive deployment
Preview — 9f3ca9f0 Deployed Apr 4, 2026 by krishpra2315 via drop-db #166
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.

E2E Test Utils

2 participants