mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-10-16 14:57:05 +08:00
- Updated test cases in `providerWeightTransformers.test.ts` to reflect changes in API key structure from 'api-key-entries' to 'keys'. - Introduced new tests in `providerWorkbenchUi.test.ts` to verify the editing surface of provider workbench. - Modified `sponsorCustomEndpoint.test.ts` to adapt to the new API key structure. - Adjusted `visualConfigAntigravitySensitiveWords.test.ts` and `visualConfigConcurrency.test.ts` to accommodate new YAML structure for sensitive words and concurrency settings. - Enhanced `visualConfigDefaults.test.ts` to ensure proper handling of boolean defaults and YAML structure. - Updated `visualConfigDevinSensitiveWords.test.ts` to reflect changes in the YAML structure for sensitive words. - Refined `visualConfigDisableImageGeneration.test.ts` to align with new multimedia settings. - Added comprehensive tests in `visualConfigV8.test.ts` to validate the v8 visual config contract and ensure scalar read/write path parity. - Improved validation tests in `visualConfigValidation.test.ts` to handle new routing and requests structure. - Cleaned up `xaiApiKeyProvider.test.ts` by removing unnecessary API client mocks and focusing on normalization of the xAI API key contract.
71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { metaToResource } from '../src/features/providers/adapters';
|
|
import { PROVIDER_BRAND_ORDER, PROVIDER_DESCRIPTORS } from '../src/features/providers/descriptors';
|
|
import { MODEL_DISCOVERY_BRANDS } from '../src/features/providers/sheets/forms/useModelDiscovery';
|
|
import { buildProviderGroups } from '../src/features/providers/useProviderWorkbench';
|
|
import { normalizeConfigResponse } from '../src/services/api/transformers';
|
|
|
|
describe('Meta Muse API key provider', () => {
|
|
test('normalizes the backend contract and exposes a dedicated workbench resource', () => {
|
|
const config = normalizeConfigResponse({
|
|
'api-keys': {
|
|
meta: [
|
|
{
|
|
name: 'meta-1',
|
|
'base-url': 'https://api.meta.ai/v1',
|
|
keys: [
|
|
{
|
|
'api-key': 'meta-secret',
|
|
priority: 7,
|
|
weight: 3,
|
|
prefix: 'muse',
|
|
'proxy-url': 'socks5://proxy.example:1080',
|
|
headers: { 'X-Custom': 'value' },
|
|
models: [{ name: 'muse-spark-1.3', alias: 'muse-latest' }],
|
|
'excluded-models': ['muse-spark-1.1'],
|
|
'disable-cooling': true,
|
|
'auth-index': 'meta:apikey:1',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
expect(config.metaApiKeys).toMatchObject([
|
|
{
|
|
apiKey: 'meta-secret',
|
|
priority: 7,
|
|
weight: 3,
|
|
prefix: 'muse',
|
|
baseUrl: 'https://api.meta.ai/v1',
|
|
proxyUrl: 'socks5://proxy.example:1080',
|
|
headers: { 'X-Custom': 'value' },
|
|
models: [{ name: 'muse-spark-1.3', alias: 'muse-latest' }],
|
|
excludedModels: ['muse-spark-1.1'],
|
|
disableCooling: true,
|
|
authIndex: 'meta:apikey:1',
|
|
},
|
|
]);
|
|
|
|
const resource = metaToResource(config.metaApiKeys![0], 0);
|
|
expect(resource.brand).toBe('meta');
|
|
expect(resource.baseUrl).toBe('https://api.meta.ai/v1');
|
|
expect(resource.models).toEqual(['muse-spark-1.3']);
|
|
expect(resource.selector).toEqual({
|
|
brand: 'meta',
|
|
apiKey: 'meta-secret',
|
|
baseUrl: 'https://api.meta.ai/v1',
|
|
index: 0,
|
|
});
|
|
expect(
|
|
buildProviderGroups(config).find((group) => group.id === 'meta')?.resources
|
|
).toHaveLength(1);
|
|
expect(PROVIDER_DESCRIPTORS.meta.baseUrlRequired).toBe(false);
|
|
expect(PROVIDER_DESCRIPTORS.meta.supportsWebsockets).toBe(false);
|
|
expect(PROVIDER_DESCRIPTORS.meta.supportsTestModel).toBe(true);
|
|
expect(PROVIDER_BRAND_ORDER.indexOf('meta')).toBe(PROVIDER_BRAND_ORDER.indexOf('codex') + 1);
|
|
expect(MODEL_DISCOVERY_BRANDS).toContain('meta');
|
|
});
|
|
});
|