2026-07-31 00:50:04 +08:00
|
|
|
import { describe, expect, it } from 'vitest'
|
2026-08-06 04:40:32 +08:00
|
|
|
import { resolveTelemetryPatch } from '../src/profile-boot.ts'
|
2026-07-31 00:50:04 +08:00
|
|
|
|
|
|
|
|
describe('resolveTelemetryPatch', () => {
|
|
|
|
|
it('keeps telemetry enabled when the switch is unset or empty', () => {
|
|
|
|
|
expect(resolveTelemetryPatch(undefined, true)).toBeUndefined()
|
|
|
|
|
expect(resolveTelemetryPatch('', true)).toBeUndefined()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('disables on ANY non-empty value, including falsy-looking ones', () => {
|
|
|
|
|
for (const value of ['1', '0', 'false', 'no']) {
|
|
|
|
|
expect(resolveTelemetryPatch(value, true)).toEqual({ id: 'telemetry-otel', disabled: true })
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-06 07:30:32 +08:00
|
|
|
it('is trivially satisfied by a composition without the telemetry row', () => {
|
|
|
|
|
// A custom profile need not mount telemetry: nothing exports, so the
|
|
|
|
|
// privacy switch has nothing to disable and generates no patch.
|
|
|
|
|
expect(resolveTelemetryPatch('1', false)).toBeUndefined()
|
2026-07-31 00:50:04 +08:00
|
|
|
expect(resolveTelemetryPatch(undefined, false)).toBeUndefined()
|
|
|
|
|
})
|
|
|
|
|
})
|