Files
clawhub/emails/emailTemplates.test.tsx
T
Patrick Erichsen a16ff751bb feat: notify plugin owners only for hard compatibility errors (#3365)
* chore: update plugin inspector to 0.3.20

* feat: gate plugin compatibility emails on hard errors
2026-07-31 17:37:52 -07:00

47 lines
1.6 KiB
TypeScript

/* @vitest-environment node */
import { readFileSync } from "node:fs";
import { join } from "node:path";
import { render, toPlainText } from "@react-email/render";
import type { ReactElement } from "react";
import { describe, expect, it } from "vitest";
type PreviewableTemplate = {
default: ((props: Record<string, unknown>) => ReactElement) & {
PreviewProps?: Record<string, unknown>;
};
};
const templates = [
["account suspended", "./account-suspended"],
["account reinstated", "./account-reinstated"],
["blocked version", "./blocked-version"],
["plugin inspector findings", "./plugin-inspector-findings"],
["admin one-off", "./admin-one-off"],
] as const;
describe("React Email templates", () => {
it("adds a local preview command on the expected port", () => {
const packageJson = JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf8"));
expect(packageJson.scripts["email:dev"]).toBe("email dev --dir emails --port 8765");
});
it.each(templates)("renders %s from PreviewProps", async (_name, modulePath) => {
const template = (await import(modulePath)) as PreviewableTemplate;
expect(typeof template.default).toBe("function");
expect(template.default.PreviewProps).toBeDefined();
const html = await render(template.default(template.default.PreviewProps ?? {}));
const text = toPlainText(html);
expect(html).toContain("ClawHub");
expect(html).toContain("OpenClaw");
if (_name !== "plugin inspector findings") {
expect(html).toContain("https://docs.openclaw.ai/clawhub");
}
expect(text).toContain("ClawHub");
});
});