MVP底座②:四域十八对象声明 —— 流转归项目,沉淀归客户/情报/供应商
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 四域十八对象 —— 声明即物化的输入。守三件事:数量与域别齐、主键齐、按名可取。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { MVP_OBJECTS, declarationsFor } from '../seed-mvp-data.ts';
|
||||
|
||||
describe('MVP_OBJECTS', () => {
|
||||
it('四域十八对象,不多不少 —— 定价审批表载体是审批流,不入台账', () => {
|
||||
expect(MVP_OBJECTS).toHaveLength(18);
|
||||
const count = (domain: string) => MVP_OBJECTS.filter((o) => o.domain === domain).length;
|
||||
expect(count('project')).toBe(12);
|
||||
expect(count('customer')).toBe(1);
|
||||
expect(count('intel')).toBe(3);
|
||||
expect(count('supplier')).toBe(2);
|
||||
});
|
||||
|
||||
it('每个对象至少一个主键字段 —— 只增不破坏靠主键立身', () => {
|
||||
for (const o of MVP_OBJECTS) {
|
||||
expect(o.fields.some((f) => f.primaryKey), `${o.domain}.${o.object}`).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('declarationsFor 按名取子集,名不存在即抛', () => {
|
||||
expect(declarationsFor(['project.intake_record', 'intel.history_price'])).toHaveLength(2);
|
||||
expect(() => declarationsFor(['project.nope'])).toThrow('未知对象');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user