feat(v2.2): 完成高频读取热路径

This commit is contained in:
Script Generator
2026-07-03 11:53:25 +08:00
parent 5a90923031
commit 70460c3273
28 changed files with 3042 additions and 121 deletions

View File

@@ -0,0 +1,38 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { selectWorkspaceCollections } from './workspace-v22-source';
const appData = {
plans: [{ id: 'app-plan' }] as any[],
devTasks: [{ id: 'app-dev' }] as any[],
testCases: [{ id: 'app-test' }] as any[],
bugs: [{ id: 'app-bug' }] as any[],
};
test('selectWorkspaceCollections prefers successfully loaded V2.2 data even when it is empty', () => {
const selected = selectWorkspaceCollections({
v22Loaded: true,
v22Failed: false,
v22Data: { versionPlans: [], devTasks: [], testCases: [], bugs: [] },
appData,
});
assert.deepEqual(selected, { versionPlans: [], devTasks: [], testCases: [], bugs: [] });
});
test('selectWorkspaceCollections falls back to AppData only when V2.2 is unavailable', () => {
const selected = selectWorkspaceCollections({
v22Loaded: false,
v22Failed: true,
v22Data: null,
appData,
});
assert.deepEqual(selected, {
versionPlans: appData.plans,
devTasks: appData.devTasks,
testCases: appData.testCases,
bugs: appData.bugs,
});
});