cc-haha/desktop/sidecars/launcherRouting.test.ts
程序员阿江(Relakkes) f379a9928a fix: remove pr-checks lane and fix test env isolation
- Remove pr-checks lane from quality gate (not needed locally)
- Fix launcherRouting tests to pass explicit null envAppRoot to avoid CLAUDE_APP_ROOT pollution
- Fix cron-scheduler-launcher test: CLAUDE_CODE_ENTRYPOINT is correctly set to sdk-cli for scheduled tasks, update assertion and restore env var in cleanup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 21:00:06 +08:00

57 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { parseLauncherArgs, resolveSidecarInvocation } from './launcherRouting'
describe('resolveSidecarInvocation', () => {
it('keeps explicit sidecar modes unchanged', () => {
expect(
resolveSidecarInvocation(
['server', '--host', '127.0.0.1'],
'/tmp/claude-sidecar',
null,
),
).toEqual({
mode: 'server',
restArgs: ['--host', '127.0.0.1'],
defaultAppRoot: null,
})
})
it('defaults claude-haha invocations to cli mode', () => {
expect(
resolveSidecarInvocation(
['plugin', 'install', 'demo'],
'/Users/demo/.local/bin/claude-haha',
null,
),
).toEqual({
mode: 'cli',
restArgs: ['plugin', 'install', 'demo'],
defaultAppRoot: '/Users/demo/.local/bin',
})
})
})
describe('parseLauncherArgs', () => {
it('falls back to the provided default app root', () => {
expect(
parseLauncherArgs(['plugin', 'install', 'demo'], '/Users/demo/.local/bin'),
).toEqual({
appRoot: '/Users/demo/.local/bin',
args: ['plugin', 'install', 'demo'],
})
})
it('lets explicit app root override the default', () => {
expect(
parseLauncherArgs(
['--app-root', '/tmp/app', 'plugin', 'install', 'demo'],
'/Users/demo/.local/bin',
),
).toEqual({
appRoot: '/tmp/app',
args: ['plugin', 'install', 'demo'],
})
})
})