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.

build: add test environment

Brad Barbin35ba0dc06bad
diff --git a/packages/auth/src/config/env.ts b/packages/auth/src/config/env.ts
index eaa0918f9d..07a39933ac 100644
--- a/packages/auth/src/config/env.ts
+++ b/packages/auth/src/config/env.ts
@@ -109,6 +109,9 @@ const getEdition = () => {
if (CARBON_EDITION === "enterprise") {
return Edition.Enterprise;
}
+ if (CARBON_EDITION === "test") {
+ return Edition.Test;
+ }
return Edition.Community;
};
diff --git a/packages/auth/src/services/company.server.ts b/packages/auth/src/services/company.server.ts
index b721d229f0..c59cf3e028 100644
--- a/packages/auth/src/services/company.server.ts
+++ b/packages/auth/src/services/company.server.ts
@@ -1,20 +1,22 @@
-import { DOMAIN } from "@carbon/auth";
+import { CarbonEdition, DOMAIN } from "@carbon/auth";
+import { Edition } from "@carbon/utils";
import * as cookie from "cookie";
const cookieName = "companyId";
+const isTestEdition = CarbonEdition === Edition.Test;
export function setCompanyId(companyId: string | null) {
if (!companyId) {
return cookie.serialize(cookieName, "", {
path: "/",
expires: new Date(0),
- domain: DOMAIN
+ domain: isTestEdition ? undefined : DOMAIN
});
}
return cookie.serialize(cookieName, companyId, {
path: "/",
maxAge: 31536000, // 1 year
- domain: DOMAIN
+ domain: isTestEdition ? undefined : DOMAIN
});
}
diff --git a/packages/auth/src/services/session.server.ts b/packages/auth/src/services/session.server.ts
index 581923370b..7cb8c7a8ba 100644
--- a/packages/auth/src/services/session.server.ts
+++ b/packages/auth/src/services/session.server.ts
@@ -1,7 +1,9 @@
import { redis } from "@carbon/kv";
+import { Edition } from "@carbon/utils";
import { createCookieSessionStorage, redirect } from "react-router";
import {
+ CarbonEdition,
DOMAIN,
REFRESH_ACCESS_TOKEN_THRESHOLD,
SESSION_KEY,
@@ -31,14 +33,16 @@ async function assertAuthSession(
return authSession;
}
+const isTestEdition = CarbonEdition === Edition.Test;
+
const sessionStorage = createCookieSessionStorage({
cookie: {
name: "carbon",
- httpOnly: VERCEL_ENV === "production",
+ httpOnly: isTestEdition || VERCEL_ENV === "production",
path: "/",
- sameSite: "lax",
+ sameSite: isTestEdition ? "none" : "lax",
secrets: [SESSION_SECRET],
- secure: VERCEL_ENV === "production",
+ secure: isTestEdition || VERCEL_ENV === "production",
domain: VERCEL_ENV === "production" ? DOMAIN : undefined // eg. carbon.ms
}
});
diff --git a/packages/utils/src/types.ts b/packages/utils/src/types.ts
index b2f7108e86..30e25aa36c 100644
--- a/packages/utils/src/types.ts
+++ b/packages/utils/src/types.ts
@@ -3,7 +3,8 @@ import { z } from "zod";
export enum Edition {
Cloud = "cloud",
Enterprise = "enterprise",
- Community = "community"
+ Community = "community",
+ Test = "test"
}
export type Mode = "light" | "dark";