// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0 // What a page says about itself, rendered with a customer's brand: their name, their colours on the // first byte of the document, and no trace of ConusAI's (plan item AT2.6 done_when, the rendered-page // half; there are no emails or share images in the template to render). import { brandTokenStyle, defineBrand } from "@app/config" import { createElement } from "react" import { renderToStaticMarkup } from "react-dom/server" import { describe, expect, it } from "vitest" import { brandHead, brandMetadata, brandTokensOnly, Document } from "../apps/web/src/ui/document" import { appCatalogues } from "../apps/web/src/ui/messages" const customer = defineBrand({ name: "Acme Review", shortName: "Acme", primary: "#1a1a8c", logo: { light: "/acme-light.svg", dark: "/acme-dark.svg", favicon: "/acme.svg" }, }) // The layout's own consent wording in the page's locale, as RootLayout passes it. const consent = (key: string): string => { const text = appCatalogues.lt?.consent?.[key] if (!text) throw new Error(`missing lt consent.${key}`) return text } const privacy = { title: consent("title"), body: consent("body"), replay: consent("replay"), accept: consent("accept"), reject: consent("reject"), reopen: consent("reopen"), gpc: consent("gpc"), } const render = (extra: { theme?: "dark" | "light"; observe?: { release: string; environment: string } } = {}): string => renderToStaticMarkup( createElement(Document, { brand: { ...customer, style: brandTokenStyle(customer) }, locale: "lt", theme: extra.theme ?? "dark", signedIn: false, signIn: "Prisijungti", signOut: null, controls: null, privacy, ...(extra.observe ? { observe: extra.observe } : {}), children: createElement("main", null, "turinys"), }), ) const html = render() describe("a page rendered with a customer's brand", () => { it("carries the customer's name and logos and no ConusAI name", () => { expect(html).toContain("Acme Review") expect(html).toContain('src="/acme-dark.svg"') expect(html.toLowerCase()).not.toContain("conusai") }) it("writes the brand layer as a stylesheet in the head, so the first paint is branded and a platform theme can win", () => { const root = /]*>/.exec(html)?.[0] ?? "" expect(root).toContain('lang="lt"') expect(root).not.toContain("--primary") const layer = /