diff --git a/ui/src/components/MarkdownBody.test.tsx b/ui/src/components/MarkdownBody.test.tsx index 894fa8a7344..63e92cb5810 100644 --- a/ui/src/components/MarkdownBody.test.tsx +++ b/ui/src/components/MarkdownBody.test.tsx @@ -119,6 +119,20 @@ describe("MarkdownBody", () => { expect(html).not.toContain("javascript:"); }); + it("renders raw HTML tags as escaped text", () => { + const html = renderMarkdown( + '\n\n

Plain text

', + ); + + expect(html).not.toContain("\n\n

Plain text

'} + onChange={() => {}} + placeholder="Markdown body" + />, + ); + }); + + await flush(); + expect(mdxEditorMockState.suppressHtmlProcessingValues).toContain(true); + expect(container.querySelector("textarea")).toBeNull(); + expect(container.querySelector("script, iframe, p[onclick]")).toBeNull(); + expect(container.textContent).toContain('fetch("/api/secrets")'); + expect(container.textContent).toContain("Plain text"); + + await act(async () => { + root.unmount(); + }); + }); + it("falls back to a raw textarea when the rich parser rejects the markdown", async () => { mdxEditorMockState.emitMountParseError = true; const handleChange = vi.fn();