import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import type { LlmProfileSummary } from "#/api/settings-service/profiles-service.api"; import { ProfilesBody } from "#/components/features/settings/profiles-body"; const profiles: LlmProfileSummary[] = [ { name: "p1", model: "openai/gpt-4o", base_url: null, api_key_set: true }, { name: "p2", model: "anthropic/claude", base_url: null, api_key_set: true }, ]; describe("ProfilesBody", () => { it("shows a loading spinner while isLoading is true", () => { render( , ); expect(screen.getByTestId("loading-spinner")).toBeInTheDocument(); }); it("shows the load-error paragraph when loadError is set", () => { render( , ); expect( screen.getByText("SETTINGS$PROFILES_LOAD_ERROR"), ).toBeInTheDocument(); }); it("shows the empty-state paragraph when no profiles are passed", () => { render( , ); expect(screen.getByText("SETTINGS$PROFILES_EMPTY")).toBeInTheDocument(); }); it("renders one ProfileRow per profile and marks the active one", () => { render( , ); const rows = screen.getAllByTestId("profile-row"); expect(rows).toHaveLength(2); expect(rows[0]).toHaveTextContent("p1"); expect(rows[0]).toHaveTextContent("SETTINGS$PROFILE_ACTIVE_BADGE"); expect(rows[1]).not.toHaveTextContent("SETTINGS$PROFILE_ACTIVE_BADGE"); }); it("renders profiles without action menus when management is disabled", () => { render( , ); expect(screen.getAllByTestId("profile-row")).toHaveLength(2); expect( screen.queryByTestId("profile-menu-trigger"), ).not.toBeInTheDocument(); }); });