@transitrix/diagrams 1.8.6 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fgca/index.js +10 -10
- package/dist/fgca/layout.js +1 -1
- package/dist/fgca/nodeTypes.js +4 -4
- package/dist/index.js +33 -33
- package/package.json +8 -2
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -55
- package/dist/__tests__/node-size-presets.test.d.ts +0 -1
- package/dist/__tests__/node-size-presets.test.js +0 -30
- package/dist/__tests__/scope.test.d.ts +0 -1
- package/dist/__tests__/scope.test.js +0 -23
- package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
- package/dist/__tests__/yaml-normalize.test.js +0 -148
- package/dist/activities/__tests__/cpm.test.d.ts +0 -1
- package/dist/activities/__tests__/cpm.test.js +0 -146
- package/dist/activities/__tests__/gantt.test.d.ts +0 -1
- package/dist/activities/__tests__/gantt.test.js +0 -263
- package/dist/activities/__tests__/layout.test.d.ts +0 -1
- package/dist/activities/__tests__/layout.test.js +0 -98
- package/dist/activities/__tests__/validate.test.d.ts +0 -1
- package/dist/activities/__tests__/validate.test.js +0 -397
- package/dist/activity-card/__tests__/example.test.d.ts +0 -1
- package/dist/activity-card/__tests__/example.test.js +0 -73
- package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
- package/dist/activity-card/__tests__/layout.test.js +0 -141
- package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
- package/dist/activity-card/__tests__/resolver.test.js +0 -325
- package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
- package/dist/activity-card/__tests__/validate.test.js +0 -149
- package/dist/actor/__tests__/validate.test.d.ts +0 -1
- package/dist/actor/__tests__/validate.test.js +0 -95
- package/dist/applications/__tests__/validate.test.d.ts +0 -1
- package/dist/applications/__tests__/validate.test.js +0 -223
- package/dist/assertion/__tests__/example.test.d.ts +0 -1
- package/dist/assertion/__tests__/example.test.js +0 -32
- package/dist/assertion/__tests__/validate.test.d.ts +0 -1
- package/dist/assertion/__tests__/validate.test.js +0 -130
- package/dist/blocks/__tests__/layout.test.d.ts +0 -1
- package/dist/blocks/__tests__/layout.test.js +0 -153
- package/dist/blocks/__tests__/validate.test.d.ts +0 -1
- package/dist/blocks/__tests__/validate.test.js +0 -235
- package/dist/business-service/__tests__/validate.test.d.ts +0 -1
- package/dist/business-service/__tests__/validate.test.js +0 -135
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
- package/dist/capability-map/__tests__/address.test.d.ts +0 -1
- package/dist/capability-map/__tests__/address.test.js +0 -49
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
- package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/validate.test.js +0 -212
- package/dist/change/__tests__/validate.test.d.ts +0 -1
- package/dist/change/__tests__/validate.test.js +0 -79
- package/dist/codex/__tests__/example.test.d.ts +0 -1
- package/dist/codex/__tests__/example.test.js +0 -33
- package/dist/codex/__tests__/validate.test.d.ts +0 -1
- package/dist/codex/__tests__/validate.test.js +0 -68
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
- package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
- package/dist/compliance/__tests__/classify.test.d.ts +0 -1
- package/dist/compliance/__tests__/classify.test.js +0 -58
- package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
- package/dist/compliance/__tests__/confidence.test.js +0 -78
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
- package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
- package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
- package/dist/compliance/__tests__/example.test.d.ts +0 -1
- package/dist/compliance/__tests__/example.test.js +0 -51
- package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
- package/dist/compliance/__tests__/gap-report.test.js +0 -113
- package/dist/compliance/__tests__/html.test.d.ts +0 -1
- package/dist/compliance/__tests__/html.test.js +0 -122
- package/dist/compliance/__tests__/impact.test.d.ts +0 -1
- package/dist/compliance/__tests__/impact.test.js +0 -913
- package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
- package/dist/compliance/__tests__/markdown.test.js +0 -85
- package/dist/compliance/__tests__/trace.test.d.ts +0 -1
- package/dist/compliance/__tests__/trace.test.js +0 -144
- package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
- package/dist/compliance/__tests__/view-resolution.test.js +0 -59
- package/dist/compliance/__tests__/views.test.d.ts +0 -1
- package/dist/compliance/__tests__/views.test.js +0 -59
- package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/build.test.js +0 -183
- package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/example.test.js +0 -49
- package/dist/confidence/__tests__/score.test.d.ts +0 -1
- package/dist/confidence/__tests__/score.test.js +0 -188
- package/dist/constraint/__tests__/example.test.d.ts +0 -1
- package/dist/constraint/__tests__/example.test.js +0 -14
- package/dist/constraint/__tests__/validate.test.d.ts +0 -1
- package/dist/constraint/__tests__/validate.test.js +0 -58
- package/dist/factor/__tests__/validate.test.d.ts +0 -1
- package/dist/factor/__tests__/validate.test.js +0 -112
- package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
- package/dist/fgca/__tests__/chain-table.test.js +0 -158
- package/dist/fgca/__tests__/layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/layout.test.js +0 -140
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
- package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/preview-layout.test.js +0 -106
- package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
- package/dist/fgca/__tests__/resolver.test.js +0 -185
- package/dist/fgca/__tests__/validate.test.d.ts +0 -1
- package/dist/fgca/__tests__/validate.test.js +0 -125
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
- package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
- package/dist/goals/__tests__/layout.test.d.ts +0 -1
- package/dist/goals/__tests__/layout.test.js +0 -153
- package/dist/goals/__tests__/mutations.test.d.ts +0 -1
- package/dist/goals/__tests__/mutations.test.js +0 -134
- package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/goals/__tests__/parse-canonical.test.js +0 -131
- package/dist/goals/__tests__/validate.test.d.ts +0 -1
- package/dist/goals/__tests__/validate.test.js +0 -183
- package/dist/integration/__tests__/validate.test.d.ts +0 -1
- package/dist/integration/__tests__/validate.test.js +0 -169
- package/dist/location/__tests__/validate.test.d.ts +0 -1
- package/dist/location/__tests__/validate.test.js +0 -107
- package/dist/node/__tests__/validate.test.d.ts +0 -1
- package/dist/node/__tests__/validate.test.js +0 -100
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
- package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/layout.test.js +0 -196
- package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/validate.test.js +0 -280
- package/dist/process-map/__tests__/validate.test.d.ts +0 -1
- package/dist/process-map/__tests__/validate.test.js +0 -199
- package/dist/products/__tests__/validate.test.d.ts +0 -1
- package/dist/products/__tests__/validate.test.js +0 -210
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
- package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
- package/dist/requirement/__tests__/example.test.d.ts +0 -1
- package/dist/requirement/__tests__/example.test.js +0 -21
- package/dist/requirement/__tests__/validate.test.d.ts +0 -1
- package/dist/requirement/__tests__/validate.test.js +0 -80
- package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
- package/dist/scenarios/__tests__/validate.test.js +0 -183
- package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
- package/dist/stakeholder/__tests__/validate.test.js +0 -88
- package/dist/target-state/__tests__/validate.test.d.ts +0 -1
- package/dist/target-state/__tests__/validate.test.js +0 -78
- package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
- package/dist/technology-service/__tests__/validate.test.js +0 -121
- package/dist/theme/__tests__/tokens.test.d.ts +0 -1
- package/dist/theme/__tests__/tokens.test.js +0 -159
- package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
- package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
- package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
- package/dist/webview/__tests__/entry-notations.test.js +0 -62
- package/dist/webview/__tests__/entry.test.d.ts +0 -1
- package/dist/webview/__tests__/entry.test.js +0 -56
- package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
- package/dist/webview/__tests__/render-activities.test.js +0 -91
- package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
- package/dist/webview/__tests__/render-blocks.test.js +0 -175
- package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
- package/dist/webview/__tests__/render-goals.test.js +0 -120
- package/dist/webview/__tests__/render-process.test.d.ts +0 -1
- package/dist/webview/__tests__/render-process.test.js +0 -463
- package/dist/webview/__tests__/render-util.test.d.ts +0 -1
- package/dist/webview/__tests__/render-util.test.js +0 -54
- package/src/__tests__/edge-path.test.ts +0 -67
- package/src/__tests__/node-size-presets.test.ts +0 -50
- package/src/__tests__/scope.test.ts +0 -27
- package/src/__tests__/yaml-normalize.test.ts +0 -158
- package/src/activities/__tests__/cpm.test.ts +0 -164
- package/src/activities/__tests__/gantt.test.ts +0 -290
- package/src/activities/__tests__/layout.test.ts +0 -112
- package/src/activities/__tests__/validate.test.ts +0 -446
- package/src/activity-card/__tests__/example.test.ts +0 -83
- package/src/activity-card/__tests__/layout.test.ts +0 -162
- package/src/activity-card/__tests__/resolver.test.ts +0 -357
- package/src/activity-card/__tests__/validate.test.ts +0 -167
- package/src/actor/__tests__/validate.test.ts +0 -114
- package/src/applications/__tests__/validate.test.ts +0 -256
- package/src/assertion/__tests__/example.test.ts +0 -37
- package/src/assertion/__tests__/validate.test.ts +0 -142
- package/src/blocks/__tests__/layout.test.ts +0 -169
- package/src/blocks/__tests__/validate.test.ts +0 -260
- package/src/business-service/__tests__/validate.test.ts +0 -160
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
- package/src/capability-map/__tests__/address.test.ts +0 -59
- package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
- package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
- package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
- package/src/capability-map/__tests__/validate.test.ts +0 -238
- package/src/change/__tests__/validate.test.ts +0 -97
- package/src/codex/__tests__/example.test.ts +0 -40
- package/src/codex/__tests__/validate.test.ts +0 -84
- package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
- package/src/compliance/__tests__/classify.test.ts +0 -64
- package/src/compliance/__tests__/confidence.test.ts +0 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
- package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
- package/src/compliance/__tests__/example.test.ts +0 -57
- package/src/compliance/__tests__/gap-report.test.ts +0 -129
- package/src/compliance/__tests__/html.test.ts +0 -142
- package/src/compliance/__tests__/impact.test.ts +0 -1060
- package/src/compliance/__tests__/markdown.test.ts +0 -95
- package/src/compliance/__tests__/trace.test.ts +0 -157
- package/src/compliance/__tests__/view-resolution.test.ts +0 -80
- package/src/compliance/__tests__/views.test.ts +0 -64
- package/src/compliance-matrix/__tests__/build.test.ts +0 -200
- package/src/compliance-matrix/__tests__/example.test.ts +0 -57
- package/src/confidence/__tests__/score.test.ts +0 -254
- package/src/constraint/__tests__/example.test.ts +0 -19
- package/src/constraint/__tests__/validate.test.ts +0 -68
- package/src/factor/__tests__/validate.test.ts +0 -133
- package/src/fgca/__tests__/chain-table.test.ts +0 -172
- package/src/fgca/__tests__/layout.test.ts +0 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
- package/src/fgca/__tests__/preview-layout.test.ts +0 -124
- package/src/fgca/__tests__/resolver.test.ts +0 -209
- package/src/fgca/__tests__/validate.test.ts +0 -142
- package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
- package/src/goals/__tests__/layout.test.ts +0 -175
- package/src/goals/__tests__/mutations.test.ts +0 -153
- package/src/goals/__tests__/parse-canonical.test.ts +0 -147
- package/src/goals/__tests__/validate.test.ts +0 -202
- package/src/integration/__tests__/validate.test.ts +0 -203
- package/src/location/__tests__/validate.test.ts +0 -127
- package/src/node/__tests__/validate.test.ts +0 -118
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
- package/src/process-blueprint/__tests__/layout.test.ts +0 -240
- package/src/process-blueprint/__tests__/validate.test.ts +0 -310
- package/src/process-map/__tests__/validate.test.ts +0 -223
- package/src/products/__tests__/validate.test.ts +0 -239
- package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
- package/src/requirement/__tests__/example.test.ts +0 -24
- package/src/requirement/__tests__/validate.test.ts +0 -96
- package/src/scenarios/__tests__/validate.test.ts +0 -209
- package/src/stakeholder/__tests__/validate.test.ts +0 -105
- package/src/target-state/__tests__/validate.test.ts +0 -95
- package/src/technology-service/__tests__/validate.test.ts +0 -143
- package/src/theme/__tests__/tokens.test.ts +0 -185
- package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
- package/src/webview/__tests__/entry-notations.test.ts +0 -77
- package/src/webview/__tests__/entry.test.ts +0 -64
- package/src/webview/__tests__/render-activities.test.ts +0 -100
- package/src/webview/__tests__/render-blocks.test.ts +0 -206
- package/src/webview/__tests__/render-goals.test.ts +0 -128
- package/src/webview/__tests__/render-process.test.ts +0 -538
- package/src/webview/__tests__/render-util.test.ts +0 -66
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { layoutGoalTree } from '../layout.js';
|
|
3
|
-
const TREE = {
|
|
4
|
-
goal_types: [
|
|
5
|
-
{ name: 'Strategy', level: 0 },
|
|
6
|
-
{ name: 'Business Goal', level: 1 },
|
|
7
|
-
{ name: 'Project', level: 2 },
|
|
8
|
-
],
|
|
9
|
-
goals: [
|
|
10
|
-
{ id: 1, name: 'North Star', type: 'Strategy', level: 0, parent_id: 0 },
|
|
11
|
-
{ id: 2, name: 'EU Expansion', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
12
|
-
{ id: 3, name: 'Berlin Office', type: 'Project', level: 2, parent_id: 2 },
|
|
13
|
-
{ id: 4, name: 'London Office', type: 'Project', level: 2, parent_id: 2 },
|
|
14
|
-
],
|
|
15
|
-
};
|
|
16
|
-
describe('layoutGoalTree', () => {
|
|
17
|
-
it('returns nodes for all goals', () => {
|
|
18
|
-
const layout = layoutGoalTree(TREE);
|
|
19
|
-
expect(layout.nodes).toHaveLength(4);
|
|
20
|
-
});
|
|
21
|
-
it('returns edges for parent-child pairs', () => {
|
|
22
|
-
const layout = layoutGoalTree(TREE);
|
|
23
|
-
expect(layout.edges).toHaveLength(3); // 1→2, 2→3, 2→4
|
|
24
|
-
});
|
|
25
|
-
it('levels map to increasing x positions', () => {
|
|
26
|
-
const layout = layoutGoalTree(TREE);
|
|
27
|
-
const byId = new Map(layout.nodes.map(n => [n.id, n]));
|
|
28
|
-
expect(byId.get(1).x).toBeLessThan(byId.get(2).x);
|
|
29
|
-
expect(byId.get(2).x).toBeLessThan(byId.get(3).x);
|
|
30
|
-
});
|
|
31
|
-
it('siblings at same level have different y positions', () => {
|
|
32
|
-
const layout = layoutGoalTree(TREE);
|
|
33
|
-
const byId = new Map(layout.nodes.map(n => [n.id, n]));
|
|
34
|
-
expect(byId.get(3).y).not.toBe(byId.get(4).y);
|
|
35
|
-
});
|
|
36
|
-
it('returns non-zero bounds for non-empty tree', () => {
|
|
37
|
-
const layout = layoutGoalTree(TREE);
|
|
38
|
-
expect(layout.bounds.width).toBeGreaterThan(0);
|
|
39
|
-
expect(layout.bounds.height).toBeGreaterThan(0);
|
|
40
|
-
});
|
|
41
|
-
it('returns empty layout for empty goals', () => {
|
|
42
|
-
const layout = layoutGoalTree({ goal_types: [], goals: [] });
|
|
43
|
-
expect(layout.nodes).toHaveLength(0);
|
|
44
|
-
expect(layout.edges).toHaveLength(0);
|
|
45
|
-
});
|
|
46
|
-
it('nodes have default 250×80 size', () => {
|
|
47
|
-
const layout = layoutGoalTree(TREE);
|
|
48
|
-
expect(layout.nodes[0].width).toBe(250);
|
|
49
|
-
expect(layout.nodes[0].height).toBe(80);
|
|
50
|
-
});
|
|
51
|
-
it('respects custom nodeWidth/nodeHeight', () => {
|
|
52
|
-
const layout = layoutGoalTree(TREE, { nodeWidth: 200, nodeHeight: 60 });
|
|
53
|
-
expect(layout.nodes[0].width).toBe(200);
|
|
54
|
-
expect(layout.nodes[0].height).toBe(60);
|
|
55
|
-
});
|
|
56
|
-
// vkgeorgia/strategy#75 — configurable spacing. The preview maps
|
|
57
|
-
// horizontalGap → rankSep and verticalGap → nodeSep.
|
|
58
|
-
it('larger rankSep widens the column step', () => {
|
|
59
|
-
const tight = layoutGoalTree(TREE, { rankSep: 80 });
|
|
60
|
-
const wide = layoutGoalTree(TREE, { rankSep: 200 });
|
|
61
|
-
const stepOf = (l) => {
|
|
62
|
-
const byId = new Map(l.nodes.map(n => [n.id, n]));
|
|
63
|
-
return byId.get(2).x - byId.get(1).x;
|
|
64
|
-
};
|
|
65
|
-
expect(stepOf(wide)).toBeGreaterThan(stepOf(tight));
|
|
66
|
-
});
|
|
67
|
-
it('larger nodeSep increases the gap between stacked siblings', () => {
|
|
68
|
-
const gapOf = (sep) => {
|
|
69
|
-
const l = layoutGoalTree(TREE, { nodeSep: sep });
|
|
70
|
-
const byId = new Map(l.nodes.map(n => [n.id, n]));
|
|
71
|
-
return Math.abs(byId.get(4).y - byId.get(3).y);
|
|
72
|
-
};
|
|
73
|
-
expect(gapOf(120)).toBeGreaterThan(gapOf(24));
|
|
74
|
-
});
|
|
75
|
-
it('each node carries original goal data', () => {
|
|
76
|
-
const layout = layoutGoalTree(TREE);
|
|
77
|
-
const node1 = layout.nodes.find(n => n.id === 1);
|
|
78
|
-
expect(node1.data.name).toBe('North Star');
|
|
79
|
-
});
|
|
80
|
-
it('viewDepth hides nodes beyond depth', () => {
|
|
81
|
-
const layout = layoutGoalTree(TREE, { viewDepth: 1 });
|
|
82
|
-
// Level 2 nodes (id 3, 4) should be hidden
|
|
83
|
-
expect(layout.nodes.every(n => n.data.level <= 1)).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
it('compresses non-contiguous levels into adjacent columns (no phantom empty columns)', () => {
|
|
86
|
-
// Legacy / non-canonical input: goal_types skip levels 1 and 3, so
|
|
87
|
-
// goals sit at levels 0, 2, 4. Column x must advance by exactly one
|
|
88
|
-
// step per used level, not per absolute level value — otherwise the
|
|
89
|
-
// skipped levels open empty columns and double the horizontal spacing.
|
|
90
|
-
const gapped = {
|
|
91
|
-
goal_types: [
|
|
92
|
-
{ name: 'Strategy', level: 0 },
|
|
93
|
-
{ name: 'Strategic Goal', level: 2 },
|
|
94
|
-
{ name: 'Project Goal', level: 4 },
|
|
95
|
-
],
|
|
96
|
-
goals: [
|
|
97
|
-
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
98
|
-
{ id: 2, name: 'Mid', type: 'Strategic Goal', level: 2, parent_id: 1 },
|
|
99
|
-
{ id: 3, name: 'Leaf', type: 'Project Goal', level: 4, parent_id: 2 },
|
|
100
|
-
],
|
|
101
|
-
};
|
|
102
|
-
const layout = layoutGoalTree(gapped);
|
|
103
|
-
const byId = new Map(layout.nodes.map(n => [n.id, n]));
|
|
104
|
-
const step = byId.get(2).x - byId.get(1).x;
|
|
105
|
-
// Root→Mid and Mid→Leaf must use the same single-column step despite
|
|
106
|
-
// the level numbers jumping by 2 each time.
|
|
107
|
-
expect(byId.get(3).x - byId.get(2).x).toBe(step);
|
|
108
|
-
// And that step is one node width + one rank separator (250 + 80).
|
|
109
|
-
expect(step).toBe(250 + 80);
|
|
110
|
-
});
|
|
111
|
-
// Pre-release blocker regression (orchestrator review 2026-05-21).
|
|
112
|
-
it('[blocker] does not stack-overflow on a self-parent cycle', () => {
|
|
113
|
-
const cyclic = {
|
|
114
|
-
goal_types: [{ name: 'X', level: 0 }],
|
|
115
|
-
goals: [{ id: 1, name: 'self-parent', type: 'X', level: 0, parent_id: 1 }],
|
|
116
|
-
};
|
|
117
|
-
// Without a visited-set inside placeSubtree, this recurses forever.
|
|
118
|
-
expect(() => layoutGoalTree(cyclic)).not.toThrow();
|
|
119
|
-
});
|
|
120
|
-
it('[blocker] does not stack-overflow on a 2-node mutual cycle', () => {
|
|
121
|
-
const cyclic = {
|
|
122
|
-
goal_types: [{ name: 'X', level: 0 }, { name: 'Y', level: 1 }],
|
|
123
|
-
goals: [
|
|
124
|
-
{ id: 1, name: 'A', type: 'X', level: 0, parent_id: 2 },
|
|
125
|
-
{ id: 2, name: 'B', type: 'Y', level: 1, parent_id: 1 },
|
|
126
|
-
],
|
|
127
|
-
};
|
|
128
|
-
expect(() => layoutGoalTree(cyclic)).not.toThrow();
|
|
129
|
-
});
|
|
130
|
-
// vkgeorgia/strategy#77 — scope filtering.
|
|
131
|
-
describe('scope', () => {
|
|
132
|
-
const ids = (l) => l.nodes.map(n => n.id).sort((a, b) => a - b);
|
|
133
|
-
it("mode 'all' matches the baseline", () => {
|
|
134
|
-
expect(ids(layoutGoalTree(TREE, { scope: { mode: 'all' } }))).toEqual(ids(layoutGoalTree(TREE)));
|
|
135
|
-
});
|
|
136
|
-
it("mode 'level' trims goals strictly above the cap", () => {
|
|
137
|
-
// TREE: id1 level0, id2 level1, id3/id4 level2.
|
|
138
|
-
const layout = layoutGoalTree(TREE, { scope: { mode: 'level', maxLevel: 1 } });
|
|
139
|
-
expect(ids(layout)).toEqual([1, 2]);
|
|
140
|
-
expect(layout.nodes.every(n => n.data.level <= 1)).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
it("mode 'root' keeps the chosen goal and its descendants", () => {
|
|
143
|
-
// root id2 → itself + children id3, id4.
|
|
144
|
-
const layout = layoutGoalTree(TREE, { scope: { mode: 'root', rootGoalId: '2' } });
|
|
145
|
-
expect(ids(layout)).toEqual([2, 3, 4]);
|
|
146
|
-
});
|
|
147
|
-
it("mode 'root' returns an empty layout when the root is absent", () => {
|
|
148
|
-
const layout = layoutGoalTree(TREE, { scope: { mode: 'root', rootGoalId: '999' } });
|
|
149
|
-
expect(layout.nodes).toHaveLength(0);
|
|
150
|
-
expect(layout.edges).toHaveLength(0);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { reparent, addChild, deleteWithDescendants, moveToBacklog, restoreFromBacklog } from '../mutations.js';
|
|
3
|
-
const TREE = {
|
|
4
|
-
goal_types: [
|
|
5
|
-
{ name: 'Strategy', level: 0 },
|
|
6
|
-
{ name: 'Business Goal', level: 1 },
|
|
7
|
-
{ name: 'Project', level: 2 },
|
|
8
|
-
],
|
|
9
|
-
goals: [
|
|
10
|
-
{ id: 1, name: 'North Star', type: 'Strategy', level: 0, parent_id: 0 },
|
|
11
|
-
{ id: 2, name: 'EU Expansion', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
12
|
-
{ id: 3, name: 'Berlin Office', type: 'Project', level: 2, parent_id: 2 },
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
describe('reparent', () => {
|
|
16
|
-
it('moves a goal to a new parent', () => {
|
|
17
|
-
const r = reparent(TREE, 3, 1);
|
|
18
|
-
expect(r.ok).toBe(true);
|
|
19
|
-
const moved = r.result.goals.find(g => g.id === 3);
|
|
20
|
-
expect(moved.parent_id).toBe(1);
|
|
21
|
-
expect(moved.level).toBe(1);
|
|
22
|
-
});
|
|
23
|
-
it('refuses to create a cycle', () => {
|
|
24
|
-
const r = reparent(TREE, 1, 3);
|
|
25
|
-
expect(r.ok).toBe(false);
|
|
26
|
-
expect(r.error?.code).toBe('MUTATION_REFUSED');
|
|
27
|
-
});
|
|
28
|
-
it('refuses self-reparent', () => {
|
|
29
|
-
expect(reparent(TREE, 1, 1).ok).toBe(false);
|
|
30
|
-
});
|
|
31
|
-
it('refuses reparent that would exceed max level', () => {
|
|
32
|
-
const r = reparent(TREE, 1, 3); // would make level 3 which exceeds max 2
|
|
33
|
-
expect(r.ok).toBe(false);
|
|
34
|
-
});
|
|
35
|
-
it('preserves immutability — original tree unchanged', () => {
|
|
36
|
-
reparent(TREE, 3, 1);
|
|
37
|
-
expect(TREE.goals.find(g => g.id === 3).parent_id).toBe(2);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('addChild', () => {
|
|
41
|
-
it('adds a child with auto-assigned id and level', () => {
|
|
42
|
-
const r = addChild(TREE, 2, { name: 'Warsaw Office', type: 'Project', level: 2, parent_id: 2 });
|
|
43
|
-
expect(r.ok).toBe(true);
|
|
44
|
-
const newGoal = r.result.goals.find(g => g.name === 'Warsaw Office');
|
|
45
|
-
expect(newGoal.id).toBeGreaterThan(3);
|
|
46
|
-
expect(newGoal.parent_id).toBe(2);
|
|
47
|
-
expect(newGoal.level).toBe(2);
|
|
48
|
-
});
|
|
49
|
-
it('adds root-level child when parentId is 0', () => {
|
|
50
|
-
const r = addChild(TREE, 0, { name: 'Second Strategy', type: 'Strategy', level: 0, parent_id: 0 });
|
|
51
|
-
expect(r.ok).toBe(true);
|
|
52
|
-
expect(r.result.goals.find(g => g.name === 'Second Strategy').level).toBe(0);
|
|
53
|
-
});
|
|
54
|
-
it('refuses when parent not found', () => {
|
|
55
|
-
const r = addChild(TREE, 99, { name: 'X', type: 'Project', level: 2, parent_id: 99 });
|
|
56
|
-
expect(r.ok).toBe(false);
|
|
57
|
-
});
|
|
58
|
-
it('preserves immutability', () => {
|
|
59
|
-
const before = TREE.goals.length;
|
|
60
|
-
addChild(TREE, 1, { name: 'New', type: 'Business Goal', level: 1, parent_id: 1 });
|
|
61
|
-
expect(TREE.goals.length).toBe(before);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe('deleteWithDescendants', () => {
|
|
65
|
-
it('deletes goal and all descendants', () => {
|
|
66
|
-
const r = deleteWithDescendants(TREE, 2);
|
|
67
|
-
expect(r.ok).toBe(true);
|
|
68
|
-
const ids = r.result.goals.map(g => g.id);
|
|
69
|
-
expect(ids).not.toContain(2);
|
|
70
|
-
expect(ids).not.toContain(3);
|
|
71
|
-
expect(ids).toContain(1);
|
|
72
|
-
});
|
|
73
|
-
it('refuses when goal not found', () => {
|
|
74
|
-
expect(deleteWithDescendants(TREE, 99).ok).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
it('preserves immutability', () => {
|
|
77
|
-
deleteWithDescendants(TREE, 2);
|
|
78
|
-
expect(TREE.goals.length).toBe(3);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe('moveToBacklog', () => {
|
|
82
|
-
it('sets parent_id to 0', () => {
|
|
83
|
-
const r = moveToBacklog(TREE, 3);
|
|
84
|
-
expect(r.ok).toBe(true);
|
|
85
|
-
expect(r.result.goals.find(g => g.id === 3).parent_id).toBe(0);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('restoreFromBacklog', () => {
|
|
89
|
-
it('reparents the goal to the new parent', () => {
|
|
90
|
-
const backlogged = moveToBacklog(TREE, 3).result;
|
|
91
|
-
const r = restoreFromBacklog(backlogged, 3, 1);
|
|
92
|
-
expect(r.ok).toBe(true);
|
|
93
|
-
expect(r.result.goals.find(g => g.id === 3).parent_id).toBe(1);
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe('reparent — descendant type relabeling and level cap', () => {
|
|
97
|
-
const DEEP = {
|
|
98
|
-
goal_types: [
|
|
99
|
-
{ name: 'Strategy', level: 0 },
|
|
100
|
-
{ name: 'Business Goal', level: 1 },
|
|
101
|
-
{ name: 'Project', level: 2 },
|
|
102
|
-
{ name: 'Task', level: 3 },
|
|
103
|
-
],
|
|
104
|
-
goals: [
|
|
105
|
-
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
106
|
-
{ id: 2, name: 'BG1', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
107
|
-
{ id: 3, name: 'Proj1', type: 'Project', level: 2, parent_id: 2 },
|
|
108
|
-
{ id: 4, name: 'Task1', type: 'Task', level: 3, parent_id: 3 },
|
|
109
|
-
],
|
|
110
|
-
};
|
|
111
|
-
it('relabels descendant types via getTypeForLevel when reparenting shifts levels', () => {
|
|
112
|
-
// Move Proj1 (id=3, level=2) directly under Root (id=1, level=0); delta = -1
|
|
113
|
-
// Task1 (child of Proj1, level=3): new level = 2, type should be 'Project'
|
|
114
|
-
const r = reparent(DEEP, 3, 1);
|
|
115
|
-
expect(r.ok).toBe(true);
|
|
116
|
-
const proj = r.result.goals.find(g => g.id === 3);
|
|
117
|
-
const task = r.result.goals.find(g => g.id === 4);
|
|
118
|
-
expect(proj.level).toBe(1);
|
|
119
|
-
expect(proj.type).toBe('Business Goal');
|
|
120
|
-
expect(task.level).toBe(2);
|
|
121
|
-
expect(task.type).toBe('Project');
|
|
122
|
-
});
|
|
123
|
-
it('caps descendant level at maxLevel and refuses when that violates GOALS-012', () => {
|
|
124
|
-
// Move Root (id=1, level=0) under Root2 (id=5, level=0); delta = +1
|
|
125
|
-
// BG1: 1→2, Proj1: 2→3 (maxLevel), Task1: 3→4, capped at 3
|
|
126
|
-
// Task1 (capped level=3) under Proj1 (level=3) violates GOALS-012 → refused
|
|
127
|
-
const tree = {
|
|
128
|
-
...DEEP,
|
|
129
|
-
goals: [...DEEP.goals, { id: 5, name: 'Root2', type: 'Strategy', level: 0, parent_id: 0 }],
|
|
130
|
-
};
|
|
131
|
-
const r = reparent(tree, 1, 5);
|
|
132
|
-
expect(r.ok).toBe(false);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
import { parseCanonicalGoals } from '../parse-canonical.js';
|
|
6
|
-
const VALID = {
|
|
7
|
-
notation: 'goals',
|
|
8
|
-
spec_version: '0.1',
|
|
9
|
-
id: 'GOALS-SAMPLE-1',
|
|
10
|
-
name: 'Sample goals tree',
|
|
11
|
-
goal_types: [
|
|
12
|
-
{ name: 'Strategy', level: 0 },
|
|
13
|
-
{ name: 'Project', level: 1 },
|
|
14
|
-
],
|
|
15
|
-
goals: [
|
|
16
|
-
{ id: 'GOAL-1', name: 'Root', type: 'Strategy', level: 0 },
|
|
17
|
-
{ id: 'GOAL-2', name: 'Child', type: 'Project', level: 1, parent: 'GOAL-1' },
|
|
18
|
-
],
|
|
19
|
-
};
|
|
20
|
-
describe('parseCanonicalGoals', () => {
|
|
21
|
-
it('accepts a valid canonical document', () => {
|
|
22
|
-
const r = parseCanonicalGoals(VALID);
|
|
23
|
-
expect(r.valid).toBe(true);
|
|
24
|
-
expect(r.errors).toEqual([]);
|
|
25
|
-
expect(r.parsed?.goals).toHaveLength(2);
|
|
26
|
-
});
|
|
27
|
-
it('GOALS-001: rejects non-object input', () => {
|
|
28
|
-
expect(parseCanonicalGoals(null).errors[0].code).toBe('GOALS-001');
|
|
29
|
-
});
|
|
30
|
-
it('GOALS-001: rejects wrong notation', () => {
|
|
31
|
-
const r = parseCanonicalGoals({ ...VALID, notation: 'fga' });
|
|
32
|
-
expect(r.errors.some((e) => e.code === 'GOALS-001')).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
it('GOALS-002: rejects malformed doc id', () => {
|
|
35
|
-
const r = parseCanonicalGoals({ ...VALID, id: 'goals-1' });
|
|
36
|
-
expect(r.errors.some((e) => e.code === 'GOALS-002')).toBe(true);
|
|
37
|
-
});
|
|
38
|
-
it('GOALS-003: rejects missing name', () => {
|
|
39
|
-
const { name: _, ...rest } = VALID;
|
|
40
|
-
const r = parseCanonicalGoals(rest);
|
|
41
|
-
expect(r.errors.some((e) => e.code === 'GOALS-003')).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
it('GOALS-004: rejects empty goal_types', () => {
|
|
44
|
-
const r = parseCanonicalGoals({ ...VALID, goal_types: [] });
|
|
45
|
-
expect(r.errors.some((e) => e.code === 'GOALS-004')).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
it('GOALS-007: rejects malformed goal id', () => {
|
|
48
|
-
const r = parseCanonicalGoals({
|
|
49
|
-
...VALID,
|
|
50
|
-
goals: [{ id: 'goal-1', name: 'A', type: 'Strategy', level: 0 }],
|
|
51
|
-
});
|
|
52
|
-
expect(r.errors.some((e) => e.code === 'GOALS-007')).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
it('GOALS-007: rejects duplicate goal ids', () => {
|
|
55
|
-
const r = parseCanonicalGoals({
|
|
56
|
-
...VALID,
|
|
57
|
-
goals: [
|
|
58
|
-
{ id: 'GOAL-1', name: 'A', type: 'Strategy', level: 0 },
|
|
59
|
-
{ id: 'GOAL-1', name: 'B', type: 'Strategy', level: 0 },
|
|
60
|
-
],
|
|
61
|
-
});
|
|
62
|
-
expect(r.errors.some((e) => e.code === 'GOALS-007')).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
it('GOALS-008: rejects goal.type not in goal_types', () => {
|
|
65
|
-
const r = parseCanonicalGoals({
|
|
66
|
-
...VALID,
|
|
67
|
-
goals: [{ id: 'GOAL-1', name: 'A', type: 'Unknown', level: 0 }],
|
|
68
|
-
});
|
|
69
|
-
expect(r.errors.some((e) => e.code === 'GOALS-008')).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
it('GOALS-008: rejects goal.level mismatched with goal_types', () => {
|
|
72
|
-
const r = parseCanonicalGoals({
|
|
73
|
-
...VALID,
|
|
74
|
-
goals: [{ id: 'GOAL-1', name: 'A', type: 'Strategy', level: 5 }],
|
|
75
|
-
});
|
|
76
|
-
expect(r.errors.some((e) => e.code === 'GOALS-008')).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
it('GOALS-009: warns on broken parent ref', () => {
|
|
79
|
-
const r = parseCanonicalGoals({
|
|
80
|
-
...VALID,
|
|
81
|
-
goals: [
|
|
82
|
-
{ id: 'GOAL-1', name: 'Root', type: 'Strategy', level: 0 },
|
|
83
|
-
{ id: 'GOAL-2', name: 'Orphan', type: 'Project', level: 1, parent: 'GOAL-99' },
|
|
84
|
-
],
|
|
85
|
-
});
|
|
86
|
-
expect(r.valid).toBe(true);
|
|
87
|
-
expect(r.warnings.some((w) => w.code === 'GOALS-009')).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
it('GOALS-010: detects parent-chain cycle', () => {
|
|
90
|
-
const r = parseCanonicalGoals({
|
|
91
|
-
...VALID,
|
|
92
|
-
goals: [
|
|
93
|
-
{ id: 'GOAL-1', name: 'A', type: 'Strategy', level: 0, parent: 'GOAL-2' },
|
|
94
|
-
{ id: 'GOAL-2', name: 'B', type: 'Strategy', level: 0, parent: 'GOAL-1' },
|
|
95
|
-
],
|
|
96
|
-
});
|
|
97
|
-
expect(r.errors.some((e) => e.code === 'GOALS-010')).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
it('GOALS-011: warns when non-root goal has no parent', () => {
|
|
100
|
-
const r = parseCanonicalGoals({
|
|
101
|
-
...VALID,
|
|
102
|
-
goals: [{ id: 'GOAL-1', name: 'A', type: 'Project', level: 1 }],
|
|
103
|
-
});
|
|
104
|
-
expect(r.valid).toBe(true);
|
|
105
|
-
expect(r.warnings.some((w) => w.code === 'GOALS-011')).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
it('maps canonical IDs to internal numeric ids; parent_id is the parent\'s mapped id', () => {
|
|
108
|
-
const r = parseCanonicalGoals(VALID);
|
|
109
|
-
expect(r.parsed?.goals[0].id).toBe(1);
|
|
110
|
-
expect(r.parsed?.goals[0].canonical_id).toBe('GOAL-1');
|
|
111
|
-
expect(r.parsed?.goals[0].parent_id).toBe(0);
|
|
112
|
-
expect(r.parsed?.goals[1].id).toBe(2);
|
|
113
|
-
expect(r.parsed?.goals[1].canonical_id).toBe('GOAL-2');
|
|
114
|
-
expect(r.parsed?.goals[1].parent_id).toBe(1);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
describe('parseCanonicalGoals — example file regression', () => {
|
|
118
|
-
const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'goals');
|
|
119
|
-
const files = fs.existsSync(EXAMPLES_DIR)
|
|
120
|
-
? fs.readdirSync(EXAMPLES_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
|
|
121
|
-
: [];
|
|
122
|
-
for (const file of files) {
|
|
123
|
-
it(`accepts tests/fixtures/notation-corpus/goals/${file}`, () => {
|
|
124
|
-
const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
|
|
125
|
-
const parsedYaml = yaml.load(text);
|
|
126
|
-
const r = parseCanonicalGoals(parsedYaml);
|
|
127
|
-
expect(r.errors).toEqual([]);
|
|
128
|
-
expect(r.valid).toBe(true);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateGoalTree } from '../validate.js';
|
|
3
|
-
const VALID_TREE = {
|
|
4
|
-
goal_types: [
|
|
5
|
-
{ name: 'Strategy', level: 0 },
|
|
6
|
-
{ name: 'Business Goal', level: 1 },
|
|
7
|
-
{ name: 'Project', level: 2 },
|
|
8
|
-
],
|
|
9
|
-
goals: [
|
|
10
|
-
{ id: 1, name: 'Triple revenue', type: 'Strategy', level: 0, parent_id: 0 },
|
|
11
|
-
{ id: 2, name: 'Launch EU', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
12
|
-
{ id: 3, name: 'Open Berlin office', type: 'Project', level: 2, parent_id: 2 },
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
describe('validateGoalTree', () => {
|
|
16
|
-
it('passes on valid input', () => {
|
|
17
|
-
const r = validateGoalTree(VALID_TREE);
|
|
18
|
-
expect(r.valid).toBe(true);
|
|
19
|
-
expect(r.errors).toHaveLength(0);
|
|
20
|
-
});
|
|
21
|
-
it('SCHEMA_INVALID: rejects non-object', () => {
|
|
22
|
-
expect(validateGoalTree(null).valid).toBe(false);
|
|
23
|
-
expect(validateGoalTree('string').errors[0].code).toBe('SCHEMA_INVALID');
|
|
24
|
-
});
|
|
25
|
-
it('SCHEMA_INVALID: rejects missing goals array', () => {
|
|
26
|
-
const r = validateGoalTree({ goal_types: [] });
|
|
27
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
it('DUPLICATE_ID: detects duplicate goal ids', () => {
|
|
30
|
-
const tree = {
|
|
31
|
-
...VALID_TREE,
|
|
32
|
-
goals: [
|
|
33
|
-
{ id: 1, name: 'A', type: 'Strategy', level: 0, parent_id: 0 },
|
|
34
|
-
{ id: 1, name: 'B', type: 'Strategy', level: 0, parent_id: 0 },
|
|
35
|
-
],
|
|
36
|
-
};
|
|
37
|
-
const r = validateGoalTree(tree);
|
|
38
|
-
expect(r.errors.some(e => e.code === 'DUPLICATE_ID')).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
it('EMPTY_NAME: detects empty name', () => {
|
|
41
|
-
const tree = {
|
|
42
|
-
...VALID_TREE,
|
|
43
|
-
goals: [{ id: 1, name: '', type: 'Strategy', level: 0, parent_id: 0 }],
|
|
44
|
-
};
|
|
45
|
-
expect(validateGoalTree(tree).errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
it('MAX_LEVEL_EXCEEDED: detects level overflow', () => {
|
|
48
|
-
const tree = {
|
|
49
|
-
goal_types: [{ name: 'Strategy', level: 0 }],
|
|
50
|
-
goals: [{ id: 1, name: 'Too deep', type: 'Strategy', level: 5, parent_id: 0 }],
|
|
51
|
-
};
|
|
52
|
-
expect(validateGoalTree(tree).errors.some(e => e.code === 'MAX_LEVEL_EXCEEDED')).toBe(true);
|
|
53
|
-
});
|
|
54
|
-
it('TYPE_LEVEL_MISMATCH: warns when type level disagrees', () => {
|
|
55
|
-
const tree = {
|
|
56
|
-
...VALID_TREE,
|
|
57
|
-
goals: [{ id: 1, name: 'Mismatch', type: 'Project', level: 0, parent_id: 0 }],
|
|
58
|
-
};
|
|
59
|
-
const r = validateGoalTree(tree);
|
|
60
|
-
expect(r.warnings.some(w => w.code === 'TYPE_LEVEL_MISMATCH')).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
it('BROKEN_PARENT_REF: warns on missing parent (renders to backlog)', () => {
|
|
63
|
-
const tree = {
|
|
64
|
-
...VALID_TREE,
|
|
65
|
-
goals: [
|
|
66
|
-
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
67
|
-
{ id: 2, name: 'Orphan', type: 'Business Goal', level: 1, parent_id: 99 },
|
|
68
|
-
],
|
|
69
|
-
};
|
|
70
|
-
const r = validateGoalTree(tree);
|
|
71
|
-
expect(r.valid).toBe(true);
|
|
72
|
-
expect(r.warnings.some(w => w.code === 'BROKEN_PARENT_REF')).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
it('CYCLE_DETECTED: detects direct cycle', () => {
|
|
75
|
-
const tree = {
|
|
76
|
-
goal_types: [{ name: 'S', level: 0 }, { name: 'B', level: 1 }],
|
|
77
|
-
goals: [
|
|
78
|
-
{ id: 1, name: 'A', type: 'S', level: 0, parent_id: 2 },
|
|
79
|
-
{ id: 2, name: 'B', type: 'B', level: 1, parent_id: 1 },
|
|
80
|
-
],
|
|
81
|
-
};
|
|
82
|
-
expect(validateGoalTree(tree).errors.some(e => e.code === 'CYCLE_DETECTED')).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
// Pre-release blocker regression tests (orchestrator review 2026-05-21).
|
|
85
|
-
it('[blocker] tolerates a null element in goals[] without throwing', () => {
|
|
86
|
-
const tree = { ...VALID_TREE, goals: [null] };
|
|
87
|
-
const r = validateGoalTree(tree);
|
|
88
|
-
expect(r.valid).toBe(false);
|
|
89
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
90
|
-
});
|
|
91
|
-
it('[blocker] tolerates a non-object element in goals[] without throwing', () => {
|
|
92
|
-
const tree = { ...VALID_TREE, goals: ['x'] };
|
|
93
|
-
const r = validateGoalTree(tree);
|
|
94
|
-
expect(r.valid).toBe(false);
|
|
95
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
it('[blocker] rejects non-numeric level (does not silently slip a string compare)', () => {
|
|
98
|
-
const tree = {
|
|
99
|
-
...VALID_TREE,
|
|
100
|
-
goals: [{ id: 1, name: 'A', type: 'Strategy', level: '5', parent_id: 0 }],
|
|
101
|
-
};
|
|
102
|
-
const r = validateGoalTree(tree);
|
|
103
|
-
expect(r.valid).toBe(false);
|
|
104
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID' && /level/.test(e.message))).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
it('[blocker] rejects missing level (does not silently slip undefined > N)', () => {
|
|
107
|
-
const tree = {
|
|
108
|
-
...VALID_TREE,
|
|
109
|
-
goals: [{ id: 1, name: 'A', type: 'Strategy', parent_id: 0 }],
|
|
110
|
-
};
|
|
111
|
-
const r = validateGoalTree(tree);
|
|
112
|
-
expect(r.valid).toBe(false);
|
|
113
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID' && /level/.test(e.message))).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
// GOALS-012 / GOALS-013 — N+1 parent/child hierarchy keyed on goal_types[]
|
|
116
|
-
// (decision in vkgeorgia/strategy#66; spec in transitrix/methodology
|
|
117
|
-
// notations/04-goals.md §6).
|
|
118
|
-
it('GOALS-012/013: accepts a contiguous goal_types + N+1 parent/child tree', () => {
|
|
119
|
-
const r = validateGoalTree(VALID_TREE);
|
|
120
|
-
expect(r.valid).toBe(true);
|
|
121
|
-
expect(r.errors.some(e => e.code === 'GOALS-012')).toBe(false);
|
|
122
|
-
expect(r.errors.some(e => e.code === 'GOALS-013')).toBe(false);
|
|
123
|
-
});
|
|
124
|
-
it('GOALS-013: rejects a gap in goal_types[].level', () => {
|
|
125
|
-
const tree = {
|
|
126
|
-
goal_types: [
|
|
127
|
-
{ name: 'Strategy', level: 0 },
|
|
128
|
-
{ name: 'Strategic Goal', level: 2 },
|
|
129
|
-
{ name: 'Project Goal', level: 4 },
|
|
130
|
-
],
|
|
131
|
-
goals: [
|
|
132
|
-
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
133
|
-
],
|
|
134
|
-
};
|
|
135
|
-
const r = validateGoalTree(tree);
|
|
136
|
-
expect(r.valid).toBe(false);
|
|
137
|
-
expect(r.errors.some(e => e.code === 'GOALS-013')).toBe(true);
|
|
138
|
-
});
|
|
139
|
-
it('GOALS-013: rejects goal_types[].level that does not start at 0', () => {
|
|
140
|
-
const tree = {
|
|
141
|
-
goal_types: [
|
|
142
|
-
{ name: 'Mid', level: 1 },
|
|
143
|
-
{ name: 'Deep', level: 2 },
|
|
144
|
-
],
|
|
145
|
-
goals: [
|
|
146
|
-
{ id: 1, name: 'A', type: 'Mid', level: 1, parent_id: 0 },
|
|
147
|
-
],
|
|
148
|
-
};
|
|
149
|
-
const r = validateGoalTree(tree);
|
|
150
|
-
expect(r.valid).toBe(false);
|
|
151
|
-
expect(r.errors.some(e => e.code === 'GOALS-013')).toBe(true);
|
|
152
|
-
});
|
|
153
|
-
it('GOALS-012: rejects a parent–child level gap > 1', () => {
|
|
154
|
-
const tree = {
|
|
155
|
-
goal_types: [
|
|
156
|
-
{ name: 'Strategy', level: 0 },
|
|
157
|
-
{ name: 'Business Goal', level: 1 },
|
|
158
|
-
{ name: 'Project', level: 2 },
|
|
159
|
-
],
|
|
160
|
-
goals: [
|
|
161
|
-
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
162
|
-
// Skips level 1: a Project (level 2) attached directly to a Strategy
|
|
163
|
-
// (level 0) violates N+1.
|
|
164
|
-
{ id: 2, name: 'Sub', type: 'Project', level: 2, parent_id: 1 },
|
|
165
|
-
],
|
|
166
|
-
};
|
|
167
|
-
const r = validateGoalTree(tree);
|
|
168
|
-
expect(r.valid).toBe(false);
|
|
169
|
-
expect(r.errors.some(e => e.code === 'GOALS-012')).toBe(true);
|
|
170
|
-
});
|
|
171
|
-
it('GOALS-012: does not fire when the parent reference is broken (BROKEN_PARENT_REF covers it)', () => {
|
|
172
|
-
const tree = {
|
|
173
|
-
...VALID_TREE,
|
|
174
|
-
goals: [
|
|
175
|
-
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
176
|
-
{ id: 2, name: 'Orphan', type: 'Project', level: 2, parent_id: 99 },
|
|
177
|
-
],
|
|
178
|
-
};
|
|
179
|
-
const r = validateGoalTree(tree);
|
|
180
|
-
expect(r.errors.some(e => e.code === 'GOALS-012')).toBe(false);
|
|
181
|
-
expect(r.warnings.some(w => w.code === 'BROKEN_PARENT_REF')).toBe(true);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|