mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-20 05:11:48 +00:00
test(cliproxy): cover Claude long-context parity flows
- add regression coverage for runtime, api create flags, and help text - add provider-editor tests for multi-key [1m] state and preset preservation Refs #789
This commit is contained in:
1 parent
c05189b4b1
commit
5e11bba514
5 files changed
+305
-2
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
|
||||
import {
|
||||
applyClaudeExtendedContextPreference,
|
||||
collectUnexpectedApiArgs,
|
||||
hasClaudeModelMapping,
|
||||
hasExplicitClaudeExtendedContext,
|
||||
parseApiCommandArgs,
|
||||
} from '../../../src/commands/api-command/shared';
|
||||
|
||||
@@ -132,6 +135,27 @@ describe('api-command arg parser', () => {
|
||||
expect(parsed.model).toBe('-preview');
|
||||
expect(parsed.errors).toEqual([]);
|
||||
});
|
||||
|
||||
test('parses --1m for explicit Claude long context', () => {
|
||||
const parsed = parseApiCommandArgs(['my-api', '--1m']);
|
||||
|
||||
expect(parsed.extendedContext).toBe(true);
|
||||
expect(parsed.errors).toEqual([]);
|
||||
});
|
||||
|
||||
test('parses --no-1m for explicit standard-context preference', () => {
|
||||
const parsed = parseApiCommandArgs(['my-api', '--no-1m']);
|
||||
|
||||
expect(parsed.extendedContext).toBe(false);
|
||||
expect(parsed.errors).toEqual([]);
|
||||
});
|
||||
|
||||
test('rejects conflicting --1m and --no-1m flags', () => {
|
||||
const parsed = parseApiCommandArgs(['my-api', '--1m', '--no-1m']);
|
||||
|
||||
expect(parsed.extendedContext).toBeUndefined();
|
||||
expect(parsed.errors).toEqual(['Cannot combine --1m and --no-1m']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('collectUnexpectedApiArgs', () => {
|
||||
@@ -155,3 +179,55 @@ describe('collectUnexpectedApiArgs', () => {
|
||||
expect(parsed.errors).toEqual(['Unknown option: --bogus', 'Unexpected arguments: value']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Claude long-context mapping helpers', () => {
|
||||
test('detects Claude mappings and explicit [1m] state across all tiers', () => {
|
||||
const models = {
|
||||
default: 'gpt-5.4',
|
||||
opus: 'claude-opus-4-6[1m]',
|
||||
sonnet: 'claude-sonnet-4-6',
|
||||
haiku: 'claude-haiku-4-5-20251001',
|
||||
};
|
||||
|
||||
expect(hasClaudeModelMapping(models)).toBe(true);
|
||||
expect(hasExplicitClaudeExtendedContext(models)).toBe(true);
|
||||
});
|
||||
|
||||
test('applies [1m] only to compatible Claude mappings and leaves Haiku plain', () => {
|
||||
const models = applyClaudeExtendedContextPreference(
|
||||
{
|
||||
default: 'claude-sonnet-4-6',
|
||||
opus: 'claude-opus-4-6',
|
||||
sonnet: 'claude-sonnet-4-6',
|
||||
haiku: 'claude-haiku-4-5-20251001',
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
expect(models).toEqual({
|
||||
default: 'claude-sonnet-4-6[1m]',
|
||||
opus: 'claude-opus-4-6[1m]',
|
||||
sonnet: 'claude-sonnet-4-6[1m]',
|
||||
haiku: 'claude-haiku-4-5-20251001',
|
||||
});
|
||||
});
|
||||
|
||||
test('strips [1m] from Claude mappings when standard context is requested', () => {
|
||||
const models = applyClaudeExtendedContextPreference(
|
||||
{
|
||||
default: 'claude-sonnet-4-6[1m]',
|
||||
opus: 'claude-opus-4-6[1m]',
|
||||
sonnet: 'claude-sonnet-4-6[1m]',
|
||||
haiku: 'claude-haiku-4-5-20251001',
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(models).toEqual({
|
||||
default: 'claude-sonnet-4-6',
|
||||
opus: 'claude-opus-4-6',
|
||||
sonnet: 'claude-sonnet-4-6',
|
||||
haiku: 'claude-haiku-4-5-20251001',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user