refactor(data): 收口关系表运行时数据源
Some checks failed
Deploy Production / Build, push, deploy, verify (push) Has been cancelled
Some checks failed
Deploy Production / Build, push, deploy, verify (push) Has been cancelled
- 移除已迁移业务 AppData 运行时 fallback,改走领域 API 和关系表快读 - 补齐需求产品负责人、版本计划任务 JSON 和成员 username 回填迁移 - 统一治理字典入口,并补充 AI provider、数据源契约和领域服务测试 Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import test from 'node:test';
|
||||
|
||||
const testCaseStore = () => readFileSync(join(process.cwd(), 'stores/useTestCaseStore.ts'), 'utf8');
|
||||
const bugStore = () => readFileSync(join(process.cwd(), 'stores/useBugStore.ts'), 'utf8');
|
||||
const testCaseTab = () => readFileSync(join(process.cwd(), 'components/test-case/TestCaseTab.tsx'), 'utf8');
|
||||
const bugTab = () => readFileSync(join(process.cwd(), 'components/bug/BugTab.tsx'), 'utf8');
|
||||
|
||||
function storeMethodBody(text: string, name: string) {
|
||||
const implementationStart = text.indexOf('export const');
|
||||
@@ -30,8 +32,11 @@ function storeMethodBody(text: string, name: string) {
|
||||
|
||||
test('test case store uses domain APIs for version-scoped writes', () => {
|
||||
const text = testCaseStore();
|
||||
const fetchTestCases = storeMethodBody(text, 'fetchTestCases');
|
||||
|
||||
assert.match(text, /from '@\/lib\/domain-api'/);
|
||||
assert.match(fetchTestCases, /listTestCasesByVersionId\(options\.versionId\)/);
|
||||
assert.match(fetchTestCases, /!options\?\.versionId && !options\?\.force/);
|
||||
assert.match(storeMethodBody(text, 'createTestCase'), /createTestCaseByVersionId\(tc\.versionId,/);
|
||||
assert.match(storeMethodBody(text, 'createTestCases'), /createTestCasesByVersionId\(created\[0\]\.versionId,/);
|
||||
assert.match(storeMethodBody(text, 'updateTestCase'), /updateTestCaseByVersionId\(versionId, id,/);
|
||||
@@ -42,8 +47,11 @@ test('test case store uses domain APIs for version-scoped writes', () => {
|
||||
|
||||
test('bug store uses domain APIs for version-scoped writes', () => {
|
||||
const text = bugStore();
|
||||
const fetchBugs = storeMethodBody(text, 'fetchBugs');
|
||||
|
||||
assert.match(text, /from '@\/lib\/domain-api'/);
|
||||
assert.match(fetchBugs, /listBugsByVersionId\(options\.versionId\)/);
|
||||
assert.match(fetchBugs, /!options\?\.versionId && !options\?\.force/);
|
||||
assert.match(storeMethodBody(text, 'createBug'), /createBugByVersionId\(bug\.versionId,/);
|
||||
assert.match(storeMethodBody(text, 'updateBug'), /updateBugByVersionId\(versionId, id,/);
|
||||
assert.match(storeMethodBody(text, 'changeStatus'), /updateBugStatusByVersionId\(bug\.versionId,/);
|
||||
@@ -51,3 +59,32 @@ test('bug store uses domain APIs for version-scoped writes', () => {
|
||||
assert.doesNotMatch(storeMethodBody(text, 'createBug'), /saveServerData\('bugs'/);
|
||||
assert.doesNotMatch(storeMethodBody(text, 'updateBug'), /saveServerData\('bugs'/);
|
||||
});
|
||||
|
||||
test('workspace test case and bug drawers load version-scoped relation data', () => {
|
||||
const page = readFileSync(join(process.cwd(), 'app/workspace/page.tsx'), 'utf8');
|
||||
|
||||
assert.match(page, /fetchTestCases\(\{ versionId: item\.versionId \}\)/);
|
||||
assert.match(page, /fetchBugs\(\{ versionId: item\.versionId \}\)/);
|
||||
assert.doesNotMatch(page, /item\.type === 'testCase' && !testCasesLoaded/);
|
||||
assert.doesNotMatch(page, /item\.type === 'bug' && !bugsLoaded/);
|
||||
assert.doesNotMatch(page, /pendingLoads\.push\(fetchTestCases\(\)\);/);
|
||||
assert.doesNotMatch(page, /pendingLoads\.push\(fetchBugs\(\)\);/);
|
||||
});
|
||||
|
||||
test('test case tab fallback fetches current version relation partitions', () => {
|
||||
const text = testCaseTab();
|
||||
|
||||
assert.match(text, /fetchTestCases\(\{ versionId \}\)/);
|
||||
assert.match(text, /fetchBugs\(\{ versionId \}\)/);
|
||||
assert.doesNotMatch(text, /if \(!scopedVersionCases\) fetchTestCases\(\);/);
|
||||
assert.doesNotMatch(text, /if \(!scopedVersionBugs\) fetchBugs\(\);/);
|
||||
});
|
||||
|
||||
test('bug tab fallback fetches current version relation partitions', () => {
|
||||
const text = bugTab();
|
||||
|
||||
assert.match(text, /fetchBugs\(\{ versionId \}\)/);
|
||||
assert.match(text, /fetchTestCases\(\{ versionId \}\)/);
|
||||
assert.doesNotMatch(text, /if \(!scopedVersionBugs\) fetchBugs\(\);/);
|
||||
assert.doesNotMatch(text, /if \(!versionTestCases\) fetchTestCases\(\);/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user