generated from psd401/psd-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or requestpriority-highP1 - High priorityP1 - High priority
Description
Summary
Add comprehensive E2E test coverage for the User Management feature (Issue #579, PR #580) as required by CLAUDE.md.
Per CLAUDE.md requirement: "Testing: Add E2E tests for new features"
Motivation
The User Management feature is a critical admin feature with 2,519 lines of code across multiple components. E2E tests will ensure:
- User workflows function correctly
- Race conditions are handled properly
- Error states provide good UX
- Security features (authorization, self-deletion prevention) work as expected
Test Plan
Comprehensive test plan documented in app/(protected)/admin/users/_components/users-page-client.tsx:1-46
1. User Listing with Filters
Tests needed:
- Search by name (debounced input)
- Search by email (debounced input)
- Filter by status (active/inactive/pending)
- Filter by role (administrator/staff/student)
- Role tabs switch correctly (All/Admins/Staff/Students)
- Clear filters button resets all filters
- Filters combine correctly (search + status + role)
- Debounce prevents excessive requests (< 300ms)
2. User Detail Sheet Interactions
Tests needed:
- Click table row opens detail sheet
- Detail sheet displays correct user information
- Name, email, roles, status
- Created date, last sign-in date
- Activity summary (conversations, prompts used, last activity)
- Tab navigation works (Overview, Permissions, API Usage, Activity)
- Loading state shows while activity data fetches
- Close detail sheet with X button or backdrop click
3. Role Updates
Tests needed:
- Click Edit button enters edit mode
- Edit first name and last name
- Change user role (single selection)
- Save button updates user successfully
- Local state updates immediately after save
- Cancel button reverts changes
- Error message displays on failed update
- Cannot save without first name
- Cannot save without last name
4. User Deletion Flow
Tests needed:
- Click Delete from row menu opens confirmation dialog
- Dialog shows correct user name
- Cancel button closes dialog without deletion
- Confirm button deletes user
- User removed from list after deletion
- Stats refresh after deletion (total users count decreases)
- Error message on failed deletion
- Cannot delete own account (admin self-deletion prevention)
5. Stats Display
Tests needed:
- Stats display on page load
- Total users count
- Active users (signed in within 30 days)
- Pending invites (never signed in)
- Administrator count
- Stats update after user deletion
- Stats loading skeleton shows while loading
6. Race Condition Prevention
Tests needed:
- Multiple rapid filter changes handled correctly
- Multiple rapid tab changes handled correctly
- Loading indicator prevents concurrent requests
- Latest request wins if multiple queued
Implementation Notes
Test Location
- All tests should be added to
/tests/e2e/working-tests.spec.ts - Alternatively, use Playwright MCP during development for faster iteration
Test Data Setup
- Tests require admin user authentication
- May need test user seeding for consistent results
- Consider database reset between test runs
Existing Patterns
- Reference existing E2E tests in
/tests/e2e/working-tests.spec.ts - Follow established patterns for authentication, navigation, assertions
- See
/tests/e2e/playwright-mcp-examples.mdfor examples
Acceptance Criteria
- All 30+ test scenarios documented above are implemented
- Tests pass consistently on CI
- Tests use proper Playwright selectors (prefer
data-testidover text) - Tests clean up after themselves (no database pollution)
- Tests run in under 5 minutes total
Related
- Feature: feat: Redesign User Management Admin Section #579
- PR: feat(admin): redesign user management with dashboard stats and detail view #580
- Documentation:
/docs/features/user-management.md(to be created)
Priority
High - This is a critical admin feature that requires test coverage before merging to main.
coderabbitai
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestpriority-highP1 - High priorityP1 - High priority