fix(ai): 收紧AI任务类型入库规则

This commit is contained in:
Script Generator
2026-07-02 18:19:34 +08:00
parent a39dde3824
commit 68b768788b
10 changed files with 90 additions and 22 deletions

View File

@@ -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');
});