3884038b06
Two structural fixes (not query-specific): - Proxy prompt: forbid ANY trailing "Quellen:"/"Quellen im RAG-System" list and make it the LAST instruction so it overrides the soul file's answer-structure + example that teach a closing sources section. Applies to every answer. - KnowledgeUnitCard: render the label only when it differs from regulation.short, so a source whose label == short name no longer prints twice. Applies to every source. Answer text is still never parsed in the FE (sources live in the pane). + card test. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { render } from '@testing-library/react'
|
|
import { KnowledgeUnitCard } from './KnowledgeUnitCard'
|
|
import type { KnowledgeUnit } from '@/lib/sdk/advisor/evidence'
|
|
|
|
const base: KnowledgeUnit = { id: 's1', regulation: { code: 'dsk', short: 'DSK Sdm B51' } }
|
|
|
|
describe('KnowledgeUnitCard', () => {
|
|
it('does not duplicate the regulation when label equals the short name', () => {
|
|
const { container } = render(<KnowledgeUnitCard unit={{ ...base, label: 'DSK Sdm B51' }} />)
|
|
const occurrences = (container.textContent?.match(/DSK Sdm B51/g) || []).length
|
|
expect(occurrences).toBe(1)
|
|
})
|
|
|
|
it('shows the label when it differs from the short name (no breadcrumb)', () => {
|
|
const { container } = render(<KnowledgeUnitCard unit={{ ...base, label: 'Art. 30 DSGVO' }} />)
|
|
expect(container.textContent).toContain('DSK Sdm B51')
|
|
expect(container.textContent).toContain('Art. 30 DSGVO')
|
|
})
|
|
|
|
it('renders the section/paragraph breadcrumb when present', () => {
|
|
const { container } = render(
|
|
<KnowledgeUnitCard unit={{ ...base, section: 'Art. 5', paragraph: 'Abs. 2' }} />,
|
|
)
|
|
expect(container.textContent).toContain('Art. 5')
|
|
expect(container.textContent).toContain('Abs. 2')
|
|
})
|
|
})
|