fix(ai): 收紧AI任务类型入库规则
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
getDefaultCategoryByGroup,
|
||||
ensureTaskCategoryByName,
|
||||
normalizeTaskCategories,
|
||||
resolveAiTaskCategoryByName,
|
||||
resolveCategoryIdFromCode,
|
||||
} from './task-category';
|
||||
|
||||
@@ -68,3 +69,25 @@ test('creates non-system category for missing AI task type name', () => {
|
||||
assert.ok(result.category.id.startsWith('cat-ai-'));
|
||||
assert.equal(result.categories.at(-1)?.id, result.category.id);
|
||||
});
|
||||
|
||||
test('does not create document-specific testing type when auto creation is disabled', () => {
|
||||
const result = resolveAiTaskCategoryByName(PRESET_CATEGORIES, '排行榜测试', 'testing', {
|
||||
allowCreate: false,
|
||||
fallbackCode: 'test_data_consistency',
|
||||
});
|
||||
|
||||
assert.equal(result.created, false);
|
||||
assert.equal(result.category.code, 'test_data_consistency');
|
||||
assert.equal(result.categories.length, PRESET_CATEGORIES.length);
|
||||
});
|
||||
|
||||
test('keeps testing fallback within the testing category group', () => {
|
||||
const result = resolveAiTaskCategoryByName(PRESET_CATEGORIES, '排行榜测试', 'testing', {
|
||||
allowCreate: false,
|
||||
fallbackCode: 'frontend_development',
|
||||
});
|
||||
|
||||
assert.equal(result.created, false);
|
||||
assert.equal(result.category.id, DEFAULT_TEST_CATEGORY_ID);
|
||||
assert.equal(result.category.group, 'testing');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user