@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.
Files changed (251) hide show
  1. package/dist/fgca/index.js +10 -10
  2. package/dist/fgca/layout.js +1 -1
  3. package/dist/fgca/nodeTypes.js +4 -4
  4. package/dist/index.js +33 -33
  5. package/package.json +8 -2
  6. package/dist/__tests__/edge-path.test.d.ts +0 -1
  7. package/dist/__tests__/edge-path.test.js +0 -55
  8. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  9. package/dist/__tests__/node-size-presets.test.js +0 -30
  10. package/dist/__tests__/scope.test.d.ts +0 -1
  11. package/dist/__tests__/scope.test.js +0 -23
  12. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  13. package/dist/__tests__/yaml-normalize.test.js +0 -148
  14. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  15. package/dist/activities/__tests__/cpm.test.js +0 -146
  16. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  17. package/dist/activities/__tests__/gantt.test.js +0 -263
  18. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  19. package/dist/activities/__tests__/layout.test.js +0 -98
  20. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  21. package/dist/activities/__tests__/validate.test.js +0 -397
  22. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  23. package/dist/activity-card/__tests__/example.test.js +0 -73
  24. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  25. package/dist/activity-card/__tests__/layout.test.js +0 -141
  26. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  27. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  28. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  29. package/dist/activity-card/__tests__/validate.test.js +0 -149
  30. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  31. package/dist/actor/__tests__/validate.test.js +0 -95
  32. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  33. package/dist/applications/__tests__/validate.test.js +0 -223
  34. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  35. package/dist/assertion/__tests__/example.test.js +0 -32
  36. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  37. package/dist/assertion/__tests__/validate.test.js +0 -130
  38. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  39. package/dist/blocks/__tests__/layout.test.js +0 -153
  40. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  41. package/dist/blocks/__tests__/validate.test.js +0 -235
  42. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  43. package/dist/business-service/__tests__/validate.test.js +0 -135
  44. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  45. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  46. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  47. package/dist/capability-map/__tests__/address.test.js +0 -49
  48. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  49. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  50. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  51. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  52. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  53. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  54. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  55. package/dist/capability-map/__tests__/validate.test.js +0 -212
  56. package/dist/change/__tests__/validate.test.d.ts +0 -1
  57. package/dist/change/__tests__/validate.test.js +0 -79
  58. package/dist/codex/__tests__/example.test.d.ts +0 -1
  59. package/dist/codex/__tests__/example.test.js +0 -33
  60. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  61. package/dist/codex/__tests__/validate.test.js +0 -68
  62. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  63. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  64. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  65. package/dist/compliance/__tests__/classify.test.js +0 -58
  66. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  67. package/dist/compliance/__tests__/confidence.test.js +0 -78
  68. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  69. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  70. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  71. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  72. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  73. package/dist/compliance/__tests__/example.test.js +0 -51
  74. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  75. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  76. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  77. package/dist/compliance/__tests__/html.test.js +0 -122
  78. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  79. package/dist/compliance/__tests__/impact.test.js +0 -913
  80. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  81. package/dist/compliance/__tests__/markdown.test.js +0 -85
  82. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  83. package/dist/compliance/__tests__/trace.test.js +0 -144
  84. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  85. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  86. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  87. package/dist/compliance/__tests__/views.test.js +0 -59
  88. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  89. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  90. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  91. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  92. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  93. package/dist/confidence/__tests__/score.test.js +0 -188
  94. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  95. package/dist/constraint/__tests__/example.test.js +0 -14
  96. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  97. package/dist/constraint/__tests__/validate.test.js +0 -58
  98. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  99. package/dist/factor/__tests__/validate.test.js +0 -112
  100. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  101. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  102. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  103. package/dist/fgca/__tests__/layout.test.js +0 -140
  104. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  105. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  106. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  107. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  108. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  109. package/dist/fgca/__tests__/resolver.test.js +0 -185
  110. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  111. package/dist/fgca/__tests__/validate.test.js +0 -125
  112. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  113. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  114. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  115. package/dist/goals/__tests__/layout.test.js +0 -153
  116. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  117. package/dist/goals/__tests__/mutations.test.js +0 -134
  118. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  119. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  120. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  121. package/dist/goals/__tests__/validate.test.js +0 -183
  122. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  123. package/dist/integration/__tests__/validate.test.js +0 -169
  124. package/dist/location/__tests__/validate.test.d.ts +0 -1
  125. package/dist/location/__tests__/validate.test.js +0 -107
  126. package/dist/node/__tests__/validate.test.d.ts +0 -1
  127. package/dist/node/__tests__/validate.test.js +0 -100
  128. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  129. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  130. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  131. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  132. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  133. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  134. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  135. package/dist/process-map/__tests__/validate.test.js +0 -199
  136. package/dist/products/__tests__/validate.test.d.ts +0 -1
  137. package/dist/products/__tests__/validate.test.js +0 -210
  138. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  139. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  140. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  141. package/dist/requirement/__tests__/example.test.js +0 -21
  142. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  143. package/dist/requirement/__tests__/validate.test.js +0 -80
  144. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  145. package/dist/scenarios/__tests__/validate.test.js +0 -183
  146. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  147. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  148. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  149. package/dist/target-state/__tests__/validate.test.js +0 -78
  150. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  151. package/dist/technology-service/__tests__/validate.test.js +0 -121
  152. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  153. package/dist/theme/__tests__/tokens.test.js +0 -159
  154. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  155. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  156. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  157. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  158. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  159. package/dist/webview/__tests__/entry.test.js +0 -56
  160. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  161. package/dist/webview/__tests__/render-activities.test.js +0 -91
  162. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  163. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  164. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  165. package/dist/webview/__tests__/render-goals.test.js +0 -120
  166. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  167. package/dist/webview/__tests__/render-process.test.js +0 -463
  168. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  169. package/dist/webview/__tests__/render-util.test.js +0 -54
  170. package/src/__tests__/edge-path.test.ts +0 -67
  171. package/src/__tests__/node-size-presets.test.ts +0 -50
  172. package/src/__tests__/scope.test.ts +0 -27
  173. package/src/__tests__/yaml-normalize.test.ts +0 -158
  174. package/src/activities/__tests__/cpm.test.ts +0 -164
  175. package/src/activities/__tests__/gantt.test.ts +0 -290
  176. package/src/activities/__tests__/layout.test.ts +0 -112
  177. package/src/activities/__tests__/validate.test.ts +0 -446
  178. package/src/activity-card/__tests__/example.test.ts +0 -83
  179. package/src/activity-card/__tests__/layout.test.ts +0 -162
  180. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  181. package/src/activity-card/__tests__/validate.test.ts +0 -167
  182. package/src/actor/__tests__/validate.test.ts +0 -114
  183. package/src/applications/__tests__/validate.test.ts +0 -256
  184. package/src/assertion/__tests__/example.test.ts +0 -37
  185. package/src/assertion/__tests__/validate.test.ts +0 -142
  186. package/src/blocks/__tests__/layout.test.ts +0 -169
  187. package/src/blocks/__tests__/validate.test.ts +0 -260
  188. package/src/business-service/__tests__/validate.test.ts +0 -160
  189. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  190. package/src/capability-map/__tests__/address.test.ts +0 -59
  191. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  192. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  193. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  194. package/src/capability-map/__tests__/validate.test.ts +0 -238
  195. package/src/change/__tests__/validate.test.ts +0 -97
  196. package/src/codex/__tests__/example.test.ts +0 -40
  197. package/src/codex/__tests__/validate.test.ts +0 -84
  198. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  199. package/src/compliance/__tests__/classify.test.ts +0 -64
  200. package/src/compliance/__tests__/confidence.test.ts +0 -98
  201. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  202. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  203. package/src/compliance/__tests__/example.test.ts +0 -57
  204. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  205. package/src/compliance/__tests__/html.test.ts +0 -142
  206. package/src/compliance/__tests__/impact.test.ts +0 -1060
  207. package/src/compliance/__tests__/markdown.test.ts +0 -95
  208. package/src/compliance/__tests__/trace.test.ts +0 -157
  209. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  210. package/src/compliance/__tests__/views.test.ts +0 -64
  211. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  212. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  213. package/src/confidence/__tests__/score.test.ts +0 -254
  214. package/src/constraint/__tests__/example.test.ts +0 -19
  215. package/src/constraint/__tests__/validate.test.ts +0 -68
  216. package/src/factor/__tests__/validate.test.ts +0 -133
  217. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  218. package/src/fgca/__tests__/layout.test.ts +0 -179
  219. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  220. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  221. package/src/fgca/__tests__/resolver.test.ts +0 -209
  222. package/src/fgca/__tests__/validate.test.ts +0 -142
  223. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  224. package/src/goals/__tests__/layout.test.ts +0 -175
  225. package/src/goals/__tests__/mutations.test.ts +0 -153
  226. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  227. package/src/goals/__tests__/validate.test.ts +0 -202
  228. package/src/integration/__tests__/validate.test.ts +0 -203
  229. package/src/location/__tests__/validate.test.ts +0 -127
  230. package/src/node/__tests__/validate.test.ts +0 -118
  231. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  232. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  233. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  234. package/src/process-map/__tests__/validate.test.ts +0 -223
  235. package/src/products/__tests__/validate.test.ts +0 -239
  236. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  237. package/src/requirement/__tests__/example.test.ts +0 -24
  238. package/src/requirement/__tests__/validate.test.ts +0 -96
  239. package/src/scenarios/__tests__/validate.test.ts +0 -209
  240. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  241. package/src/target-state/__tests__/validate.test.ts +0 -95
  242. package/src/technology-service/__tests__/validate.test.ts +0 -143
  243. package/src/theme/__tests__/tokens.test.ts +0 -185
  244. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  245. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  246. package/src/webview/__tests__/entry.test.ts +0 -64
  247. package/src/webview/__tests__/render-activities.test.ts +0 -100
  248. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  249. package/src/webview/__tests__/render-goals.test.ts +0 -128
  250. package/src/webview/__tests__/render-process.test.ts +0 -538
  251. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1,140 +0,0 @@
1
- import { describe, it, expect, vi, beforeAll } from "vitest";
2
- // reactflow uses browser APIs — stub the minimum required before importing layout
3
- beforeAll(() => {
4
- vi.mock("reactflow", () => ({
5
- Position: { Left: "left", Right: "right" },
6
- MarkerType: { ArrowClosed: "arrowclosed" },
7
- }));
8
- });
9
- import { buildFGCALayout } from "../layout";
10
- import { ALL_FGCA_COLUMNS } from "../types";
11
- const ALL_COLS = new Set(ALL_FGCA_COLUMNS);
12
- const factors = [
13
- { id: 1, name: "Digital growth" },
14
- { id: 2, name: "Talent shortage" },
15
- ];
16
- const goals = [
17
- { id: 10, name: "Grow revenue", level: 0, factor: [{ id: 1 }] },
18
- { id: 11, name: "Build talent pipeline", level: 1, factor: [{ id: 2 }] },
19
- ];
20
- const changes = [
21
- { id: 100, name: "Launch digital channel", goal_id: 10, activity_ids: [200] },
22
- { id: 101, name: "Partner with bootcamps", goal_id: 11, activity_ids: [201] },
23
- ];
24
- const activities = [
25
- { id: 200, name: "Build e-commerce MVP", goal_id: 10, activity_type_id: 1 },
26
- { id: 201, name: "Run hiring sprint", goal_id: 11, activity_type_id: 1 },
27
- ];
28
- describe("buildFGCALayout — all columns visible", () => {
29
- const { nodes, edges } = buildFGCALayout({
30
- factors,
31
- goals,
32
- changes,
33
- activities,
34
- visibleColumns: ALL_COLS,
35
- activityTypeList: [{ id: 1, name: "Initiative" }],
36
- });
37
- it("produces the correct number of nodes", () => {
38
- expect(nodes).toHaveLength(factors.length + goals.length + changes.length + activities.length);
39
- });
40
- it("assigns correct node types", () => {
41
- const types = nodes.map((n) => n.type);
42
- expect(types.filter((t) => t === "fgcaDriver")).toHaveLength(factors.length);
43
- expect(types.filter((t) => t === "fgcaGoal")).toHaveLength(goals.length);
44
- expect(types.filter((t) => t === "fgcaChange")).toHaveLength(changes.length);
45
- expect(types.filter((t) => t === "fgcaActivity")).toHaveLength(activities.length);
46
- });
47
- it("creates Factor→Goal edges", () => {
48
- const fgEdges = edges.filter((e) => e.source.startsWith("driver_") && e.target.startsWith("goal_"));
49
- expect(fgEdges).toHaveLength(2);
50
- expect(fgEdges.find((e) => e.source === "driver_1" && e.target === "goal_10")).toBeTruthy();
51
- });
52
- it("creates Goal→Change edges", () => {
53
- const gcEdges = edges.filter((e) => e.source.startsWith("goal_") && e.target.startsWith("change_"));
54
- expect(gcEdges).toHaveLength(2);
55
- });
56
- it("creates Change→Activity edges", () => {
57
- const caEdges = edges.filter((e) => e.source.startsWith("change_") && e.target.startsWith("activity_"));
58
- expect(caEdges).toHaveLength(2);
59
- });
60
- it("does NOT create direct Goal→Activity edges when Change column is visible and all activities are covered", () => {
61
- const directEdges = edges.filter((e) => e.source.startsWith("goal_") && e.target.startsWith("activity_"));
62
- expect(directEdges).toHaveLength(0);
63
- });
64
- it("uses the activity type name in activity node data", () => {
65
- const actNode = nodes.find((n) => n.id === "activity_200");
66
- expect(actNode?.data.activityTypeName).toBe("Initiative");
67
- });
68
- it("encodes F-XXXX label format via id in node data", () => {
69
- const factorNode = nodes.find((n) => n.id === "driver_1");
70
- expect(String(factorNode?.data.id).padStart(4, "0")).toBe("0001");
71
- });
72
- it("encodes C-XXX label format via id in node data", () => {
73
- const changeNode = nodes.find((n) => n.id === "change_100");
74
- expect(String(changeNode?.data.id).padStart(3, "0")).toBe("100");
75
- });
76
- });
77
- describe("buildFGCALayout — Driver column hidden", () => {
78
- const cols = new Set(ALL_FGCA_COLUMNS.filter((c) => c !== "driver"));
79
- const { nodes, edges } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: cols });
80
- it("produces no driver nodes", () => {
81
- expect(nodes.filter((n) => n.type === "fgcaDriver")).toHaveLength(0);
82
- });
83
- it("produces no Driver→Goal edges", () => {
84
- expect(edges.filter((e) => e.source.startsWith("driver_"))).toHaveLength(0);
85
- });
86
- it("still produces Goal and downstream nodes", () => {
87
- expect(nodes.filter((n) => n.type === "fgcaGoal")).toHaveLength(goals.length);
88
- });
89
- });
90
- describe("buildFGCALayout — Change column hidden", () => {
91
- const cols = new Set(ALL_FGCA_COLUMNS.filter((c) => c !== "change"));
92
- const { nodes, edges } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: cols });
93
- it("produces no change nodes", () => {
94
- expect(nodes.filter((n) => n.type === "fgcaChange")).toHaveLength(0);
95
- });
96
- it("creates direct Goal→Activity edges when Change column is hidden", () => {
97
- const directEdges = edges.filter((e) => e.source.startsWith("goal_") && e.target.startsWith("activity_"));
98
- expect(directEdges.length).toBeGreaterThan(0);
99
- });
100
- });
101
- describe("buildFGCALayout — only one column visible", () => {
102
- const { nodes, edges } = buildFGCALayout({
103
- factors,
104
- goals,
105
- changes,
106
- activities,
107
- visibleColumns: new Set(["goal"]),
108
- });
109
- it("produces only goal nodes", () => {
110
- expect(nodes.filter((n) => n.type !== "fgcaGoal")).toHaveLength(0);
111
- });
112
- it("produces no edges", () => {
113
- expect(edges).toHaveLength(0);
114
- });
115
- });
116
- describe("buildFGCALayout — columns are positioned left to right", () => {
117
- const { nodes } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: ALL_COLS });
118
- it("factor column x < goal column x", () => {
119
- const f = nodes.find((n) => n.type === "fgcaDriver");
120
- const g = nodes.find((n) => n.type === "fgcaGoal");
121
- expect(f.position.x).toBeLessThan(g.position.x);
122
- });
123
- it("goal column x < change column x", () => {
124
- const g = nodes.find((n) => n.type === "fgcaGoal");
125
- const c = nodes.find((n) => n.type === "fgcaChange");
126
- expect(g.position.x).toBeLessThan(c.position.x);
127
- });
128
- it("change column x < activity column x", () => {
129
- const c = nodes.find((n) => n.type === "fgcaChange");
130
- const a = nodes.find((n) => n.type === "fgcaActivity");
131
- expect(c.position.x).toBeLessThan(a.position.x);
132
- });
133
- // Pre-release blocker regression (orchestrator review 2026-05-21).
134
- it("[blocker] tolerates a change with no activity_ids (optional per validator)", () => {
135
- const changesNoIds = [
136
- { id: 100, name: "No activities", goal_id: 10 },
137
- ];
138
- expect(() => buildFGCALayout({ factors, goals, changes: changesNoIds, activities, visibleColumns: ALL_COLS })).not.toThrow();
139
- });
140
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,268 +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 { parseCanonicalFGCA, parseCanonicalFGA } from '../parse-canonical.js';
6
- const VALID = {
7
- notation: 'dgca',
8
- spec_version: '0.1',
9
- id: 'FGCA-SAMPLE-1',
10
- name: 'Sample FGCA chain',
11
- factors: [
12
- { id: 'FACTOR-1', name: 'Driver one', type: 'external' },
13
- ],
14
- goals: [
15
- { id: 'GOAL-1', name: 'Outcome one', factors: ['FACTOR-1'] },
16
- ],
17
- changes: [
18
- { id: 'CHANGE-1', name: 'Transformation', goals: ['GOAL-1'] },
19
- ],
20
- actions: [
21
- { id: 'ACTIVITY-1', name: 'Workstream', changes: ['CHANGE-1'] },
22
- ],
23
- };
24
- describe('parseCanonicalFGCA', () => {
25
- it('accepts a valid canonical document', () => {
26
- const r = parseCanonicalFGCA(VALID);
27
- expect(r.valid).toBe(true);
28
- expect(r.errors).toEqual([]);
29
- expect(r.parsed).toBeDefined();
30
- expect(r.parsed?.factors).toHaveLength(1);
31
- expect(r.parsed?.goals).toHaveLength(1);
32
- expect(r.parsed?.changes).toHaveLength(1);
33
- expect(r.parsed?.activities).toHaveLength(1);
34
- });
35
- it('accepts ACTION-* ids (methodology 1.0) alongside legacy ACTIVITY-*', () => {
36
- const r = parseCanonicalFGCA({
37
- ...VALID,
38
- actions: [
39
- { id: 'ACTION-CRM-EU-1', name: 'CRM rollout', changes: ['CHANGE-1'] },
40
- { id: 'ACTIVITY-2', name: 'Legacy workstream', changes: ['CHANGE-1'] },
41
- ],
42
- });
43
- expect(r.valid, JSON.stringify(r.errors)).toBe(true);
44
- expect(r.parsed?.activities.map((a) => a.id)).toEqual(['ACTION-CRM-EU-1', 'ACTIVITY-2']);
45
- });
46
- it('defaults changes to [] when view_config.layers.changes is off (DGA-in-dgca)', () => {
47
- const r = parseCanonicalFGCA({
48
- ...VALID,
49
- changes: undefined,
50
- view_config: { layers: { changes: 'off' } },
51
- actions: [
52
- { id: 'ACTION-DISCOVERY-1', name: 'Gap assessment', goals: ['GOAL-1'] },
53
- ],
54
- });
55
- expect(r.valid, JSON.stringify(r.errors)).toBe(true);
56
- expect(r.parsed?.changes).toEqual([]);
57
- });
58
- it('FGCA-001: rejects non-object input', () => {
59
- expect(parseCanonicalFGCA(null).errors[0].code).toBe('FGCA-001');
60
- expect(parseCanonicalFGCA('string').errors[0].code).toBe('FGCA-001');
61
- });
62
- it('FGCA-001: rejects wrong notation', () => {
63
- const r = parseCanonicalFGCA({ ...VALID, notation: 'fga' });
64
- expect(r.valid).toBe(false);
65
- expect(r.errors.some((e) => e.code === 'FGCA-001')).toBe(true);
66
- });
67
- it('FGCA-002: rejects malformed doc id', () => {
68
- const r = parseCanonicalFGCA({ ...VALID, id: 'fgca-lowercase-1' });
69
- expect(r.valid).toBe(false);
70
- expect(r.errors.some((e) => e.code === 'FGCA-002')).toBe(true);
71
- });
72
- it('FGCA-003: rejects missing name', () => {
73
- const { name: _, ...rest } = VALID;
74
- const r = parseCanonicalFGCA(rest);
75
- expect(r.valid).toBe(false);
76
- expect(r.errors.some((e) => e.code === 'FGCA-003')).toBe(true);
77
- });
78
- it('FGCA-004: rejects missing factors array', () => {
79
- const { factors: _, ...rest } = VALID;
80
- const r = parseCanonicalFGCA(rest);
81
- expect(r.valid).toBe(false);
82
- expect(r.errors.some((e) => e.code === 'FGCA-004')).toBe(true);
83
- });
84
- it('FGCA-006: rejects duplicate IDs within a layer', () => {
85
- const r = parseCanonicalFGCA({
86
- ...VALID,
87
- factors: [
88
- { id: 'FACTOR-1', name: 'A' },
89
- { id: 'FACTOR-1', name: 'B' },
90
- ],
91
- });
92
- expect(r.valid).toBe(false);
93
- expect(r.errors.some((e) => e.code === 'FGCA-006')).toBe(true);
94
- });
95
- it('FGCA-007: rejects malformed factor id', () => {
96
- const r = parseCanonicalFGCA({
97
- ...VALID,
98
- factors: [{ id: 'F-1', name: 'A' }],
99
- });
100
- expect(r.valid).toBe(false);
101
- expect(r.errors.some((e) => e.code === 'FGCA-007')).toBe(true);
102
- });
103
- it('FGCA-008: rejects goal.factors[] referencing undefined factor', () => {
104
- const r = parseCanonicalFGCA({
105
- ...VALID,
106
- goals: [{ id: 'GOAL-1', name: 'A', factors: ['FACTOR-99'] }],
107
- });
108
- expect(r.valid).toBe(false);
109
- expect(r.errors.some((e) => e.code === 'FGCA-008')).toBe(true);
110
- });
111
- it('FGCA-009: rejects change.goals[] referencing undefined goal', () => {
112
- const r = parseCanonicalFGCA({
113
- ...VALID,
114
- changes: [{ id: 'CHANGE-1', name: 'A', goals: ['GOAL-99'] }],
115
- });
116
- expect(r.valid).toBe(false);
117
- expect(r.errors.some((e) => e.code === 'FGCA-009')).toBe(true);
118
- });
119
- it('FGCA-010: rejects activity.changes[] referencing undefined change', () => {
120
- const r = parseCanonicalFGCA({
121
- ...VALID,
122
- actions: [{ id: 'ACTIVITY-1', name: 'A', changes: ['CHANGE-99'] }],
123
- });
124
- expect(r.valid).toBe(false);
125
- expect(r.errors.some((e) => e.code === 'FGCA-010')).toBe(true);
126
- });
127
- it('FGCA-015: rejects factor.references_constraint with malformed ID', () => {
128
- const r = parseCanonicalFGCA({
129
- ...VALID,
130
- factors: [{ id: 'FACTOR-1', name: 'A', references_constraint: ['BAD-1'] }],
131
- });
132
- expect(r.valid).toBe(false);
133
- expect(r.errors.some((e) => e.code === 'FGCA-015')).toBe(true);
134
- });
135
- it('accepts factor.references_constraint with valid CONSTRAINT ID', () => {
136
- const r = parseCanonicalFGCA({
137
- ...VALID,
138
- factors: [{ id: 'FACTOR-1', name: 'A', references_constraint: ['CONSTRAINT-GDPR-1'] }],
139
- });
140
- expect(r.valid).toBe(true);
141
- });
142
- it('populates internal change.activity_ids from canonical activity.changes (reversed direction)', () => {
143
- const r = parseCanonicalFGCA({
144
- ...VALID,
145
- changes: [{ id: 'CHANGE-1', name: 'C', goals: ['GOAL-1'] }],
146
- actions: [
147
- { id: 'ACTIVITY-1', name: 'A1', changes: ['CHANGE-1'] },
148
- { id: 'ACTIVITY-2', name: 'A2', changes: ['CHANGE-1'] },
149
- ],
150
- });
151
- expect(r.valid).toBe(true);
152
- expect(r.parsed?.changes[0].activity_ids).toHaveLength(2);
153
- });
154
- });
155
- // The "FGCA preview blank / FGA no edges" regression (vkgeorgia/strategy#65,
156
- // transitrix/methodology#65) was a data defect: the canonical flat shape was
157
- // not being mapped to the internal cross-ref fields the renderer turns into
158
- // edges. These assert the edge-driving fields are populated, so the renderer
159
- // has something to draw — locking the fix.
160
- describe('parseCanonicalFGCA — edge-driving fields populated', () => {
161
- it('maps goal.factors → goal.factor[], change.goals → change.goal_id, activity.changes → change.activity_ids', () => {
162
- const r = parseCanonicalFGCA(VALID);
163
- expect(r.valid).toBe(true);
164
- const parsed = r.parsed;
165
- // factor → goal edge source
166
- expect(parsed.goals[0].factor).toHaveLength(1);
167
- // goal → change edge
168
- expect(parsed.changes[0].goal_id).not.toBe(0);
169
- expect(parsed.changes[0].goal_id).not.toBe('');
170
- // change → activity edge
171
- expect(parsed.changes[0].activity_ids).toHaveLength(1);
172
- });
173
- it('preserves canonical string IDs — not converted to sequential numbers', () => {
174
- const r = parseCanonicalFGCA(VALID);
175
- expect(r.valid).toBe(true);
176
- const parsed = r.parsed;
177
- expect(parsed.factors[0].id).toBe('FACTOR-1');
178
- expect(parsed.goals[0].id).toBe('GOAL-1');
179
- expect(parsed.goals[0].factor[0].id).toBe('FACTOR-1');
180
- expect(parsed.changes[0].id).toBe('CHANGE-1');
181
- expect(parsed.changes[0].goal_id).toBe('GOAL-1');
182
- expect(parsed.changes[0].activity_ids[0]).toBe('ACTIVITY-1');
183
- expect(parsed.activities[0].id).toBe('ACTIVITY-1');
184
- });
185
- });
186
- describe('parseCanonicalFGA', () => {
187
- const VALID_FGA = {
188
- notation: 'dga',
189
- spec_version: '0.1',
190
- id: 'FGA-SAMPLE-1',
191
- name: 'Sample FGA chain',
192
- factors: [{ id: 'FACTOR-1', name: 'Driver' }],
193
- goals: [{ id: 'GOAL-1', name: 'Outcome', factors: ['FACTOR-1'] }],
194
- actions: [{ id: 'ACTIVITY-1', name: 'Workstream', goals: ['GOAL-1'] }],
195
- };
196
- it('accepts a valid canonical FGA document (no changes layer)', () => {
197
- const r = parseCanonicalFGA(VALID_FGA);
198
- expect(r.valid).toBe(true);
199
- expect(r.errors).toEqual([]);
200
- expect(r.parsed?.factors).toHaveLength(1);
201
- expect(r.parsed?.goals).toHaveLength(1);
202
- expect(r.parsed?.activities).toHaveLength(1);
203
- });
204
- it('accepts ACTION-* ids in FGA mode', () => {
205
- const r = parseCanonicalFGA({
206
- ...VALID_FGA,
207
- actions: [{ id: 'ACTION-GDPR-DSR-WORKFLOW-1', name: 'DSR workflow', goals: ['GOAL-1'] }],
208
- });
209
- expect(r.valid, JSON.stringify(r.errors)).toBe(true);
210
- expect(r.parsed?.activities[0].id).toBe('ACTION-GDPR-DSR-WORKFLOW-1');
211
- });
212
- it('populates activity.goal_id from activity.goals[] (the FGA edge-driving field)', () => {
213
- // The "FGA nodes render, no edges" bug: activities had no resolvable
214
- // goal_id, so the renderer drew no goal → activity edges.
215
- const r = parseCanonicalFGA(VALID_FGA);
216
- expect(r.valid).toBe(true);
217
- expect(r.parsed?.activities[0].goal_id).not.toBeNull();
218
- expect(r.parsed?.activities[0].goal_id).not.toBe(0);
219
- });
220
- it('FGA-001: rejects wrong notation', () => {
221
- const r = parseCanonicalFGA({ ...VALID_FGA, notation: 'fgca' });
222
- expect(r.valid).toBe(false);
223
- expect(r.errors.some((e) => e.code === 'FGA-001')).toBe(true);
224
- });
225
- it('FGA-002: rejects malformed doc id', () => {
226
- const r = parseCanonicalFGA({ ...VALID_FGA, id: 'fga-lower-1' });
227
- expect(r.valid).toBe(false);
228
- expect(r.errors.some((e) => e.code === 'FGA-002')).toBe(true);
229
- });
230
- it('remaps FGCA layer codes into the FGA registry (e.g. FGA-007 for a bad id)', () => {
231
- const r = parseCanonicalFGA({ ...VALID_FGA, factors: [{ id: 'F-1', name: 'bad' }] });
232
- expect(r.valid).toBe(false);
233
- expect(r.errors.some((e) => e.code === 'FGA-007')).toBe(true);
234
- // No raw FGCA-prefixed code should leak through the remap.
235
- expect(r.errors.every((e) => !e.code.startsWith('FGCA-'))).toBe(true);
236
- });
237
- });
238
- describe('parseCanonicalFGCA — example file regression', () => {
239
- const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dgca');
240
- const files = fs.existsSync(EXAMPLES_DIR)
241
- ? fs.readdirSync(EXAMPLES_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
242
- : [];
243
- for (const file of files) {
244
- it(`accepts tests/fixtures/notation-corpus/dgca/${file}`, () => {
245
- const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
246
- const parsedYaml = yaml.load(text);
247
- const r = parseCanonicalFGCA(parsedYaml);
248
- expect(r.errors).toEqual([]);
249
- expect(r.valid).toBe(true);
250
- });
251
- }
252
- });
253
- describe('parseCanonicalFGA — example file regression', () => {
254
- const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dga');
255
- const files = fs.existsSync(EXAMPLES_DIR)
256
- ? fs.readdirSync(EXAMPLES_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
257
- : [];
258
- for (const file of files) {
259
- it(`accepts tests/fixtures/notation-corpus/dga/${file} and resolves every activity to a goal`, () => {
260
- const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
261
- const r = parseCanonicalFGA(yaml.load(text));
262
- expect(r.errors).toEqual([]);
263
- expect(r.valid).toBe(true);
264
- // Every activity must carry a goal_id, or the FGA preview draws no edges.
265
- expect(r.parsed.activities.every((a) => a.goal_id != null && a.goal_id !== 0 && a.goal_id !== '')).toBe(true);
266
- });
267
- }
268
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,106 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { layoutFGCAPreview, FGCA_PAD, FGCA_NODE_W, } from '../preview-layout.js';
3
- const doc = {
4
- factors: [
5
- { id: 1, name: 'F1' },
6
- { id: 2, name: 'F2' },
7
- ],
8
- goals: [
9
- { id: 10, name: 'G1', factor: [{ id: 1 }] },
10
- { id: 11, name: 'G2', factor: [{ id: 2 }] },
11
- ],
12
- changes: [{ id: 20, name: 'C1', goal_id: 10, activity_ids: [30] }],
13
- activities: [
14
- { id: 30, name: 'A1', goal_id: 10 },
15
- { id: 31, name: 'A2', goal_id: 11 },
16
- ],
17
- };
18
- describe('layoutFGCAPreview', () => {
19
- it('lays out all four columns in order (FGCA)', () => {
20
- const layout = layoutFGCAPreview(doc);
21
- expect(layout.columns.map(c => c.col)).toEqual(['driver', 'goal', 'change', 'activity']);
22
- // 2 factors + 2 goals + 1 change + 2 activities
23
- expect(layout.nodes).toHaveLength(7);
24
- expect(layout.width).toBeGreaterThan(0);
25
- expect(layout.height).toBeGreaterThan(0);
26
- });
27
- it('produces the expected FGCA edge set', () => {
28
- // F1→G1, F2→G2 (2), G1→C1 (1), C1→A1 (1), G2→A2 direct (1) = 5
29
- const layout = layoutFGCAPreview(doc);
30
- expect(layout.edges).toHaveLength(5);
31
- });
32
- it('hideChanges (FGA) drops the Changes column and links goals to activities', () => {
33
- const layout = layoutFGCAPreview(doc, { hideChanges: true });
34
- expect(layout.columns.map(c => c.col)).toEqual(['driver', 'goal', 'activity']);
35
- // 2 factors + 2 goals + 2 activities
36
- expect(layout.nodes).toHaveLength(6);
37
- // F1→G1, F2→G2 (2), G1→A1, G2→A2 (2) = 4
38
- expect(layout.edges).toHaveLength(4);
39
- });
40
- it('first column sits at the pad origin', () => {
41
- const layout = layoutFGCAPreview(doc);
42
- expect(layout.columns[0].x).toBe(FGCA_PAD);
43
- });
44
- it('empty options reproduce the default layout', () => {
45
- const a = layoutFGCAPreview(doc);
46
- const b = layoutFGCAPreview(doc, {});
47
- expect(b.nodes.map(n => `${n.id}:${n.x},${n.y}`)).toEqual(a.nodes.map(n => `${n.id}:${n.x},${n.y}`));
48
- });
49
- it('larger colGap widens the column step', () => {
50
- const stepOf = (colGap) => {
51
- const cols = layoutFGCAPreview(doc, { colGap }).columns;
52
- return cols[1].x - cols[0].x;
53
- };
54
- expect(stepOf(80)).toBe(FGCA_NODE_W + 80);
55
- expect(stepOf(240)).toBe(FGCA_NODE_W + 240);
56
- expect(stepOf(240)).toBeGreaterThan(stepOf(80));
57
- });
58
- it('larger rowGap increases the gap between stacked nodes', () => {
59
- const gapOf = (rowGap) => {
60
- const factors = layoutFGCAPreview(doc, { rowGap }).nodes.filter(n => n.col === 'driver');
61
- return factors[1].y - factors[0].y;
62
- };
63
- expect(gapOf(120)).toBeGreaterThan(gapOf(20));
64
- });
65
- // vkgeorgia/strategy#77 — scope filtering. FGCA goals are flat, so 'root'
66
- // selects the single matching goal plus the factors/changes/activities that
67
- // touch it.
68
- describe('scope', () => {
69
- const idsOf = (layout) => new Set(layout.nodes.map(n => n.id));
70
- it("mode 'root' keeps only the root goal and what connects to it", () => {
71
- // root 10 → factor 1 (referenced by G10), change 20 (goal_id 10),
72
- // activity 30 (via change 20). G11/F2/A31 are dropped.
73
- const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '10' } });
74
- expect(idsOf(layout)).toEqual(new Set(['driver_1', 'goal_10', 'change_20', 'activity_30']));
75
- });
76
- it("mode 'root' filters factors and activities to those touching the visible goal", () => {
77
- // root 11 → factor 2, activity 31 (direct goal link); no change touches G11.
78
- const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '11' } });
79
- expect(idsOf(layout)).toEqual(new Set(['driver_2', 'goal_11', 'activity_31']));
80
- // F1, A30, C20 (which only touch the hidden G10) are excluded.
81
- expect(layout.nodes.some(n => n.id === 'driver_1')).toBe(false);
82
- expect(layout.nodes.some(n => n.id === 'activity_30')).toBe(false);
83
- });
84
- it("mode 'level' trims goals above the cap and their connections", () => {
85
- const leveled = {
86
- factors: [{ id: 1, name: 'F1' }, { id: 2, name: 'F2' }],
87
- goals: [
88
- { id: 10, name: 'G1', level: 0, factor: [{ id: 1 }] },
89
- { id: 11, name: 'G2', level: 1, factor: [{ id: 2 }] },
90
- ],
91
- changes: [],
92
- activities: [
93
- { id: 30, name: 'A1', goal_id: 10 },
94
- { id: 31, name: 'A2', goal_id: 11 },
95
- ],
96
- };
97
- const layout = layoutFGCAPreview(leveled, { scope: { mode: 'level', maxLevel: 0 } });
98
- expect(idsOf(layout)).toEqual(new Set(['driver_1', 'goal_10', 'activity_30']));
99
- });
100
- it("mode 'root' returns an empty layout when the root is absent", () => {
101
- const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '999' } });
102
- expect(layout.nodes).toHaveLength(0);
103
- expect(layout.edges).toHaveLength(0);
104
- });
105
- });
106
- });
@@ -1 +0,0 @@
1
- export {};