feat: Rechtliche-Texte-Module auf 100% — Dead Code, RAG-Fallback, Fehler-UI
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 33s
CI / test-python-backend-compliance (push) Successful in 35s
CI / test-python-document-crawler (push) Successful in 24s
CI / test-python-dsms-gateway (push) Successful in 18s

Paket A:
- einwilligungen/page.tsx: mockRecords (80 Zeilen toter Code) entfernt
- consent/page.tsx: RAG-Suggest-Button im Create-Dialog (+handleRagSuggest)
- workflow/page.tsx: uploadError State + rotes Fehler-Banner statt alert()

Paket B:
- cookie-banner/page.tsx: mockCategories → DEFAULT_COOKIE_CATEGORIES (Bug-Fix)
  DB-Kategorien haben jetzt immer Vorrang — kein Mock-Überschreiben mehr
- test_einwilligungen_routes.py: +4 TestCookieBannerEmbedCode-Tests (36 gesamt)

Paket C:
- searchTemplates.ts: neue Hilfsdatei mit zwei-stufiger Suche
  1. KLAUSUR_SERVICE (5s Timeout), 2. RAG-Fallback via ai-compliance-sdk
- document-generator/page.tsx: ServiceMode State + UI-Badges (rag-only/offline)
- searchTemplates.test.ts: 3 Vitest-Tests (KLAUSUR ok / RAG-Fallback / offline)

flow-data.ts: alle 5 Rechtliche-Texte-Module auf completion: 100

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-03 22:27:13 +01:00
parent 30bccfa39a
commit 7a55955439
9 changed files with 354 additions and 333 deletions

View File

@@ -0,0 +1,72 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { searchTemplates } from './searchTemplates'
describe('searchTemplates', () => {
beforeEach(() => {
vi.restoreAllMocks()
})
it('gibt Ergebnisse zurück wenn KLAUSUR_SERVICE verfügbar', async () => {
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({
ok: true,
json: () => Promise.resolve([{
id: 't1',
score: 0.9,
text: 'Inhalt',
document_title: 'DSE Template',
template_type: 'privacy_policy',
clause_category: null,
language: 'de',
jurisdiction: 'de',
license_id: 'mit',
license_name: 'MIT',
license_url: null,
attribution_required: false,
attribution_text: null,
source_name: 'Test',
source_url: null,
source_repo: null,
placeholders: [],
is_complete_document: true,
is_modular: false,
requires_customization: false,
output_allowed: true,
modification_allowed: true,
distortion_prohibited: false,
}]),
}))
const results = await searchTemplates({ query: 'Datenschutzerklärung' })
expect(results).toHaveLength(1)
expect(results[0].documentTitle).toBe('DSE Template')
})
it('fällt auf RAG zurück wenn KLAUSUR_SERVICE fehlschlägt', async () => {
vi.stubGlobal('fetch', vi.fn()
.mockRejectedValueOnce(new Error('KLAUSUR down'))
.mockResolvedValueOnce({
ok: true,
json: () => Promise.resolve({
results: [{
regulation_name: 'DSGVO Art. 13',
text: 'Informationspflichten',
regulation_code: 'DSGVO-13',
score: 0.8,
}],
}),
})
)
const results = await searchTemplates({ query: 'test' })
expect(results).toHaveLength(1)
expect(results[0].documentTitle).toBe('DSGVO Art. 13')
expect((results[0] as any).source).toBe('rag')
})
it('gibt [] zurück wenn beide Services down sind', async () => {
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('all down')))
const results = await searchTemplates({ query: 'test' })
expect(results).toEqual([])
})
})