mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-15 12:53:31 +08:00
commit
fd542e4a44
@ -58,6 +58,24 @@ describe('MermaidRenderer Mermaid integration', () => {
|
||||
expect(surface.innerHTML).not.toContain('onerror')
|
||||
})
|
||||
|
||||
it('auto-quotes flowchart labels containing forward slashes to avoid lexical errors', async () => {
|
||||
render(
|
||||
<MermaidRenderer
|
||||
code={[
|
||||
'flowchart TD',
|
||||
' D1[/api/dcl] --> D2[直接调用 dclService]',
|
||||
' D2 --> R[返回结果]',
|
||||
].join('\n')}
|
||||
/>,
|
||||
)
|
||||
|
||||
const surface = await screen.findByTestId('mermaid-diagram-surface')
|
||||
|
||||
expect(surface).toHaveTextContent('/api/dcl')
|
||||
expect(surface).toHaveTextContent('直接调用 dclService')
|
||||
expect(screen.queryByText('Mermaid Error')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders generated flowchart labels with HTML breaks and structural characters', async () => {
|
||||
render(
|
||||
<MermaidRenderer
|
||||
|
||||
@ -40,7 +40,7 @@ type MermaidThemeColors = {
|
||||
|
||||
const FLOWCHART_START = /^\s*(?:graph|flowchart)\b/i
|
||||
const FLOWCHART_NODE_START = /^([A-Za-z][\w-]*)\[/
|
||||
const UNQUOTED_FLOWCHART_LABEL_UNSAFE = /<br\s*\/?>|[{}[\]*]/i
|
||||
const UNQUOTED_FLOWCHART_LABEL_UNSAFE = /<br\s*\/?>|[{}[\]*\/]/i
|
||||
|
||||
function isFlowchartDiagram(code: string) {
|
||||
const firstMeaningfulLine = code
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user