import { afterEach, describe, expect, it } from "vitest"; import { cleanup, render, screen } from "@testing-library/react"; import { PluginErrorDiagnostic } from "./plugin-error-diagnostic"; import type { PluginRecord } from "@/lib/types/plugins"; afterEach(() => cleanup()); function plugin(overrides: Partial = {}): PluginRecord { return { id: "acme", api_version: 1, version: "1.0.0", display_name: "Acme", description: "", author: "acme", categories: [], capabilities: {}, status: "error", install_path: "/p", signed: true, installed_at: "2026-01-01T00:00:00Z", restart_count: 0, ...overrides, }; } describe("PluginErrorDiagnostic", () => { it("renders the normalized message and machine-readable failure time", () => { render( , ); expect(screen.getByRole("alert").textContent).toContain("plugins/runtime: handshake failed"); expect(screen.getByRole("time").getAttribute("dateTime")).toBe("2026-08-02T12:34:56Z"); }); it("renders nothing when there is no persisted diagnostic", () => { const { container } = render(); expect(container.innerHTML).toBe(""); }); });