Files
ccs/tests/unit/cliproxy/backend-ui-provider-arrays-sync.test.ts
T
Tam Nhu Tran 94b03c7f75 refactor(cliproxy): DRY provider lists into single source of truth
- unify CLIPROXY_SUPPORTED_PROVIDERS to import from CLIPROXY_PROVIDER_IDS
- replace 4 inline union types with CLIProxyProvider import
- replace hardcoded provider arrays in migration-manager and proxy-routes
- remove duplicate PROVIDER_DISPLAY_NAMES, use getProviderDisplayName()
- sync test now imports from ui/src/lib/provider-config instead of hardcoded array

Adding a new CLIProxy provider no longer requires updating 14+ hardcoded lists.
2026-02-17 17:02:45 +07:00

30 lines
922 B
TypeScript

/**
* Provider Sync Test
*
* Validates that backend CLIPROXY_PROFILES and UI CLIPROXY_PROVIDERS stay in sync.
* This test catches mismatches when adding new providers.
*/
import { describe, expect, test } from 'bun:test';
import { CLIPROXY_PROFILES } from '../../../src/auth/profile-detector';
import { CLIPROXY_PROVIDERS } from '../../../ui/src/lib/provider-config';
describe('Provider Sync', () => {
test('backend CLIPROXY_PROFILES matches UI CLIPROXY_PROVIDERS', () => {
const backend = [...CLIPROXY_PROFILES].sort();
const ui = [...CLIPROXY_PROVIDERS].sort();
expect(backend).toEqual(ui);
});
test('both arrays have same length', () => {
expect(CLIPROXY_PROFILES.length).toBe(CLIPROXY_PROVIDERS.length);
});
test('UI array contains all backend providers', () => {
for (const provider of CLIPROXY_PROFILES) {
expect(CLIPROXY_PROVIDERS).toContain(provider);
}
});
});