2026-07-17 09:31:28 +02:00
|
|
|
# Test Report - T08: Bildretusche + Preisvergleich
|
2026-07-14 11:51:32 +02:00
|
|
|
|
2026-07-14 12:03:19 +02:00
|
|
|
## Backend Tests
|
2026-07-14 11:51:32 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
**Command:** `cd backend && python -m pytest tests/test_retouch.py --cov=app.services.retouch_service --cov=app.routers.image_retouch --cov-report=term-missing -v`
|
2026-07-14 11:51:32 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
**Result:** 38 passed, 0 failed
|
2026-07-14 11:51:32 +02:00
|
|
|
|
2026-07-17 02:28:41 +02:00
|
|
|
### Coverage
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-17 02:28:41 +02:00
|
|
|
| Module | Stmts | Miss | Cover |
|
|
|
|
|
|--------|-------|------|-------|
|
2026-07-17 09:31:28 +02:00
|
|
|
| app/routers/image_retouch.py | 52 | 16 | 69% |
|
|
|
|
|
| app/services/retouch_service.py | 132 | 5 | 96% |
|
|
|
|
|
| **TOTAL** | **184** | **21** | **89%** |
|
2026-07-17 01:58:34 +02:00
|
|
|
|
2026-07-17 02:28:41 +02:00
|
|
|
### Test Categories
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
#### TestRetouchService (20 tests)
|
|
|
|
|
- validate_mime_type_valid/invalid
|
|
|
|
|
- validate_file_size_valid/too_large
|
|
|
|
|
- generate_retouch_prompt_default/with_vehicle_info
|
|
|
|
|
- upload_retouch_file_success/invalid_mime/too_large
|
|
|
|
|
- get_result_not_found
|
|
|
|
|
- list_results_empty/with_data/filter_by_vehicle
|
|
|
|
|
- process_retouch_success (mocked Flux.1-Pro)
|
|
|
|
|
- process_retouch_failure (OpenRouter unavailable → status=failed)
|
|
|
|
|
- process_retouch_not_found
|
|
|
|
|
- _call_flux_pro_no_api_key
|
|
|
|
|
- _call_flux_pro_success_data_uri (base64 response)
|
|
|
|
|
- _call_flux_pro_success_list_content (list content parts)
|
|
|
|
|
- _call_flux_pro_fallback_original_bytes (no image in response)
|
|
|
|
|
|
|
|
|
|
#### TestPriceCompareService (4 tests)
|
|
|
|
|
- compare_prices_success (listings + average_price)
|
|
|
|
|
- compare_prices_vehicle_not_found
|
|
|
|
|
- compare_prices_listings_have_correct_make_model
|
|
|
|
|
- compare_prices_average_calculation
|
|
|
|
|
|
|
|
|
|
#### TestRetouchRouter (14 tests)
|
|
|
|
|
- POST /retouch/process → 202 + retouch_id (valid image)
|
|
|
|
|
- POST /retouch/process → 422 (no file)
|
|
|
|
|
- POST /retouch/process → 422 (invalid MIME)
|
|
|
|
|
- POST /retouch/process → 202 (with vehicle_id)
|
|
|
|
|
- GET /retouch/results/:id → 200 (completed)
|
|
|
|
|
- GET /retouch/results/:id → 200 (processing)
|
|
|
|
|
- GET /retouch/results/:id → 200 (failed + error_message)
|
|
|
|
|
- GET /retouch/results/:id → 404 (not found)
|
|
|
|
|
- POST /retouch/price-compare → 200 (success)
|
|
|
|
|
- POST /retouch/price-compare → 422 (no vehicle_id)
|
|
|
|
|
- POST /retouch/price-compare → 404 (vehicle not found)
|
|
|
|
|
- POST /retouch/process → 401 (unauthorized)
|
|
|
|
|
- GET /retouch/results/:id → 401 (unauthorized)
|
|
|
|
|
- POST /retouch/price-compare → 401 (unauthorized)
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-17 02:28:41 +02:00
|
|
|
## Frontend Tests
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
**Command:** `cd frontend && npx vitest run tests/retouch.test.tsx`
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
**Result:** 13 passed, 0 failed
|
2026-07-14 11:51:32 +02:00
|
|
|
|
2026-07-17 02:28:41 +02:00
|
|
|
### Test Categories
|
2026-07-14 11:51:32 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
#### RetouchUpload (5 tests)
|
|
|
|
|
- renders drag-and-drop zone
|
|
|
|
|
- shows file input with image accept
|
|
|
|
|
- shows error for non-image file
|
|
|
|
|
- uploads image file successfully (mocked fetch)
|
|
|
|
|
- shows error on upload failure
|
|
|
|
|
|
|
|
|
|
#### BeforeAfterSlider (3 tests)
|
|
|
|
|
- renders both images (before + after)
|
|
|
|
|
- renders labels (Original / Retuschiert)
|
|
|
|
|
- renders slider handle
|
|
|
|
|
|
|
|
|
|
#### PriceComparison (5 tests)
|
|
|
|
|
- renders vehicle ID input and compare button
|
|
|
|
|
- shows error when comparing without vehicle ID
|
|
|
|
|
- fetches and displays comparable listings (mocked apiFetch)
|
|
|
|
|
- shows empty state when no listings found
|
|
|
|
|
- shows error on fetch failure
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-14 20:16:15 +02:00
|
|
|
## Smoke Test
|
2026-07-14 12:03:19 +02:00
|
|
|
|
2026-07-17 09:31:28 +02:00
|
|
|
- Backend: App imports successfully, router registered at /api/v1/retouch
|
|
|
|
|
- Frontend: All 3 components render without errors in test environment
|
|
|
|
|
- OpenRouter mocked in all backend tests (no real API calls)
|
|
|
|
|
- Background task mocked in router integration tests (avoids event loop conflicts)
|