| name | audit-tests |
| description | Audit & fix unit tests for permission-gated components |
Check that unit tests exist and pass for permission-gated components. Write missing tests immediately.
Infrastructure
- Framework: Vitest with jsdom
- Component testing:
@testing-library/react + @testing-library/jest-dom
- Setup:
apps/app/src/test-utils/setup.ts
- Permission mocks:
apps/app/src/test-utils/mocks/permissions.ts
- Run:
cd apps/app && bunx vitest run
Required Test Pattern
Every component importing usePermissions MUST have tests covering:
- Admin (write) user: mutation elements visible/enabled
- Auditor (read-only): mutation elements hidden/disabled
- Data always visible: read-only content renders regardless of permissions
Use setMockPermissions, ADMIN_PERMISSIONS, AUDITOR_PERMISSIONS from test utils.
Process
- Find components with
usePermissions in $ARGUMENTS
- Check for corresponding
.test.tsx files
- Write missing tests following the pattern above
- Fix any failing tests
- Run:
cd apps/app && bunx vitest run