37 lines
1.8 KiB
TypeScript
37 lines
1.8 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, expect, it } from "vitest";
|
|
import { isDemoDataUiEnabled, isManagedNormalDataTenant } from "./demoDataUi.server";
|
|
|
|
describe("isDemoDataUiEnabled", () => {
|
|
it("is enabled outside production regardless of the staging flags", () => {
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "development" })).toBe(true);
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "test" })).toBe(true);
|
|
expect(isDemoDataUiEnabled({})).toBe(true);
|
|
});
|
|
|
|
it("is enabled on staging (NODE_ENV=production + both staging demo flags)", () => {
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "production", SEED_DEMO_DATA: "true", ALLOW_STAGING_DEMO_SEED: "true" })).toBe(true);
|
|
});
|
|
|
|
it("is disabled on production (no or partial staging demo flags)", () => {
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "production" })).toBe(false);
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "production", SEED_DEMO_DATA: "true" })).toBe(false);
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "production", ALLOW_STAGING_DEMO_SEED: "true" })).toBe(false);
|
|
expect(isDemoDataUiEnabled({ NODE_ENV: "production", SEED_DEMO_DATA: "false", ALLOW_STAGING_DEMO_SEED: "true" })).toBe(false);
|
|
});
|
|
|
|
it("is disabled for the managed normal-data tenant even on staging", () => {
|
|
const env = {
|
|
NODE_ENV: "production",
|
|
SEED_DEMO_DATA: "true",
|
|
ALLOW_STAGING_DEMO_SEED: "true",
|
|
SEED_DEMO_PRO_MANAGED: "true",
|
|
SEED_DEMO_PRO_EXPECTED_TENANT_ID: "tenant-normal-data",
|
|
};
|
|
expect(isManagedNormalDataTenant({ tenantId: "tenant-normal-data" }, env)).toBe(true);
|
|
expect(isManagedNormalDataTenant({ tenantSlug: "demo-pro-crm" }, env)).toBe(true);
|
|
expect(isDemoDataUiEnabled(env, { tenantId: "tenant-normal-data", tenantSlug: "demo-pro-crm" })).toBe(false);
|
|
expect(isDemoDataUiEnabled(env, { tenantId: "tenant-other", tenantSlug: "other" })).toBe(true);
|
|
});
|
|
});
|