fix(sharing): hide signup link when registration is disabled (#3409)

This commit is contained in:
Amruth Pillai
2026-09-05 07:32:07 -07:00
committed by GitHub
parent 8354c39c45
commit 18b5aa4745
2 changed files with 32 additions and 10 deletions
@@ -15,6 +15,7 @@ type PdfViewerProps = {
};
const publicResumeMock = vi.hoisted(() => ({
flags: { disableSignups: false },
onDownloadPDF: vi.fn(),
PdfViewer: vi.fn<(_props: PdfViewerProps) => ReactNode>(() => null),
useResumeExport: vi.fn(),
@@ -29,7 +30,10 @@ const publicResumeMock = vi.hoisted(() => ({
vi.mock("@tanstack/react-query", () => ({ useQuery: () => ({ data: publicResumeMock.resume }) }));
vi.mock("@tanstack/react-router", () => ({
getRouteApi: () => ({ useParams: () => ({ username: "amruth", slug: "sample" }) }),
getRouteApi: () => ({
useParams: () => ({ username: "amruth", slug: "sample" }),
useRouteContext: () => ({ flags: publicResumeMock.flags }),
}),
}));
vi.mock("./pdf-viewer", () => ({ PdfViewer: publicResumeMock.PdfViewer }));
vi.mock("@/libs/orpc/client", () => ({
@@ -44,6 +48,7 @@ const { PublicResumeRoute } = await import("./public-resume");
beforeAll(() => i18n.loadAndActivate({ locale: "en", messages: {} }));
beforeEach(() => {
publicResumeMock.flags.disableSignups = false;
publicResumeMock.resume = { data: sampleResumeData, name: "Sample Resume", slug: "sample" };
publicResumeMock.PdfViewer.mockClear();
publicResumeMock.useResumeExport.mockReset();
@@ -64,6 +69,20 @@ const renderPublicResumeRoute = () =>
);
describe("PublicResumeRoute", () => {
it("shows the create-resume link when registration is enabled", () => {
renderPublicResumeRoute();
expect(screen.getByRole("link", { name: /Build your own resume/ })).toHaveAttribute("href", "/");
});
it("hides the create-resume link when registration is disabled", () => {
publicResumeMock.flags.disableSignups = true;
renderPublicResumeRoute();
expect(screen.queryByRole("link", { name: /Build your own resume/ })).not.toBeInTheDocument();
expect(screen.getByTestId("pdf-viewer")).toBeInTheDocument();
});
it("passes exposed source data directly to the browser viewer and export fallback", () => {
renderPublicResumeRoute();
@@ -15,6 +15,7 @@ const publicResumeRoute = getRouteApi("/$username/$slug");
export function PublicResumeRoute() {
const { username, slug } = publicResumeRoute.useParams();
const { flags } = publicResumeRoute.useRouteContext();
const { data: resume } = useQuery(orpc.resume.getBySlug.queryOptions({ input: { username, slug } }));
const publicResume = useMemo(() => ({ username, slug }), [slug, username]);
@@ -51,15 +52,17 @@ export function PublicResumeRoute() {
<PdfViewer data={resume.data} className="block w-full" publicResume={publicResume} />
</main>
<footer className="flex justify-center print:hidden">
<a
href="/"
className="flex items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground"
>
<BrandIcon variant="icon" className="size-5" />
<Trans>Build your own resume</Trans>
</a>
</footer>
{!flags.disableSignups && (
<footer className="flex justify-center print:hidden">
<a
href="/"
className="flex items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground"
>
<BrandIcon variant="icon" className="size-5" />
<Trans>Build your own resume</Trans>
</a>
</footer>
)}
</div>
<Button