fix(ai): 自动追加AI任务类型
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
PRESET_CATEGORIES,
|
||||
findCategoryByCode,
|
||||
getDefaultCategoryByGroup,
|
||||
ensureTaskCategoryByName,
|
||||
normalizeTaskCategories,
|
||||
resolveCategoryIdFromCode,
|
||||
} from './task-category';
|
||||
@@ -47,3 +48,23 @@ test('falls back to default group category for unknown code', () => {
|
||||
test('finds category by code', () => {
|
||||
assert.equal(findCategoryByCode(PRESET_CATEGORIES, 'backend_api')?.name, '后端接口');
|
||||
});
|
||||
|
||||
test('returns existing category when AI task type name already exists in same group', () => {
|
||||
const result = ensureTaskCategoryByName(PRESET_CATEGORIES, ' 前端开发 ', 'development');
|
||||
|
||||
assert.equal(result.created, false);
|
||||
assert.equal(result.category.id, 'cat-1');
|
||||
assert.equal(result.categories.length, PRESET_CATEGORIES.length);
|
||||
});
|
||||
|
||||
test('creates non-system category for missing AI task type name', () => {
|
||||
const result = ensureTaskCategoryByName(PRESET_CATEGORIES, '人员名片交互', 'development');
|
||||
|
||||
assert.equal(result.created, true);
|
||||
assert.equal(result.category.name, '人员名片交互');
|
||||
assert.equal(result.category.group, 'development');
|
||||
assert.equal(result.category.isSystem, false);
|
||||
assert.equal(result.category.code, '人员名片交互');
|
||||
assert.ok(result.category.id.startsWith('cat-ai-'));
|
||||
assert.equal(result.categories.at(-1)?.id, result.category.id);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user