// @vitest-environment jsdom import { render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { MemoryRouter } from "react-router-dom"; import { describe, expect, it } from "vitest"; import { LocaleProvider } from "../../src/presentation/i18n/index.ts"; import HomePage from "../../src/presentation/pages/home-page.tsx"; import { ApplicationProvider } from "../../src/presentation/providers/application-provider.tsx"; import { PreferenceProviders } from "../../src/presentation/providers/preference-providers.tsx"; import { AppRouter } from "../../src/presentation/routes/app-router.tsx"; import { createTestApplication } from "../helpers/create-test-application.ts"; /** * The starter screens (`/` and `/examples/platform`) are the template's * content, not the platform (0929/10-02). A product that replaces them deletes * the `starter-*.test.tsx` files with them; the platform tests run on the * test-only feature's pages and keep passing. 1103/09-04: the other example * screens are a removable feature, tested in its own test folder. */ function renderApp( url: string, application = createTestApplication(), ) { window.history.pushState({}, "", url); return render( , ); } describe("starter home page", () => { it("reaches the platform overview from the starter actions", async () => { const user = userEvent.setup(); renderApp("/"); await user.click( await screen.findByRole("link", { name: "플랫폼 구성 보기" }), ); await waitFor(() => expect( screen.getByRole("heading", { name: "플랫폼 구성", level: 1 }), ).toHaveFocus(), ); }); it("stops the release summary from loading forever", async () => { render( { throw new Error("manifest unavailable"); }, refresh: async () => { throw new Error("manifest unavailable"); }, }, })} > {/* HomePage renders router links, so it needs a router but not the app one. */} , ); await waitFor(() => expect( screen.getByText("런타임 정보를 확인하지 못했습니다."), ).toBeVisible(), ); expect( screen.queryByText("검증된 런타임 정보를 확인하고 있습니다."), ).not.toBeInTheDocument(); }); });