@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,235 +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 { validateNestedBlocks } from '../validate.js';
6
- const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'blocks');
7
- const VALID_DOC = {
8
- notation: 'blocks',
9
- spec_version: '0.1',
10
- nested_blocks: {
11
- id: 'BLOCKS-ARCH-1',
12
- name: 'Software architecture',
13
- blocks: [
14
- {
15
- id: 'APPLICATION_LAYER',
16
- name: 'Application Layer',
17
- children: [
18
- { id: 'FRONTEND', name: 'Frontend' },
19
- { id: 'BACKEND', name: 'Backend' },
20
- ],
21
- },
22
- {
23
- id: 'DATA_LAYER',
24
- name: 'Data Layer',
25
- children: [
26
- { id: 'POSTGRESQL', name: 'PostgreSQL' },
27
- { id: 'REDIS_CACHE', name: 'Redis Cache' },
28
- ],
29
- },
30
- ],
31
- },
32
- };
33
- describe('validateNestedBlocks', () => {
34
- it('passes on a valid document', () => {
35
- const r = validateNestedBlocks(VALID_DOC);
36
- expect(r.valid).toBe(true);
37
- expect(r.errors).toHaveLength(0);
38
- });
39
- it('BL-001: rejects non-object input', () => {
40
- expect(validateNestedBlocks(null).valid).toBe(false);
41
- expect(validateNestedBlocks(null).errors[0].code).toBe('BL-001');
42
- expect(validateNestedBlocks('string').errors[0].code).toBe('BL-001');
43
- });
44
- it('BL-001: rejects missing nested_blocks root key', () => {
45
- const r = validateNestedBlocks({ notation: 'blocks' });
46
- expect(r.errors.some((e) => e.code === 'BL-001')).toBe(true);
47
- });
48
- it('BL-001: rejects wrong notation value', () => {
49
- const r = validateNestedBlocks({ ...VALID_DOC, notation: 'goals' });
50
- expect(r.errors.some((e) => e.code === 'BL-001')).toBe(true);
51
- });
52
- it('BL-001: tolerates a missing notation field (header check is contract-level)', () => {
53
- const { notation: _, ...rest } = VALID_DOC;
54
- const r = validateNestedBlocks(rest);
55
- expect(r.errors.some((e) => e.code === 'BL-001')).toBe(false);
56
- });
57
- it('BL-002: rejects missing id', () => {
58
- const r = validateNestedBlocks({
59
- ...VALID_DOC,
60
- nested_blocks: { ...VALID_DOC.nested_blocks, id: '' },
61
- });
62
- expect(r.errors.some((e) => e.code === 'BL-002')).toBe(true);
63
- });
64
- it('BL-002: rejects id that does not match BLOCKS grammar', () => {
65
- const r = validateNestedBlocks({
66
- ...VALID_DOC,
67
- nested_blocks: { ...VALID_DOC.nested_blocks, id: 'BLK-1' },
68
- });
69
- expect(r.errors.some((e) => e.code === 'BL-002')).toBe(true);
70
- });
71
- it('BL-003: rejects missing name', () => {
72
- const r = validateNestedBlocks({
73
- ...VALID_DOC,
74
- nested_blocks: { ...VALID_DOC.nested_blocks, name: '' },
75
- });
76
- expect(r.errors.some((e) => e.code === 'BL-003')).toBe(true);
77
- });
78
- it('BL-004: rejects missing blocks array', () => {
79
- const { blocks: _, ...rest } = VALID_DOC.nested_blocks;
80
- const r = validateNestedBlocks({ ...VALID_DOC, nested_blocks: rest });
81
- expect(r.errors.some((e) => e.code === 'BL-004')).toBe(true);
82
- });
83
- it('BL-004: rejects empty blocks array', () => {
84
- const r = validateNestedBlocks({
85
- ...VALID_DOC,
86
- nested_blocks: { ...VALID_DOC.nested_blocks, blocks: [] },
87
- });
88
- expect(r.errors.some((e) => e.code === 'BL-004')).toBe(true);
89
- });
90
- it('BL-005: rejects block missing id', () => {
91
- const r = validateNestedBlocks({
92
- ...VALID_DOC,
93
- nested_blocks: {
94
- ...VALID_DOC.nested_blocks,
95
- blocks: [{ name: 'Anonymous' }],
96
- },
97
- });
98
- expect(r.errors.some((e) => e.code === 'BL-005' && /id/.test(e.message))).toBe(true);
99
- });
100
- it('BL-005: rejects block missing name', () => {
101
- const r = validateNestedBlocks({
102
- ...VALID_DOC,
103
- nested_blocks: {
104
- ...VALID_DOC.nested_blocks,
105
- blocks: [{ id: 'X', name: '' }],
106
- },
107
- });
108
- expect(r.errors.some((e) => e.code === 'BL-005' && /name/.test(e.message))).toBe(true);
109
- });
110
- it('BL-005: rejects an id with whitespace (not a valid free label)', () => {
111
- const r = validateNestedBlocks({
112
- ...VALID_DOC,
113
- nested_blocks: {
114
- ...VALID_DOC.nested_blocks,
115
- blocks: [{ id: 'bad id', name: 'X' }],
116
- },
117
- });
118
- expect(r.errors.some((e) => e.code === 'BL-005' && /whitespace/.test(e.message))).toBe(true);
119
- });
120
- it('BL-006: rejects a canonical-shaped id whose TYPE is not registered', () => {
121
- const r = validateNestedBlocks({
122
- ...VALID_DOC,
123
- nested_blocks: {
124
- ...VALID_DOC.nested_blocks,
125
- blocks: [{ id: 'XYZ-SOMETHING-1', name: 'X' }],
126
- },
127
- });
128
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(true);
129
- });
130
- it('BL-006: accepts canonical ids with registered TYPE (APPLICATION-OMS-1)', () => {
131
- const r = validateNestedBlocks({
132
- ...VALID_DOC,
133
- nested_blocks: {
134
- ...VALID_DOC.nested_blocks,
135
- blocks: [{ id: 'APPLICATION-OMS-1', name: 'OMS' }],
136
- },
137
- });
138
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(false);
139
- });
140
- it('BL-006: accepts the CAPABILITY V/H exception (CAPABILITY-V1.2)', () => {
141
- const r = validateNestedBlocks({
142
- ...VALID_DOC,
143
- nested_blocks: {
144
- ...VALID_DOC.nested_blocks,
145
- blocks: [{ id: 'CAPABILITY-V1.2', name: 'Order intake' }],
146
- },
147
- });
148
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(false);
149
- });
150
- it('BL-006: accepts free-form local labels (APPLICATION_LAYER, frontend, my-thing)', () => {
151
- const r = validateNestedBlocks({
152
- ...VALID_DOC,
153
- nested_blocks: {
154
- ...VALID_DOC.nested_blocks,
155
- blocks: [
156
- { id: 'APPLICATION_LAYER', name: 'AL' },
157
- { id: 'my-thing', name: 'MT' },
158
- { id: 'FRONTEND', name: 'FE' },
159
- ],
160
- },
161
- });
162
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(false);
163
- });
164
- it('BL-007: rejects duplicate ids anywhere in the tree', () => {
165
- const r = validateNestedBlocks({
166
- ...VALID_DOC,
167
- nested_blocks: {
168
- ...VALID_DOC.nested_blocks,
169
- blocks: [
170
- {
171
- id: 'A',
172
- name: 'A',
173
- children: [{ id: 'A', name: 'A again' }],
174
- },
175
- ],
176
- },
177
- });
178
- expect(r.errors.some((e) => e.code === 'BL-007' && /Duplicate/.test(e.message))).toBe(true);
179
- });
180
- it('BL-008: warns when nesting exceeds depth 5', () => {
181
- // 6-deep chain: blocks[0] (depth 1) → c → c → c → c → c (depth 6)
182
- let inner = { id: 'L6', name: 'L6' };
183
- for (const id of ['L5', 'L4', 'L3', 'L2', 'L1']) {
184
- inner = { id, name: id, children: [inner] };
185
- }
186
- const r = validateNestedBlocks({
187
- ...VALID_DOC,
188
- nested_blocks: { ...VALID_DOC.nested_blocks, blocks: [inner] },
189
- });
190
- expect(r.warnings.some((w) => w.code === 'BL-008')).toBe(true);
191
- expect(r.valid).toBe(true);
192
- });
193
- it('BL-008: does not warn at exactly depth 5', () => {
194
- let inner = { id: 'L5', name: 'L5' };
195
- for (const id of ['L4', 'L3', 'L2', 'L1']) {
196
- inner = { id, name: id, children: [inner] };
197
- }
198
- const r = validateNestedBlocks({
199
- ...VALID_DOC,
200
- nested_blocks: { ...VALID_DOC.nested_blocks, blocks: [inner] },
201
- });
202
- expect(r.warnings.some((w) => w.code === 'BL-008')).toBe(false);
203
- });
204
- it('BL-009: warns on an empty children array', () => {
205
- const r = validateNestedBlocks({
206
- ...VALID_DOC,
207
- nested_blocks: {
208
- ...VALID_DOC.nested_blocks,
209
- blocks: [{ id: 'A', name: 'A', children: [] }],
210
- },
211
- });
212
- expect(r.warnings.some((w) => w.code === 'BL-009')).toBe(true);
213
- expect(r.valid).toBe(true);
214
- });
215
- it('happy path: surfaces no warnings on a clean document', () => {
216
- const r = validateNestedBlocks(VALID_DOC);
217
- expect(r.valid).toBe(true);
218
- expect(r.warnings).toHaveLength(0);
219
- });
220
- });
221
- describe('blocks examples (regression)', () => {
222
- const files = fs.existsSync(EXAMPLES_DIR)
223
- ? fs.readdirSync(EXAMPLES_DIR).filter((f) => f.endsWith('.yaml'))
224
- : [];
225
- expect(files.length).toBeGreaterThan(0);
226
- for (const file of files) {
227
- it(`validates tests/fixtures/notation-corpus/blocks/${file}`, () => {
228
- const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
229
- const parsed = yaml.load(text);
230
- const r = validateNestedBlocks(parsed);
231
- expect(r.errors).toEqual([]);
232
- expect(r.valid).toBe(true);
233
- });
234
- }
235
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,135 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { validateBusinessService } from '../validate.js';
3
- function valid() {
4
- return {
5
- notation: 'business-service',
6
- id: 'BUSINESS_SERVICE-CRM-1',
7
- name: 'CRM Service',
8
- type: 'internal',
9
- description: 'Customer relationship management service offering contact management and deal tracking.',
10
- offering_unit: 'ACTOR-SALES-OPS-1',
11
- capability: 'CAPABILITY-V2.1',
12
- zone: 'canon',
13
- admitted_at: '2026-06-28',
14
- admitted_by: 'v.korobeinikov',
15
- gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
16
- valid_from: '2024-01-01',
17
- valid_to: null,
18
- };
19
- }
20
- const codes = (input) => validateBusinessService(input).errors.map(e => e.code);
21
- describe('validateBusinessService — positive', () => {
22
- it('accepts a well-formed internal service with all optional fields', () => {
23
- const r = validateBusinessService(valid());
24
- expect(r.valid, JSON.stringify(r.errors)).toBe(true);
25
- });
26
- it('accepts an external service with no optional fields', () => {
27
- const a = valid();
28
- a.id = 'BUSINESS_SERVICE-ONBOARDING-1';
29
- a.name = 'Onboarding Service';
30
- a.type = 'external';
31
- delete a.description;
32
- delete a.offering_unit;
33
- delete a.capability;
34
- expect(validateBusinessService(a).valid).toBe(true);
35
- });
36
- it('accepts a shared service offered by a ROLE', () => {
37
- expect(validateBusinessService({ ...valid(), type: 'shared', offering_unit: 'ROLE-PLATFORM-OWNER-1' }).valid).toBe(true);
38
- });
39
- it('accepts valid_to as a date string', () => {
40
- expect(validateBusinessService({ ...valid(), valid_to: '2026-12-31' }).valid).toBe(true);
41
- });
42
- it('accepts a service with no offering_unit or capability', () => {
43
- const a = valid();
44
- delete a.offering_unit;
45
- delete a.capability;
46
- expect(validateBusinessService(a).valid).toBe(true);
47
- });
48
- });
49
- describe('validateBusinessService — BSV-001 (shape / id grammar)', () => {
50
- it('flags a missing required envelope field (name)', () => {
51
- const a = valid();
52
- delete a.name;
53
- expect(codes(a)).toContain('BSV-001');
54
- });
55
- it('flags an id that violates the grammar', () => {
56
- expect(codes({ ...valid(), id: 'BUSINESS_SERVICE-001' })).toContain('BSV-001');
57
- expect(codes({ ...valid(), id: 'BSV-1' })).toContain('BSV-001');
58
- expect(codes({ ...valid(), id: 'business-service-1' })).toContain('BSV-001');
59
- });
60
- it('flags a wrong notation tag', () => {
61
- expect(codes({ ...valid(), notation: 'service' })).toContain('BSV-001');
62
- expect(codes({ ...valid(), notation: 'business_service' })).toContain('BSV-001');
63
- });
64
- it('flags a non-canon zone', () => {
65
- expect(codes({ ...valid(), zone: 'sandbox' })).toContain('BSV-001');
66
- });
67
- it('flags a missing zone', () => {
68
- const a = valid();
69
- delete a.zone;
70
- expect(codes(a)).toContain('BSV-001');
71
- });
72
- it('flags a missing type', () => {
73
- const a = valid();
74
- delete a.type;
75
- expect(codes(a)).toContain('BSV-001');
76
- });
77
- it('flags a missing valid_to key', () => {
78
- const a = valid();
79
- delete a.valid_to;
80
- expect(codes(a)).toContain('BSV-001');
81
- });
82
- it('flags missing gate_checks', () => {
83
- const a = valid();
84
- delete a.gate_checks;
85
- expect(codes(a)).toContain('BSV-001');
86
- });
87
- it('rejects a non-object', () => {
88
- expect(codes(null)).toEqual(['BSV-001']);
89
- expect(codes('string')).toEqual(['BSV-001']);
90
- });
91
- });
92
- describe('validateBusinessService — BSV-002 (type enum)', () => {
93
- it('flags a type outside the allowed enum', () => {
94
- expect(codes({ ...valid(), type: 'public' })).toContain('BSV-002');
95
- expect(codes({ ...valid(), type: 'platform' })).toContain('BSV-002');
96
- });
97
- it('accepts all valid type values', () => {
98
- for (const t of ['internal', 'external', 'shared']) {
99
- expect(codes({ ...valid(), type: t })).not.toContain('BSV-002');
100
- }
101
- });
102
- });
103
- describe('validateBusinessService — BSV-003 (offering_unit grammar)', () => {
104
- it('flags an offering_unit that is not an ACTOR-… or ROLE-… id', () => {
105
- expect(codes({ ...valid(), offering_unit: 'PRODUCT-PLATFORM-1' })).toContain('BSV-003');
106
- expect(codes({ ...valid(), offering_unit: 'not-an-id' })).toContain('BSV-003');
107
- expect(codes({ ...valid(), offering_unit: 'BUSINESS_SERVICE-CRM-1' })).toContain('BSV-003');
108
- });
109
- it('accepts a null or absent offering_unit without error', () => {
110
- expect(codes({ ...valid(), offering_unit: undefined })).not.toContain('BSV-003');
111
- const a = valid();
112
- delete a.offering_unit;
113
- expect(codes(a)).not.toContain('BSV-003');
114
- });
115
- it('accepts ACTOR-… and ROLE-… ids', () => {
116
- expect(codes({ ...valid(), offering_unit: 'ACTOR-OPS-1' })).not.toContain('BSV-003');
117
- expect(codes({ ...valid(), offering_unit: 'ROLE-SERVICE-OWNER-1' })).not.toContain('BSV-003');
118
- });
119
- });
120
- describe('validateBusinessService — BSV-004 (capability grammar)', () => {
121
- it('flags a capability that is not a CAPABILITY-… id', () => {
122
- expect(codes({ ...valid(), capability: 'PRODUCT-MOBILE-1' })).toContain('BSV-004');
123
- expect(codes({ ...valid(), capability: 'not-a-capability' })).toContain('BSV-004');
124
- });
125
- it('accepts a null or absent capability without error', () => {
126
- expect(codes({ ...valid(), capability: undefined })).not.toContain('BSV-004');
127
- const a = valid();
128
- delete a.capability;
129
- expect(codes(a)).not.toContain('BSV-004');
130
- });
131
- it('accepts a CAPABILITY-… id', () => {
132
- expect(codes({ ...valid(), capability: 'CAPABILITY-V2.1' })).not.toContain('BSV-004');
133
- expect(codes({ ...valid(), capability: 'CAPABILITY-H3.1' })).not.toContain('BSV-004');
134
- });
135
- });
@@ -1,217 +0,0 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _MockResizeObserver_callback;
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
- // @vitest-environment jsdom
15
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
16
- import { render, screen, cleanup, waitFor } from '@testing-library/react';
17
- import { CapabilityMapView, computeDragOutcome } from '../CapabilityMapView.js';
18
- // See goals/__tests__/GoalTreeView.test.tsx for why these three shims are
19
- // needed — reactflow keeps a node `visibility: hidden` (and inert to
20
- // drag/measurement logic) until ResizeObserver reports its size, and reads
21
- // the computed transform back out via DOMMatrixReadOnly; jsdom has neither.
22
- class MockResizeObserver {
23
- constructor(callback) {
24
- _MockResizeObserver_callback.set(this, void 0);
25
- __classPrivateFieldSet(this, _MockResizeObserver_callback, callback, "f");
26
- }
27
- observe(target) {
28
- queueMicrotask(() => {
29
- __classPrivateFieldGet(this, _MockResizeObserver_callback, "f").call(this, [{ target, contentRect: target.getBoundingClientRect() }], this);
30
- });
31
- }
32
- unobserve() { }
33
- disconnect() { }
34
- }
35
- _MockResizeObserver_callback = new WeakMap();
36
- class MockDOMMatrixReadOnly {
37
- constructor(transform) {
38
- this.m41 = 0;
39
- this.m42 = 0;
40
- if (!transform || transform === 'none')
41
- return;
42
- const t = /translate\((-?[\d.]+)px,\s*(-?[\d.]+)px\)/.exec(transform);
43
- if (t) {
44
- this.m41 = Number(t[1]);
45
- this.m42 = Number(t[2]);
46
- }
47
- }
48
- }
49
- function makeMap() {
50
- return {
51
- organisation: 'Acme Corp',
52
- set_id: 'v1.0',
53
- capabilities: [
54
- { id: 1, name: 'Customer Acquisition', address: '1.0.0', maturity: [{ date: '2026-04-01', level: 3 }] },
55
- { id: 2, name: 'Lead Qualification', address: '1.1.0' },
56
- { id: 3, name: 'Inbound Lead Scoring', address: '1.1.1' },
57
- ],
58
- };
59
- }
60
- beforeEach(() => {
61
- global.ResizeObserver = MockResizeObserver;
62
- window.DOMMatrixReadOnly = MockDOMMatrixReadOnly;
63
- vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function () {
64
- const isNode = this.classList?.contains('react-flow__node');
65
- const width = isNode ? 250 : 1000;
66
- const height = isNode ? 64 : 800;
67
- return { width, height, top: 0, left: 0, right: width, bottom: height, x: 0, y: 0, toJSON() { return this; } };
68
- });
69
- });
70
- afterEach(() => {
71
- cleanup();
72
- vi.restoreAllMocks();
73
- });
74
- describe('CapabilityMapView', () => {
75
- it('renders the virtual root and every on-diagram capability', async () => {
76
- render(_jsx(CapabilityMapView, { map: makeMap() }));
77
- await waitFor(() => {
78
- expect(screen.getByText('Acme Corp')).toBeTruthy();
79
- expect(screen.getByText('Customer Acquisition')).toBeTruthy();
80
- expect(screen.getByText('Lead Qualification')).toBeTruthy();
81
- expect(screen.getByText('Inbound Lead Scoring')).toBeTruthy();
82
- });
83
- });
84
- it('renders a maturity dot only for capabilities with a maturity snapshot', async () => {
85
- render(_jsx(CapabilityMapView, { map: makeMap() }));
86
- await waitFor(() => expect(screen.getByText('Customer Acquisition')).toBeTruthy());
87
- expect(screen.getByLabelText('Maturity 3')).toBeTruthy();
88
- expect(screen.queryByLabelText(/Maturity/, { selector: '[aria-label="Maturity undefined"]' })).toBeNull();
89
- });
90
- it('shows backlog capabilities in the sidebar, not on canvas', async () => {
91
- const map = {
92
- organisation: 'Acme Corp',
93
- set_id: 'v1.0',
94
- capabilities: [
95
- { id: 1, name: 'Customer Acquisition', address: '1.0.0' },
96
- { id: 2, name: 'Parked idea', address: '0.0.0', backlog: true },
97
- ],
98
- };
99
- render(_jsx(CapabilityMapView, { map: map, showBacklog: true }));
100
- await waitFor(() => expect(screen.getByText('Customer Acquisition')).toBeTruthy());
101
- expect(screen.getByText('Backlog')).toBeTruthy();
102
- expect(screen.getByText('Parked idea')).toBeTruthy();
103
- });
104
- it('does not render add/delete affordances when readOnly', async () => {
105
- render(_jsx(CapabilityMapView, { map: makeMap(), readOnly: true }));
106
- await waitFor(() => expect(screen.getByText('Customer Acquisition')).toBeTruthy());
107
- expect(screen.queryByLabelText('Add child capability')).toBeNull();
108
- expect(screen.queryByLabelText('Delete capability')).toBeNull();
109
- });
110
- it('fires onChange with kind "addChild" when the add-child button is clicked', async () => {
111
- const onChange = vi.fn();
112
- render(_jsx(CapabilityMapView, { map: makeMap(), onChange: onChange }));
113
- await waitFor(() => expect(screen.getByText('Customer Acquisition')).toBeTruthy());
114
- const rootCard = document.querySelector('.react-flow__node[data-id="1"]');
115
- rootCard.querySelector('[aria-label="Add child capability"]')
116
- .dispatchEvent(new MouseEvent('click', { bubbles: true }));
117
- await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
118
- const event = onChange.mock.calls[0][0];
119
- expect(event.kind).toBe('addChild');
120
- if (event.kind === 'addChild') {
121
- expect(event.newCap.address).toBe('1.2.0');
122
- }
123
- });
124
- it('fires onChange with kind "delete" when the delete button is clicked', async () => {
125
- const onChange = vi.fn();
126
- render(_jsx(CapabilityMapView, { map: makeMap(), onChange: onChange }));
127
- await waitFor(() => expect(screen.getByText('Inbound Lead Scoring')).toBeTruthy());
128
- const leafCard = document.querySelector('.react-flow__node[data-id="3"]');
129
- leafCard.querySelector('[aria-label="Delete capability"]')
130
- .dispatchEvent(new MouseEvent('click', { bubbles: true }));
131
- await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
132
- expect(onChange.mock.calls[0][0].kind).toBe('delete');
133
- });
134
- it('fires onEditRequest on double-click', async () => {
135
- const onEditRequest = vi.fn();
136
- render(_jsx(CapabilityMapView, { map: makeMap(), onEditRequest: onEditRequest }));
137
- await waitFor(() => expect(screen.getByText('Customer Acquisition')).toBeTruthy());
138
- document.querySelector('.react-flow__node[data-id="1"]')
139
- .dispatchEvent(new MouseEvent('dblclick', { bubbles: true }));
140
- await waitFor(() => expect(onEditRequest).toHaveBeenCalledTimes(1));
141
- expect(onEditRequest.mock.calls[0][0]).toMatchObject({ id: 1, name: 'Customer Acquisition' });
142
- });
143
- it('fires onChange with kind "normaliseAddresses" from the toolbar button', async () => {
144
- const onChange = vi.fn();
145
- render(_jsx(CapabilityMapView, { map: makeMap(), onChange: onChange }));
146
- await waitFor(() => expect(screen.getByText('Customer Acquisition')).toBeTruthy());
147
- screen.getByText('Normalise addresses').dispatchEvent(new MouseEvent('click', { bubbles: true }));
148
- await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
149
- expect(onChange.mock.calls[0][0].kind).toBe('normaliseAddresses');
150
- });
151
- it('fires onChange with kind "restoreFromBacklog" when a backlog card is dropped onto a canvas card', async () => {
152
- const map = {
153
- organisation: 'Acme Corp',
154
- set_id: 'v1.0',
155
- capabilities: [
156
- { id: 1, name: 'Customer Acquisition', address: '1.0.0' },
157
- { id: 2, name: 'Parked idea', address: '0.0.0', backlog: true },
158
- ],
159
- };
160
- const onChange = vi.fn();
161
- render(_jsx(CapabilityMapView, { map: map, onChange: onChange, showBacklog: true }));
162
- await waitFor(() => expect(screen.getByText('Parked idea')).toBeTruthy());
163
- const store = new Map();
164
- const dataTransfer = { setData: (k, v) => store.set(k, v), getData: (k) => store.get(k) ?? '', effectAllowed: 'move' };
165
- function fireDnd(el, type, coords) {
166
- const event = new Event(type, { bubbles: true, cancelable: true });
167
- Object.defineProperty(event, 'dataTransfer', { value: dataTransfer });
168
- Object.assign(event, coords);
169
- el.dispatchEvent(event);
170
- }
171
- const backlogItem = screen.getByText('Parked idea').closest('div[draggable]');
172
- const rootCard = document.querySelector('.react-flow__node[data-id="1"]');
173
- document.elementFromPoint = vi.fn().mockReturnValue(rootCard);
174
- fireDnd(backlogItem, 'dragstart', { clientX: 0, clientY: 0 });
175
- fireDnd(rootCard, 'drop', { clientX: 10, clientY: 10 });
176
- await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
177
- const event = onChange.mock.calls[0][0];
178
- expect(event.kind).toBe('restoreFromBacklog');
179
- if (event.kind === 'restoreFromBacklog') {
180
- expect(event.id).toBe(2);
181
- expect(event.parentId).toBe(1);
182
- }
183
- });
184
- });
185
- // Dragging a card is choreographed by reactflow's own pointer/DOM-measurement
186
- // machinery — see the equivalent note in goals/__tests__/GoalTreeView.test.tsx.
187
- // computeDragOutcome() is the pure decision this component's onNodeDragStop
188
- // calls once reactflow reports a drag, tested directly here.
189
- describe('computeDragOutcome (reparent / moveBranchToBacklog decision logic)', () => {
190
- const map = makeMap();
191
- it('fires a "reparent" change when dropped onto another card', () => {
192
- const change = computeDragOutcome(map, 3, { kind: 'node', id: 1 });
193
- expect(change?.kind).toBe('reparent');
194
- if (change?.kind === 'reparent') {
195
- expect(change.sourceId).toBe(3);
196
- expect(change.targetId).toBe(1);
197
- }
198
- });
199
- it('fires a "reparent" change (promotion to L1) when dropped on the root', () => {
200
- const change = computeDragOutcome(map, 2, { kind: 'root' });
201
- expect(change?.kind).toBe('reparent');
202
- if (change?.kind === 'reparent') {
203
- expect(change.targetId).toBe(0);
204
- expect(change.result.capabilities.find((c) => c.id === 2)?.address).toBe('2.0.0');
205
- }
206
- });
207
- it('fires a "moveBranchToBacklog" change when dropped on the backlog zone', () => {
208
- const change = computeDragOutcome(map, 2, { kind: 'backlog' });
209
- expect(change?.kind).toBe('moveBranchToBacklog');
210
- });
211
- it('is a no-op when dropped nowhere in particular', () => {
212
- expect(computeDragOutcome(map, 2, null)).toBeNull();
213
- });
214
- it('is a no-op when dropped on itself', () => {
215
- expect(computeDragOutcome(map, 2, { kind: 'node', id: 2 })).toBeNull();
216
- });
217
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { parseAddress, formatAddress, getLevel, getParentAddress, getFirstFreeAddress, isAddressTaken } from '../address.js';
3
- function cap(id, address, backlog = false) {
4
- return { id, name: `Cap ${id}`, address, backlog };
5
- }
6
- describe('parseAddress / formatAddress', () => {
7
- it('round-trips X.Y.Z', () => {
8
- for (const addr of ['1.0.0', '1.2.0', '1.2.3', '0.0.0', '42.7.19']) {
9
- expect(formatAddress(parseAddress(addr))).toBe(addr);
10
- }
11
- });
12
- it('throws on malformed input', () => {
13
- expect(() => parseAddress('1.2')).toThrow();
14
- expect(() => parseAddress('1.2.3.4')).toThrow();
15
- expect(() => parseAddress('a.b.c')).toThrow();
16
- });
17
- });
18
- describe('getLevel', () => {
19
- it('classifies each address shape', () => {
20
- expect(getLevel('1.0.0')).toBe(1);
21
- expect(getLevel('1.2.0')).toBe(2);
22
- expect(getLevel('1.2.3')).toBe(3);
23
- expect(getLevel('0.0.0')).toBe('backlog');
24
- });
25
- });
26
- describe('getParentAddress', () => {
27
- it('walks up one level at a time', () => {
28
- expect(getParentAddress('1.2.3')).toBe('1.2.0');
29
- expect(getParentAddress('1.2.0')).toBe('1.0.0');
30
- expect(getParentAddress('1.0.0')).toBeNull();
31
- });
32
- });
33
- describe('getFirstFreeAddress / isAddressTaken', () => {
34
- it('finds the first unused L2 slot under an L1 parent', () => {
35
- const caps = [cap(1, '1.0.0'), cap(2, '1.1.0'), cap(3, '1.2.0')];
36
- expect(getFirstFreeAddress('1.0.0', caps)).toBe('1.3.0');
37
- });
38
- it('finds the first unused L3 slot under an L2 parent', () => {
39
- const caps = [cap(1, '1.0.0'), cap(2, '1.1.0'), cap(3, '1.1.1')];
40
- expect(getFirstFreeAddress('1.1.0', caps)).toBe('1.1.2');
41
- });
42
- it('ignores backlog entries when checking occupancy', () => {
43
- const caps = [cap(1, '1.0.0'), cap(2, '0.0.0', true)];
44
- expect(isAddressTaken('1.1.0', caps)).toBe(false);
45
- });
46
- it('rejects an L3 address as a parent', () => {
47
- expect(() => getFirstFreeAddress('1.1.1', [])).toThrow();
48
- });
49
- });
@@ -1 +0,0 @@
1
- export {};