46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
buildQuickTaskPrompt,
|
|
buildQuickTaskUserMessage,
|
|
getQuickTaskTriggerNames,
|
|
} from '@/lib/quick-task-prompt';
|
|
|
|
describe('quick task prompt builder', () => {
|
|
it('builds a single capability-pack trigger', () => {
|
|
expect(buildQuickTaskPrompt({
|
|
name: '写报告',
|
|
skills: [{ id: 'docx', name: 'docx' }],
|
|
})).toBe('使用docx skill');
|
|
});
|
|
|
|
it('builds multiple capability-pack triggers and removes duplicates', () => {
|
|
expect(buildQuickTaskPrompt({
|
|
name: '文档处理',
|
|
skills: [
|
|
{ id: 'docx', name: 'docx' },
|
|
{ id: 'DOCX', name: 'DOCX' },
|
|
{ id: 'pdf', name: 'pdf' },
|
|
],
|
|
})).toBe('使用docx skill 使用pdf skill');
|
|
});
|
|
|
|
it('falls back to the task name when no capability pack exists', () => {
|
|
expect(getQuickTaskTriggerNames({ name: '内容策划', skills: [] })).toEqual(['内容策划']);
|
|
expect(buildQuickTaskPrompt({ name: '内容策划', skills: [] })).toBe('使用内容策划 skill');
|
|
});
|
|
|
|
it('combines trigger prompt and user task content', () => {
|
|
expect(buildQuickTaskUserMessage({
|
|
name: '写PPT',
|
|
skills: [{ id: 'pptx', name: '炫酷ppt' }],
|
|
}, '帮我做一份亚马逊丛林讲解 PPT')).toBe('使用炫酷ppt skill 帮我做一份亚马逊丛林讲解 PPT');
|
|
});
|
|
|
|
it('keeps empty task content out of the final message', () => {
|
|
expect(buildQuickTaskUserMessage({
|
|
name: '写Word',
|
|
skills: [{ id: 'docx', name: 'word' }],
|
|
}, ' ')).toBe('使用word skill');
|
|
});
|
|
});
|