Files
core2026/app/gateway-api/test/profileOrder.test.ts
T
Hide_D d80ea1bd0e fix: Gateway 화면에서 raw 프로필 ID 노출을 제거한다
불변 profileName은 라우팅과 저장 경계에 유지하고 사용자 출력은 공통 표시명을 사용한다. 기본 인스턴스 suffix를 숨기고 비기본 인스턴스만 사람이 읽을 수 있게 구분한다.
2026-08-24 07:15:25 +00:00

69 lines
2.7 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
GATEWAY_PROFILE_KOREAN_NAMES,
GATEWAY_PROFILE_ORDER,
orderGatewayProfiles,
resolveGatewayProfileDisplayName,
resolveGatewayProfileKoreanName,
} from '../src/profileOrder.js';
describe('orderGatewayProfiles', () => {
it('uses the public server order instead of alphabetical profile order', () => {
const profiles = ['hwe', 'pya', 'che', 'nya', 'twe', 'pwe', 'kwe'].map((profile) => ({
profile,
instanceKey: 'default',
}));
expect(orderGatewayProfiles(profiles).map(({ profile }) => profile)).toEqual(GATEWAY_PROFILE_ORDER);
});
it('orders instance keys within a profile and places unknown profiles afterward', () => {
const profiles = [
{ profile: 'zeta', instanceKey: 'default' },
{ profile: 'che', instanceKey: '20' },
{ profile: 'alpha', instanceKey: 'default' },
{ profile: 'che', instanceKey: '10' },
];
expect(orderGatewayProfiles(profiles)).toEqual([
{ profile: 'che', instanceKey: '10' },
{ profile: 'che', instanceKey: '20' },
{ profile: 'alpha', instanceKey: 'default' },
{ profile: 'zeta', instanceKey: 'default' },
]);
expect(profiles[0]?.profile).toBe('zeta');
});
});
describe('resolveGatewayProfileKoreanName', () => {
it('uses the canonical Korean labels for every public profile', () => {
expect(GATEWAY_PROFILE_ORDER.map((profile) => resolveGatewayProfileKoreanName(profile))).toEqual(
GATEWAY_PROFILE_ORDER.map((profile) => GATEWAY_PROFILE_KOREAN_NAMES[profile])
);
expect(GATEWAY_PROFILE_ORDER.map((profile) => `${resolveGatewayProfileKoreanName(profile)}섭`)).toEqual([
'체섭',
'퀘섭',
'풰섭',
'퉤섭',
'냐섭',
'퍄섭',
'훼섭',
]);
});
it('preserves configured and unknown profile names', () => {
expect(resolveGatewayProfileKoreanName('che', ' 천하서버 ')).toBe('천하서버');
expect(resolveGatewayProfileKoreanName('custom')).toBe('custom');
});
});
describe('resolveGatewayProfileDisplayName', () => {
it('hides the default instance key and distinguishes non-default instances', () => {
expect(resolveGatewayProfileDisplayName('che', 'default')).toBe('체');
expect(resolveGatewayProfileDisplayName('hwe', '2')).toBe('훼 [2]');
expect(resolveGatewayProfileDisplayName('che', 'default', ' 천하서버 ')).toBe('천하서버');
expect(resolveGatewayProfileDisplayName('custom', 'blue')).toBe('custom [blue]');
});
});