fix(profile): handle km compatibility for legacy kimi api users

This commit is contained in:
Tam Nhu Tran committed 2026-02-19 12:43:41 +07:00
1 parent 7efbac6c1a
commit cf8070b5f0
17 files changed
+266 -54

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
import { describe, expect, it } from 'bun:test';
import { getProfileLookupCandidates, isLegacyProfileAlias } from '../../../src/utils/profile-compat';
describe('profile-compat', () => {
describe('getProfileLookupCandidates', () => {
it('returns km candidates with legacy kimi fallback', () => {
expect(getProfileLookupCandidates('km')).toEqual(['km', 'kimi']);
});
it('keeps non-aliased profiles unchanged', () => {
expect(getProfileLookupCandidates('glm')).toEqual(['glm']);
});
it('normalizes uppercase input and still resolves aliases', () => {
expect(getProfileLookupCandidates('KM')).toEqual(['KM', 'km', 'kimi']);
});
});
describe('isLegacyProfileAlias', () => {
it('returns true for km -> kimi', () => {
expect(isLegacyProfileAlias('km', 'kimi')).toBe(true);
});
it('returns false for canonical names', () => {
expect(isLegacyProfileAlias('km', 'km')).toBe(false);
expect(isLegacyProfileAlias('glm', 'glm')).toBe(false);
});
it('returns false for unrelated names', () => {
expect(isLegacyProfileAlias('glm', 'kimi')).toBe(false);
});
});
});