Skip to content

Add Jest Test Infrastructure and Comprehensive Tests for User - #54

Open
Shengle-Dai wants to merge 3 commits into
mainfrom
setup-backend-test
Open

Add Jest Test Infrastructure and Comprehensive Tests for User#54
Shengle-Dai wants to merge 3 commits into
mainfrom
setup-backend-test

Conversation

@Shengle-Dai

Copy link
Copy Markdown
Contributor

This PR introduces Jest testing infrastructure with ts-jest, along with mocks and fixtures for Prisma, Supabase, and Express. It adds comprehensive unit and E2E tests for the User domain (services, handlers, and router), ensuring coverage of authentication, validation, and data access flows.

Added tests for:

  • Services: user lookup, orders, organizations, updates, email search.
  • Router: E2E coverage for /api/user endpoints with validation, auth, and success paths.
  • Handlers: full unit tests for all user handlers.

Notes:

  • Tests run fully offline with mocked Prisma/Supabase.
  • No runtime changes, test-only update.

@netlify

netlify Bot commented Oct 10, 2025

Copy link
Copy Markdown

Deploy Preview for curaise ready!

Name Link
🔨 Latest commit 0ec5967
🔍 Latest deploy log https://app.netlify.com/projects/curaise/deploys/68f2a9b3d1860e00083045bf
😎 Deploy Preview https://deploy-preview-54--curaise.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.

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.

Nice work on the pr! this will be really useful for us. Just had one comment to add:

In a few tests there is:

mockSupabaseAuth.getUser.mockResolvedValue({
  data: { user: createMockSupabaseUser(userId) },
});

but the supabase.auth.getUser() and default mock return both data and error:

{ data: { user: ... }, error: null }

You could make the overrides always include error: null or add a small helper func like setAuthenticatedUser() that sets the full shape for consistency. That’ll help us avoid tests breaking if auth logic ever checks error.

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.

2 participants