diff --git a/desktop/src/components/chat/MermaidRenderer.integration.test.tsx b/desktop/src/components/chat/MermaidRenderer.integration.test.tsx index eafb81c8..137491e6 100644 --- a/desktop/src/components/chat/MermaidRenderer.integration.test.tsx +++ b/desktop/src/components/chat/MermaidRenderer.integration.test.tsx @@ -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( + 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( |[{}[\]*]/i +const UNQUOTED_FLOWCHART_LABEL_UNSAFE = /|[{}[\]*\/]/i function isFlowchartDiagram(code: string) { const firstMeaningfulLine = code