@transitrix/diagrams 1.8.6 → 1.8.7

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 (247) hide show
  1. package/package.json +7 -2
  2. package/dist/__tests__/edge-path.test.d.ts +0 -1
  3. package/dist/__tests__/edge-path.test.js +0 -55
  4. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  5. package/dist/__tests__/node-size-presets.test.js +0 -30
  6. package/dist/__tests__/scope.test.d.ts +0 -1
  7. package/dist/__tests__/scope.test.js +0 -23
  8. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  9. package/dist/__tests__/yaml-normalize.test.js +0 -148
  10. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  11. package/dist/activities/__tests__/cpm.test.js +0 -146
  12. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  13. package/dist/activities/__tests__/gantt.test.js +0 -263
  14. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  15. package/dist/activities/__tests__/layout.test.js +0 -98
  16. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  17. package/dist/activities/__tests__/validate.test.js +0 -397
  18. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  19. package/dist/activity-card/__tests__/example.test.js +0 -73
  20. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  21. package/dist/activity-card/__tests__/layout.test.js +0 -141
  22. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  23. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  24. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  25. package/dist/activity-card/__tests__/validate.test.js +0 -149
  26. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  27. package/dist/actor/__tests__/validate.test.js +0 -95
  28. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  29. package/dist/applications/__tests__/validate.test.js +0 -223
  30. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  31. package/dist/assertion/__tests__/example.test.js +0 -32
  32. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  33. package/dist/assertion/__tests__/validate.test.js +0 -130
  34. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  35. package/dist/blocks/__tests__/layout.test.js +0 -153
  36. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  37. package/dist/blocks/__tests__/validate.test.js +0 -235
  38. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  39. package/dist/business-service/__tests__/validate.test.js +0 -135
  40. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  41. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  42. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  43. package/dist/capability-map/__tests__/address.test.js +0 -49
  44. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  45. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  46. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  47. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  48. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  49. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  50. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  51. package/dist/capability-map/__tests__/validate.test.js +0 -212
  52. package/dist/change/__tests__/validate.test.d.ts +0 -1
  53. package/dist/change/__tests__/validate.test.js +0 -79
  54. package/dist/codex/__tests__/example.test.d.ts +0 -1
  55. package/dist/codex/__tests__/example.test.js +0 -33
  56. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  57. package/dist/codex/__tests__/validate.test.js +0 -68
  58. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  59. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  60. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  61. package/dist/compliance/__tests__/classify.test.js +0 -58
  62. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  63. package/dist/compliance/__tests__/confidence.test.js +0 -78
  64. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  65. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  66. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  67. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  68. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  69. package/dist/compliance/__tests__/example.test.js +0 -51
  70. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  71. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  72. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  73. package/dist/compliance/__tests__/html.test.js +0 -122
  74. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  75. package/dist/compliance/__tests__/impact.test.js +0 -913
  76. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  77. package/dist/compliance/__tests__/markdown.test.js +0 -85
  78. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  79. package/dist/compliance/__tests__/trace.test.js +0 -144
  80. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  81. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  82. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  83. package/dist/compliance/__tests__/views.test.js +0 -59
  84. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  85. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  86. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  87. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  88. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  89. package/dist/confidence/__tests__/score.test.js +0 -188
  90. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  91. package/dist/constraint/__tests__/example.test.js +0 -14
  92. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  93. package/dist/constraint/__tests__/validate.test.js +0 -58
  94. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  95. package/dist/factor/__tests__/validate.test.js +0 -112
  96. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  97. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  98. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  99. package/dist/fgca/__tests__/layout.test.js +0 -140
  100. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  101. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  102. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  103. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  104. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  105. package/dist/fgca/__tests__/resolver.test.js +0 -185
  106. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  107. package/dist/fgca/__tests__/validate.test.js +0 -125
  108. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  109. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  110. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  111. package/dist/goals/__tests__/layout.test.js +0 -153
  112. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  113. package/dist/goals/__tests__/mutations.test.js +0 -134
  114. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  115. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  116. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  117. package/dist/goals/__tests__/validate.test.js +0 -183
  118. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  119. package/dist/integration/__tests__/validate.test.js +0 -169
  120. package/dist/location/__tests__/validate.test.d.ts +0 -1
  121. package/dist/location/__tests__/validate.test.js +0 -107
  122. package/dist/node/__tests__/validate.test.d.ts +0 -1
  123. package/dist/node/__tests__/validate.test.js +0 -100
  124. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  125. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  126. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  127. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  128. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  129. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  130. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  131. package/dist/process-map/__tests__/validate.test.js +0 -199
  132. package/dist/products/__tests__/validate.test.d.ts +0 -1
  133. package/dist/products/__tests__/validate.test.js +0 -210
  134. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  135. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  136. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  137. package/dist/requirement/__tests__/example.test.js +0 -21
  138. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  139. package/dist/requirement/__tests__/validate.test.js +0 -80
  140. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  141. package/dist/scenarios/__tests__/validate.test.js +0 -183
  142. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  143. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  144. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  145. package/dist/target-state/__tests__/validate.test.js +0 -78
  146. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  147. package/dist/technology-service/__tests__/validate.test.js +0 -121
  148. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  149. package/dist/theme/__tests__/tokens.test.js +0 -159
  150. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  151. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  152. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  153. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  154. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  155. package/dist/webview/__tests__/entry.test.js +0 -56
  156. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  157. package/dist/webview/__tests__/render-activities.test.js +0 -91
  158. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  159. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  160. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  161. package/dist/webview/__tests__/render-goals.test.js +0 -120
  162. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  163. package/dist/webview/__tests__/render-process.test.js +0 -463
  164. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  165. package/dist/webview/__tests__/render-util.test.js +0 -54
  166. package/src/__tests__/edge-path.test.ts +0 -67
  167. package/src/__tests__/node-size-presets.test.ts +0 -50
  168. package/src/__tests__/scope.test.ts +0 -27
  169. package/src/__tests__/yaml-normalize.test.ts +0 -158
  170. package/src/activities/__tests__/cpm.test.ts +0 -164
  171. package/src/activities/__tests__/gantt.test.ts +0 -290
  172. package/src/activities/__tests__/layout.test.ts +0 -112
  173. package/src/activities/__tests__/validate.test.ts +0 -446
  174. package/src/activity-card/__tests__/example.test.ts +0 -83
  175. package/src/activity-card/__tests__/layout.test.ts +0 -162
  176. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  177. package/src/activity-card/__tests__/validate.test.ts +0 -167
  178. package/src/actor/__tests__/validate.test.ts +0 -114
  179. package/src/applications/__tests__/validate.test.ts +0 -256
  180. package/src/assertion/__tests__/example.test.ts +0 -37
  181. package/src/assertion/__tests__/validate.test.ts +0 -142
  182. package/src/blocks/__tests__/layout.test.ts +0 -169
  183. package/src/blocks/__tests__/validate.test.ts +0 -260
  184. package/src/business-service/__tests__/validate.test.ts +0 -160
  185. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  186. package/src/capability-map/__tests__/address.test.ts +0 -59
  187. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  188. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  189. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  190. package/src/capability-map/__tests__/validate.test.ts +0 -238
  191. package/src/change/__tests__/validate.test.ts +0 -97
  192. package/src/codex/__tests__/example.test.ts +0 -40
  193. package/src/codex/__tests__/validate.test.ts +0 -84
  194. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  195. package/src/compliance/__tests__/classify.test.ts +0 -64
  196. package/src/compliance/__tests__/confidence.test.ts +0 -98
  197. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  198. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  199. package/src/compliance/__tests__/example.test.ts +0 -57
  200. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  201. package/src/compliance/__tests__/html.test.ts +0 -142
  202. package/src/compliance/__tests__/impact.test.ts +0 -1060
  203. package/src/compliance/__tests__/markdown.test.ts +0 -95
  204. package/src/compliance/__tests__/trace.test.ts +0 -157
  205. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  206. package/src/compliance/__tests__/views.test.ts +0 -64
  207. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  208. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  209. package/src/confidence/__tests__/score.test.ts +0 -254
  210. package/src/constraint/__tests__/example.test.ts +0 -19
  211. package/src/constraint/__tests__/validate.test.ts +0 -68
  212. package/src/factor/__tests__/validate.test.ts +0 -133
  213. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  214. package/src/fgca/__tests__/layout.test.ts +0 -179
  215. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  216. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  217. package/src/fgca/__tests__/resolver.test.ts +0 -209
  218. package/src/fgca/__tests__/validate.test.ts +0 -142
  219. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  220. package/src/goals/__tests__/layout.test.ts +0 -175
  221. package/src/goals/__tests__/mutations.test.ts +0 -153
  222. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  223. package/src/goals/__tests__/validate.test.ts +0 -202
  224. package/src/integration/__tests__/validate.test.ts +0 -203
  225. package/src/location/__tests__/validate.test.ts +0 -127
  226. package/src/node/__tests__/validate.test.ts +0 -118
  227. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  228. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  229. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  230. package/src/process-map/__tests__/validate.test.ts +0 -223
  231. package/src/products/__tests__/validate.test.ts +0 -239
  232. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  233. package/src/requirement/__tests__/example.test.ts +0 -24
  234. package/src/requirement/__tests__/validate.test.ts +0 -96
  235. package/src/scenarios/__tests__/validate.test.ts +0 -209
  236. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  237. package/src/target-state/__tests__/validate.test.ts +0 -95
  238. package/src/technology-service/__tests__/validate.test.ts +0 -143
  239. package/src/theme/__tests__/tokens.test.ts +0 -185
  240. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  241. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  242. package/src/webview/__tests__/entry.test.ts +0 -64
  243. package/src/webview/__tests__/render-activities.test.ts +0 -100
  244. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  245. package/src/webview/__tests__/render-goals.test.ts +0 -128
  246. package/src/webview/__tests__/render-process.test.ts +0 -538
  247. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1,209 +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 { resolveFGCA, isFGCAViewDoc } from '../resolver.js';
6
- import { parseCanonicalFGCA } from '../parse-canonical.js';
7
-
8
- // ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
9
-
10
- const ELEMENTS = [
11
- { notation: 'driver', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
12
- { notation: 'driver', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
13
- { notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
14
- { notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
15
- { notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
16
- { notation: 'change', id: 'CHANGE-1', name: 'Launch new product line', goals: ['GOAL-1'] },
17
- { notation: 'change', id: 'CHANGE-2', name: 'Automate manual processes', goals: ['GOAL-2'] },
18
- { notation: 'change', id: 'CHANGE-3', name: 'Enhance support platform', goals: ['GOAL-3'] },
19
- { notation: 'activity', id: 'ACTIVITY-1', name: 'Market research', changes: ['CHANGE-1'] },
20
- { notation: 'activity', id: 'ACTIVITY-2', name: 'MVP development', changes: ['CHANGE-1'] },
21
- { notation: 'activity', id: 'ACTIVITY-3', name: 'Process audit', changes: ['CHANGE-2'] },
22
- { notation: 'activity', id: 'ACTIVITY-4', name: 'RPA tooling rollout', changes: ['CHANGE-2'] },
23
- { notation: 'activity', id: 'ACTIVITY-5', name: 'CRM implementation', changes: ['CHANGE-3'] },
24
- ];
25
-
26
- const SOURCES = { elements: ELEMENTS, relations: [] };
27
-
28
- const VIEW_DOC = {
29
- notation: 'dgca',
30
- id: 'FGCA-STRAT-1',
31
- name: 'Strategy 2026 — FGCA chain',
32
- spec_version: '0.1',
33
- view_config: {
34
- goals: { filter: 'all' },
35
- factors: { surface: 'derived' },
36
- changes: { surface: 'derived' },
37
- activities: { surface: 'derived' },
38
- },
39
- };
40
-
41
- // ── isFGCAViewDoc ─────────────────────────────────────────────────────────────
42
-
43
- describe('isFGCAViewDoc', () => {
44
- it('returns true for a view_config-based doc', () => {
45
- expect(isFGCAViewDoc(VIEW_DOC)).toBe(true);
46
- });
47
-
48
- it('returns false for an inline doc with factors/goals arrays', () => {
49
- expect(isFGCAViewDoc({
50
- notation: 'dgca', id: 'FGCA-1', name: 'x',
51
- factors: [], goals: [], changes: [], activities: [],
52
- })).toBe(false);
53
- });
54
-
55
- it('returns false for non-objects', () => {
56
- expect(isFGCAViewDoc(null)).toBe(false);
57
- expect(isFGCAViewDoc('string')).toBe(false);
58
- expect(isFGCAViewDoc(42)).toBe(false);
59
- });
60
- });
61
-
62
- // ── resolveFGCA — goals.filter=all (default) ──────────────────────────────────
63
-
64
- describe('resolveFGCA — goals.filter=all', () => {
65
- it('includes all goals, changes, and activities', () => {
66
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
67
- expect((doc['goals'] as unknown[]).length).toBe(3);
68
- expect((doc['changes'] as unknown[]).length).toBe(3);
69
- expect((doc['actions'] as unknown[]).length).toBe(5);
70
- });
71
-
72
- it('derives factors from all goal.factors[] refs', () => {
73
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
74
- const factorIds = (doc['factors'] as Array<{ id: string }>).map((f) => f.id);
75
- expect(factorIds).toContain('FACTOR-1');
76
- expect(factorIds).toContain('FACTOR-2');
77
- expect(factorIds.length).toBe(2);
78
- });
79
-
80
- it('passes parseCanonicalFGCA and produces a fully valid internal doc', () => {
81
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
82
- const r = parseCanonicalFGCA(doc);
83
- expect(r.valid).toBe(true);
84
- expect(r.errors).toEqual([]);
85
- expect(r.parsed?.goals).toHaveLength(3);
86
- expect(r.parsed?.factors).toHaveLength(2);
87
- expect(r.parsed?.changes).toHaveLength(3);
88
- expect(r.parsed?.activities).toHaveLength(5);
89
- });
90
-
91
- it('carries view doc metadata (id, name, spec_version)', () => {
92
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
93
- expect(doc['notation']).toBe('dgca');
94
- expect(doc['id']).toBe('FGCA-STRAT-1');
95
- expect(doc['name']).toBe('Strategy 2026 — FGCA chain');
96
- expect(doc['spec_version']).toBe('0.1');
97
- });
98
- });
99
-
100
- // ── resolveFGCA — goals.filter=ids ────────────────────────────────────────────
101
-
102
- describe('resolveFGCA — goals.filter=ids', () => {
103
- it('narrows to the specified goal and its derived changes + activities', () => {
104
- const viewDoc = {
105
- ...VIEW_DOC,
106
- view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
107
- };
108
- const doc = resolveFGCA(viewDoc, SOURCES);
109
- const goalIds = (doc['goals'] as Array<{ id: string }>).map((g) => g.id);
110
- expect(goalIds).toEqual(['GOAL-1']);
111
- const changeIds = (doc['changes'] as Array<{ id: string }>).map((c) => c.id);
112
- expect(changeIds).toEqual(['CHANGE-1']);
113
- const actIds = (doc['actions'] as Array<{ id: string }>).map((a) => a.id).sort();
114
- expect(actIds).toEqual(['ACTIVITY-1', 'ACTIVITY-2']);
115
- const r = parseCanonicalFGCA(doc);
116
- expect(r.valid).toBe(true);
117
- });
118
-
119
- it('returns empty arrays when none of the requested ids exist in canon', () => {
120
- const viewDoc = {
121
- ...VIEW_DOC,
122
- view_config: { goals: { filter: 'ids', ids: ['GOAL-NONEXISTENT-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
123
- };
124
- const doc = resolveFGCA(viewDoc, SOURCES);
125
- expect((doc['goals'] as unknown[]).length).toBe(0);
126
- expect((doc['changes'] as unknown[]).length).toBe(0);
127
- expect((doc['factors'] as unknown[]).length).toBe(0);
128
- });
129
- });
130
-
131
- // ── resolveFGCA — surface=all ─────────────────────────────────────────────────
132
-
133
- describe('resolveFGCA — surface=all', () => {
134
- it('factors.surface=all includes every factor even when only some are referenced', () => {
135
- const viewDoc = {
136
- ...VIEW_DOC,
137
- view_config: { goals: { filter: 'ids', ids: ['GOAL-3'] }, factors: { surface: 'all' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
138
- };
139
- const doc = resolveFGCA(viewDoc, SOURCES);
140
- // GOAL-3 only references FACTOR-1, but surface=all → both factors
141
- expect((doc['factors'] as unknown[]).length).toBe(2);
142
- });
143
-
144
- it('changes.surface=all includes every change', () => {
145
- const viewDoc = {
146
- ...VIEW_DOC,
147
- view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'all' }, activities: { surface: 'derived' } },
148
- };
149
- const doc = resolveFGCA(viewDoc, SOURCES);
150
- expect((doc['changes'] as unknown[]).length).toBe(3);
151
- });
152
- });
153
-
154
- // ── resolveFGCA — empty / degenerate inputs ───────────────────────────────────
155
-
156
- describe('resolveFGCA — empty sources', () => {
157
- it('returns empty arrays when canon has no elements', () => {
158
- const doc = resolveFGCA(VIEW_DOC, { elements: [], relations: [] });
159
- expect((doc['goals'] as unknown[]).length).toBe(0);
160
- expect((doc['factors'] as unknown[]).length).toBe(0);
161
- expect((doc['changes'] as unknown[]).length).toBe(0);
162
- expect((doc['actions'] as unknown[]).length).toBe(0);
163
- });
164
-
165
- it('returns empty arrays for a non-object viewDoc', () => {
166
- const doc = resolveFGCA(null, SOURCES);
167
- expect((doc['goals'] as unknown[]).length).toBe(0);
168
- });
169
- });
170
-
171
- // ── File-based regression — resolver + canon fixture + parseCanonicalFGCA ─────
172
-
173
- describe('resolveFGCA — file-based regression against canon fixture', () => {
174
- const CANON_ROOT = path.resolve(
175
- process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dgca', 'canon',
176
- );
177
- const VIEW_DIR = path.join(CANON_ROOT, 'views');
178
- const ELEM_DIR = path.join(CANON_ROOT, 'elements');
179
-
180
- function loadYamlsUnder(dir: string): unknown[] {
181
- if (!fs.existsSync(dir)) return [];
182
- const out: unknown[] = [];
183
- function walk(d: string) {
184
- for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
185
- const full = path.join(d, entry.name);
186
- if (entry.isDirectory()) { walk(full); }
187
- else if (entry.name.endsWith('.yaml')) { out.push(yaml.load(fs.readFileSync(full, 'utf8'))); }
188
- }
189
- }
190
- walk(dir);
191
- return out;
192
- }
193
-
194
- const viewFiles = fs.existsSync(VIEW_DIR)
195
- ? fs.readdirSync(VIEW_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
196
- : [];
197
-
198
- for (const file of viewFiles) {
199
- it(`resolves ${file} against canon fixtures and passes parseCanonicalFGCA`, () => {
200
- const viewDoc = yaml.load(fs.readFileSync(path.join(VIEW_DIR, file), 'utf8'));
201
- expect(isFGCAViewDoc(viewDoc)).toBe(true);
202
- const elements = loadYamlsUnder(ELEM_DIR);
203
- const doc = resolveFGCA(viewDoc, { elements, relations: [] });
204
- const r = parseCanonicalFGCA(doc);
205
- expect(r.valid).toBe(true);
206
- expect(r.errors).toEqual([]);
207
- });
208
- }
209
- });
@@ -1,142 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { validateFGCADoc } from '../validate.js';
3
-
4
- const VALID_DOC = {
5
- notation: 'dgca',
6
- factors: [{ id: 1, name: 'Market pressure' }],
7
- goals: [{ id: 1, name: 'Grow revenue', factor: [{ id: 1 }] }],
8
- changes: [{ id: 1, name: 'Launch product', goal_id: 1, activity_ids: [1] }],
9
- actions: [{ id: 1, name: 'Market research', goal_id: 1 }],
10
- };
11
-
12
- describe('validateFGCADoc', () => {
13
- it('accepts a valid document', () => {
14
- const result = validateFGCADoc(VALID_DOC);
15
- expect(result.valid).toBe(true);
16
- expect(result.errors).toHaveLength(0);
17
- });
18
-
19
- it('rejects non-object input', () => {
20
- expect(validateFGCADoc('string').valid).toBe(false);
21
- expect(validateFGCADoc(null).valid).toBe(false);
22
- expect(validateFGCADoc(42).valid).toBe(false);
23
- });
24
-
25
- it('errors on missing notation field', () => {
26
- const { notation: _, ...without } = VALID_DOC;
27
- const result = validateFGCADoc(without);
28
- expect(result.valid).toBe(false);
29
- expect(result.errors[0].code).toBe('MISSING_NOTATION');
30
- });
31
-
32
- it('errors on wrong notation value', () => {
33
- const result = validateFGCADoc({ ...VALID_DOC, notation: 'goals' });
34
- expect(result.valid).toBe(false);
35
- expect(result.errors[0].code).toBe('WRONG_NOTATION');
36
- });
37
-
38
- it('errors when factors array is missing', () => {
39
- const { factors: _, ...without } = VALID_DOC;
40
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
41
- expect(result.valid).toBe(false);
42
- expect(result.errors.some(e => e.path === 'factors')).toBe(true);
43
- });
44
-
45
- it('errors when goals array is missing', () => {
46
- const { goals: _, ...without } = VALID_DOC;
47
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
48
- expect(result.valid).toBe(false);
49
- expect(result.errors.some(e => e.path === 'goals')).toBe(true);
50
- });
51
-
52
- it('errors when changes array is missing', () => {
53
- const { changes: _, ...without } = VALID_DOC;
54
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
55
- expect(result.valid).toBe(false);
56
- expect(result.errors.some(e => e.path === 'changes')).toBe(true);
57
- });
58
-
59
- it('errors when actions array is missing', () => {
60
- const { actions: _, ...without } = VALID_DOC;
61
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
62
- expect(result.valid).toBe(false);
63
- expect(result.errors.some(e => e.path === 'actions')).toBe(true);
64
- });
65
-
66
- it('errors on empty factor name', () => {
67
- const result = validateFGCADoc({ ...VALID_DOC, factors: [{ id: 1, name: '' }] });
68
- expect(result.valid).toBe(false);
69
- expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
70
- });
71
-
72
- it('errors on empty goal name', () => {
73
- const result = validateFGCADoc({ ...VALID_DOC, goals: [{ id: 1, name: ' ', factor: [] }] });
74
- expect(result.valid).toBe(false);
75
- expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
76
- });
77
-
78
- it('warns on broken factor reference in goal', () => {
79
- const result = validateFGCADoc({
80
- ...VALID_DOC,
81
- goals: [{ id: 1, name: 'Goal', factor: [{ id: 99 }] }],
82
- });
83
- expect(result.valid).toBe(true);
84
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('factor 99'))).toBe(true);
85
- });
86
-
87
- it('warns on broken goal reference in change', () => {
88
- const result = validateFGCADoc({
89
- ...VALID_DOC,
90
- changes: [{ id: 1, name: 'Change', goal_id: 99, activity_ids: [] }],
91
- });
92
- expect(result.valid).toBe(true);
93
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('goal 99'))).toBe(true);
94
- });
95
-
96
- it('warns on broken activity reference in change', () => {
97
- const result = validateFGCADoc({
98
- ...VALID_DOC,
99
- changes: [{ id: 1, name: 'Change', goal_id: 1, activity_ids: [99] }],
100
- });
101
- expect(result.valid).toBe(true);
102
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('activity 99'))).toBe(true);
103
- });
104
-
105
- it('accepts a document with empty arrays', () => {
106
- const result = validateFGCADoc({
107
- notation: 'dgca',
108
- factors: [],
109
- goals: [],
110
- changes: [],
111
- actions: [],
112
- });
113
- expect(result.valid).toBe(true);
114
- });
115
-
116
- it('accepts optional spec_version field', () => {
117
- const result = validateFGCADoc({ ...VALID_DOC, spec_version: '0.1' });
118
- expect(result.valid).toBe(true);
119
- });
120
-
121
- // Pre-release blocker regression (orchestrator review 2026-05-21).
122
- it('[blocker] tolerates a null element in goals[] without throwing', () => {
123
- const r = validateFGCADoc({ ...VALID_DOC, goals: [null] });
124
- expect(r.valid).toBe(false);
125
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
126
- });
127
- it('[blocker] tolerates a string element in factors[] without throwing', () => {
128
- const r = validateFGCADoc({ ...VALID_DOC, factors: ['x'] });
129
- expect(r.valid).toBe(false);
130
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
131
- });
132
- it('[blocker] tolerates a null element in changes[] without throwing', () => {
133
- const r = validateFGCADoc({ ...VALID_DOC, changes: [null] });
134
- expect(r.valid).toBe(false);
135
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
136
- });
137
- it('[blocker] tolerates a null element in actions[] without throwing', () => {
138
- const r = validateFGCADoc({ ...VALID_DOC, actions: [null] });
139
- expect(r.valid).toBe(false);
140
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
141
- });
142
- });