@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,175 +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
- import { renderBlocksSvg } from '../render-blocks.js';
11
- import { CHAR_W_PRIMARY as CHAR_W, CHAR_W_ID, TEXT_MARGIN_X } from '../entity-text-layout.js';
12
- import { ENTITY_NODE_SIZE } from '../../node-size-presets.js';
13
- const LEAF_W = ENTITY_NODE_SIZE.normal.width;
14
- const LEAF_H = ENTITY_NODE_SIZE.normal.height;
15
- function leafDoc(name, id) {
16
- return {
17
- notation: 'blocks',
18
- spec_version: '0.1',
19
- nested_blocks: {
20
- id: 'BLOCKS-T-1',
21
- name: 'Test',
22
- blocks: [{ id, name }],
23
- },
24
- };
25
- }
26
- function containerDoc(name, id, childId = 'CHILD', childName = 'Child') {
27
- return {
28
- notation: 'blocks',
29
- spec_version: '0.1',
30
- nested_blocks: {
31
- id: 'BLOCKS-T-1',
32
- name: 'Test',
33
- blocks: [
34
- {
35
- id,
36
- name,
37
- children: [{ id: childId, name: childName }],
38
- },
39
- ],
40
- },
41
- };
42
- }
43
- /** Pull every text-primary / text-id line out of an SVG, in document order. */
44
- function extractLabels(svg) {
45
- const re = /<text class="(text-(?:primary|id))"[^>]*>([^<]*)<\/text>/g;
46
- const out = [];
47
- let m;
48
- while ((m = re.exec(svg)))
49
- out.push({ cls: m[1], text: m[2] });
50
- return out;
51
- }
52
- /** Extract {class, y} for each text element in SVG document order. */
53
- function extractTextY(svg) {
54
- const re = /<text class="(text-(?:primary|id))"[^>]*\by="([^"]+)"/g;
55
- const out = [];
56
- let m;
57
- while ((m = re.exec(svg)))
58
- out.push({ cls: m[1], y: parseFloat(m[2]) });
59
- return out;
60
- }
61
- describe('renderBlocksSvg — leaf labels', () => {
62
- it('wraps a long name to at most 3 lines and truncates with …', () => {
63
- const longName = 'Personal data records that linger after consent withdrawal across many systems and ' +
64
- 'archives — known erasure gap';
65
- const svg = renderBlocksSvg(leafDoc(longName, 'PII'));
66
- const nameLines = extractLabels(svg).filter((l) => l.cls === 'text-primary');
67
- expect(nameLines.length).toBeGreaterThan(0);
68
- expect(nameLines.length).toBeLessThanOrEqual(3);
69
- // If the name needed truncation, the final visible line must end with `…`.
70
- if (nameLines.length === 3) {
71
- expect(nameLines[2].text.endsWith('…')).toBe(true);
72
- }
73
- });
74
- it('wraps a long ID to at most 2 lines and truncates with …', () => {
75
- const longId = 'VERY_LONG_BLOCK_IDENTIFIER_WITH_MANY_SEGMENTS_AND_MORE_AND_MORE_EXTRA_TAIL_TO_FORCE_TRUNCATION';
76
- const svg = renderBlocksSvg(leafDoc('Short name', longId));
77
- const idLines = extractLabels(svg).filter((l) => l.cls === 'text-id');
78
- expect(idLines.length).toBeGreaterThan(0);
79
- expect(idLines.length).toBeLessThanOrEqual(2);
80
- if (idLines.length === 2) {
81
- expect(idLines[1].text.endsWith('…')).toBe(true);
82
- }
83
- });
84
- it(`keeps every label inside the ${LEAF_W}px leaf width (approximated by CHAR_W * length)`, () => {
85
- const svg = renderBlocksSvg(leafDoc('Personal data records that linger after consent withdrawal across many systems', 'PII_RECORDS_WITH_A_FAIRLY_LONG_IDENTIFIER_HERE'));
86
- const labels = extractLabels(svg);
87
- const inner = LEAF_W - TEXT_MARGIN_X * 2;
88
- for (const l of labels) {
89
- const cw = l.cls === 'text-primary' ? CHAR_W : CHAR_W_ID;
90
- expect(l.text.length * cw).toBeLessThanOrEqual(inner);
91
- }
92
- });
93
- });
94
- describe('renderBlocksSvg — container headers', () => {
95
- it('renders the name and ID as two separate stacked text elements', () => {
96
- const svg = renderBlocksSvg(containerDoc('Active systems', 'ACTIVE_SYSTEMS'));
97
- const labels = extractLabels(svg);
98
- // Container header contributes one text-primary (name) and one text-id (id);
99
- // the leaf child contributes another pair. So 2 of each kind in total.
100
- const primaries = labels.filter((l) => l.cls === 'text-primary').map((l) => l.text);
101
- const ids = labels.filter((l) => l.cls === 'text-id').map((l) => l.text);
102
- expect(primaries).toContain('Active systems');
103
- expect(ids).toContain('ACTIVE_SYSTEMS');
104
- // The legacy "(id)" suffix on the name line must not appear — id has its own row.
105
- for (const t of primaries)
106
- expect(t).not.toContain('(');
107
- });
108
- it('truncates a long container ID so it does not overflow the block width', () => {
109
- const svg = renderBlocksSvg(containerDoc('Short name', 'VERY_LONG_CONTAINER_IDENTIFIER_THAT_WOULD_OTHERWISE_OVERFLOW', 'CHILD', 'Child'));
110
- const labels = extractLabels(svg);
111
- // Container width derives from its single leaf child: leafW + 2×padding.
112
- const containerW = LEAF_W + 24;
113
- const inner = containerW - TEXT_MARGIN_X * 2;
114
- for (const l of labels) {
115
- const cw = l.cls === 'text-primary' ? CHAR_W : CHAR_W_ID;
116
- expect(l.text.length * cw).toBeLessThanOrEqual(inner);
117
- }
118
- // The full ID was too long to fit on one line of `inner / CHAR_W_ID` chars, so
119
- // the rendered ID must be the truncated form ending in `…`.
120
- const renderedIds = labels.filter((l) => l.cls === 'text-id').map((l) => l.text);
121
- expect(renderedIds.some((t) => t.endsWith('…'))).toBe(true);
122
- });
123
- it('truncates a long container name with … to fit the block width', () => {
124
- const longName = 'Active systems that are erasure-reachable within the standard 30-day operational window';
125
- const svg = renderBlocksSvg(containerDoc(longName, 'ACTIVE'));
126
- const labels = extractLabels(svg);
127
- const containerW = LEAF_W + 24;
128
- const inner = containerW - TEXT_MARGIN_X * 2;
129
- const primaries = labels.filter((l) => l.cls === 'text-primary');
130
- for (const l of primaries) {
131
- expect(l.text.length * CHAR_W).toBeLessThanOrEqual(inner);
132
- }
133
- // At least one primary line must have been truncated.
134
- expect(primaries.some((l) => l.text.endsWith('…'))).toBe(true);
135
- });
136
- });
137
- describe('renderBlocksSvg — name/ID vertical overlap regression (follows-up on #419)', () => {
138
- // Root cause: NAME_ID_GAP was 6 px. text-primary is 12 px tall (±6 px around
139
- // centre) and text-id is 10 px tall (±5 px around centre). The minimum gap
140
- // between centres to avoid overlap is 11 px; a gap of 6 caused 5 px of overlap.
141
- // Fix: NAME_ID_GAP = 14 (3 px visual buffer, matching the gap between name lines).
142
- const NAME_HALF_H = 6; // half of text-primary font size (12 px)
143
- const ID_HALF_H = 5; // half of text-id font size (10 px)
144
- it('leaf node: last name line bottom does not overlap first ID line top (1 name + 1 ID)', () => {
145
- const svg = renderBlocksSvg(leafDoc('Short', 'BLK-1'));
146
- const positions = extractTextY(svg);
147
- const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
148
- const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
149
- expect(nameY.length).toBeGreaterThan(0);
150
- expect(idY.length).toBeGreaterThan(0);
151
- const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
152
- const firstIdTop = Math.min(...idY) - ID_HALF_H;
153
- expect(firstIdTop).toBeGreaterThan(lastNameBottom);
154
- });
155
- it('leaf node: no overlap with a 3-word name (2 name lines + 1 ID)', () => {
156
- const svg = renderBlocksSvg(leafDoc('Three Word Name', 'BLK-001'));
157
- const positions = extractTextY(svg);
158
- const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
159
- const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
160
- const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
161
- const firstIdTop = Math.min(...idY) - ID_HALF_H;
162
- expect(firstIdTop).toBeGreaterThan(lastNameBottom);
163
- });
164
- it('leaf node: no overlap with a long name (3 name lines) and wrapped ID (2 lines)', () => {
165
- const longName = 'Personal data records that linger after consent withdrawal across many systems and archives';
166
- const longId = 'VERY_LONG_BLOCK_IDENTIFIER_WITH_MANY_SEGMENTS_AND_MORE';
167
- const svg = renderBlocksSvg(leafDoc(longName, longId));
168
- const positions = extractTextY(svg);
169
- const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
170
- const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
171
- const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
172
- const firstIdTop = Math.min(...idY) - ID_HALF_H;
173
- expect(firstIdTop).toBeGreaterThan(lastNameBottom);
174
- });
175
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,120 +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
- import { renderGoalsSvg } from '../render-goals.js';
9
- const SIMPLE_TREE = {
10
- goal_types: [
11
- { name: 'Strategy', level: 0 },
12
- { name: 'Tactic', level: 1 },
13
- ],
14
- goals: [
15
- { id: 1, name: 'Reach the moon', type: 'Strategy', level: 0, parent_id: 0 },
16
- { id: 2, name: 'Build a rocket', type: 'Tactic', level: 1, parent_id: 1 },
17
- ],
18
- };
19
- describe('renderGoalsSvg', () => {
20
- it('produces a self-contained <svg> with embedded theme CSS', () => {
21
- const svg = renderGoalsSvg(SIMPLE_TREE, { treeName: 'Apollo' });
22
- expect(svg.startsWith('<svg ')).toBe(true);
23
- expect(svg).toContain('xmlns="http://www.w3.org/2000/svg"');
24
- expect(svg).toContain('<style>');
25
- // The shared theme CSS contract: diagram classes are defined inline.
26
- expect(svg).toContain('.diagram-node');
27
- expect(svg).toContain('.diagram-edge');
28
- // Both goal names made it into the output.
29
- expect(svg).toContain('Reach the moon');
30
- expect(svg).toContain('Build a rocket');
31
- // The strategy → tactic parent link rendered as an edge with the arrow marker.
32
- expect(svg).toContain('marker-end="url(#arrow)"');
33
- // Title block is present when treeName is supplied.
34
- expect(svg).toContain('Goal tree — Apollo');
35
- });
36
- it('escapes user-controlled strings (XML safety)', () => {
37
- const tree = {
38
- goal_types: [{ name: 'Strategy', level: 0 }],
39
- goals: [
40
- {
41
- id: 1,
42
- name: 'Drop <script>alert(1)</script> & friends',
43
- type: 'Strategy',
44
- level: 0,
45
- parent_id: 0,
46
- },
47
- ],
48
- };
49
- const svg = renderGoalsSvg(tree);
50
- expect(svg).not.toContain('<script>alert(1)</script>');
51
- expect(svg).toContain('&lt;script&gt;');
52
- expect(svg).toContain('&amp;');
53
- });
54
- it('returns an empty SVG when the tree has no goals', () => {
55
- const empty = { goal_types: [{ name: 'Strategy', level: 0 }], goals: [] };
56
- const svg = renderGoalsSvg(empty);
57
- expect(svg).toContain('<svg ');
58
- expect(svg).toContain('width="0"');
59
- expect(svg).toContain('height="0"');
60
- });
61
- it('renders name, type, and id on separate lines without overlap', () => {
62
- const tree = {
63
- goal_types: [
64
- { name: 'Strategic', level: 0 },
65
- { name: 'Objective', level: 1 },
66
- ],
67
- goals: [
68
- {
69
- id: 1,
70
- canonical_id: 'GOAL-VALUE-1',
71
- name: 'Grow enterprise value',
72
- type: 'Strategic',
73
- level: 0,
74
- parent_id: 0,
75
- },
76
- {
77
- id: 2,
78
- canonical_id: 'GOAL-COST-1',
79
- name: 'Reduce run cost 20%',
80
- type: 'Objective',
81
- level: 1,
82
- parent_id: 1,
83
- },
84
- ],
85
- };
86
- const svg = renderGoalsSvg(tree);
87
- expect(svg).toContain('Grow enterprise value');
88
- expect(svg).toContain('Strategic');
89
- expect(svg).toContain('GOAL-VALUE-1');
90
- const typeMatches = [...svg.matchAll(/class="text-secondary"[^>]*y="(\d+)"/g)];
91
- const nameMatches = [...svg.matchAll(/class="text-primary"[^>]*y="(\d+)"/g)];
92
- expect(typeMatches.length).toBeGreaterThan(0);
93
- for (const type of typeMatches) {
94
- const typeY = Number(type[1]);
95
- const nearestName = nameMatches
96
- .map((m) => Number(m[1]))
97
- .filter((y) => y < typeY)
98
- .sort((a, b) => b - a)[0];
99
- expect(typeY - nearestName).toBeGreaterThanOrEqual(18);
100
- }
101
- });
102
- it('shows canonical goal ids in node labels when present', () => {
103
- const tree = {
104
- goal_types: [{ name: 'Strategy', level: 0 }],
105
- goals: [
106
- {
107
- id: 1,
108
- canonical_id: 'GOAL-REVENUE-1',
109
- name: 'Triple revenue',
110
- type: 'Strategy',
111
- level: 0,
112
- parent_id: 0,
113
- },
114
- ],
115
- };
116
- const svg = renderGoalsSvg(tree);
117
- expect(svg).toContain('GOAL-REVENUE-1');
118
- expect(svg).not.toMatch(/>\s*1\s*</);
119
- });
120
- });
@@ -1 +0,0 @@
1
- export {};