diff --git a/src/components/ai-edition/ChatWelcome.test.tsx b/src/components/ai-edition/ChatWelcome.test.tsx new file mode 100644 index 000000000..28ccb4248 --- /dev/null +++ b/src/components/ai-edition/ChatWelcome.test.tsx @@ -0,0 +1,61 @@ +// ChatWelcome guards the "no provider connected" empty state: the copy reaches +// the DOM, the CTA fires, and a non-English locale is really translated rather +// than falling back to English. localeParity.test.ts covers key presence for +// the other locales; only the fallback check needs a rendered card. + +import "@testing-library/jest-dom"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import type { ReactElement } from "react"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { I18nProvider } from "@/contexts/I18nContext"; +import { LOCALE_STORAGE_KEY } from "@/i18n/config"; +import { ChatWelcome } from "./ChatWelcome"; + +function renderIn(locale: string, ui: ReactElement) { + localStorage.setItem(LOCALE_STORAGE_KEY, locale); + return render({ui}); +} + +beforeEach(() => { + localStorage.clear(); +}); + +afterEach(() => { + cleanup(); + localStorage.clear(); +}); + +describe("ChatWelcome", () => { + it("renders the English welcome card with the CTA and disclaimer", () => { + const onOpen = vi.fn(); + renderIn("en", ); + + expect(screen.getByRole("heading", { name: /bring your own ai/i })).toBeInTheDocument(); + expect(screen.getByText(/talk.*language model/i)).toBeInTheDocument(); + // The 3 feature lines are inside a