@transitrix/diagrams 1.8.4 → 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 (254) hide show
  1. package/dist/edge-path.js +10 -1
  2. package/dist/webview/render-activities.d.ts +1 -1
  3. package/dist/webview/render-activities.js +2 -2
  4. package/dist/webview/render-fgca.js +1 -4
  5. package/package.json +7 -2
  6. package/src/edge-path.ts +15 -1
  7. package/src/webview/render-activities.ts +2 -2
  8. package/src/webview/render-fgca.ts +1 -4
  9. package/dist/__tests__/edge-path.test.d.ts +0 -1
  10. package/dist/__tests__/edge-path.test.js +0 -47
  11. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  12. package/dist/__tests__/node-size-presets.test.js +0 -30
  13. package/dist/__tests__/scope.test.d.ts +0 -1
  14. package/dist/__tests__/scope.test.js +0 -23
  15. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  16. package/dist/__tests__/yaml-normalize.test.js +0 -148
  17. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  18. package/dist/activities/__tests__/cpm.test.js +0 -146
  19. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  20. package/dist/activities/__tests__/gantt.test.js +0 -263
  21. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  22. package/dist/activities/__tests__/layout.test.js +0 -98
  23. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  24. package/dist/activities/__tests__/validate.test.js +0 -397
  25. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  26. package/dist/activity-card/__tests__/example.test.js +0 -73
  27. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  28. package/dist/activity-card/__tests__/layout.test.js +0 -141
  29. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  30. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  31. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  32. package/dist/activity-card/__tests__/validate.test.js +0 -149
  33. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  34. package/dist/actor/__tests__/validate.test.js +0 -95
  35. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  36. package/dist/applications/__tests__/validate.test.js +0 -223
  37. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  38. package/dist/assertion/__tests__/example.test.js +0 -32
  39. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  40. package/dist/assertion/__tests__/validate.test.js +0 -130
  41. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  42. package/dist/blocks/__tests__/layout.test.js +0 -153
  43. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  44. package/dist/blocks/__tests__/validate.test.js +0 -235
  45. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  46. package/dist/business-service/__tests__/validate.test.js +0 -135
  47. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  48. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  49. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  50. package/dist/capability-map/__tests__/address.test.js +0 -49
  51. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  52. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  53. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  54. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  55. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  56. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  57. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  58. package/dist/capability-map/__tests__/validate.test.js +0 -212
  59. package/dist/change/__tests__/validate.test.d.ts +0 -1
  60. package/dist/change/__tests__/validate.test.js +0 -79
  61. package/dist/codex/__tests__/example.test.d.ts +0 -1
  62. package/dist/codex/__tests__/example.test.js +0 -33
  63. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  64. package/dist/codex/__tests__/validate.test.js +0 -68
  65. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  66. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  67. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  68. package/dist/compliance/__tests__/classify.test.js +0 -58
  69. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  70. package/dist/compliance/__tests__/confidence.test.js +0 -78
  71. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  72. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  73. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  74. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  75. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  76. package/dist/compliance/__tests__/example.test.js +0 -51
  77. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  78. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  79. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  80. package/dist/compliance/__tests__/html.test.js +0 -122
  81. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  82. package/dist/compliance/__tests__/impact.test.js +0 -913
  83. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  84. package/dist/compliance/__tests__/markdown.test.js +0 -85
  85. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  86. package/dist/compliance/__tests__/trace.test.js +0 -144
  87. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  88. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  89. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  90. package/dist/compliance/__tests__/views.test.js +0 -59
  91. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  92. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  93. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  94. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  95. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  96. package/dist/confidence/__tests__/score.test.js +0 -188
  97. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  98. package/dist/constraint/__tests__/example.test.js +0 -14
  99. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  100. package/dist/constraint/__tests__/validate.test.js +0 -58
  101. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  102. package/dist/factor/__tests__/validate.test.js +0 -112
  103. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  104. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  105. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  106. package/dist/fgca/__tests__/layout.test.js +0 -140
  107. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  108. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  109. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  110. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  111. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  112. package/dist/fgca/__tests__/resolver.test.js +0 -185
  113. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  114. package/dist/fgca/__tests__/validate.test.js +0 -125
  115. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  116. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  117. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  118. package/dist/goals/__tests__/layout.test.js +0 -153
  119. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  120. package/dist/goals/__tests__/mutations.test.js +0 -134
  121. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  122. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  123. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  124. package/dist/goals/__tests__/validate.test.js +0 -183
  125. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  126. package/dist/integration/__tests__/validate.test.js +0 -169
  127. package/dist/location/__tests__/validate.test.d.ts +0 -1
  128. package/dist/location/__tests__/validate.test.js +0 -107
  129. package/dist/node/__tests__/validate.test.d.ts +0 -1
  130. package/dist/node/__tests__/validate.test.js +0 -100
  131. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  132. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  133. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  134. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  135. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  136. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  137. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  138. package/dist/process-map/__tests__/validate.test.js +0 -199
  139. package/dist/products/__tests__/validate.test.d.ts +0 -1
  140. package/dist/products/__tests__/validate.test.js +0 -210
  141. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  142. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  143. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  144. package/dist/requirement/__tests__/example.test.js +0 -21
  145. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  146. package/dist/requirement/__tests__/validate.test.js +0 -80
  147. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  148. package/dist/scenarios/__tests__/validate.test.js +0 -183
  149. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  150. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  151. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  152. package/dist/target-state/__tests__/validate.test.js +0 -78
  153. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  154. package/dist/technology-service/__tests__/validate.test.js +0 -121
  155. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  156. package/dist/theme/__tests__/tokens.test.js +0 -159
  157. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  158. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  159. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  160. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  161. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  162. package/dist/webview/__tests__/entry.test.js +0 -56
  163. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  164. package/dist/webview/__tests__/render-activities.test.js +0 -91
  165. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  166. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  167. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  168. package/dist/webview/__tests__/render-goals.test.js +0 -120
  169. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  170. package/dist/webview/__tests__/render-process.test.js +0 -463
  171. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  172. package/dist/webview/__tests__/render-util.test.js +0 -54
  173. package/src/__tests__/edge-path.test.ts +0 -58
  174. package/src/__tests__/node-size-presets.test.ts +0 -50
  175. package/src/__tests__/scope.test.ts +0 -27
  176. package/src/__tests__/yaml-normalize.test.ts +0 -158
  177. package/src/activities/__tests__/cpm.test.ts +0 -164
  178. package/src/activities/__tests__/gantt.test.ts +0 -290
  179. package/src/activities/__tests__/layout.test.ts +0 -112
  180. package/src/activities/__tests__/validate.test.ts +0 -446
  181. package/src/activity-card/__tests__/example.test.ts +0 -83
  182. package/src/activity-card/__tests__/layout.test.ts +0 -162
  183. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  184. package/src/activity-card/__tests__/validate.test.ts +0 -167
  185. package/src/actor/__tests__/validate.test.ts +0 -114
  186. package/src/applications/__tests__/validate.test.ts +0 -256
  187. package/src/assertion/__tests__/example.test.ts +0 -37
  188. package/src/assertion/__tests__/validate.test.ts +0 -142
  189. package/src/blocks/__tests__/layout.test.ts +0 -169
  190. package/src/blocks/__tests__/validate.test.ts +0 -260
  191. package/src/business-service/__tests__/validate.test.ts +0 -160
  192. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  193. package/src/capability-map/__tests__/address.test.ts +0 -59
  194. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  195. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  196. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  197. package/src/capability-map/__tests__/validate.test.ts +0 -238
  198. package/src/change/__tests__/validate.test.ts +0 -97
  199. package/src/codex/__tests__/example.test.ts +0 -40
  200. package/src/codex/__tests__/validate.test.ts +0 -84
  201. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  202. package/src/compliance/__tests__/classify.test.ts +0 -64
  203. package/src/compliance/__tests__/confidence.test.ts +0 -98
  204. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  205. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  206. package/src/compliance/__tests__/example.test.ts +0 -57
  207. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  208. package/src/compliance/__tests__/html.test.ts +0 -142
  209. package/src/compliance/__tests__/impact.test.ts +0 -1060
  210. package/src/compliance/__tests__/markdown.test.ts +0 -95
  211. package/src/compliance/__tests__/trace.test.ts +0 -157
  212. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  213. package/src/compliance/__tests__/views.test.ts +0 -64
  214. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  215. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  216. package/src/confidence/__tests__/score.test.ts +0 -254
  217. package/src/constraint/__tests__/example.test.ts +0 -19
  218. package/src/constraint/__tests__/validate.test.ts +0 -68
  219. package/src/factor/__tests__/validate.test.ts +0 -133
  220. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  221. package/src/fgca/__tests__/layout.test.ts +0 -179
  222. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  223. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  224. package/src/fgca/__tests__/resolver.test.ts +0 -209
  225. package/src/fgca/__tests__/validate.test.ts +0 -142
  226. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  227. package/src/goals/__tests__/layout.test.ts +0 -175
  228. package/src/goals/__tests__/mutations.test.ts +0 -153
  229. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  230. package/src/goals/__tests__/validate.test.ts +0 -202
  231. package/src/integration/__tests__/validate.test.ts +0 -203
  232. package/src/location/__tests__/validate.test.ts +0 -127
  233. package/src/node/__tests__/validate.test.ts +0 -118
  234. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  235. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  236. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  237. package/src/process-map/__tests__/validate.test.ts +0 -223
  238. package/src/products/__tests__/validate.test.ts +0 -239
  239. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  240. package/src/requirement/__tests__/example.test.ts +0 -24
  241. package/src/requirement/__tests__/validate.test.ts +0 -96
  242. package/src/scenarios/__tests__/validate.test.ts +0 -209
  243. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  244. package/src/target-state/__tests__/validate.test.ts +0 -95
  245. package/src/technology-service/__tests__/validate.test.ts +0 -143
  246. package/src/theme/__tests__/tokens.test.ts +0 -185
  247. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  248. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  249. package/src/webview/__tests__/entry.test.ts +0 -64
  250. package/src/webview/__tests__/render-activities.test.ts +0 -100
  251. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  252. package/src/webview/__tests__/render-goals.test.ts +0 -128
  253. package/src/webview/__tests__/render-process.test.ts +0 -538
  254. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1,206 +0,0 @@
1
- /**
2
- * Unit tests for the host-neutral nested-blocks SVG renderer used by both the
3
- * VS Code blocks preview and the IntelliJ JCEF webview bundle. These tests pin
4
- * the per-node label rule (CLAUDE.md "Entity block layout"): leaf nodes wrap
5
- * the name to at most 3 lines and the ID to at most 2 lines, with `…`
6
- * truncation beyond that; container headers stack name + ID, each truncated
7
- * with `…` to fit the block width. No label may extend past the rect.
8
- */
9
- import { describe, expect, it } from 'vitest';
10
-
11
- import type { BlocksFile } from '../../blocks/types.js';
12
- import { renderBlocksSvg } from '../render-blocks.js';
13
- import { CHAR_W_PRIMARY as CHAR_W, CHAR_W_ID, TEXT_MARGIN_X } from '../entity-text-layout.js';
14
- import { ENTITY_NODE_SIZE } from '../../node-size-presets.js';
15
-
16
- const LEAF_W = ENTITY_NODE_SIZE.normal.width;
17
- const LEAF_H = ENTITY_NODE_SIZE.normal.height;
18
-
19
- function leafDoc(name: string, id: string): BlocksFile {
20
- return {
21
- notation: 'blocks',
22
- spec_version: '0.1',
23
- nested_blocks: {
24
- id: 'BLOCKS-T-1',
25
- name: 'Test',
26
- blocks: [{ id, name }],
27
- },
28
- };
29
- }
30
-
31
- function containerDoc(name: string, id: string, childId = 'CHILD', childName = 'Child'): BlocksFile {
32
- return {
33
- notation: 'blocks',
34
- spec_version: '0.1',
35
- nested_blocks: {
36
- id: 'BLOCKS-T-1',
37
- name: 'Test',
38
- blocks: [
39
- {
40
- id,
41
- name,
42
- children: [{ id: childId, name: childName }],
43
- },
44
- ],
45
- },
46
- };
47
- }
48
-
49
- /** Pull every text-primary / text-id line out of an SVG, in document order. */
50
- function extractLabels(svg: string): Array<{ cls: string; text: string }> {
51
- const re = /<text class="(text-(?:primary|id))"[^>]*>([^<]*)<\/text>/g;
52
- const out: Array<{ cls: string; text: string }> = [];
53
- let m: RegExpExecArray | null;
54
- while ((m = re.exec(svg))) out.push({ cls: m[1], text: m[2] });
55
- return out;
56
- }
57
-
58
- /** Extract {class, y} for each text element in SVG document order. */
59
- function extractTextY(svg: string): Array<{ cls: string; y: number }> {
60
- const re = /<text class="(text-(?:primary|id))"[^>]*\by="([^"]+)"/g;
61
- const out: Array<{ cls: string; y: number }> = [];
62
- let m: RegExpExecArray | null;
63
- while ((m = re.exec(svg))) out.push({ cls: m[1], y: parseFloat(m[2]) });
64
- return out;
65
- }
66
-
67
- describe('renderBlocksSvg — leaf labels', () => {
68
- it('wraps a long name to at most 3 lines and truncates with …', () => {
69
- const longName =
70
- 'Personal data records that linger after consent withdrawal across many systems and ' +
71
- 'archives — known erasure gap';
72
- const svg = renderBlocksSvg(leafDoc(longName, 'PII'));
73
- const nameLines = extractLabels(svg).filter((l) => l.cls === 'text-primary');
74
- expect(nameLines.length).toBeGreaterThan(0);
75
- expect(nameLines.length).toBeLessThanOrEqual(3);
76
- // If the name needed truncation, the final visible line must end with `…`.
77
- if (nameLines.length === 3) {
78
- expect(nameLines[2].text.endsWith('…')).toBe(true);
79
- }
80
- });
81
-
82
- it('wraps a long ID to at most 2 lines and truncates with …', () => {
83
- const longId =
84
- 'VERY_LONG_BLOCK_IDENTIFIER_WITH_MANY_SEGMENTS_AND_MORE_AND_MORE_EXTRA_TAIL_TO_FORCE_TRUNCATION';
85
- const svg = renderBlocksSvg(leafDoc('Short name', longId));
86
- const idLines = extractLabels(svg).filter((l) => l.cls === 'text-id');
87
- expect(idLines.length).toBeGreaterThan(0);
88
- expect(idLines.length).toBeLessThanOrEqual(2);
89
- if (idLines.length === 2) {
90
- expect(idLines[1].text.endsWith('…')).toBe(true);
91
- }
92
- });
93
-
94
- it(`keeps every label inside the ${LEAF_W}px leaf width (approximated by CHAR_W * length)`, () => {
95
- const svg = renderBlocksSvg(
96
- leafDoc(
97
- 'Personal data records that linger after consent withdrawal across many systems',
98
- 'PII_RECORDS_WITH_A_FAIRLY_LONG_IDENTIFIER_HERE',
99
- ),
100
- );
101
- const labels = extractLabels(svg);
102
- const inner = LEAF_W - TEXT_MARGIN_X * 2;
103
- for (const l of labels) {
104
- const cw = l.cls === 'text-primary' ? CHAR_W : CHAR_W_ID;
105
- expect(l.text.length * cw).toBeLessThanOrEqual(inner);
106
- }
107
- });
108
- });
109
-
110
- describe('renderBlocksSvg — container headers', () => {
111
- it('renders the name and ID as two separate stacked text elements', () => {
112
- const svg = renderBlocksSvg(containerDoc('Active systems', 'ACTIVE_SYSTEMS'));
113
- const labels = extractLabels(svg);
114
- // Container header contributes one text-primary (name) and one text-id (id);
115
- // the leaf child contributes another pair. So 2 of each kind in total.
116
- const primaries = labels.filter((l) => l.cls === 'text-primary').map((l) => l.text);
117
- const ids = labels.filter((l) => l.cls === 'text-id').map((l) => l.text);
118
- expect(primaries).toContain('Active systems');
119
- expect(ids).toContain('ACTIVE_SYSTEMS');
120
- // The legacy "(id)" suffix on the name line must not appear — id has its own row.
121
- for (const t of primaries) expect(t).not.toContain('(');
122
- });
123
-
124
- it('truncates a long container ID so it does not overflow the block width', () => {
125
- const svg = renderBlocksSvg(
126
- containerDoc(
127
- 'Short name',
128
- 'VERY_LONG_CONTAINER_IDENTIFIER_THAT_WOULD_OTHERWISE_OVERFLOW',
129
- 'CHILD',
130
- 'Child',
131
- ),
132
- );
133
- const labels = extractLabels(svg);
134
- // Container width derives from its single leaf child: leafW + 2×padding.
135
- const containerW = LEAF_W + 24;
136
- const inner = containerW - TEXT_MARGIN_X * 2;
137
- for (const l of labels) {
138
- const cw = l.cls === 'text-primary' ? CHAR_W : CHAR_W_ID;
139
- expect(l.text.length * cw).toBeLessThanOrEqual(inner);
140
- }
141
- // The full ID was too long to fit on one line of `inner / CHAR_W_ID` chars, so
142
- // the rendered ID must be the truncated form ending in `…`.
143
- const renderedIds = labels.filter((l) => l.cls === 'text-id').map((l) => l.text);
144
- expect(renderedIds.some((t) => t.endsWith('…'))).toBe(true);
145
- });
146
-
147
- it('truncates a long container name with … to fit the block width', () => {
148
- const longName =
149
- 'Active systems that are erasure-reachable within the standard 30-day operational window';
150
- const svg = renderBlocksSvg(containerDoc(longName, 'ACTIVE'));
151
- const labels = extractLabels(svg);
152
- const containerW = LEAF_W + 24;
153
- const inner = containerW - TEXT_MARGIN_X * 2;
154
- const primaries = labels.filter((l) => l.cls === 'text-primary');
155
- for (const l of primaries) {
156
- expect(l.text.length * CHAR_W).toBeLessThanOrEqual(inner);
157
- }
158
- // At least one primary line must have been truncated.
159
- expect(primaries.some((l) => l.text.endsWith('…'))).toBe(true);
160
- });
161
- });
162
-
163
- describe('renderBlocksSvg — name/ID vertical overlap regression (follows-up on #419)', () => {
164
- // Root cause: NAME_ID_GAP was 6 px. text-primary is 12 px tall (±6 px around
165
- // centre) and text-id is 10 px tall (±5 px around centre). The minimum gap
166
- // between centres to avoid overlap is 11 px; a gap of 6 caused 5 px of overlap.
167
- // Fix: NAME_ID_GAP = 14 (3 px visual buffer, matching the gap between name lines).
168
-
169
- const NAME_HALF_H = 6; // half of text-primary font size (12 px)
170
- const ID_HALF_H = 5; // half of text-id font size (10 px)
171
-
172
- it('leaf node: last name line bottom does not overlap first ID line top (1 name + 1 ID)', () => {
173
- const svg = renderBlocksSvg(leafDoc('Short', 'BLK-1'));
174
- const positions = extractTextY(svg);
175
- const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
176
- const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
177
- expect(nameY.length).toBeGreaterThan(0);
178
- expect(idY.length).toBeGreaterThan(0);
179
- const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
180
- const firstIdTop = Math.min(...idY) - ID_HALF_H;
181
- expect(firstIdTop).toBeGreaterThan(lastNameBottom);
182
- });
183
-
184
- it('leaf node: no overlap with a 3-word name (2 name lines + 1 ID)', () => {
185
- const svg = renderBlocksSvg(leafDoc('Three Word Name', 'BLK-001'));
186
- const positions = extractTextY(svg);
187
- const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
188
- const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
189
- const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
190
- const firstIdTop = Math.min(...idY) - ID_HALF_H;
191
- expect(firstIdTop).toBeGreaterThan(lastNameBottom);
192
- });
193
-
194
- it('leaf node: no overlap with a long name (3 name lines) and wrapped ID (2 lines)', () => {
195
- const longName =
196
- 'Personal data records that linger after consent withdrawal across many systems and archives';
197
- const longId = 'VERY_LONG_BLOCK_IDENTIFIER_WITH_MANY_SEGMENTS_AND_MORE';
198
- const svg = renderBlocksSvg(leafDoc(longName, longId));
199
- const positions = extractTextY(svg);
200
- const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
201
- const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
202
- const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
203
- const firstIdTop = Math.min(...idY) - ID_HALF_H;
204
- expect(firstIdTop).toBeGreaterThan(lastNameBottom);
205
- });
206
- });
@@ -1,128 +0,0 @@
1
- /**
2
- * Unit tests for the host-neutral goals SVG renderer used by the IntelliJ
3
- * JCEF preview bundle. The IntelliJ build can't run inside Vitest, so these
4
- * tests are the only place the goals rendering path is exercised on the
5
- * webview-bundle side of the codebase.
6
- */
7
- import { describe, expect, it } from 'vitest';
8
-
9
- import type { GoalTree } from '../../goals/types.js';
10
- import { renderGoalsSvg } from '../render-goals.js';
11
-
12
- const SIMPLE_TREE: GoalTree = {
13
- goal_types: [
14
- { name: 'Strategy', level: 0 },
15
- { name: 'Tactic', level: 1 },
16
- ],
17
- goals: [
18
- { id: 1, name: 'Reach the moon', type: 'Strategy', level: 0, parent_id: 0 },
19
- { id: 2, name: 'Build a rocket', type: 'Tactic', level: 1, parent_id: 1 },
20
- ],
21
- };
22
-
23
- describe('renderGoalsSvg', () => {
24
- it('produces a self-contained <svg> with embedded theme CSS', () => {
25
- const svg = renderGoalsSvg(SIMPLE_TREE, { treeName: 'Apollo' });
26
- expect(svg.startsWith('<svg ')).toBe(true);
27
- expect(svg).toContain('xmlns="http://www.w3.org/2000/svg"');
28
- expect(svg).toContain('<style>');
29
- // The shared theme CSS contract: diagram classes are defined inline.
30
- expect(svg).toContain('.diagram-node');
31
- expect(svg).toContain('.diagram-edge');
32
- // Both goal names made it into the output.
33
- expect(svg).toContain('Reach the moon');
34
- expect(svg).toContain('Build a rocket');
35
- // The strategy → tactic parent link rendered as an edge with the arrow marker.
36
- expect(svg).toContain('marker-end="url(#arrow)"');
37
- // Title block is present when treeName is supplied.
38
- expect(svg).toContain('Goal tree — Apollo');
39
- });
40
-
41
- it('escapes user-controlled strings (XML safety)', () => {
42
- const tree: GoalTree = {
43
- goal_types: [{ name: 'Strategy', level: 0 }],
44
- goals: [
45
- {
46
- id: 1,
47
- name: 'Drop <script>alert(1)</script> & friends',
48
- type: 'Strategy',
49
- level: 0,
50
- parent_id: 0,
51
- },
52
- ],
53
- };
54
- const svg = renderGoalsSvg(tree);
55
- expect(svg).not.toContain('<script>alert(1)</script>');
56
- expect(svg).toContain('&lt;script&gt;');
57
- expect(svg).toContain('&amp;');
58
- });
59
-
60
- it('returns an empty SVG when the tree has no goals', () => {
61
- const empty: GoalTree = { goal_types: [{ name: 'Strategy', level: 0 }], goals: [] };
62
- const svg = renderGoalsSvg(empty);
63
- expect(svg).toContain('<svg ');
64
- expect(svg).toContain('width="0"');
65
- expect(svg).toContain('height="0"');
66
- });
67
-
68
- it('renders name, type, and id on separate lines without overlap', () => {
69
- const tree: GoalTree = {
70
- goal_types: [
71
- { name: 'Strategic', level: 0 },
72
- { name: 'Objective', level: 1 },
73
- ],
74
- goals: [
75
- {
76
- id: 1,
77
- canonical_id: 'GOAL-VALUE-1',
78
- name: 'Grow enterprise value',
79
- type: 'Strategic',
80
- level: 0,
81
- parent_id: 0,
82
- },
83
- {
84
- id: 2,
85
- canonical_id: 'GOAL-COST-1',
86
- name: 'Reduce run cost 20%',
87
- type: 'Objective',
88
- level: 1,
89
- parent_id: 1,
90
- },
91
- ],
92
- };
93
- const svg = renderGoalsSvg(tree);
94
- expect(svg).toContain('Grow enterprise value');
95
- expect(svg).toContain('Strategic');
96
- expect(svg).toContain('GOAL-VALUE-1');
97
- const typeMatches = [...svg.matchAll(/class="text-secondary"[^>]*y="(\d+)"/g)];
98
- const nameMatches = [...svg.matchAll(/class="text-primary"[^>]*y="(\d+)"/g)];
99
- expect(typeMatches.length).toBeGreaterThan(0);
100
- for (const type of typeMatches) {
101
- const typeY = Number(type[1]);
102
- const nearestName = nameMatches
103
- .map((m) => Number(m[1]))
104
- .filter((y) => y < typeY)
105
- .sort((a, b) => b - a)[0];
106
- expect(typeY - nearestName).toBeGreaterThanOrEqual(18);
107
- }
108
- });
109
-
110
- it('shows canonical goal ids in node labels when present', () => {
111
- const tree: GoalTree = {
112
- goal_types: [{ name: 'Strategy', level: 0 }],
113
- goals: [
114
- {
115
- id: 1,
116
- canonical_id: 'GOAL-REVENUE-1',
117
- name: 'Triple revenue',
118
- type: 'Strategy',
119
- level: 0,
120
- parent_id: 0,
121
- },
122
- ],
123
- };
124
- const svg = renderGoalsSvg(tree);
125
- expect(svg).toContain('GOAL-REVENUE-1');
126
- expect(svg).not.toMatch(/>\s*1\s*</);
127
- });
128
- });