Skip to content

test(react): add tests and mocks for invitation components#162

Open
rax7389 wants to merge 1 commit intofeat/mm-invitations-hook-containerfrom
feat/mm-invitations-tests
Open

test(react): add tests and mocks for invitation components#162
rax7389 wants to merge 1 commit intofeat/mm-invitations-hook-containerfrom
feat/mm-invitations-tests

Conversation

@rax7389
Copy link
Copy Markdown
Contributor

@rax7389 rax7389 commented Mar 14, 2026

Changes

Summary: Adds comprehensive test coverage and reusable mock utilities for all invitation management components and hooks introduced in earlier PRs.

Why: This PR adds the full test suite, ensuring every component and hook is covered for rendering, user interactions, edge cases, and accessibility. Reusable mock factories are provided so future tests can spin up test data consistently.

What:

Test Suites

  1. InvitationDetailsModal tests — Rendering, role resolution, read-only mode, button states.

  2. InvitationRevokeModal tests — Revoke vs revoke-and-resend flows, confirmation callbacks.

  3. InvitationTableActionsColumn tests — Context-aware actions, Copy URL visibility, read-only mode.

  4. InvitationCreateModal tests — Zod validation, duplicate email rejection, form submission.

  5. SearchFilter tests — Role filter rendering, empty roles handling.

describe('SearchFilter', () => {
  it('should render role filter with available roles', () => { ... });
  it('should return null when no roles available', () => { ... });
});
  1. useMemberManagementService tests — Service layer hook tests for API calls and mutations.

Mock Utilities

invitation.mocks.ts — Reusable factory functions for consistent test data:

createMockInvitation(overrides?)        // Base invitation with sensible defaults
createMockPendingInvitation(overrides?) // Invitation with future expires_at
createMockExpiredInvitation(overrides?) // Invitation with past expires_at
createMockRoles()                       // [Admin, Member, Viewer]
createMockProviders()                   // [Google, GitHub]
createMockSearchFilterProps(overrides?) // Full props for SearchFilter

core-client.mocks.ts — Added invitations mock methods (list, get, create, delete) to createMockMyOrgApiService.

References

Part of the member management invitations feature.

Testing

  • This change adds unit test coverage
  • This change has been tested on the latest version of the platform/language

All tests pass. Run with npm run test from packages/react.

Checklist

@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 2d3d1df to 312a1ae Compare March 14, 2026 12:07
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from bcca8bf to c50d1d9 Compare March 14, 2026 12:08
@rax7389 rax7389 self-assigned this Mar 15, 2026
@rax7389 rax7389 added the test contains only test cases label Mar 15, 2026
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 312a1ae to b1ad377 Compare March 29, 2026 17:45
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from c50d1d9 to 996913e Compare March 29, 2026 17:47
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from b1ad377 to 1755393 Compare March 29, 2026 17:52
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 996913e to 3a5757f Compare March 29, 2026 17:53
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 1755393 to abd498c Compare April 8, 2026 09:05
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 3a5757f to 4c1f1e1 Compare April 8, 2026 09:09
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from dd0358c to 89fff00 Compare April 8, 2026 10:45
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 4c1f1e1 to 00772c3 Compare April 8, 2026 10:45
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 89fff00 to f5d3f6e Compare April 8, 2026 11:00
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 00772c3 to 8c4baf4 Compare April 8, 2026 11:01
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from f5d3f6e to 2880189 Compare April 8, 2026 11:08
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 8c4baf4 to dba1f1b Compare April 8, 2026 11:09
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 2880189 to 4184f90 Compare April 8, 2026 11:18
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from dba1f1b to 1fc27b0 Compare April 8, 2026 11:19
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from 4184f90 to d1e9fd7 Compare April 8, 2026 11:24
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 1fc27b0 to 33e7ec0 Compare April 8, 2026 11:25
@rax7389 rax7389 force-pushed the feat/mm-invitations-hook-container branch from d1e9fd7 to 5b79311 Compare April 8, 2026 11:33
@rax7389 rax7389 force-pushed the feat/mm-invitations-tests branch from 33e7ec0 to b725dd0 Compare April 8, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test contains only test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant