Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/routes/app.$tenant/settings/billing-shell.test.tsx
T

68 lines
2.0 KiB
TypeScript

// @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<typeof import("react-router")>("react-router");
return {
...actual,
Outlet: () => <div data-testid="billing-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 }) => <div data-testid="billing-hub">{children}</div>,
}));
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(<BillingHubRoute />);
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(<BillingHubRoute />);
expect(screen.queryByTestId("billing-hub")).not.toBeInTheDocument();
expect(screen.getByTestId("billing-outlet")).toBeInTheDocument();
});
});