// @vitest-environment jsdom import "@testing-library/jest-dom"; import { render, screen } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; let subscriptionActivationRequired = false; vi.mock("react-router", async () => { const actual = await vi.importActual("react-router"); return { ...actual, Outlet: () =>
, useLoaderData: () => ({ tabs: [{ id: "plan", labelKey: "billing.plan", href: "/acme/settings/billing", exact: true }], }), useLocation: () => ({ pathname: "/acme/settings/billing" }), }; }); vi.mock("~/utils/data/useAppData", () => ({ useAppData: () => ({ mySubscription: null, subscriptionActivationRequired, }), })); vi.mock("~/utils/data/useRootData", () => ({ useRootData: () => ({ appConfiguration: { subscription: { required: false } }, }), })); vi.mock("~/components/screens/settings/SettingsHubShell", () => ({ SettingsHubShell: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock("@hivegrid/view-models", () => ({ buildSettingsHubVM: () => ({ hubId: "billing" }), })); vi.mock("@subframe/core", () => ({ FeatherCreditCard: () => null, })); import BillingHubRoute from "./billing"; describe("billing settings shell", () => { beforeEach(() => { subscriptionActivationRequired = false; }); it("renders the regular billing hub for an active workspace", () => { render(); expect(screen.getByTestId("billing-hub")).toBeInTheDocument(); expect(screen.getByTestId("billing-outlet")).toBeInTheDocument(); }); it("removes billing tabs when the persisted signup selection requires activation", () => { subscriptionActivationRequired = true; render(); expect(screen.queryByTestId("billing-hub")).not.toBeInTheDocument(); expect(screen.getByTestId("billing-outlet")).toBeInTheDocument(); }); });