fix(profile): close km legacy kimi compatibility gaps

This commit is contained in:
Tam Nhu Tran committed 2026-02-19 13:02:56 +07:00
1 parent cf8070b5f0
commit 0bf00b23d9
9 files changed
+343 -66

No files matched your search

+26 -1
View File
@@ -1,5 +1,9 @@
import { describe, expect, it } from 'bun:test';
import { getProfileLookupCandidates, isLegacyProfileAlias } from '../../../src/utils/profile-compat';
import {
getProfileLookupCandidates,
isLegacyProfileAlias,
resolveAliasToCanonical,
} from '../../../src/utils/profile-compat';
describe('profile-compat', () => {
describe('getProfileLookupCandidates', () => {
@@ -14,6 +18,15 @@ describe('profile-compat', () => {
it('normalizes uppercase input and still resolves aliases', () => {
expect(getProfileLookupCandidates('KM')).toEqual(['KM', 'km', 'kimi']);
});
it('handles surrounding whitespace', () => {
expect(getProfileLookupCandidates(' km ')).toEqual(['km', 'kimi']);
});
it('returns empty candidates for empty input', () => {
expect(getProfileLookupCandidates('')).toEqual([]);
expect(getProfileLookupCandidates(' ')).toEqual([]);
});
});
describe('isLegacyProfileAlias', () => {
@@ -30,4 +43,16 @@ describe('profile-compat', () => {
expect(isLegacyProfileAlias('glm', 'kimi')).toBe(false);
});
});
describe('resolveAliasToCanonical', () => {
it('maps legacy kimi alias to canonical km', () => {
expect(resolveAliasToCanonical('kimi')).toBe('km');
expect(resolveAliasToCanonical('KIMI')).toBe('km');
});
it('keeps canonical and non-aliased names', () => {
expect(resolveAliasToCanonical('km')).toBe('km');
expect(resolveAliasToCanonical('glm')).toBe('glm');
});
});
});