/** @jsxRuntime automatic @jsxImportSource react */ import "./test-preload.ts"; import { expect } from "@std/expect"; import { describe, test } from "@std/testing/bdd"; import { render } from "react-email"; import { Callout } from "../emails/_components/callout"; import { Footer, POSTAL_ADDRESS } from "../emails/_components/footer"; import { KeyValue } from "../emails/_components/key-value"; import { Layout, statusPageBrand } from "../emails/_components/layout"; import { renderMarkdown } from "../emails/_components/markdown"; import { Pill } from "../emails/_components/pill"; import { Steps } from "../emails/_components/steps"; import { tones } from "../emails/_components/styles"; import MonitorAlertEmail, { type MonitorAlertProps, monitorAlertPreheader, monitorAlertSubject, } from "../emails/monitor-alert"; import MonitorDeactivationEmail, { monitorDeactivationSubject, } from "../emails/monitor-deactivation"; import MonitorPausedEmail from "../emails/monitor-paused"; import PageSubscriptionEmail from "../emails/page-subscription"; import PrivateLocationAlertEmail, { privateLocationAlertSubject, } from "../emails/private-location-alert"; import StatusPageMagicLinkEmail from "../emails/status-page-magic-link"; import StatusReportEmail, { type StatusReportProps, statusReportPreheader, } from "../emails/status-report"; import TeamInvitationEmail from "../emails/team-invitation"; const alert = { type: "alert", monitorId: 42, name: "Ping Pong", url: "https://openstatus.dev/ping", method: "GET", status: "503", latency: "300 ms", region: "Amsterdam, Netherlands", timestamp: "2026-10-13T17:32:00Z", firstSeen: "2026-10-13T17:29:00Z", degradedAfter: 250, message: "upstream response time 0.302s", } satisfies MonitorAlertProps; const report = { pageTitle: "Acme", reportTitle: "API unavailable", status: "monitoring", date: "2026-09-18T12:37:00Z", reportStartedAt: "2026-09-18T10:23:00Z", updateIndex: 3, message: "We are on it.", pageComponents: ["API", "Runners"], componentImpacts: [ { name: "API", impact: "partial_outage" }, { name: "Runners", impact: "operational" }, ], statusPageUrl: "https://acme.openstatus.dev", unsubscribeUrl: "https://acme.openstatus.dev/unsubscribe/t", manageUrl: "https://acme.openstatus.dev/manage/t", } satisfies StatusReportProps; describe("primitives", () => { test("pill maps tone to colour and uppercases its label", async () => { for (const tone of ["danger", "warning", "success", "neutral"] as const) { const html = await render(down); expect(html).toContain(tones[tone].text); expect(html).toContain(tones[tone].bg); expect(html).toContain("DOWN"); } }); test("key-value renders mono, tone, dot and hint", async () => { const html = await render( , ); expect(html).toContain("ui-monospace"); expect(html).toContain(tones.warning.text); expect(html).toContain(tones.warning.dot); expect(html).toContain("●"); expect(html).toContain("threshold 250 ms"); }); test("key-value drops the value cell for null and undefined", async () => { for (const value of [null, undefined]) { const html = await render(); expect(html).toContain('colSpan="2"'); expect(html).not.toContain('align="right"'); } const html = await render(); expect(html).toContain('align="right"'); }); test("footer renders the reason, links only when given, and the address", async () => { const bare = await render(