import { describe, test, expect } from 'vitest'; import { DeploymentTypeEnum, isBrowserTelemetryEnabled } from './env.js'; describe('isBrowserTelemetryEnabled', () => { test('returns true for CLOUD deployment', () => { expect(isBrowserTelemetryEnabled(DeploymentTypeEnum.CLOUD)).toBe(true); }); test('returns false for CLOUD_PREM deployment', () => { expect(isBrowserTelemetryEnabled(DeploymentTypeEnum.CLOUD_PREM)).toBe(false); }); test('returns false when deploymentType is undefined (fail-closed on ambiguity)', () => { expect(isBrowserTelemetryEnabled(undefined)).toBe(false); }); test("returns false for empty string (helm configmap renders '' when deploymentType override is missing)", () => { expect(isBrowserTelemetryEnabled('' as DeploymentTypeEnum)).toBe(false); }); test('returns false for common typos that would bypass a blocklist check', () => { expect(isBrowserTelemetryEnabled('cloud_prem' as DeploymentTypeEnum)).toBe(false); expect(isBrowserTelemetryEnabled('CLOUD-PREM' as DeploymentTypeEnum)).toBe(false); expect(isBrowserTelemetryEnabled('cloud-prem ' as DeploymentTypeEnum)).toBe(false); }); });