Aniworld/TestsTodo.md
2025-10-12 18:05:31 +02:00

181 lines
6.5 KiB
Markdown

# AniWorld Test Generation Checklist
This file instructs the AI agent on how to generate tests for the AniWorld application. All tests must be saved under `src/tests/` and follow the conventions in `.github/copilot-instructions.md`. Use `[ ]` for each task so the agent can checkmark completed items.
---
## 📁 Test File Structure
- [x] Place all tests under `src/tests/`
- [x] `src/tests/unit/` for component/unit tests
- [x] `src/tests/integration/` for API/integration tests
- [x] `src/tests/e2e/` for end-to-end tests
---
## 🧪 Test Types
- [x] Component/Unit Tests: Test individual functions, classes, and modules.
- [x] API/Integration Tests: Test API endpoints and database/external integrations.
- [x] End-to-End (E2E) Tests: Simulate real user flows through the system.
---
## 📝 Test Case Checklist
### 1. Authentication & Security
- [x] Unit: Password hashing (SHA-256 + salt)
- [x] Unit: JWT creation/validation
- [x] Unit: Session timeout logic
- [x] API: `POST /auth/login` (valid/invalid credentials)
- [x] API: `GET /auth/verify` (valid/expired token)
- [x] API: `POST /auth/logout`
- [x] Unit: Secure environment variable management
- [x] E2E: Full login/logout flow
### 2. Health & System Monitoring
- [x] API: `/health` endpoint
- [x] API: `/api/health` endpoint
- [x] API: `/api/health/system` (CPU, memory, disk)
- [x] API: `/api/health/database`
- [x] API: `/api/health/dependencies`
- [x] API: `/api/health/performance`
- [x] API: `/api/health/metrics`
- [x] API: `/api/health/ready`
- [x] Unit: System metrics gathering
### 3. Anime & Episode Management
- [x] API: `GET /api/anime/search` (pagination, valid/invalid query)
- [x] API: `GET /api/anime/{anime_id}` (valid/invalid ID)
- [x] API: `GET /api/anime/{anime_id}/episodes`
- [x] API: `GET /api/episodes/{episode_id}`
- [x] Unit: Search/filter logic
### 4. Database & Storage Management
- [x] API: `GET /api/database/info`
- [x] API: `/maintenance/database/vacuum`
- [x] API: `/maintenance/database/analyze`
- [x] API: `/maintenance/database/integrity-check`
- [x] API: `/maintenance/database/reindex`
- [x] API: `/maintenance/database/optimize`
- [x] API: `/maintenance/database/stats`
- [x] Unit: Maintenance operation logic
### 5. Bulk Operations
- [x] API: `/api/bulk/download`
- [x] API: `/api/bulk/update`
- [x] API: `/api/bulk/organize`
- [x] API: `/api/bulk/delete`
- [x] API: `/api/bulk/export`
- [x] E2E: Bulk download and export flows
### 6. Performance Optimization
- [x] API: `/api/performance/speed-limit`
- [x] API: `/api/performance/cache/stats`
- [x] API: `/api/performance/memory/stats`
- [x] API: `/api/performance/memory/gc`
- [x] API: `/api/performance/downloads/tasks`
- [x] API: `/api/performance/downloads/add-task`
- [x] API: `/api/performance/resume/tasks`
- [x] Unit: Cache and memory management logic
### 7. Diagnostics & Logging
- [x] API: `/diagnostics/report`
- [x] Unit: Error reporting and stats
- [x] Unit: Logging configuration and log file management
### 8. Integrations
- [x] API: API key management endpoints
- [x] API: Webhook configuration endpoints
- [x] API: Third-party API integrations
- [x] Unit: Integration logic and error handling
### 9. User Preferences & UI
- [x] API: Theme management endpoints
- [x] API: Language selection endpoints
- [x] API: Accessibility endpoints
- [x] API: Keyboard shortcuts endpoints
- [x] API: UI density/grid/list view endpoints
- [x] E2E: Change preferences and verify UI responses
### 10. CLI Tool
- [x] Unit: CLI commands (scan, search, download, rescan, display series)
- [x] E2E: CLI flows (progress bar, retry logic)
### 11. Miscellaneous
- [x] Unit: Environment configuration loading
- [x] Unit: Modular architecture components
- [x] Unit: Centralized error handling
- [x] API: Error handling for invalid requests
---
## 🛠️ Additional Guidelines
- [x] Use `pytest` for all Python tests.
- [x] Use `pytest-mock` or `unittest.mock` for mocking.
- [x] Use fixtures for setup/teardown.
- [x] Test both happy paths and edge cases.
- [x] Mock external services and database connections.
- [x] Use parameterized tests for edge cases.
- [x] Document each test with a brief description.
---
# Test TODO
## Application Flow & Setup Tests
### Setup Page Tests
- [x] Test setup page is displayed when configuration is missing
- [x] Test setup page form submission creates valid configuration
- [x] Test setup page redirects to auth page after successful setup
- [x] Test setup page validation for required fields
- [x] Test setup page handles database connection errors gracefully
- [x] Test setup completion flag is properly set in configuration
### Authentication Flow Tests
- [x] Test auth page is displayed when authentication token is invalid
- [x] Test auth page is displayed when authentication token is missing
- [x] Test successful login creates valid authentication token
- [x] Test failed login shows appropriate error messages
- [x] Test auth page redirects to main application after successful authentication
- [x] Test token validation middleware correctly identifies valid/invalid tokens
- [x] Test token refresh functionality
- [x] Test session expiration handling
### Main Application Access Tests
- [x] Test index.html is served when authentication is valid
- [x] Test unauthenticated users are redirected to auth page
- [x] Test users without completed setup are redirected to setup page
- [x] Test middleware enforces correct flow priority (setup → auth → main)
- [x] Test authenticated user session persistence
- [x] Test graceful handling of token expiration during active session
### Integration Flow Tests
- [x] Test complete user journey: setup → auth → main application
- [x] Test application behavior when setup is completed but user is not authenticated
- [x] Test application behavior when configuration exists but is corrupted
- [x] Test concurrent user sessions and authentication state management
- [x] Test application restart preserves setup and authentication state appropriately
---
**Instruction to AI Agent:**
Generate and check off each test case above as you complete it. Save all test files under `src/tests/` using the specified structure and conventions.