fix: Restore all files lost during destructive rebase

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>
This commit is contained in:
Benjamin Admin
2026-02-09 09:51:32 +01:00
parent f7487ee240
commit 21a844cb8a
1986 changed files with 744143 additions and 1731 deletions

View File

@@ -0,0 +1,184 @@
# 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
```bash
cd h5p-service
npm install
npm test
```
### Im Docker Container
```bash
# 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:
```bash
# 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:**
1. Quiz (Question Set)
2. Interactive Video
3. Course Presentation
4. Flashcards
5. Timeline
6. Drag and Drop
7. Fill in the Blanks
8. 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:
```yaml
# .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
1. **Isolation**: Jeder Test ist unabhängig
2. **Cleanup**: Keine persistenten Änderungen
3. **Assertions**: Klare Expectations
4. **Speed**: Tests laufen schnell (<10s gesamt)
5. **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:**
```bash
# 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:**
```bash
# Prüfe, ob Port 8003 belegt ist
lsof -i :8003
# Stoppe andere Services
docker compose -f docker-compose.content.yml down
```
**Veraltete Dependencies:**
```bash
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
## Verwandte Dokumentation
- [H5P Service README](../../h5p-service/tests/README.md)
- [Content Service Tests](./content-service-tests.md)
- [Integration Testing Guide](./integration-testing.md)

View File

@@ -0,0 +1,333 @@
# Integration Test Environment
> **Letzte Aktualisierung:** 2026-02-04
> **Status:** Produktiv
> **Maintainer:** DevOps Team
---
## Inhaltsverzeichnis
1. [Uebersicht](#1-uebersicht)
2. [Quick Start (Lokal)](#2-quick-start-lokal)
3. [Services](#3-services)
4. [CI/CD Integration](#4-cicd-integration)
5. [Konfiguration](#5-konfiguration)
6. [Troubleshooting](#6-troubleshooting)
---
## 1. Uebersicht
Die Integration-Test-Umgebung ermoeglicht vollstaendige End-to-End-Tests aller Services in einer isolierten Docker-Compose-Umgebung. Sie wird sowohl lokal als auch in der CI/CD-Pipeline verwendet.
### Architektur
```
┌─────────────────────────────────────────────────────────────────────┐
│ docker-compose.test.yml │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ postgres-test│ │ valkey-test │ │ mailpit-test │ │
│ │ Port 55432 │ │ Port 56379 │ │ Web: 58025 │ │
│ │ PostgreSQL │ │ Redis/Valkey│ │ SMTP: 51025 │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ consent-service-test │ │
│ │ Port 58081 │ │
│ │ Go Authentication Service │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ backend-test │ │
│ │ Port 58000 │ │
│ │ Python FastAPI Backend │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘
```
### Vorteile
- **Isolation:** Keine Konflikte mit Produktions- oder Entwicklungs-Datenbanken
- **Reproduzierbarkeit:** Identische Umgebung lokal und in CI/CD
- **Health Checks:** Automatisches Warten auf Service-Verfuegbarkeit
- **Cleanup:** Automatisches Entfernen aller Volumes nach Tests
---
## 2. Quick Start (Lokal)
### Test-Umgebung starten
```bash
# 1. Test-Umgebung starten
docker compose -f docker-compose.test.yml up -d
# 2. Warten bis alle Services healthy sind
docker compose -f docker-compose.test.yml ps
# 3. Health-Status pruefen (alle sollten "healthy" zeigen)
watch docker compose -f docker-compose.test.yml ps
```
### Integration Tests ausfuehren
```bash
# In das Backend-Verzeichnis wechseln
cd backend
# Virtual Environment aktivieren (falls vorhanden)
source venv/bin/activate
# Integration Tests ausfuehren
export SKIP_INTEGRATION_TESTS=false
pytest tests/test_integration/ -v
```
### Services einzeln testen
```bash
# Datenbank-Verbindung testen
psql -h localhost -p 55432 -U breakpilot -d breakpilot_test -c "SELECT 1"
# Consent Service Health Check
curl -f http://localhost:58081/health
# Backend Health Check
curl -f http://localhost:58000/health
# Mailpit Web UI
open http://localhost:58025
```
### Aufraeumen
```bash
# Alle Container stoppen und Volumes loeschen
docker compose -f docker-compose.test.yml down -v
```
---
## 3. Services
### Port-Strategie
| Service | Test-Port (extern) | Container-Port | Prod-Port |
|---------|-------------------|----------------|-----------|
| PostgreSQL | 55432 | 5432 | 5432 |
| Valkey/Redis | 56379 | 6379 | 6379 |
| Consent Service | 58081 | 8081 | 8081 |
| Backend | 58000 | 8000 | 8000 |
| Mailpit Web | 58025 | 8025 | - |
| Mailpit SMTP | 51025 | 1025 | - |
### Service-Details
#### postgres-test
- **Image:** `postgres:16-alpine`
- **Credentials:** `breakpilot:breakpilot_test@breakpilot_test`
- **Health Check:** `pg_isready -U breakpilot -d breakpilot_test`
#### valkey-test
- **Image:** `valkey/valkey:7-alpine`
- **Health Check:** `valkey-cli ping`
- **Hinweis:** Ersetzt Redis fuer bessere ARM64-Kompatibilitaet
#### consent-service-test
- **Build:** `./consent-service/Dockerfile`
- **Health Check:** `GET /health`
- **Abhaengigkeiten:** postgres-test, valkey-test
#### backend-test
- **Build:** `./backend/Dockerfile`
- **Health Check:** `GET /health`
- **Abhaengigkeiten:** postgres-test, valkey-test, consent-service-test
#### mailpit-test
- **Image:** `axllent/mailpit:latest`
- **Web UI:** http://localhost:58025
- **SMTP:** localhost:51025
- **Zweck:** E-Mail-Testing ohne echten SMTP-Server
---
## 4. CI/CD Integration
### Woodpecker Pipeline
Die Integration-Tests laufen automatisch bei jedem Push/PR zu `main` oder `develop`:
```yaml
# .woodpecker/main.yml
integration-tests:
image: docker:27-cli
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- docker compose -f docker-compose.test.yml up -d
- # Wait for services...
- docker compose -f docker-compose.test.yml exec -T backend-test \
pytest tests/test_integration/ -v
- docker compose -f docker-compose.test.yml down -v
when:
- event: [push, pull_request]
branch: [main, develop]
```
### Pipeline-Ablauf
1. **Unit Tests** (test-go-*, test-python-*) laufen zuerst
2. **Integration Tests** starten Docker Compose Umgebung
3. **Report** sendet alle Ergebnisse ans Test Dashboard
### Manueller Pipeline-Trigger
```bash
# Via Gitea/Woodpecker UI oder:
curl -X POST "https://macmini:4431/api/repos/pilotadmin/breakpilot-pwa/pipelines" \
-H "Authorization: Bearer $WOODPECKER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"branch":"main"}'
```
---
## 5. Konfiguration
### Environment Variables
Die Test-Umgebung konfiguriert automatisch alle noetigen Variablen:
| Variable | Wert in Test-Umgebung |
|----------|----------------------|
| `DATABASE_URL` | `postgresql://breakpilot:breakpilot_test@postgres-test:5432/breakpilot_test` |
| `CONSENT_SERVICE_URL` | `http://consent-service-test:8081` |
| `VALKEY_URL` | `redis://valkey-test:6379` |
| `REDIS_URL` | `redis://valkey-test:6379` |
| `JWT_SECRET` | `test-jwt-secret-for-integration-tests` |
| `ENVIRONMENT` | `test` |
| `SMTP_HOST` | `mailpit-test` |
| `SMTP_PORT` | `1025` |
### conftest.py Integration
Das `backend/tests/conftest.py` erkennt automatisch die Integration-Umgebung:
```python
# Wird aktiviert wenn SKIP_INTEGRATION_TESTS=false
IS_INTEGRATION_ENV = os.environ.get("SKIP_INTEGRATION_TESTS", "").lower() == "false"
if IS_INTEGRATION_ENV:
os.environ.setdefault("DATABASE_URL",
"postgresql://breakpilot:breakpilot_test@postgres-test:5432/breakpilot_test")
# ... weitere Container-URLs
```
---
## 6. Troubleshooting
### Service startet nicht
```bash
# Logs eines spezifischen Services anzeigen
docker compose -f docker-compose.test.yml logs consent-service-test --tail=100
# Alle Logs anzeigen
docker compose -f docker-compose.test.yml logs
```
### Health Check schlaegt fehl
```bash
# Container-Status pruefen
docker compose -f docker-compose.test.yml ps
# In Container einloggen
docker compose -f docker-compose.test.yml exec backend-test bash
# Health-Endpoint manuell pruefen
docker compose -f docker-compose.test.yml exec backend-test curl -v http://localhost:8000/health
```
### Datenbank-Verbindungsprobleme
```bash
# Datenbank-Container pruefen
docker compose -f docker-compose.test.yml exec postgres-test pg_isready -U breakpilot
# Datenbank-Logs
docker compose -f docker-compose.test.yml logs postgres-test
```
### Port-Konflikte
Falls Ports bereits belegt sind:
```bash
# Pruefen welcher Prozess den Port belegt
lsof -i :55432
# Container mit anderen Ports starten (manuell .yml anpassen)
# Oder: Bestehende Container stoppen
docker compose -f docker-compose.test.yml down
```
### Tests finden keine Services
Stellen Sie sicher, dass:
1. `SKIP_INTEGRATION_TESTS=false` gesetzt ist
2. Tests innerhalb des Docker-Netzwerks laufen
3. Container-Namen (nicht localhost) verwendet werden
```bash
# Innerhalb des Backend-Containers:
export SKIP_INTEGRATION_TESTS=false
pytest tests/test_integration/ -v
```
### Cleanup bei Problemen
```bash
# Komplettes Aufräumen
docker compose -f docker-compose.test.yml down -v --remove-orphans
# Auch Netzwerke entfernen
docker network prune -f
# Alle Test-Container entfernen
docker rm -f $(docker ps -a -q --filter "name=breakpilot-*-test") 2>/dev/null || true
```
---
## Anhang: Test-Verzeichnisstruktur
```
backend/tests/
├── conftest.py # Pytest Konfiguration mit Integration-Detection
├── test_consent_client.py # Unit Tests (Mock-basiert)
├── test_gdpr_api.py # Unit Tests
└── test_integration/ # Integration Tests (benoetigen Docker Compose)
├── __init__.py
├── conftest.py # Integration-spezifische Fixtures
├── test_consent_flow.py # E2E Consent Workflow
├── test_auth_flow.py # E2E Auth Workflow
└── test_email_flow.py # E2E E-Mail Tests (Mailpit)
```
---
*Generiert am 2026-02-04 von Claude Code*