feat(平台): 补齐服务端持久化和AI拆解契约

This commit is contained in:
Script Generator
2026-06-25 15:21:32 +08:00
parent 5723356d08
commit 5adc7759ad
73 changed files with 5599 additions and 368 deletions

View File

@@ -0,0 +1,38 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
DEFAULT_TEST_CATEGORY_ID,
PRESET_CATEGORIES,
findCategoryByCode,
getDefaultCategoryByGroup,
normalizeTaskCategories,
resolveCategoryIdFromCode,
} from './task-category';
test('preset categories include stable codes and testing group', () => {
assert.ok(PRESET_CATEGORIES.some((c) => c.code === 'test_functional' && c.group === 'testing'));
assert.ok(PRESET_CATEGORIES.every((c) => c.code.length > 0));
});
test('normalizes legacy categories without code', () => {
const normalized = normalizeTaskCategories([
{ id: 'cat-1', name: '前端开发', group: 'development', sortOrder: 1, isSystem: true },
]);
assert.equal(normalized[0].code, 'frontend_development');
});
test('resolves category id from stable code', () => {
const id = resolveCategoryIdFromCode(PRESET_CATEGORIES, 'test_functional', 'testing');
assert.equal(id, DEFAULT_TEST_CATEGORY_ID);
});
test('falls back to default group category for unknown code', () => {
const category = getDefaultCategoryByGroup(PRESET_CATEGORIES, 'testing');
assert.equal(resolveCategoryIdFromCode(PRESET_CATEGORIES, 'unknown_code', 'testing'), category.id);
});
test('finds category by code', () => {
assert.equal(findCategoryByCode(PRESET_CATEGORIES, 'backend_api')?.name, '后端接口');
});