A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.
This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).
Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4.0 KiB
4.0 KiB
H5P Service Tests
Übersicht
Das H5P Service Modul verfügt über umfassende Integration Tests, die alle Endpoints und Content-Typen validieren.
Test-Coverage
Module
- Server Endpoints: Health, Info, Editor Selection
- 8 Content Type Editors: Quiz, Video, Presentation, Flashcards, Timeline, Drag & Drop, Fill Blanks, Memory
- 8 Content Type Players: Interaktive Player für alle Content-Typen
- Static Files: Korrekte Bereitstellung von Editoren, Players und Assets
- Error Handling: 404-Behandlung für ungültige Routen
Tests ausführen
Lokal
cd h5p-service
npm install
npm test
Im Docker Container
# Service starten
docker compose -f docker-compose.content.yml up -d h5p-service
# Tests ausführen
docker compose -f docker-compose.content.yml exec h5p-service npm test
Test-Dateien
| Datei | Beschreibung |
|---|---|
h5p-service/tests/server.test.js |
Integration Tests für alle Endpoints |
h5p-service/tests/setup.js |
Jest Test Setup & Configuration |
h5p-service/jest.config.js |
Jest Configuration |
Coverage Reports
Nach dem Ausführen der Tests:
# HTML Report öffnen
open h5p-service/coverage/lcov-report/index.html
Coverage-Ziel: >80%
Test-Kategorien
1. Health & Info Tests
- Service-Verfügbarkeit
- Health Check Endpoint
- Service Info Page
2. Editor Selection Tests
- Alle 8 Content-Typen sichtbar
- Korrekte Links zu Editoren
- UI-Elemente vorhanden
3. Content Type Tests
Für jeden der 8 Content-Typen:
- Editor lädt korrekt
- Player lädt korrekt
- Erforderliche UI-Elemente vorhanden
Content-Typen:
- Quiz (Question Set)
- Interactive Video
- Course Presentation
- Flashcards
- Timeline
- Drag and Drop
- Fill in the Blanks
- Memory Game
4. Static File Tests
- Core Files erreichbar
- Editor Files erreichbar
- Player Files erreichbar
5. Error Handling Tests
- 404 für ungültige Routes
- Fehlerbehandlung für fehlende Editoren/Players
CI/CD Integration
Die Tests sind in die CI/CD Pipeline integriert:
# .github/workflows/tests.yml (Beispiel)
name: H5P Service Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start H5P Service
run: docker compose -f docker-compose.content.yml up -d h5p-service
- name: Wait for Service
run: sleep 10
- name: Run Tests
run: docker compose -f docker-compose.content.yml exec h5p-service npm run test:ci
- name: Upload Coverage
uses: codecov/codecov-action@v3
with:
files: ./h5p-service/coverage/lcov.info
Test-Qualität
Best Practices
- Isolation: Jeder Test ist unabhängig
- Cleanup: Keine persistenten Änderungen
- Assertions: Klare Expectations
- Speed: Tests laufen schnell (<10s gesamt)
- Reliability: Tests sind deterministisch
Code Review Checklist
Bei neuen Features:
- Tests für neue Endpoints hinzugefügt
- Coverage bleibt >80%
- Tests sind dokumentiert
- CI/CD Tests bestehen
Troubleshooting
Tests schlagen fehl
Service nicht erreichbar:
# Service Status prüfen
docker compose -f docker-compose.content.yml ps
# Logs ansehen
docker compose -f docker-compose.content.yml logs h5p-service
Port-Konflikte:
# Prüfe, ob Port 8003 belegt ist
lsof -i :8003
# Stoppe andere Services
docker compose -f docker-compose.content.yml down
Veraltete Dependencies:
cd h5p-service
rm -rf node_modules package-lock.json
npm install
Zukünftige Erweiterungen
- E2E Tests mit Playwright
- Content Validation Tests
- Performance Tests
- Security Tests (XSS, CSRF)
- Load Tests
- Visual Regression Tests