mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 02:14:32 +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:
1 parent
f47ab484f3
commit
c0f0f173e0
2 files changed
+47
-16
No files matched your search
@@ -167,12 +167,14 @@ describe('CodexAdapter', () => {
|
|||||||
test('injects CCS_CODEX_API_KEY for CCS-backed launches only', () => {
|
test('injects CCS_CODEX_API_KEY for CCS-backed launches only', () => {
|
||||||
const originalCodeXHome = process.env.CODEX_HOME;
|
const originalCodeXHome = process.env.CODEX_HOME;
|
||||||
const originalCodeXCi = process.env.CODEX_CI;
|
const originalCodeXCi = process.env.CODEX_CI;
|
||||||
|
const originalCodeXManagedByBun = process.env.CODEX_MANAGED_BY_BUN;
|
||||||
const originalCodeXThreadId = process.env.CODEX_THREAD_ID;
|
const originalCodeXThreadId = process.env.CODEX_THREAD_ID;
|
||||||
const originalAnthropicBaseUrl = process.env.ANTHROPIC_BASE_URL;
|
const originalAnthropicBaseUrl = process.env.ANTHROPIC_BASE_URL;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process.env.CODEX_HOME = '/tmp/codex-home';
|
process.env.CODEX_HOME = '/tmp/codex-home';
|
||||||
process.env.CODEX_CI = '1';
|
process.env.CODEX_CI = '1';
|
||||||
|
process.env.CODEX_MANAGED_BY_BUN = '1';
|
||||||
process.env.CODEX_THREAD_ID = 'thread-123';
|
process.env.CODEX_THREAD_ID = 'thread-123';
|
||||||
process.env.ANTHROPIC_BASE_URL = 'https://stale-proxy.invalid';
|
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.CCS_CODEX_API_KEY).toBe('cliproxy-token');
|
||||||
expect(settingsEnv.CODEX_HOME).toBe('/tmp/codex-home');
|
expect(settingsEnv.CODEX_HOME).toBe('/tmp/codex-home');
|
||||||
expect(settingsEnv.CODEX_CI).toBeUndefined();
|
expect(settingsEnv.CODEX_CI).toBeUndefined();
|
||||||
|
expect(settingsEnv.CODEX_MANAGED_BY_BUN).toBeUndefined();
|
||||||
expect(settingsEnv.CODEX_THREAD_ID).toBeUndefined();
|
expect(settingsEnv.CODEX_THREAD_ID).toBeUndefined();
|
||||||
expect(settingsEnv.ANTHROPIC_BASE_URL).toBeUndefined();
|
expect(settingsEnv.ANTHROPIC_BASE_URL).toBeUndefined();
|
||||||
|
|
||||||
@@ -201,6 +204,7 @@ describe('CodexAdapter', () => {
|
|||||||
expect(defaultEnv.CCS_CODEX_API_KEY).toBeUndefined();
|
expect(defaultEnv.CCS_CODEX_API_KEY).toBeUndefined();
|
||||||
expect(defaultEnv.CODEX_HOME).toBe('/tmp/codex-home');
|
expect(defaultEnv.CODEX_HOME).toBe('/tmp/codex-home');
|
||||||
expect(defaultEnv.CODEX_CI).toBeUndefined();
|
expect(defaultEnv.CODEX_CI).toBeUndefined();
|
||||||
|
expect(defaultEnv.CODEX_MANAGED_BY_BUN).toBeUndefined();
|
||||||
expect(defaultEnv.CODEX_THREAD_ID).toBeUndefined();
|
expect(defaultEnv.CODEX_THREAD_ID).toBeUndefined();
|
||||||
expect(defaultEnv.ANTHROPIC_BASE_URL).toBeUndefined();
|
expect(defaultEnv.ANTHROPIC_BASE_URL).toBeUndefined();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -214,6 +218,11 @@ describe('CodexAdapter', () => {
|
|||||||
} else {
|
} else {
|
||||||
process.env.CODEX_CI = originalCodeXCi;
|
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) {
|
if (originalCodeXThreadId === undefined) {
|
||||||
delete process.env.CODEX_THREAD_ID;
|
delete process.env.CODEX_THREAD_ID;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ const out = process.env.CCS_TEST_CODEX_ARGS_OUT;
|
|||||||
if (out) {
|
if (out) {
|
||||||
fs.appendFileSync(out, JSON.stringify(process.argv.slice(2)) + '\\n');
|
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.stdout.write(process.env.CCS_TEST_CODEX_VERSION || 'codex-cli 0.118.0-alpha.3');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
if (process.argv[2] === '--help') {
|
if (process.argv[2] === '--help' || process.argv[2] === '-h') {
|
||||||
process.stdout.write(
|
process.stdout.write(
|
||||||
process.env.CCS_TEST_CODEX_HELP ||
|
process.env.CCS_TEST_CODEX_HELP ||
|
||||||
' -c, --config <key=value>\\n -p, --profile <CONFIG_PROFILE>\\n'
|
' -c, --config <key=value>\\n -p, --profile <CONFIG_PROFILE>\\n'
|
||||||
@@ -144,23 +144,45 @@ process.exit(0);
|
|||||||
expect(calls).toEqual([['fix failing tests']]);
|
expect(calls).toEqual([['fix failing tests']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes ccsx --version straight through to the native Codex binary', () => {
|
for (const versionFlag of ['--version', '-v']) {
|
||||||
if (process.platform === 'win32') return;
|
it(`passes ccsx ${versionFlag} straight through to the native Codex binary`, () => {
|
||||||
|
if (process.platform === 'win32') return;
|
||||||
|
|
||||||
const result = runCodexAlias(['--version'], {
|
const result = runCodexAlias([versionFlag], {
|
||||||
...process.env,
|
...process.env,
|
||||||
CI: '1',
|
CI: '1',
|
||||||
NO_COLOR: '1',
|
NO_COLOR: '1',
|
||||||
CCS_HOME: tmpHome,
|
CCS_HOME: tmpHome,
|
||||||
CCS_CODEX_PATH: fakeCodexPath,
|
CCS_CODEX_PATH: fakeCodexPath,
|
||||||
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
|
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
|
||||||
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
|
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);
|
for (const helpFlag of ['--help', '-h']) {
|
||||||
expect(result.stdout).toContain('codex-cli 9.9.9-test');
|
it(`passes ccsx ${helpFlag} straight through to the native Codex binary`, () => {
|
||||||
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([['--version']]);
|
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', () => {
|
it('fails fast when native Codex reasoning overrides need unsupported --config support', () => {
|
||||||
if (process.platform === 'win32') return;
|
if (process.platform === 'win32') return;
|
||||||
|
|||||||
Reference in new issue
Block a user