skillhub/plugins/dsh/test/catalog-error.test.ts
XiaoSeS 3560679793
Some checks failed
Deploy Docs / build (push) Has been cancelled
Security / Dependency Review (push) Has been cancelled
Security / CodeQL (java-kotlin) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(dsh): add native SkillHub plugin for DeepSeek Harness (#956)
Add the native SkillHub plugin for DeepSeek Harness with a scoped skill center, conversation search/install tools, exact-version installation and protected lifecycle management. Prepare the independently versioned 0.1.0 npm candidate with an empty default Registry and documented compatibility limits.

Keep formal specifications and executable regression tests; remove archived development screenshots and runtime reports from the final tree. Review fixes cover independent scopes, installed references, pre-staging recovery and idempotent discovery.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-16 19:22:26 +08:00

37 lines
1.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, test } from 'bun:test';
import { catalogErrorMessage } from '../src/client/catalog-error.js';
test.each([
['ANONYMOUS_DENIED', '不允许匿名读取'],
['RATE_LIMITED', '限流'],
['REGISTRY_UNAVAILABLE', '服务暂时不可用'],
['NETWORK_ERROR', '网络'],
['INVALID_SOURCE', '地址无效'],
['NOT_FOUND', '未找到'],
['CANCELLED', '已取消'],
['INVALID_RESPONSE', '数据格式'],
['RESPONSE_TOO_LARGE', '读取限制'],
])('catalog explains %s without displaying upstream diagnostics', (reason, expected) => {
const message = catalogErrorMessage({ code: 'skillhub/registry-error', details: { reason, body: 'private diagnostic' } });
expect(message).toContain(expected);
expect(message).not.toContain('private diagnostic');
});
test('unknown or malformed errors use safe fallback messages', () => {
for (const details of [undefined, null, 'private diagnostic', { reason: 'private diagnostic' }, { reason: {} }]) {
expect(catalogErrorMessage({ code: 'skillhub/registry-error', details }))
.toBe('无法读取 SkillHub,请检查来源地址或稍后重试。');
}
expect(catalogErrorMessage({ code: 'private diagnostic' })).toBe('请求失败,请稍后重试。');
expect(catalogErrorMessage({ code: 'skillhub/context-stale' })).toContain('来源已变化');
expect(catalogErrorMessage({ code: 'skillhub/source-not-configured' })).toContain('设置 SkillHub 地址');
});
test('rate limit hints only interpolate a validated wait duration', () => {
expect(catalogErrorMessage({ code: 'skillhub/registry-error', details: { reason: 'RATE_LIMITED', retryAfterSeconds: 30 } }))
.toContain('至少 30 秒后手动重试');
for (const retryAfterSeconds of [-1, 0, 1.5, Infinity, 'private diagnostic']) {
expect(catalogErrorMessage({ code: 'skillhub/registry-error', details: { reason: 'RATE_LIMITED', retryAfterSeconds } }))
.toBe('SkillHub 来源暂时限流,请稍后重试。');
}
});