Files
breakpilot-compliance/admin-compliance/components/sdk/advisor/Markdown.test.tsx
T
Benjamin Admin 49171e841f feat(advisor): Evidence Workspace — structured panes, markdown, sources as knowledge units
Rebuilds the Compliance Advisor floating widget from a plain chat into an Evidence
Workspace: pinned last question, markdown-rendered answer (clean prose), and separate
panes for Sources (hierarchical Knowledge Units), Figures (C8, conditional) and
Footnotes (C-FN), plus a stats bar (Quellen/Regelwerke/Diagramme/Fußnoten). Scrollable
turn history; stays a floating icon on every SDK page.

Architecture (user direction): the frontend renders ONLY structured evidence and NEVER
parses the answer text. The proxy now returns a JSON AdvisorEvidenceMeta line followed
by the streamed markdown answer; advisor-rag exposes structured results; an adapter maps
RAG/compiler output to the frontend envelope. Figures/footnotes wire in once the
RAG-ingestion contract lands (requested on the board) — figures pane is conditional.

- lib/sdk/advisor/{evidence,evidence-adapter}.ts (+ adapter test, 7 cases)
- components/sdk/advisor/* panes + in-house safe Markdown (no new dep, no dangerouslySetInnerHTML) + test
- useAdvisorStream (meta-line parse + streamed answer) + useAdvisorEmail (escaped)
- proxy: evidence-meta-v1 envelope + clean-prose prompt (no inline citations)
- tsc clean, 11 vitest pass, check-loc 0. ESLint not installed in this node_modules -> CI lints on push.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-07-01 07:46:37 +02:00

41 lines
1.6 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { render } from '@testing-library/react'
import { Markdown } from './Markdown'
describe('Markdown', () => {
it('renders headings, bold and bullet lists (not raw markdown markers)', () => {
const { container } = render(
<Markdown
content={'## Pflichten\n\nDer **Verantwortliche** muss:\n\n- ein Verzeichnis fuehren\n- Risiken bewerten'}
/>,
)
expect(container.querySelector('h4')?.textContent).toBe('Pflichten')
expect(container.querySelector('strong')?.textContent).toBe('Verantwortliche')
expect(container.querySelectorAll('li')).toHaveLength(2)
expect(container.textContent).not.toContain('##')
expect(container.textContent).not.toContain('**')
})
it('renders ordered lists and inline code', () => {
const { container } = render(<Markdown content={'1. Erst `init`\n2. Dann `build`'} />)
expect(container.querySelector('ol')).not.toBeNull()
expect(container.querySelectorAll('li')).toHaveLength(2)
expect(container.querySelectorAll('code')).toHaveLength(2)
})
it('renders fenced code blocks', () => {
const { container } = render(<Markdown content={'```\nconst x = 1\n```'} />)
expect(container.querySelector('pre')).not.toBeNull()
expect(container.textContent).toContain('const x = 1')
})
it('only allows http(s) links', () => {
const { container } = render(
<Markdown content={'[ok](https://example.test) and [bad](javascript:alert(1))'} />,
)
const links = container.querySelectorAll('a')
expect(links).toHaveLength(1)
expect(links[0].getAttribute('href')).toBe('https://example.test')
})
})