mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-20 09:31:54 -06:00
5ea44f5916
* refactor(ui): remove dead Control UI weight * test(ui): trim redundant preview fixture * fix(ui): preserve agent file preview behavior
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
// Control UI tests cover full-document markdown behavior.
|
|
import { describe, expect, it } from "vitest";
|
|
import { toSanitizedMarkdownHtml } from "./markdown.ts";
|
|
|
|
function htmlFragment(html: string): HTMLElement {
|
|
const container = document.createElement("div");
|
|
container.innerHTML = html;
|
|
return container;
|
|
}
|
|
|
|
describe("document markdown", () => {
|
|
it("preserves safe remote images while sanitizing unsafe sources", () => {
|
|
const safe = htmlFragment(
|
|
toSanitizedMarkdownHtml("", {
|
|
mode: "document",
|
|
}),
|
|
);
|
|
const unsafe = htmlFragment(
|
|
toSanitizedMarkdownHtml(")", { mode: "document" }),
|
|
);
|
|
|
|
expect(safe.querySelector("img")?.getAttribute("src")).toBe("https://example.com/img.png");
|
|
expect(unsafe.querySelector("img")?.hasAttribute("src")).toBe(false);
|
|
});
|
|
|
|
it("parses complete documents above message limits", () => {
|
|
const input = `# Start\n\n${"x".repeat(140_000)}\n\n## End`;
|
|
const fragment = htmlFragment(toSanitizedMarkdownHtml(input, { mode: "document" }));
|
|
|
|
expect(fragment.querySelector("h1")?.textContent).toBe("Start");
|
|
expect(fragment.querySelector("h2")?.textContent).toBe("End");
|
|
expect(fragment.textContent).not.toContain("truncated");
|
|
});
|
|
});
|