# Test: Default Status Management

# 🧪 Default Status Management Test Plan

## 📋 Test Overview

This test plan validates the default status management functionality for custom task statuses.

Requirements: 5.1, 5.2, 5.3, 5.4, 5.5

## 🔧 Setup Instructions

1. Ensure backend server is running: `cd backend && uvicorn main:app --reload`
2. Ensure frontend server is running: `cd frontend && npm run dev`
3. Login as a coordinator or admin user
4. Navigate to a project's settings page
5. Go to the "Tasks" tab to access Custom Task Status Manager

## ✅ Test Cases

### Test 1: Visual Indicator for Default Status

Requirement: 5.1 - WHEN a user views the status list THEN the system SHALL indicate which status is the default

- View the custom statuses list
- Verify that the default status has a "Default" badge with a star icon
- Verify that non-default statuses show "Custom" badge instead
- Verify that system statuses show "System" badge

Expected: Default status should be clearly marked with a distinctive badge containing a star icon.

### Test 2: Set Status as Default

Requirement: 5.2 - WHEN a user clicks "Set as Default" on a status THEN the system SHALL mark that status as the default and remove the default flag from other statuses

- Create at least 2 custom statuses if not already present
- Identify which status is currently the default
- Click "Set as Default" button on a different status
- Verify success toast message appears
- Verify the clicked status now shows "Default" badge
- Verify the previous default status now shows "Custom" badge
- Verify only ONE status has the "Default" badge

Expected: Only one status should be marked as default at any time. Setting a new default should automatically unset the previous default.

### Test 3: Set as Default Button Visibility

Requirement: UI should show "Set as Default" button only for non-default statuses

- View the custom statuses list
- Verify that non-default statuses have a "Set as Default" button
- Verify that the default status does NOT have a "Set as Default" button
- Set a different status as default
- Verify the button visibility updates correctly

Expected: The "Set as Default" button should only appear for statuses that are not currently the default.

### Test 4: Default Status for New Tasks

Requirement: 5.3 - WHEN a new task is created without an explicit status THEN the system SHALL assign the project's default status

- Set a custom status as the default (e.g., "Ready to Start")
- Navigate to a shot or asset in the project
- Create a new task without specifying a status
- Verify the task is created with the default custom status
- Change the default status to a different one
- Create another new task
- Verify the new task uses the updated default status

Expected: New tasks should automatically receive the project's default status when no status is explicitly specified.

### Test 5: Fallback to System Default

Requirement: 5.4 - WHEN no custom statuses exist THEN the system SHALL use "not_started" as the default status

- Delete all custom statuses (if any exist)
- Create a new task
- Verify the task is created with "not_started" status
- Create a custom status but don't set it as default
- Create another new task
- Verify the task still uses "not_started" as default

Expected: When no custom default is set, the system should fall back to "not_started" as the default status.

### Test 6: Default Status Deletion Handling

Requirement: 5.5 - WHEN a default status is deleted THEN the system SHALL automatically assign the first status in the list as the new default

- Create at least 2 custom statuses
- Set one as the default
- Delete the default status (with task reassignment if needed)
- Verify the deletion succeeds
- Verify another status is automatically marked as default
- Create a new task to confirm the new default is applied

Expected: Deleting the default status should automatically promote another status to be the new default.

### Test 7: Edit Dialog Default Checkbox

Requirement: Users should be able to set default status through the edit dialog

- Click the edit button on a non-default status
- Verify the "Set as default status for new tasks" checkbox is present
- Verify the checkbox is unchecked
- Check the checkbox and save
- Verify the status is now marked as default
- Edit the default status
- Verify the checkbox is checked
- Uncheck it and save
- Verify the status is no longer default

Expected: The edit dialog should allow toggling the default status via checkbox.

### Test 8: Concurrent Default Status Updates

Requirement: System should handle multiple users trying to set default status

- Open the project settings in two different browser tabs/windows
- In tab 1, set status A as default
- In tab 2, set status B as default
- Refresh both tabs
- Verify only one status is marked as default
- Verify the last update wins

Expected: The system should maintain consistency even with concurrent updates.

### Test 9: Button Disabled States

Requirement: UI should prevent actions during operations

- Click "Set as Default" on a status
- Verify the button shows loading state or is disabled
- Verify other "Set as Default" buttons are also disabled
- Wait for the operation to complete
- Verify buttons are re-enabled
- Start a drag-and-drop reorder operation
- Verify "Set as Default" buttons are disabled during reorder

Expected: Buttons should be disabled during operations to prevent race conditions.

### Test 10: API Response Validation

Requirement: Backend should correctly handle default status updates

- Open browser DevTools Network tab
- Set a status as default
- Verify PUT request to `/api/projects/{id}/task-statuses/{status_id}`
- Verify request body includes `is_default: true`
- Verify response includes updated statuses list
- Verify only one status has `is_default: true` in response

Expected: API should correctly update the default status and return consistent data.

## 🐛 Known Issues / Edge Cases

- What happens if all custom statuses are deleted? (Should fall back to system default)
- Can system statuses be set as default? (No, only custom statuses)
- What if the default status is in use by many tasks and gets deleted? (Should reassign and set new default)

## 📊 Test Results

Record your test results here:

✅ All tests passed? If yes, mark task 15 as complete in the implementation plan!