feat: add admin dashboard, audit logs, token expiry check and test suite

Frontend Features:
- Add ProtectedRoute component with token expiry validation
- Create AdminDashboardPage with system statistics and user management
- Create AuditLogsPage with filtering and pagination
- Add admin-only navigation (Shield icon) for ymirliu@panjit.com.tw
- Add admin API methods to apiV2 service
- Add admin type definitions (SystemStats, AuditLog, etc.)

Token Management:
- Auto-redirect to login on token expiry
- Check authentication on route change
- Show loading state during auth check
- Admin privilege verification

Backend Testing:
- Add pytest configuration (pytest.ini)
- Create test fixtures (conftest.py)
- Add unit tests for auth, tasks, and admin endpoints
- Add integration tests for complete workflows
- Test user isolation and admin access control

Documentation:
- Add TESTING.md with comprehensive testing guide
- Include test running instructions
- Document fixtures and best practices

Routes:
- /admin - Admin dashboard (admin only)
- /admin/audit-logs - Audit logs viewer (admin only)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-11-16 18:01:50 +08:00
parent fd98018ddd
commit 8f94191914
13 changed files with 1554 additions and 45 deletions

View File

@@ -1,32 +1,13 @@
[pytest]
# Pytest configuration for Tool_OCR backend tests
# Test discovery patterns
testpaths = tests
python_files = test_*.py
python_classes = Test*
python_functions = test_*
# Directories to search for tests
testpaths = tests
# Output options
addopts =
-v
--strict-markers
--tb=short
--color=yes
--maxfail=5
# Markers for categorizing tests
markers =
unit: Unit tests for individual components
integration: Integration tests for service interactions
slow: Tests that take longer to run
requires_models: Tests that require PaddleOCR models
# Coverage options (optional)
# addopts = --cov=app --cov-report=html --cov-report=term
# Logging
log_cli = false
log_cli_level = INFO
unit: Unit tests
integration: Integration tests
slow: Slow running tests