This directory contains integration tests for the team management feature in league settings. The tests are written using Vitest and cover the following functionality:
- **Remove Team Owner**: Commissioners can remove owners from teams
- **Assign Team Owner**: Admins can assign users to teams via dropdown
- **Authorization**: Proper access control for commissioners vs admins
- **Edge Cases**: Handling invalid inputs and error scenarios
- **Integration Scenarios**: Complete workflows and multi-team operations
## Test Structure
### Test File
-`team-management.test.ts` - Main test suite for team management features
### Fixtures
-`app/test/fixtures/user.ts` - Mock user data including admin and regular users
-`app/test/fixtures/team.ts` - Mock team data
-`app/test/fixtures/league.ts` - Mock league data
## Running Tests
### Run all tests
```bash
npm test
```
### Run tests in watch mode
```bash
npm run dev:test
```
### Run tests with UI
```bash
npm run test:ui
```
### Run tests with coverage
```bash
npm run test:coverage
```
### Run only team management tests
```bash
npm test team-management
```
## Test Coverage
The test suite covers:
### 1. Remove Owner Functionality (4 tests)
- ✅ Successfully remove an owner from a team
- ✅ Handle errors when removal fails
- ✅ Allow commissioners to remove owners
- ✅ Verify proper database calls
### 2. Assign Owner Functionality (5 tests)
- ✅ Successfully assign an owner to a team
- ✅ Handle errors when assignment fails
- ✅ Only allow admins to assign owners
- ✅ Prevent non-admins from assigning owners
- ✅ Replace existing owner when assigning new owner
### 3. Admin User List (3 tests)
- ✅ Fetch all users for admin dropdown
- ✅ Only fetch users when user is admin
- ✅ Return empty array for non-admin users
### 4. Authorization (3 tests)
- ✅ Verify admin status before allowing assignment
- ✅ Reject assignment for non-admin users
- ✅ Allow commissioners to remove owners regardless of admin status