feat(compliance): P-06 Upload-Einwilligungsdialog v1-conservative
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Failing after 1m23s
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Failing after 1m23s
Implementiert server-seitige Rechteerklärungspflicht für alle Medien-Uploads
und Sichtbarkeits-Promotions (konservative Erstannahme: alle Uploads).
Backend:
- backend/media_rights.py (NEU): Kernmodul — validate_rights_declaration,
check_rights_coverage, assert_rights_for_promotion, assert_rights_for_exercise_link,
write_rights_declaration, update_rights_quick_fields
- backend/migrations/048_media_rights_declarations.sql (NEU): Tabelle
media_asset_rights_declarations (Append-only Audit-Log), Felder
rights_status/rights_visibility_level in media_assets
- backend/routers/media_assets.py: P-06-Pflichtprüfung in PATCH (single + bulk),
POST /api/media-assets/{id}/rights-declarations (Re-Deklaration),
GET /api/admin/media-rights/legacy-summary|legacy-assets (Admin-Endpoints)
- backend/routers/exercises.py: P-06-Felder in upload_exercise_media,
assert_rights_for_exercise_link in attach_exercise_media_from_asset
- backend/main.py: admin_rights_router registriert
Frontend:
- frontend/src/components/RightsDeclarationDialog.jsx (NEU): 9-Felder-Dialog
(konservativ: immer alle Fragen), Client-Validierung, VORLÄUFIG-Hinweis
- frontend/src/pages/MediaLibraryPage.jsx: Dialog-Intercept vor Upload,
Altbestand-Indikator (legacy_unreviewed)
- frontend/src/utils/api.js: P-06-Felder in bulkUploadMediaAssets weitergeleitet
Tests:
- backend/tests/test_media_rights_declaration.py (NEU): 28 Unit-/Integrationstests
- backend/tests/test_media_assets_archive.py: P-06 fetchone-Slots + Mock ergänzt
- backend/tests/test_media_assets_copyright_promotion.py: check_rights_coverage gemockt
- tests/dev-smoke-test.spec.js: 5 P-06 E2E-Tests ergänzt
Dokumentation:
- docs/compliance-implementation.md: P-06-Abschnitt
- docs/compliance-package-register.md: Status ⚠️ teilweise umgesetzt (KRIT-04 offen)
- docs/compliance-roadmap.md: P-06 im Freigaben-Log
Offen: KRIT-04 (rechtliche Finalisierung Einwilligungsformulierung) — technisch
vollständig, Rechtstext VORLÄUFIG.
version: 0.8.75
module: media_rights 1.0.0, media_assets 1.13.0, exercises 2.20.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
8cda5c27ec
commit
34235ef46d
18 files changed
+1829
-41
No files matched your search
@@ -332,6 +332,127 @@ test('P-01c: Admin-Nav enthält Link zu Rechtstexten', async ({ page }) => {
|
||||
console.log('✓ P-01c: Admin-Nav enthält Link /admin/legal-documents');
|
||||
});
|
||||
|
||||
// ── P-06: Upload-Einwilligungsdialog ────────────────────────────────────────
|
||||
|
||||
test('P-06a: Medienbibliothek lädt ohne Fehler', async ({ page }) => {
|
||||
await login(page);
|
||||
await expect(page.locator('.spinner')).toHaveCount(0, { timeout: 10000 });
|
||||
|
||||
await gotoAuthenticated(page, '/media');
|
||||
await expect(page.locator('h1')).toContainText('Medienbibliothek', { timeout: 8000 });
|
||||
|
||||
await page.screenshot({ path: 'screenshots/p06a-media-library.png' });
|
||||
console.log('✓ P-06a: Medienbibliothek erreichbar');
|
||||
});
|
||||
|
||||
test('P-06b: Rechte-Dialog erscheint bei Dateiauswahl', async ({ page }) => {
|
||||
await login(page);
|
||||
await expect(page.locator('.spinner')).toHaveCount(0, { timeout: 10000 });
|
||||
|
||||
await gotoAuthenticated(page, '/media');
|
||||
await expect(page.locator('h1')).toContainText('Medienbibliothek', { timeout: 8000 });
|
||||
|
||||
// Datei-Upload simulieren (ohne echte Datei – Datei-Input finden und Datei setzen)
|
||||
const fileInput = page.locator('input[type="file"]').first();
|
||||
await fileInput.setInputFiles({
|
||||
name: 'test.png',
|
||||
mimeType: 'image/png',
|
||||
buffer: Buffer.from('PNG-Testinhalt'),
|
||||
});
|
||||
|
||||
// Rechte-Dialog muss erscheinen
|
||||
await expect(page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
await expect(page.locator('[role="dialog"]')).toContainText('Rechte-Erklärung');
|
||||
await expect(page.locator('[role="dialog"]')).toContainText('VORLÄUFIG');
|
||||
|
||||
await page.screenshot({ path: 'screenshots/p06b-rights-dialog.png' });
|
||||
console.log('✓ P-06b: Rechte-Dialog erscheint bei Dateiauswahl');
|
||||
});
|
||||
|
||||
test('P-06c: Dialog-Abbrechen bricht Upload ab', async ({ page }) => {
|
||||
await login(page);
|
||||
await expect(page.locator('.spinner')).toHaveCount(0, { timeout: 10000 });
|
||||
|
||||
await gotoAuthenticated(page, '/media');
|
||||
await expect(page.locator('h1')).toContainText('Medienbibliothek', { timeout: 8000 });
|
||||
|
||||
const fileInput = page.locator('input[type="file"]').first();
|
||||
await fileInput.setInputFiles({
|
||||
name: 'test.png',
|
||||
mimeType: 'image/png',
|
||||
buffer: Buffer.from('PNG-Testinhalt'),
|
||||
});
|
||||
|
||||
await expect(page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
await page.locator('[role="dialog"] button:has-text("Abbrechen")').click();
|
||||
|
||||
// Dialog geschlossen, kein Upload-Fortschrittsbalken
|
||||
await expect(page.locator('[role="dialog"]')).toHaveCount(0, { timeout: 3000 });
|
||||
|
||||
await page.screenshot({ path: 'screenshots/p06c-dialog-cancel.png' });
|
||||
console.log('✓ P-06c: Dialog-Abbrechen schließt Dialog ohne Upload');
|
||||
});
|
||||
|
||||
test('P-06d: Dialog-Bestätigung ohne Pflichtfelder zeigt Fehler', async ({ page }) => {
|
||||
await login(page);
|
||||
await expect(page.locator('.spinner')).toHaveCount(0, { timeout: 10000 });
|
||||
|
||||
await gotoAuthenticated(page, '/media');
|
||||
await expect(page.locator('h1')).toContainText('Medienbibliothek', { timeout: 8000 });
|
||||
|
||||
const fileInput = page.locator('input[type="file"]').first();
|
||||
await fileInput.setInputFiles({
|
||||
name: 'test.png',
|
||||
mimeType: 'image/png',
|
||||
buffer: Buffer.from('PNG-Testinhalt'),
|
||||
});
|
||||
|
||||
await expect(page.locator('[role="dialog"]')).toBeVisible({ timeout: 5000 });
|
||||
// Ohne Felder ausfüllen direkt bestätigen
|
||||
await page.locator('[role="dialog"] button:has-text("Bestätigen")').click();
|
||||
|
||||
// Fehlermeldung im Dialog
|
||||
const dialog = page.locator('[role="dialog"]');
|
||||
await expect(dialog).toBeVisible({ timeout: 2000 });
|
||||
// Fehlermeldung muss sichtbar sein
|
||||
await expect(dialog.locator('p[style*="danger"], p[style*="color: var(--danger)"]')).toBeVisible({ timeout: 2000 });
|
||||
|
||||
await page.screenshot({ path: 'screenshots/p06d-dialog-validation.png' });
|
||||
console.log('✓ P-06d: Dialog zeigt Fehler ohne Pflichtfelder');
|
||||
});
|
||||
|
||||
test('P-06e: API-Endpoint /api/admin/media-rights/legacy-summary erreichbar (Superadmin)', async ({ request }) => {
|
||||
// Superadmin-Login via API
|
||||
const loginRes = await request.post('/api/auth/login', {
|
||||
data: { email: TEST_EMAIL, password: TEST_PASSWORD },
|
||||
});
|
||||
if (!loginRes.ok()) {
|
||||
console.log('⚠ P-06e: Login fehlgeschlagen – Test übersprungen');
|
||||
return;
|
||||
}
|
||||
const loginData = await loginRes.json();
|
||||
const token = loginData.token;
|
||||
if (!token) {
|
||||
console.log('⚠ P-06e: Kein Token – Test übersprungen');
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await request.get('/api/admin/media-rights/legacy-summary', {
|
||||
headers: { 'X-Auth-Token': token },
|
||||
});
|
||||
|
||||
// Endpoint existiert (200 oder 403 wenn kein Superadmin — aber nicht 404/500)
|
||||
expect([200, 403]).toContain(res.status());
|
||||
if (res.status() === 200) {
|
||||
const data = await res.json();
|
||||
expect(data).toHaveProperty('total_active_assets');
|
||||
expect(data).toHaveProperty('legacy_unreviewed');
|
||||
console.log(`✓ P-06e: Legacy-Summary: ${data.legacy_unreviewed} von ${data.total_active_assets} Medien`);
|
||||
} else {
|
||||
console.log('✓ P-06e: Endpoint existiert (403 erwartet für Nicht-Superadmin)');
|
||||
}
|
||||
});
|
||||
|
||||
test('8. Keine kritischen Console-Fehler', async ({ page }) => {
|
||||
const errors = [];
|
||||
page.on('console', msg => {
|
||||
|
||||
Reference in new issue
Block a user