Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Show Enterprise quote action and continue setup after account linking (#8384)

ConnorYoh33dbe5477857
diff --git a/frontend/editor/src/portal/components/account-link/LinkAccountModal.test.tsx b/frontend/editor/src/portal/components/account-link/LinkAccountModal.test.tsx
index b388020bcd..fc5993b077 100644
--- a/frontend/editor/src/portal/components/account-link/LinkAccountModal.test.tsx
+++ b/frontend/editor/src/portal/components/account-link/LinkAccountModal.test.tsx
@@ -8,6 +8,7 @@ import {
} from "@app/portal/contexts/UIContext";
import { PortalTestProviders } from "@app/portal/test/TestQueryProvider";
import { HttpError } from "@app/portal/api/http";
+import { readPendingConnect } from "@app/portal/auth/pendingConnect";
/** The step machine: what drives each step, and what must not skip or repeat one. */
const { startConnect, startReauth, fetchWallet, EMAIL } = vi.hoisted(() => ({
@@ -96,10 +97,11 @@ const CONNECT = /Connect Stirling account/;
function renderModal(
mode?: LinkModalMode,
outcome: ConnectOutcome | null = null,
+ entry = "/processor/usage",
) {
return render(
<PortalTestProviders>
- <MemoryRouter initialEntries={["/processor/usage"]}>
+ <MemoryRouter initialEntries={[entry]}>
<UIProvider>
<LinkAccountModal
open
@@ -302,6 +304,15 @@ describe("LinkAccountModal", () => {
).toBeNull();
});
+ it("retains the Enterprise request when leaving for account approval", async () => {
+ const entry = "/settings/billing?source=sales&procurement=start";
+ renderModal("link", null, entry);
+ click(CONNECT);
+
+ await waitFor(() => expect(assign).toHaveBeenCalledWith(AUTHORIZE));
+ expect(readPendingConnect()?.returnTo).toBe(entry);
+ });
+
it("hands over on the first click, showing the ghost while it goes", async () => {
renderModal();
click(CONNECT);
diff --git a/frontend/editor/src/portal/components/billing/FreeTierPlanView.test.tsx b/frontend/editor/src/portal/components/billing/FreeTierPlanView.test.tsx
index e442f28934..c2800657f7 100644
--- a/frontend/editor/src/portal/components/billing/FreeTierPlanView.test.tsx
+++ b/frontend/editor/src/portal/components/billing/FreeTierPlanView.test.tsx
@@ -3,7 +3,7 @@ import type { ReactNode } from "react";
import { act, fireEvent, render, screen } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { MantineProvider } from "@mantine/core";
-import { MemoryRouter } from "react-router-dom";
+import { MemoryRouter, useLocation } from "react-router-dom";
import { PortalTestProviders } from "@portal/test/TestQueryProvider";
import type { ServerPlan } from "@app/billing/serverPlan";
import { qk } from "@portal/queries/keys";
@@ -54,10 +54,25 @@ const BALANCE = {
periodEnd: "2026-10-01T00:00:00",
};
-const renderView = (serverPlan?: ServerPlan, licenseSection?: ReactNode) =>
+function Location() {
+ const location = useLocation();
+ return (
+ <output data-testid="location">
+ {location.pathname}
+ {location.search}
+ </output>
+ );
+}
+
+const renderView = (
+ serverPlan?: ServerPlan,
+ licenseSection?: ReactNode,
+ entry = "/settings/billing",
+) =>
render(
<PortalTestProviders>
- <MemoryRouter>
+ <MemoryRouter initialEntries={[entry]}>
+ <Location />
<FreeTierPlanView
serverPlan={serverPlan}
licenseSection={licenseSection}
@@ -160,6 +175,26 @@ describe("FreeTierPlanView", () => {
expect(screen.getByText("Connect a Stirling account")).toBeInTheDocument();
});
+ it.each(["Get an enterprise quote", "Explore Enterprise"])(
+ "retains the Enterprise request across linking from %s",
+ async (button) => {
+ fetchFreeTier.mockResolvedValue(BALANCE);
+ renderView(undefined, undefined, "/settings/billing?source=sales");
+ await screen.findByText("120 of 500 used");
+ if (button === "Explore Enterprise") {
+ fireEvent.click(screen.getByRole("button", { name: "Compare plans" }));
+ }
+
+ fireEvent.click(screen.getByRole("button", { name: button }));
+
+ expect(openLinkModal).toHaveBeenCalledWith("link");
+ expect(screen.getByTestId("location")).toHaveTextContent(
+ "/settings/billing?source=sales&procurement=start",
+ );
+ expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
+ },
+ );
+
it("tells a non-admin the figures are not theirs to see, rather than failing", async () => {
fetchFreeTier.mockRejectedValue(new HttpError(403, "Forbidden", null));
renderView();
diff --git a/frontend/editor/src/portal/components/billing/FreeTierPlanView.tsx b/frontend/editor/src/portal/components/billing/FreeTierPlanView.tsx
index 1e3587451f..81cac232b2 100644
--- a/frontend/editor/src/portal/components/billing/FreeTierPlanView.tsx
+++ b/frontend/editor/src/portal/components/billing/FreeTierPlanView.tsx
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import type { ServerPlan } from "@app/billing/serverPlan";
import { useEffect, useState } from "react";
+import { useSearchParams } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";
import { useAuth } from "@app/auth";
import { qk } from "@portal/queries/keys";
@@ -92,6 +93,7 @@ export function FreeTierPlanView({
const { t } = useTranslation();
const { isAdmin } = useAuth();
const { openLinkModal } = useUI();
+ const [searchParams, setSearchParams] = useSearchParams();
const query = useQuery({
queryKey: qk.freeTier(),
queryFn: fetchFreeTier,
@@ -140,6 +142,14 @@ export function FreeTierPlanView({
? () => openLinkModal(exhausted ? "exhausted" : "link")
: undefined;
+ function requestEnterpriseQuote() {
+ // The link handoff retains the URL across sign-in; Usage consumes this request once linked.
+ const next = new URLSearchParams(searchParams);
+ next.set("procurement", "start");
+ setSearchParams(next, { replace: true });
+ openLinkModal("link");
+ }
+
return (
<BillingScreen
wallet={wallet}
@@ -152,6 +162,7 @@ export function FreeTierPlanView({
pdfsProcessed={fleetStats?.pdfsProcessed ?? null}
onAddCapacity={onLink}
onActivateProcessor={onLink}
+ onEnterpriseQuote={isAdmin ? requestEnterpriseQuote : undefined}
notices={
<>
<Banner