Files
Cli-Proxy-API-Management-Ce…/tests/configAdditionsLocalization.test.ts
Supra4E8C af75f6539e Refactor tests to enhance InfoTip functionality and localization
- Updated `providerErrorRulesUi.test.ts` to ensure controls are disabled while saving or disconnected, and added tests for InfoTips related to regex conditions and rule-order hints.
- Created `providerFormHints.test.ts` to validate the transformation of notes into InfoTips, ensuring accessibility and proper descriptions for various form elements.
- Enhanced `providerModelOptions.test.ts` to confirm that field notes are represented as InfoTips and that existing thinking JSON adds preservation notes.
- Added tests in `quotaBodyRendering.test.ts` for Antigravity and Plugin quota groups to ensure descriptions are displayed as InfoTips.
- Implemented `quotaTimelineRendering.test.ts` to verify InfoTip functionality in the QuotaTimeline component.
- Updated `routingPage.test.ts` to check that policy explanations are presented as InfoTips and that the preview caveat is correctly positioned.
- Introduced `tooltipMarkup.test.ts` to validate the structure and behavior of InfoTips and Tooltips, ensuring proper accessibility attributes.
- Added `tooltipPosition.test.ts` to test the positioning logic of tooltips within the viewport.
- Fixed Turkish locale test to ensure correct hint extraction from the configuration.
2026-11-14 20:40:37 +08:00

74 lines
2.6 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import { CONFIG_FIELD_SEARCH_INDEX } from '@/features/config/searchIndex';
const addedFieldIds = [
'routingSessionAffinitySubagents',
'saveCooldownStatus',
'transientErrorCooldownSeconds',
'videoResultAuthCacheTTL',
'claudeHeaderTimezone',
'claudeModelLevelCooling',
'claudeDisableCloakMode',
'claudeCodeDisableCloakingModelList',
'codexDisableCloaking',
'codexModelLevelCooling',
'codexStreamBootstrapBuffering',
'codexStreamBootstrapTimeout',
'codexOptimizeMultiAgentV2',
'codexOrphanDelegationCompatibility',
'codexResponseSteering',
'antigravityConnectionPoolEnabled',
'antigravityConnectionPoolIdleTimeout',
'antigravityConnectionPoolMaxIdleConnsPerHost',
'xaiInjectXSearch',
'codexLiveMediaRelayEnabled',
'codexLiveMediaRelayMaxSessions',
'codexLiveMediaRelayDisablePrivateRemoteIPs',
'codexLiveMediaRelayPublicIP',
'codexLiveMediaRelayUDPPortMin',
'codexLiveMediaRelayUDPPortMax',
'codexLiveMediaRelayICEServers',
];
function resolveKey(root: unknown, path: string): unknown {
return path.split('.').reduce<unknown>((node, key) => {
if (node && typeof node === 'object') return (node as Record<string, unknown>)[key];
return undefined;
}, root);
}
describe('added configuration field localization', () => {
for (const locale of ['en', 'zh-CN', 'zh-TW', 'ru']) {
test(`${locale} includes searchable labels, help, and accessible ICE actions`, async () => {
const messages: unknown = await Bun.file(`src/i18n/locales/${locale}.json`).json();
for (const fieldId of addedFieldIds) {
const entry = CONFIG_FIELD_SEARCH_INDEX.find((item) => item.fieldId === fieldId);
expect(entry).toBeDefined();
expect(entry?.labelKey).toBe(`config_management.visual.additions.${fieldId}.label`);
expect(entry?.hintKey).toBe(`config_management.visual.additions.${fieldId}.hint`);
expect(resolveKey(messages, entry!.labelKey)).toBeString();
expect(resolveKey(messages, entry!.hintKey!)).toBeString();
}
for (const key of [
'oauthTitle',
'oauthHint',
'claudeTitle',
'codexTitle',
'antigravityTitle',
'xaiTitle',
'liveRelayTitle',
'iceAdd',
'iceRemove',
'iceURLs',
'iceUsername',
'iceCredential',
'iceServer',
]) {
const text = resolveKey(messages, `config_management.visual.additions.${key}`);
expect(text).toBeString();
expect(String(text).trim().length).toBeGreaterThan(0);
}
});
}
});