mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 02:11:28 +00:00
test(codex): cover alias passthrough gaps
- add integration coverage for ccsx help and version short/long flags - assert CODEX_MANAGED_BY_BUN is stripped from nested Codex launches
This commit is contained in:
@@ -167,12 +167,14 @@ describe('CodexAdapter', () => {
|
||||
test('injects CCS_CODEX_API_KEY for CCS-backed launches only', () => {
|
||||
const originalCodeXHome = process.env.CODEX_HOME;
|
||||
const originalCodeXCi = process.env.CODEX_CI;
|
||||
const originalCodeXManagedByBun = process.env.CODEX_MANAGED_BY_BUN;
|
||||
const originalCodeXThreadId = process.env.CODEX_THREAD_ID;
|
||||
const originalAnthropicBaseUrl = process.env.ANTHROPIC_BASE_URL;
|
||||
|
||||
try {
|
||||
process.env.CODEX_HOME = '/tmp/codex-home';
|
||||
process.env.CODEX_CI = '1';
|
||||
process.env.CODEX_MANAGED_BY_BUN = '1';
|
||||
process.env.CODEX_THREAD_ID = 'thread-123';
|
||||
process.env.ANTHROPIC_BASE_URL = 'https://stale-proxy.invalid';
|
||||
|
||||
@@ -187,6 +189,7 @@ describe('CodexAdapter', () => {
|
||||
expect(settingsEnv.CCS_CODEX_API_KEY).toBe('cliproxy-token');
|
||||
expect(settingsEnv.CODEX_HOME).toBe('/tmp/codex-home');
|
||||
expect(settingsEnv.CODEX_CI).toBeUndefined();
|
||||
expect(settingsEnv.CODEX_MANAGED_BY_BUN).toBeUndefined();
|
||||
expect(settingsEnv.CODEX_THREAD_ID).toBeUndefined();
|
||||
expect(settingsEnv.ANTHROPIC_BASE_URL).toBeUndefined();
|
||||
|
||||
@@ -201,6 +204,7 @@ describe('CodexAdapter', () => {
|
||||
expect(defaultEnv.CCS_CODEX_API_KEY).toBeUndefined();
|
||||
expect(defaultEnv.CODEX_HOME).toBe('/tmp/codex-home');
|
||||
expect(defaultEnv.CODEX_CI).toBeUndefined();
|
||||
expect(defaultEnv.CODEX_MANAGED_BY_BUN).toBeUndefined();
|
||||
expect(defaultEnv.CODEX_THREAD_ID).toBeUndefined();
|
||||
expect(defaultEnv.ANTHROPIC_BASE_URL).toBeUndefined();
|
||||
} finally {
|
||||
@@ -214,6 +218,11 @@ describe('CodexAdapter', () => {
|
||||
} else {
|
||||
process.env.CODEX_CI = originalCodeXCi;
|
||||
}
|
||||
if (originalCodeXManagedByBun === undefined) {
|
||||
delete process.env.CODEX_MANAGED_BY_BUN;
|
||||
} else {
|
||||
process.env.CODEX_MANAGED_BY_BUN = originalCodeXManagedByBun;
|
||||
}
|
||||
if (originalCodeXThreadId === undefined) {
|
||||
delete process.env.CODEX_THREAD_ID;
|
||||
} else {
|
||||
|
||||
@@ -82,11 +82,11 @@ const out = process.env.CCS_TEST_CODEX_ARGS_OUT;
|
||||
if (out) {
|
||||
fs.appendFileSync(out, JSON.stringify(process.argv.slice(2)) + '\\n');
|
||||
}
|
||||
if (process.argv[2] === '--version') {
|
||||
if (process.argv[2] === '--version' || process.argv[2] === '-v') {
|
||||
process.stdout.write(process.env.CCS_TEST_CODEX_VERSION || 'codex-cli 0.118.0-alpha.3');
|
||||
process.exit(0);
|
||||
}
|
||||
if (process.argv[2] === '--help') {
|
||||
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
|
||||
process.stdout.write(
|
||||
process.env.CCS_TEST_CODEX_HELP ||
|
||||
' -c, --config <key=value>\\n -p, --profile <CONFIG_PROFILE>\\n'
|
||||
@@ -144,23 +144,45 @@ process.exit(0);
|
||||
expect(calls).toEqual([['fix failing tests']]);
|
||||
});
|
||||
|
||||
it('passes ccsx --version straight through to the native Codex binary', () => {
|
||||
if (process.platform === 'win32') return;
|
||||
for (const versionFlag of ['--version', '-v']) {
|
||||
it(`passes ccsx ${versionFlag} straight through to the native Codex binary`, () => {
|
||||
if (process.platform === 'win32') return;
|
||||
|
||||
const result = runCodexAlias(['--version'], {
|
||||
...process.env,
|
||||
CI: '1',
|
||||
NO_COLOR: '1',
|
||||
CCS_HOME: tmpHome,
|
||||
CCS_CODEX_PATH: fakeCodexPath,
|
||||
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
|
||||
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
|
||||
const result = runCodexAlias([versionFlag], {
|
||||
...process.env,
|
||||
CI: '1',
|
||||
NO_COLOR: '1',
|
||||
CCS_HOME: tmpHome,
|
||||
CCS_CODEX_PATH: fakeCodexPath,
|
||||
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
|
||||
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
|
||||
});
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toContain('codex-cli 9.9.9-test');
|
||||
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([[versionFlag]]);
|
||||
});
|
||||
}
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toContain('codex-cli 9.9.9-test');
|
||||
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([['--version']]);
|
||||
});
|
||||
for (const helpFlag of ['--help', '-h']) {
|
||||
it(`passes ccsx ${helpFlag} straight through to the native Codex binary`, () => {
|
||||
if (process.platform === 'win32') return;
|
||||
|
||||
const result = runCodexAlias([helpFlag], {
|
||||
...process.env,
|
||||
CI: '1',
|
||||
NO_COLOR: '1',
|
||||
CCS_HOME: tmpHome,
|
||||
CCS_CODEX_PATH: fakeCodexPath,
|
||||
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
|
||||
CCS_TEST_CODEX_HELP: 'codex native help text',
|
||||
});
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toContain('codex native help text');
|
||||
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([[helpFlag]]);
|
||||
});
|
||||
}
|
||||
|
||||
it('fails fast when native Codex reasoning overrides need unsupported --config support', () => {
|
||||
if (process.platform === 'win32') return;
|
||||
|
||||
Reference in New Issue
Block a user