feat: 重构 Skill 管理与编辑工作台
- 统一列表、分类、新建与详情页的产品交互 - 提供 Markdown 实时编辑、源码与脚本资源工作台 - 实现能力自动保存、导入导出及完整状态反馈
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
buildInitialSkillDraft,
|
||||
createSkillCanonicalName,
|
||||
} from './skill-create';
|
||||
import { readFrontmatterScalar, splitSkillMarkdown } from './skill-markdown';
|
||||
|
||||
describe('skill creation draft', () => {
|
||||
it('creates a stable canonical name without exposing it to the form', () => {
|
||||
expect(createSkillCanonicalName('Research Assistant', 'abc123')).toBe(
|
||||
'research-assistant-abc123',
|
||||
);
|
||||
expect(createSkillCanonicalName('研究助手', 'abc123')).toBe('skill-abc123');
|
||||
});
|
||||
|
||||
it('builds a valid initial SKILL.md package', () => {
|
||||
const skill = buildInitialSkillDraft({
|
||||
categoryId: 8,
|
||||
displayName: '研究助手',
|
||||
visibilityScope: 'DEPT',
|
||||
});
|
||||
const parts = splitSkillMarkdown(String(skill.skillContent));
|
||||
|
||||
expect(skill).toMatchObject({
|
||||
categoryId: 8,
|
||||
description: '研究助手',
|
||||
displayName: '研究助手',
|
||||
enabled: true,
|
||||
publishStatus: 'DRAFT',
|
||||
visibilityScope: 'DEPT',
|
||||
});
|
||||
expect(skill.name).toMatch(/^skill-[a-z0-9]{10}$/);
|
||||
expect(readFrontmatterScalar(parts.frontmatter, 'name')).toBe(skill.name);
|
||||
expect(readFrontmatterScalar(parts.frontmatter, 'description')).toBe(
|
||||
'研究助手',
|
||||
);
|
||||
expect(parts.body).toContain('# Instructions');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user