// The analytics panel's markup, rendered on the server the way the account page renders it, in both // languages: both actions are named buttons, the irreversible one is marked, and no confirmation, // status or table shows before the person asked for anything. import { buildRegistry } from "@conusai-kit/core" import { createI18n } from "@conusai-kit/i18n" import { TransportProvider } from "@conusai-kit/ui" import { renderToStaticMarkup } from "react-dom/server" import { describe, expect, it } from "vitest" import { appModules } from "../../index.js" import { AccountAnalyticsPanel, analyticsLabels } from "../ui/index.js" const catalogues = buildRegistry([...appModules]).catalogues const render = (locale: "en" | "lt") => { const i18n = createI18n(locale, { [locale]: { account: catalogues[locale]?.account ?? {} } }) const t = (key: string, values?: Record) => i18n.message(`account.${key}`, values) const labels = analyticsLabels(t, "That did not work: {detail}") const html = renderToStaticMarkup( undefined} describe={() => "x"}> , ) return { html, labels } } describe("the analytics panel", () => { it.each(["en", "lt"] as const)("offers the download and the erasure as named buttons (%s)", (locale) => { const { html, labels } = render(locale) expect(html).toContain(`

]*class="app-danger"[^>]*>/) }) it("asks for nothing yet: no confirmation, no status and no table before a click", () => { const { html, labels } = render("en") expect(html).not.toContain(labels.confirmErase) expect(html).not.toContain('role="alertdialog"') expect(html).not.toContain('role="status"') expect(html).not.toContain("kit-table") }) it("says the erasure cannot be undone in its confirmation, in both languages", () => { expect(render("en").labels.confirmErase).toMatch(/cannot be undone/) expect(render("lt").labels.confirmErase).toMatch(/atšaukti negalima/) }) })