Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

test(integrations): stub the install-withheld check in the connect route test

Raul29ac44edd88b
diff --git a/apps/erp/app/routes/api+/integrations.$id.connect.test.ts b/apps/erp/app/routes/api+/integrations.$id.connect.test.ts
index ddd363d5aa..5e45d5a878 100644
--- a/apps/erp/app/routes/api+/integrations.$id.connect.test.ts
+++ b/apps/erp/app/routes/api+/integrations.$id.connect.test.ts
@@ -5,6 +5,9 @@
import { describe, expect, it, vi } from "vitest";
const requirePermissions = vi.hoisted(() => vi.fn());
+// The rule itself is pinned by `isIntegrationComingSoon`'s tests in
+// `@carbon/ee`; here only the route's answer to a withheld install is.
+const isIntegrationInstallWithheld = vi.hoisted(() => vi.fn(async () => false));
// Role-aware, because the guard compares the incumbent row against the ids of
// that ROLE. "brex" stands in for a second spend provider: with only Ramp
// registered today a spend role conflict is unreachable, so the guard would
@@ -51,6 +54,9 @@ vi.mock("@carbon/ee", () => ({
integrations: [RAMP],
getIntegrationIdsByRole
}));
+vi.mock("~/modules/settings/settings.service", () => ({
+ isIntegrationInstallWithheld
+}));
import { loader } from "./integrations.$id.connect";
@@ -68,6 +74,7 @@ async function connect(mode: string | null, rows: Array<{ id: string }> = []) {
requirePermissions.mockResolvedValue({
userId: "user-1",
companyId: "company-1",
+ email: "[email protected]",
client: activeRows(rows)
});
@@ -141,4 +148,12 @@ describe("integration connect route", () => {
expect(response.headers.get("Location")).toContain("ramp.com");
});
+
+ it("refuses before consent when the install is withheld from this user", async () => {
+ isIntegrationInstallWithheld.mockResolvedValueOnce(true);
+ const response = await connect("push-only");
+
+ expect(response.headers.get("Location")).toContain("error=coming-soon");
+ expect(response.headers.get("Location")).not.toContain("ramp.com");
+ });
});