Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { ProcessMessage } from "./process-message";
function render(value: string) {
return renderToStaticMarkup(<ProcessMessage value={value} />);
}
describe("ProcessMessage", () => {
it("renders markdown formatting", () => {
const html = render("We are **investigating** `api` latency.");
expect(html).toContain("<strong>investigating</strong>");
expect(html).toContain("<code>api</code>");
});
it("opens links in a new tab without a referrer", () => {
const html = render("See [the docs](https://docs.openstatus.dev).");
expect(html).toMatch(
/<a [^>]*href="https:\/\/docs\.openstatus\.dev"[^>]*>the docs<\/a>/,
);
expect(html).toContain('target="_blank"');
expect(html).toContain('rel="noreferrer"');
});
it("styles unordered lists and keeps their items", () => {
const html = render("- first\n- second");
expect(html).toContain("list-disc");
expect(html).toContain("<li>first</li>");
expect(html).toContain("<li>second</li>");
});
it("does not render raw HTML from the message", () => {
const html = render('<img src=x onerror="alert(1)">\n\n<script>x</script>');
expect(html).not.toContain("<img");
expect(html).not.toContain("<script");
});
// remark keeps the URL; React swaps it for a throwing stub
it("does not ship a javascript: link payload", () => {
expect(render("[click](javascript:alert(1))")).not.toContain("alert(1)");
});
// the `ol` override drops its props, so ordered list items vanish
it.skip("keeps the items of ordered lists", () => {
const html = render("1. first\n2. second");
expect(html).toContain("list-decimal");
expect(html).toContain("<li>first</li>");
});
});