import { describe, expect, it } from 'vitest'; import { stripSystemdSupervisorEnv } from '@electron/gateway/config-sync-env'; describe('stripSystemdSupervisorEnv', () => { it('removes systemd supervisor marker env vars', () => { const env = { PATH: '/usr/bin:/bin', OPENCLAW_SYSTEMD_UNIT: 'openclaw-gateway.service', INVOCATION_ID: 'abc123', SYSTEMD_EXEC_PID: '777', JOURNAL_STREAM: '8:12345', OTHER: 'keep-me', }; const result = stripSystemdSupervisorEnv(env); expect(result).toEqual({ PATH: '/usr/bin:/bin', OTHER: 'keep-me', }); }); it('keeps unrelated variables unchanged', () => { const env = { NODE_ENV: 'production', OPENCLAW_GATEWAY_TOKEN: 'token', CLAWDBOT_SKIP_CHANNELS: '0', }; expect(stripSystemdSupervisorEnv(env)).toEqual(env); }); it('does not mutate source env object', () => { const env = { OPENCLAW_SYSTEMD_UNIT: 'openclaw-gateway.service', VALUE: '1', }; const before = { ...env }; const result = stripSystemdSupervisorEnv(env); expect(env).toEqual(before); expect(result).toEqual({ VALUE: '1' }); }); });