telemetry-switch.spec.ts 1001 B

12345678910111213141516171819202122
  1. import { describe, expect, it } from 'vitest'
  2. import { resolveTelemetryPatch } from '../src/profile-boot.ts'
  3. describe('resolveTelemetryPatch', () => {
  4. it('preserves the configured telemetry mode when the hard-disable switch is unset or empty', () => {
  5. expect(resolveTelemetryPatch(undefined, true)).toBeUndefined()
  6. expect(resolveTelemetryPatch('', true)).toBeUndefined()
  7. })
  8. it('disables on ANY non-empty value, including falsy-looking ones', () => {
  9. for (const value of ['1', '0', 'false', 'no']) {
  10. expect(resolveTelemetryPatch(value, true)).toEqual({ id: 'session-telemetry-otel', disabled: true })
  11. }
  12. })
  13. it('is trivially satisfied by a composition without the telemetry row', () => {
  14. // A custom profile need not mount telemetry: nothing exports, so the
  15. // privacy switch has nothing to disable and generates no patch.
  16. expect(resolveTelemetryPatch('1', false)).toBeUndefined()
  17. expect(resolveTelemetryPatch(undefined, false)).toBeUndefined()
  18. })
  19. })