41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
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');
|
|
});
|
|
});
|