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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
// SPDX-License-Identifier: LicenseRef-Carbon-Commercial
// Carbon Enterprise file, licensed only under the Carbon Commercial License
// (packages/ee/LICENSE). Not AGPL. Running, modifying, or copying it beyond those terms requires a commercial license.
import { describe, expect, it, vi } from "vitest";
import { RampProvider } from "../provider";
type Metadata = ConstructorParameters<typeof RampProvider>[2];
function makeProvider(
sync: Partial<{ pushPurchaseOrders: boolean; pushInvoices: boolean }> = {}
) {
const getBusiness = vi.fn().mockResolvedValue({ id: "business-1" });
const client = { getBusiness } as unknown as ConstructorParameters<
typeof RampProvider
>[0];
const metadata = {
sync: {
pullTransactions: true,
pullBills: true,
pullReimbursements: true,
pushPurchaseOrders: sync.pushPurchaseOrders ?? true,
pushInvoices: sync.pushInvoices ?? true
}
} as Metadata;
return {
provider: new RampProvider(client, "company-1", metadata),
getBusiness
};
}
describe("RampProvider", () => {
it("maps the stored push flags onto the entities it syncs", () => {
const { provider } = makeProvider({ pushInvoices: false });
expect(provider.getSyncConfig("purchaseOrder").enabled).toBe(true);
expect(provider.getSyncConfig("bill").enabled).toBe(false);
});
it("reports every entity it does not sync as disabled", () => {
const { provider } = makeProvider();
// The inbound families (cards, reimbursements) do not run through this
// config, and Ramp is not an accounting provider — it must never claim
// invoices or journals.
expect(provider.getSyncConfig("invoice").enabled).toBe(false);
expect(provider.getSyncConfig("journalEntry").enabled).toBe(false);
expect(provider.getSyncConfig("charge").enabled).toBe(false);
});
it("validates with a cheap authenticated read", async () => {
const { provider, getBusiness } = makeProvider();
expect(await provider.validate()).toBe(true);
expect(getBusiness).toHaveBeenCalledOnce();
});
it("reports invalid rather than throwing when the read fails", async () => {
const { provider, getBusiness } = makeProvider();
getBusiness.mockRejectedValueOnce(new Error("401"));
expect(await provider.validate()).toBe(false);
});
});