fix(ui): show Registry subscription and setup prompts (#13038)

This commit is contained in:
Alejandro Bailo authored and GitHub committed 2026-10-14 13:51:08 +02:00
1 parent 286ae6c7cf
commit 64c19b3db6
23 files changed
+571 -73

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
import { render, screen } from "@testing-library/react";
import type { ReactNode } from "react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { getRegistryBootstrap } from "@/actions/registry/registry";
import RegistryPage from "./page";
vi.mock("@/actions/registry/registry", () => ({
getRegistryBootstrap: vi.fn(),
}));
vi.mock("@/lib/registry/presentation", () => ({
readRegistryPresentation: () => ({}),
}));
vi.mock("@/components/shadcn/content-layout/content-layout", () => ({
ContentLayout: ({ children }: { children: ReactNode }) => children,
}));
vi.mock("@/components/registry/registry-explorer", () => ({
RegistryExplorer: () => <p>Registry catalog</p>,
}));
vi.mock("next/navigation", () => ({
redirect: vi.fn((path: string) => {
throw new Error(`redirect:${path}`);
}),
}));
describe("Registry paid access", () => {
beforeEach(() => vi.clearAllMocks());
it("offers an upgrade on direct visits without loading the catalog", async () => {
// Given
vi.mocked(getRegistryBootstrap).mockResolvedValue({
status: "subscription_required",
});
// When
render(await RegistryPage());
// Then
expect(
screen.getByRole("button", { name: "Unlock Registry" }),
).toBeVisible();
expect(screen.queryByText("Registry catalog")).not.toBeInTheDocument();
});
it("keeps access denial separate from a paid plan upgrade", async () => {
// Given
vi.mocked(getRegistryBootstrap).mockResolvedValue({
status: "access_denied",
});
// When / Then
await expect(RegistryPage()).rejects.toThrow("redirect:/profile");
});
});
+9 -4
View File
@@ -3,6 +3,7 @@ import { redirect } from "next/navigation";
import { getRegistryBootstrap } from "@/actions/registry/registry";
import { RegistryExplorer } from "@/components/registry/registry-explorer";
import { RegistryUpgradePrompt } from "@/components/registry/registry-upgrade-prompt";
import { ContentLayout } from "@/components/shadcn/content-layout/content-layout";
import { readRegistryPresentation } from "@/lib/registry/presentation";
import { REGISTRY_FAILURE } from "@/types/registry";
@@ -15,10 +16,14 @@ export default async function RegistryPage() {
return (
<ContentLayout title="Registry" icon={<Package />}>
<RegistryExplorer
initialState={bootstrap.state}
registryUrl={readRegistryPresentation().registryUrl}
/>
{bootstrap.status === REGISTRY_FAILURE.SUBSCRIPTION_REQUIRED ? (
<RegistryUpgradePrompt />
) : (
<RegistryExplorer
initialState={bootstrap.state}
registryUrl={readRegistryPresentation().registryUrl}
/>
)}
</ContentLayout>
);
}