// Render tests for the key entry form of the License card (#347). No jsdom needed: // react-dom/server renders in vitest's node environment, and `t` echoes its key. import { describe, it, expect, vi } from "vitest"; import { renderToStaticMarkup } from "react-dom/server"; vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() })); vi.mock("react-i18next", async () => (await import("../../test/i18nMock")).i18nMock()); import LicenseKeyForm from "./LicenseKeyForm"; function render(validationError: string | null, busy = false): string { return renderToStaticMarkup( {}} onSubmit={() => {}} onCancel={() => {}} validating={false} busy={busy} validationError={validationError} />, ); } describe("LicenseKeyForm", () => { it("names a refused key in the app language", () => { const html = render('{"code":"invalid_prefix"}'); expect(html).toContain("t(license.errors.invalidPrefix)"); expect(html).not.toContain("{"code""); }); it("never prints a raw backend string", () => { const html = render("License key must start with SR-BASE- or SR-PREMIUM-"); expect(html).toContain("t(license.errors.unknown)"); expect(html).not.toContain("License key must start"); }); it("shows no error line before a submission is refused", () => { expect(render(null)).not.toContain("t(license.errors."); }); it("blocks the submission while a machine activation runs", () => { // The activation writes the token of the key it read (#364 review). expect(render(null, true)).toMatch(/