@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.
- package/package.json +7 -2
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -55
- package/dist/__tests__/node-size-presets.test.d.ts +0 -1
- package/dist/__tests__/node-size-presets.test.js +0 -30
- package/dist/__tests__/scope.test.d.ts +0 -1
- package/dist/__tests__/scope.test.js +0 -23
- package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
- package/dist/__tests__/yaml-normalize.test.js +0 -148
- package/dist/activities/__tests__/cpm.test.d.ts +0 -1
- package/dist/activities/__tests__/cpm.test.js +0 -146
- package/dist/activities/__tests__/gantt.test.d.ts +0 -1
- package/dist/activities/__tests__/gantt.test.js +0 -263
- package/dist/activities/__tests__/layout.test.d.ts +0 -1
- package/dist/activities/__tests__/layout.test.js +0 -98
- package/dist/activities/__tests__/validate.test.d.ts +0 -1
- package/dist/activities/__tests__/validate.test.js +0 -397
- package/dist/activity-card/__tests__/example.test.d.ts +0 -1
- package/dist/activity-card/__tests__/example.test.js +0 -73
- package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
- package/dist/activity-card/__tests__/layout.test.js +0 -141
- package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
- package/dist/activity-card/__tests__/resolver.test.js +0 -325
- package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
- package/dist/activity-card/__tests__/validate.test.js +0 -149
- package/dist/actor/__tests__/validate.test.d.ts +0 -1
- package/dist/actor/__tests__/validate.test.js +0 -95
- package/dist/applications/__tests__/validate.test.d.ts +0 -1
- package/dist/applications/__tests__/validate.test.js +0 -223
- package/dist/assertion/__tests__/example.test.d.ts +0 -1
- package/dist/assertion/__tests__/example.test.js +0 -32
- package/dist/assertion/__tests__/validate.test.d.ts +0 -1
- package/dist/assertion/__tests__/validate.test.js +0 -130
- package/dist/blocks/__tests__/layout.test.d.ts +0 -1
- package/dist/blocks/__tests__/layout.test.js +0 -153
- package/dist/blocks/__tests__/validate.test.d.ts +0 -1
- package/dist/blocks/__tests__/validate.test.js +0 -235
- package/dist/business-service/__tests__/validate.test.d.ts +0 -1
- package/dist/business-service/__tests__/validate.test.js +0 -135
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
- package/dist/capability-map/__tests__/address.test.d.ts +0 -1
- package/dist/capability-map/__tests__/address.test.js +0 -49
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
- package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/validate.test.js +0 -212
- package/dist/change/__tests__/validate.test.d.ts +0 -1
- package/dist/change/__tests__/validate.test.js +0 -79
- package/dist/codex/__tests__/example.test.d.ts +0 -1
- package/dist/codex/__tests__/example.test.js +0 -33
- package/dist/codex/__tests__/validate.test.d.ts +0 -1
- package/dist/codex/__tests__/validate.test.js +0 -68
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
- package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
- package/dist/compliance/__tests__/classify.test.d.ts +0 -1
- package/dist/compliance/__tests__/classify.test.js +0 -58
- package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
- package/dist/compliance/__tests__/confidence.test.js +0 -78
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
- package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
- package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
- package/dist/compliance/__tests__/example.test.d.ts +0 -1
- package/dist/compliance/__tests__/example.test.js +0 -51
- package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
- package/dist/compliance/__tests__/gap-report.test.js +0 -113
- package/dist/compliance/__tests__/html.test.d.ts +0 -1
- package/dist/compliance/__tests__/html.test.js +0 -122
- package/dist/compliance/__tests__/impact.test.d.ts +0 -1
- package/dist/compliance/__tests__/impact.test.js +0 -913
- package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
- package/dist/compliance/__tests__/markdown.test.js +0 -85
- package/dist/compliance/__tests__/trace.test.d.ts +0 -1
- package/dist/compliance/__tests__/trace.test.js +0 -144
- package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
- package/dist/compliance/__tests__/view-resolution.test.js +0 -59
- package/dist/compliance/__tests__/views.test.d.ts +0 -1
- package/dist/compliance/__tests__/views.test.js +0 -59
- package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/build.test.js +0 -183
- package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/example.test.js +0 -49
- package/dist/confidence/__tests__/score.test.d.ts +0 -1
- package/dist/confidence/__tests__/score.test.js +0 -188
- package/dist/constraint/__tests__/example.test.d.ts +0 -1
- package/dist/constraint/__tests__/example.test.js +0 -14
- package/dist/constraint/__tests__/validate.test.d.ts +0 -1
- package/dist/constraint/__tests__/validate.test.js +0 -58
- package/dist/factor/__tests__/validate.test.d.ts +0 -1
- package/dist/factor/__tests__/validate.test.js +0 -112
- package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
- package/dist/fgca/__tests__/chain-table.test.js +0 -158
- package/dist/fgca/__tests__/layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/layout.test.js +0 -140
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
- package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/preview-layout.test.js +0 -106
- package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
- package/dist/fgca/__tests__/resolver.test.js +0 -185
- package/dist/fgca/__tests__/validate.test.d.ts +0 -1
- package/dist/fgca/__tests__/validate.test.js +0 -125
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
- package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
- package/dist/goals/__tests__/layout.test.d.ts +0 -1
- package/dist/goals/__tests__/layout.test.js +0 -153
- package/dist/goals/__tests__/mutations.test.d.ts +0 -1
- package/dist/goals/__tests__/mutations.test.js +0 -134
- package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/goals/__tests__/parse-canonical.test.js +0 -131
- package/dist/goals/__tests__/validate.test.d.ts +0 -1
- package/dist/goals/__tests__/validate.test.js +0 -183
- package/dist/integration/__tests__/validate.test.d.ts +0 -1
- package/dist/integration/__tests__/validate.test.js +0 -169
- package/dist/location/__tests__/validate.test.d.ts +0 -1
- package/dist/location/__tests__/validate.test.js +0 -107
- package/dist/node/__tests__/validate.test.d.ts +0 -1
- package/dist/node/__tests__/validate.test.js +0 -100
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
- package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/layout.test.js +0 -196
- package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/validate.test.js +0 -280
- package/dist/process-map/__tests__/validate.test.d.ts +0 -1
- package/dist/process-map/__tests__/validate.test.js +0 -199
- package/dist/products/__tests__/validate.test.d.ts +0 -1
- package/dist/products/__tests__/validate.test.js +0 -210
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
- package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
- package/dist/requirement/__tests__/example.test.d.ts +0 -1
- package/dist/requirement/__tests__/example.test.js +0 -21
- package/dist/requirement/__tests__/validate.test.d.ts +0 -1
- package/dist/requirement/__tests__/validate.test.js +0 -80
- package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
- package/dist/scenarios/__tests__/validate.test.js +0 -183
- package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
- package/dist/stakeholder/__tests__/validate.test.js +0 -88
- package/dist/target-state/__tests__/validate.test.d.ts +0 -1
- package/dist/target-state/__tests__/validate.test.js +0 -78
- package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
- package/dist/technology-service/__tests__/validate.test.js +0 -121
- package/dist/theme/__tests__/tokens.test.d.ts +0 -1
- package/dist/theme/__tests__/tokens.test.js +0 -159
- package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
- package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
- package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
- package/dist/webview/__tests__/entry-notations.test.js +0 -62
- package/dist/webview/__tests__/entry.test.d.ts +0 -1
- package/dist/webview/__tests__/entry.test.js +0 -56
- package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
- package/dist/webview/__tests__/render-activities.test.js +0 -91
- package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
- package/dist/webview/__tests__/render-blocks.test.js +0 -175
- package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
- package/dist/webview/__tests__/render-goals.test.js +0 -120
- package/dist/webview/__tests__/render-process.test.d.ts +0 -1
- package/dist/webview/__tests__/render-process.test.js +0 -463
- package/dist/webview/__tests__/render-util.test.d.ts +0 -1
- package/dist/webview/__tests__/render-util.test.js +0 -54
- package/src/__tests__/edge-path.test.ts +0 -67
- package/src/__tests__/node-size-presets.test.ts +0 -50
- package/src/__tests__/scope.test.ts +0 -27
- package/src/__tests__/yaml-normalize.test.ts +0 -158
- package/src/activities/__tests__/cpm.test.ts +0 -164
- package/src/activities/__tests__/gantt.test.ts +0 -290
- package/src/activities/__tests__/layout.test.ts +0 -112
- package/src/activities/__tests__/validate.test.ts +0 -446
- package/src/activity-card/__tests__/example.test.ts +0 -83
- package/src/activity-card/__tests__/layout.test.ts +0 -162
- package/src/activity-card/__tests__/resolver.test.ts +0 -357
- package/src/activity-card/__tests__/validate.test.ts +0 -167
- package/src/actor/__tests__/validate.test.ts +0 -114
- package/src/applications/__tests__/validate.test.ts +0 -256
- package/src/assertion/__tests__/example.test.ts +0 -37
- package/src/assertion/__tests__/validate.test.ts +0 -142
- package/src/blocks/__tests__/layout.test.ts +0 -169
- package/src/blocks/__tests__/validate.test.ts +0 -260
- package/src/business-service/__tests__/validate.test.ts +0 -160
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
- package/src/capability-map/__tests__/address.test.ts +0 -59
- package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
- package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
- package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
- package/src/capability-map/__tests__/validate.test.ts +0 -238
- package/src/change/__tests__/validate.test.ts +0 -97
- package/src/codex/__tests__/example.test.ts +0 -40
- package/src/codex/__tests__/validate.test.ts +0 -84
- package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
- package/src/compliance/__tests__/classify.test.ts +0 -64
- package/src/compliance/__tests__/confidence.test.ts +0 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
- package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
- package/src/compliance/__tests__/example.test.ts +0 -57
- package/src/compliance/__tests__/gap-report.test.ts +0 -129
- package/src/compliance/__tests__/html.test.ts +0 -142
- package/src/compliance/__tests__/impact.test.ts +0 -1060
- package/src/compliance/__tests__/markdown.test.ts +0 -95
- package/src/compliance/__tests__/trace.test.ts +0 -157
- package/src/compliance/__tests__/view-resolution.test.ts +0 -80
- package/src/compliance/__tests__/views.test.ts +0 -64
- package/src/compliance-matrix/__tests__/build.test.ts +0 -200
- package/src/compliance-matrix/__tests__/example.test.ts +0 -57
- package/src/confidence/__tests__/score.test.ts +0 -254
- package/src/constraint/__tests__/example.test.ts +0 -19
- package/src/constraint/__tests__/validate.test.ts +0 -68
- package/src/factor/__tests__/validate.test.ts +0 -133
- package/src/fgca/__tests__/chain-table.test.ts +0 -172
- package/src/fgca/__tests__/layout.test.ts +0 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
- package/src/fgca/__tests__/preview-layout.test.ts +0 -124
- package/src/fgca/__tests__/resolver.test.ts +0 -209
- package/src/fgca/__tests__/validate.test.ts +0 -142
- package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
- package/src/goals/__tests__/layout.test.ts +0 -175
- package/src/goals/__tests__/mutations.test.ts +0 -153
- package/src/goals/__tests__/parse-canonical.test.ts +0 -147
- package/src/goals/__tests__/validate.test.ts +0 -202
- package/src/integration/__tests__/validate.test.ts +0 -203
- package/src/location/__tests__/validate.test.ts +0 -127
- package/src/node/__tests__/validate.test.ts +0 -118
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
- package/src/process-blueprint/__tests__/layout.test.ts +0 -240
- package/src/process-blueprint/__tests__/validate.test.ts +0 -310
- package/src/process-map/__tests__/validate.test.ts +0 -223
- package/src/products/__tests__/validate.test.ts +0 -239
- package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
- package/src/requirement/__tests__/example.test.ts +0 -24
- package/src/requirement/__tests__/validate.test.ts +0 -96
- package/src/scenarios/__tests__/validate.test.ts +0 -209
- package/src/stakeholder/__tests__/validate.test.ts +0 -105
- package/src/target-state/__tests__/validate.test.ts +0 -95
- package/src/technology-service/__tests__/validate.test.ts +0 -143
- package/src/theme/__tests__/tokens.test.ts +0 -185
- package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
- package/src/webview/__tests__/entry-notations.test.ts +0 -77
- package/src/webview/__tests__/entry.test.ts +0 -64
- package/src/webview/__tests__/render-activities.test.ts +0 -100
- package/src/webview/__tests__/render-blocks.test.ts +0 -206
- package/src/webview/__tests__/render-goals.test.ts +0 -128
- package/src/webview/__tests__/render-process.test.ts +0 -538
- package/src/webview/__tests__/render-util.test.ts +0 -66
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { layoutCapabilityMap } from '../dsm-layout.js';
|
|
3
|
-
function map() {
|
|
4
|
-
return {
|
|
5
|
-
organisation: 'Acme Corp',
|
|
6
|
-
set_id: 'v1.0',
|
|
7
|
-
capabilities: [
|
|
8
|
-
{ id: 1, name: 'Customer Acquisition', address: '1.0.0' },
|
|
9
|
-
{ id: 2, name: 'Lead Qualification', address: '1.1.0' },
|
|
10
|
-
{ id: 3, name: 'Inbound Lead Scoring', address: '1.1.1' },
|
|
11
|
-
{ id: 4, name: 'Order Management', address: '2.0.0' },
|
|
12
|
-
{ id: 5, name: 'Parked idea', address: '0.0.0', backlog: true },
|
|
13
|
-
],
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
describe('layoutCapabilityMap', () => {
|
|
17
|
-
it('lays out a virtual root plus every on-diagram capability, one column per level', () => {
|
|
18
|
-
const layout = layoutCapabilityMap(map());
|
|
19
|
-
expect(layout.rootNode.data).toBeNull();
|
|
20
|
-
expect(layout.nodes).toHaveLength(4); // backlog entry excluded
|
|
21
|
-
const byId = new Map(layout.nodes.map((n) => [n.id, n]));
|
|
22
|
-
expect(byId.get(1).x).toBe(byId.get(4).x); // both L1s share a column
|
|
23
|
-
expect(byId.get(2).x).toBeGreaterThan(byId.get(1).x); // L2 one column further right
|
|
24
|
-
expect(byId.get(3).x).toBeGreaterThan(byId.get(2).x); // L3 further still
|
|
25
|
-
expect(byId.get(1).x).toBeGreaterThan(layout.rootNode.x); // root sits left of the L1s
|
|
26
|
-
});
|
|
27
|
-
it('connects the root to every L1 and each parent to its children', () => {
|
|
28
|
-
const layout = layoutCapabilityMap(map());
|
|
29
|
-
const edgeSet = new Set(layout.edges.map((e) => `${e.source}->${e.target}`));
|
|
30
|
-
expect(edgeSet.has('root->1')).toBe(true);
|
|
31
|
-
expect(edgeSet.has('root->4')).toBe(true);
|
|
32
|
-
expect(edgeSet.has('1->2')).toBe(true);
|
|
33
|
-
expect(edgeSet.has('2->3')).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
it('marks a node as having hidden children when its subtree is collapsed', () => {
|
|
36
|
-
const layout = layoutCapabilityMap(map(), { hideCollapsed: [2] });
|
|
37
|
-
const cap2 = layout.nodes.find((n) => n.id === 2);
|
|
38
|
-
expect(cap2.hasHiddenChildren).toBe(true);
|
|
39
|
-
expect(layout.nodes.some((n) => n.id === 3)).toBe(false); // hidden subtree omitted
|
|
40
|
-
});
|
|
41
|
-
it('returns just the root when there are no on-diagram capabilities', () => {
|
|
42
|
-
const layout = layoutCapabilityMap({ organisation: 'Empty Co', set_id: 'v1', capabilities: [] });
|
|
43
|
-
expect(layout.nodes).toHaveLength(0);
|
|
44
|
-
expect(layout.rootNode.data).toBeNull();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { reparent, addChild, deleteWithDescendants, moveBranchToBacklog, restoreFromBacklog, normaliseAddresses } from '../dsm-mutations.js';
|
|
3
|
-
function baseMap() {
|
|
4
|
-
return {
|
|
5
|
-
organisation: 'Acme Corp',
|
|
6
|
-
set_id: 'v1.0',
|
|
7
|
-
capabilities: [
|
|
8
|
-
{ id: 1, name: 'Customer Acquisition', address: '1.0.0' },
|
|
9
|
-
{ id: 2, name: 'Lead Qualification', address: '1.1.0' },
|
|
10
|
-
{ id: 3, name: 'Inbound Lead Scoring', address: '1.1.1' },
|
|
11
|
-
{ id: 4, name: 'Order Management', address: '2.0.0' },
|
|
12
|
-
],
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
describe('reparent', () => {
|
|
16
|
-
it('moves an L3 under a different L2 (no cascade)', () => {
|
|
17
|
-
const map = baseMap();
|
|
18
|
-
const r = reparent(map, 3, 4); // Inbound Lead Scoring (L3) -> Order Management (L1)... newLevel would be 2
|
|
19
|
-
expect(r.ok).toBe(true);
|
|
20
|
-
const moved = r.result.capabilities.find((c) => c.id === 3);
|
|
21
|
-
expect(moved.address).toBe('2.1.0'); // now an L2 under capability 4
|
|
22
|
-
});
|
|
23
|
-
it('promotes an L2 to L1 and cascades its L3 children to L2 (spec §9)', () => {
|
|
24
|
-
const map = baseMap();
|
|
25
|
-
const r = reparent(map, 2, 0); // Lead Qualification (L2, id 2) -> virtual root
|
|
26
|
-
expect(r.ok).toBe(true);
|
|
27
|
-
const promoted = r.result.capabilities.find((c) => c.id === 2);
|
|
28
|
-
const child = r.result.capabilities.find((c) => c.id === 3);
|
|
29
|
-
expect(promoted.address).toBe('3.0.0'); // first free L1 slot (1 and 2 taken)
|
|
30
|
-
expect(child.address).toBe('3.1.0'); // cascaded from L3 to L2 under the new L1
|
|
31
|
-
});
|
|
32
|
-
it('refuses a demotion that would push a grandchild past L3', () => {
|
|
33
|
-
const map = baseMap();
|
|
34
|
-
// Capability 1 (L1) has descendant 2 (L2) and 3 (L3, a grandchild).
|
|
35
|
-
// Demoting 1 under 4 (making 1 an L2) would need 3 to become L4.
|
|
36
|
-
const r = reparent(map, 1, 4);
|
|
37
|
-
expect(r.ok).toBe(false);
|
|
38
|
-
});
|
|
39
|
-
it('refuses reparenting onto its own descendant (cycle)', () => {
|
|
40
|
-
const map = baseMap();
|
|
41
|
-
const r = reparent(map, 2, 3); // Lead Qualification onto its own child
|
|
42
|
-
expect(r.ok).toBe(false);
|
|
43
|
-
});
|
|
44
|
-
it('refuses reparenting onto itself', () => {
|
|
45
|
-
const map = baseMap();
|
|
46
|
-
expect(reparent(map, 1, 1).ok).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
it('leaves the original map untouched', () => {
|
|
49
|
-
const map = baseMap();
|
|
50
|
-
reparent(map, 3, 4);
|
|
51
|
-
expect(map.capabilities.find((c) => c.id === 3).address).toBe('1.1.1');
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
describe('addChild', () => {
|
|
55
|
-
it('assigns the first free address under the parent', () => {
|
|
56
|
-
const map = baseMap();
|
|
57
|
-
const r = addChild(map, 1, { name: 'New L2' });
|
|
58
|
-
expect(r.ok).toBe(true);
|
|
59
|
-
const added = r.result.capabilities.find((c) => c.name === 'New L2');
|
|
60
|
-
expect(added.address).toBe('1.2.0');
|
|
61
|
-
expect(added.backlog).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
it('assigns a new L1 address when parentId is 0 (root)', () => {
|
|
64
|
-
const map = baseMap();
|
|
65
|
-
const r = addChild(map, 0, { name: 'New L1' });
|
|
66
|
-
expect(r.ok).toBe(true);
|
|
67
|
-
expect(r.result.capabilities.find((c) => c.name === 'New L1').address).toBe('3.0.0');
|
|
68
|
-
});
|
|
69
|
-
it('refuses adding a child under an L3 (would exceed max depth)', () => {
|
|
70
|
-
const map = baseMap();
|
|
71
|
-
const r = addChild(map, 3, { name: 'Too deep' });
|
|
72
|
-
expect(r.ok).toBe(false);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe('deleteWithDescendants', () => {
|
|
76
|
-
it('removes the capability and every descendant', () => {
|
|
77
|
-
const map = baseMap();
|
|
78
|
-
const r = deleteWithDescendants(map, 2); // Lead Qualification + its L3 child
|
|
79
|
-
expect(r.ok).toBe(true);
|
|
80
|
-
const ids = r.result.capabilities.map((c) => c.id);
|
|
81
|
-
expect(ids).not.toContain(2);
|
|
82
|
-
expect(ids).not.toContain(3);
|
|
83
|
-
expect(ids).toContain(1);
|
|
84
|
-
expect(ids).toContain(4);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
describe('moveBranchToBacklog / restoreFromBacklog', () => {
|
|
88
|
-
it('moves a branch to the backlog and back', () => {
|
|
89
|
-
const map = baseMap();
|
|
90
|
-
const toBacklog = moveBranchToBacklog(map, 2);
|
|
91
|
-
expect(toBacklog.ok).toBe(true);
|
|
92
|
-
const backlogged = toBacklog.result.capabilities.filter((c) => c.id === 2 || c.id === 3);
|
|
93
|
-
expect(backlogged.every((c) => c.backlog && c.address === '0.0.0')).toBe(true);
|
|
94
|
-
const restored = restoreFromBacklog(toBacklog.result, 2, 4);
|
|
95
|
-
expect(restored.ok).toBe(true);
|
|
96
|
-
const cap2 = restored.result.capabilities.find((c) => c.id === 2);
|
|
97
|
-
expect(cap2.backlog).toBe(false);
|
|
98
|
-
expect(cap2.address).toBe('2.1.0');
|
|
99
|
-
// Restoring the parent doesn't automatically restore its backlogged
|
|
100
|
-
// children — matches deleteWithDescendants/addChild's scope (this
|
|
101
|
-
// mutation acts on the single named id only).
|
|
102
|
-
expect(restored.result.capabilities.find((c) => c.id === 3).backlog).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
describe('normaliseAddresses', () => {
|
|
106
|
-
it('moves a capability with an unresolvable parent address to the backlog', () => {
|
|
107
|
-
const map = {
|
|
108
|
-
organisation: 'Acme Corp',
|
|
109
|
-
set_id: 'v1.0',
|
|
110
|
-
capabilities: [
|
|
111
|
-
{ id: 1, name: 'Customer Acquisition', address: '1.0.0' },
|
|
112
|
-
{ id: 2, name: 'Dangling L2', address: '9.1.0' }, // no capability at 9.0.0
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
|
-
const result = normaliseAddresses(map);
|
|
116
|
-
const dangling = result.capabilities.find((c) => c.id === 2);
|
|
117
|
-
expect(dangling.backlog).toBe(true);
|
|
118
|
-
expect(dangling.address).toBe('0.0.0');
|
|
119
|
-
});
|
|
120
|
-
it('leaves a well-formed hierarchy unchanged', () => {
|
|
121
|
-
const map = baseMap();
|
|
122
|
-
const result = normaliseAddresses(map);
|
|
123
|
-
expect(result.capabilities).toEqual(map.capabilities);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateCapabilityMapData } from '../dsm-validate.js';
|
|
3
|
-
function validMap() {
|
|
4
|
-
return {
|
|
5
|
-
organisation: 'Acme Corp',
|
|
6
|
-
set_id: 'v1.0',
|
|
7
|
-
capabilities: [
|
|
8
|
-
{ id: 1, name: 'Customer Acquisition', address: '1.0.0' },
|
|
9
|
-
{ id: 2, name: 'Lead Qualification', address: '1.1.0' },
|
|
10
|
-
{ id: 3, name: 'Inbound Lead Scoring', address: '1.1.1' },
|
|
11
|
-
],
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
describe('validateCapabilityMapData', () => {
|
|
15
|
-
it('accepts a well-formed map', () => {
|
|
16
|
-
expect(validateCapabilityMapData(validMap()).valid).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
it('flags a duplicate id', () => {
|
|
19
|
-
const map = validMap();
|
|
20
|
-
map.capabilities[1].id = 1;
|
|
21
|
-
const result = validateCapabilityMapData(map);
|
|
22
|
-
expect(result.valid).toBe(false);
|
|
23
|
-
expect(result.errors.some((e) => e.code === 'DUPLICATE_ID')).toBe(true);
|
|
24
|
-
});
|
|
25
|
-
it('flags a malformed address', () => {
|
|
26
|
-
const map = validMap();
|
|
27
|
-
map.capabilities[0].address = 'not-an-address';
|
|
28
|
-
const result = validateCapabilityMapData(map);
|
|
29
|
-
expect(result.errors.some((e) => e.code === 'INVALID_ADDRESS_FORMAT')).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
it('flags a too-deep address as MAX_DEPTH_EXCEEDED, not INVALID_ADDRESS_FORMAT', () => {
|
|
32
|
-
const map = validMap();
|
|
33
|
-
map.capabilities[0].address = '1.2.3.4';
|
|
34
|
-
const result = validateCapabilityMapData(map);
|
|
35
|
-
expect(result.errors.some((e) => e.code === 'MAX_DEPTH_EXCEEDED')).toBe(true);
|
|
36
|
-
expect(result.errors.some((e) => e.code === 'INVALID_ADDRESS_FORMAT')).toBe(false);
|
|
37
|
-
});
|
|
38
|
-
it('flags a duplicate on-diagram address', () => {
|
|
39
|
-
const map = validMap();
|
|
40
|
-
map.capabilities[1].address = '1.0.0';
|
|
41
|
-
const result = validateCapabilityMapData(map);
|
|
42
|
-
expect(result.errors.some((e) => e.code === 'DUPLICATE_ADDRESS')).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
it('warns on a missing parent by address', () => {
|
|
45
|
-
const map = validMap();
|
|
46
|
-
map.capabilities[1].address = '9.1.0'; // no capability at 9.0.0
|
|
47
|
-
const result = validateCapabilityMapData(map);
|
|
48
|
-
expect(result.warnings.some((w) => w.code === 'MISSING_PARENT_BY_ADDRESS')).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
it('does not flag a backlog entry\'s address as a duplicate or requiring a parent', () => {
|
|
51
|
-
const map = validMap();
|
|
52
|
-
map.capabilities.push({ id: 4, name: 'Parked idea', address: '0.0.0', backlog: true });
|
|
53
|
-
const result = validateCapabilityMapData(map);
|
|
54
|
-
expect(result.valid).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,212 +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 { validateCapabilityMap } from '../validate.js';
|
|
6
|
-
const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'capability-map');
|
|
7
|
-
const VALID_MAP = {
|
|
8
|
-
notation: 'capability-map',
|
|
9
|
-
capability_map: {
|
|
10
|
-
id: 'CM-BUSINESS-001',
|
|
11
|
-
name: 'Business Capabilities Map',
|
|
12
|
-
assessment_date: '2026-05-08',
|
|
13
|
-
capabilities: [
|
|
14
|
-
{
|
|
15
|
-
id: 'V1',
|
|
16
|
-
name: 'Order Management',
|
|
17
|
-
type: 'domain',
|
|
18
|
-
current_maturity: 2,
|
|
19
|
-
target_maturity: 3,
|
|
20
|
-
target_date: '2026-12-31',
|
|
21
|
-
children: [
|
|
22
|
-
{ id: 'V1.1', name: 'Order Intake', current_maturity: 3 },
|
|
23
|
-
{ id: 'V1.2', name: 'Order Fulfilment', current_maturity: 2, target_maturity: 3 },
|
|
24
|
-
],
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: 'H1',
|
|
28
|
-
name: 'Master Data Management',
|
|
29
|
-
type: 'supporting',
|
|
30
|
-
current_maturity: 1,
|
|
31
|
-
target_maturity: 3,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
describe('validateCapabilityMap', () => {
|
|
37
|
-
it('passes on valid input', () => {
|
|
38
|
-
const r = validateCapabilityMap(VALID_MAP);
|
|
39
|
-
expect(r.valid).toBe(true);
|
|
40
|
-
expect(r.errors).toHaveLength(0);
|
|
41
|
-
});
|
|
42
|
-
it('CMAP-001: rejects non-object input', () => {
|
|
43
|
-
const r = validateCapabilityMap(null);
|
|
44
|
-
expect(r.errors[0].code).toBe('CMAP-001');
|
|
45
|
-
});
|
|
46
|
-
it('CMAP-001: rejects missing notation', () => {
|
|
47
|
-
const { notation: _, ...rest } = VALID_MAP;
|
|
48
|
-
const r = validateCapabilityMap(rest);
|
|
49
|
-
expect(r.errors.some(e => e.code === 'CMAP-001')).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
it('CMAP-001: rejects wrong notation value', () => {
|
|
52
|
-
const r = validateCapabilityMap({ ...VALID_MAP, notation: 'goals' });
|
|
53
|
-
expect(r.errors.some(e => e.code === 'CMAP-001')).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
it('CMAP-002: rejects missing capability_map', () => {
|
|
56
|
-
const r = validateCapabilityMap({ notation: 'capability-map' });
|
|
57
|
-
expect(r.errors.some(e => e.code === 'CMAP-002')).toBe(true);
|
|
58
|
-
});
|
|
59
|
-
it('CMAP-002: rejects missing id/name/assessment_date', () => {
|
|
60
|
-
const r = validateCapabilityMap({ notation: 'capability-map', capability_map: { capabilities: [] } });
|
|
61
|
-
expect(r.errors.filter(e => e.code === 'CMAP-002').length).toBeGreaterThanOrEqual(3);
|
|
62
|
-
});
|
|
63
|
-
it('CMAP-002: rejects non-array capabilities', () => {
|
|
64
|
-
const map = { ...VALID_MAP.capability_map, capabilities: 'oops' };
|
|
65
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
66
|
-
expect(r.errors.some(e => e.code === 'CMAP-002')).toBe(true);
|
|
67
|
-
});
|
|
68
|
-
it('CMAP-003: rejects capability missing id/name/current_maturity', () => {
|
|
69
|
-
const map = { ...VALID_MAP.capability_map, capabilities: [{}] };
|
|
70
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
71
|
-
expect(r.errors.filter(e => e.code === 'CMAP-003').length).toBeGreaterThanOrEqual(3);
|
|
72
|
-
});
|
|
73
|
-
it('CMAP-004: rejects invalid type', () => {
|
|
74
|
-
const map = {
|
|
75
|
-
...VALID_MAP.capability_map,
|
|
76
|
-
capabilities: [{ id: 'V1', name: 'X', type: 'core', current_maturity: 2 }],
|
|
77
|
-
};
|
|
78
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
79
|
-
expect(r.errors.some(e => e.code === 'CMAP-004')).toBe(true);
|
|
80
|
-
});
|
|
81
|
-
it('CMAP-004: accepts type domain/supporting', () => {
|
|
82
|
-
for (const type of ['domain', 'supporting']) {
|
|
83
|
-
const map = {
|
|
84
|
-
...VALID_MAP.capability_map,
|
|
85
|
-
capabilities: [{ id: 'V1', name: 'X', type, current_maturity: 2 }],
|
|
86
|
-
};
|
|
87
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
88
|
-
expect(r.errors.some(e => e.code === 'CMAP-004')).toBe(false);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
it('CMAP-005: rejects current_maturity out of range', () => {
|
|
92
|
-
const map = {
|
|
93
|
-
...VALID_MAP.capability_map,
|
|
94
|
-
capabilities: [{ id: 'V1', name: 'X', current_maturity: 6 }],
|
|
95
|
-
};
|
|
96
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
97
|
-
expect(r.errors.some(e => e.code === 'CMAP-005')).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
it('CMAP-005: rejects non-integer current_maturity', () => {
|
|
100
|
-
const map = {
|
|
101
|
-
...VALID_MAP.capability_map,
|
|
102
|
-
capabilities: [{ id: 'V1', name: 'X', current_maturity: 2.5 }],
|
|
103
|
-
};
|
|
104
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
105
|
-
expect(r.errors.some(e => e.code === 'CMAP-005')).toBe(true);
|
|
106
|
-
});
|
|
107
|
-
it('CMAP-006: rejects target_maturity out of range', () => {
|
|
108
|
-
const map = {
|
|
109
|
-
...VALID_MAP.capability_map,
|
|
110
|
-
capabilities: [{ id: 'V1', name: 'X', current_maturity: 2, target_maturity: 0 }],
|
|
111
|
-
};
|
|
112
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
113
|
-
expect(r.errors.some(e => e.code === 'CMAP-006')).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
it('CMAP-007: rejects malformed assessment_date', () => {
|
|
116
|
-
const map = { ...VALID_MAP.capability_map, assessment_date: '08-05-2026' };
|
|
117
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
118
|
-
expect(r.errors.some(e => e.code === 'CMAP-007')).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
it('CMAP-007: rejects malformed target_date on a node', () => {
|
|
121
|
-
const map = {
|
|
122
|
-
...VALID_MAP.capability_map,
|
|
123
|
-
capabilities: [{ id: 'V1', name: 'X', current_maturity: 2, target_date: 'tomorrow' }],
|
|
124
|
-
};
|
|
125
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
126
|
-
expect(r.errors.some(e => e.code === 'CMAP-007')).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
it('CMAP-008: rejects duplicate capability id across the tree', () => {
|
|
129
|
-
const map = {
|
|
130
|
-
...VALID_MAP.capability_map,
|
|
131
|
-
capabilities: [
|
|
132
|
-
{ id: 'V1', name: 'A', current_maturity: 2, children: [{ id: 'V1', name: 'B', current_maturity: 1 }] },
|
|
133
|
-
],
|
|
134
|
-
};
|
|
135
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
136
|
-
expect(r.errors.some(e => e.code === 'CMAP-008')).toBe(true);
|
|
137
|
-
});
|
|
138
|
-
it('CMAP-009: rejects malformed capability id', () => {
|
|
139
|
-
const map = {
|
|
140
|
-
...VALID_MAP.capability_map,
|
|
141
|
-
capabilities: [{ id: 'X1', name: 'A', current_maturity: 2 }],
|
|
142
|
-
};
|
|
143
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
144
|
-
expect(r.errors.some(e => e.code === 'CMAP-009')).toBe(true);
|
|
145
|
-
});
|
|
146
|
-
it('CMAP-009: accepts V/H ids with dotted levels', () => {
|
|
147
|
-
for (const id of ['V1', 'V1.2', 'V1.2.3', 'H1', 'H1.2', 'H10.20.30']) {
|
|
148
|
-
const map = {
|
|
149
|
-
...VALID_MAP.capability_map,
|
|
150
|
-
capabilities: [{ id, name: 'A', current_maturity: 2 }],
|
|
151
|
-
};
|
|
152
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
153
|
-
expect(r.errors.some(e => e.code === 'CMAP-009')).toBe(false);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
it('CMAP-009: accepts the canonical CAPABILITY- prefix', () => {
|
|
157
|
-
for (const id of ['CAPABILITY-V1', 'CAPABILITY-V1.2', 'CAPABILITY-V1.2.3', 'CAPABILITY-H1', 'CAPABILITY-H1.2']) {
|
|
158
|
-
const map = {
|
|
159
|
-
...VALID_MAP.capability_map,
|
|
160
|
-
capabilities: [{ id, name: 'A', current_maturity: 2 }],
|
|
161
|
-
};
|
|
162
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
163
|
-
expect(r.errors.some(e => e.code === 'CMAP-009')).toBe(false);
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
it('validates children recursively', () => {
|
|
167
|
-
const map = {
|
|
168
|
-
...VALID_MAP.capability_map,
|
|
169
|
-
capabilities: [{
|
|
170
|
-
id: 'V1', name: 'Root', current_maturity: 2,
|
|
171
|
-
children: [{ id: 'BAD_ID', name: 'X', current_maturity: 7 }],
|
|
172
|
-
}],
|
|
173
|
-
};
|
|
174
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
175
|
-
expect(r.errors.some(e => e.code === 'CMAP-009')).toBe(true);
|
|
176
|
-
expect(r.errors.some(e => e.code === 'CMAP-005')).toBe(true);
|
|
177
|
-
});
|
|
178
|
-
it('accepts empty capabilities array', () => {
|
|
179
|
-
const map = { ...VALID_MAP.capability_map, capabilities: [] };
|
|
180
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
181
|
-
expect(r.valid).toBe(true);
|
|
182
|
-
});
|
|
183
|
-
// Pre-release blocker regression (orchestrator review 2026-05-21).
|
|
184
|
-
it('[blocker] tolerates a null element in capabilities[] without throwing', () => {
|
|
185
|
-
const map = { ...VALID_MAP.capability_map, capabilities: [null] };
|
|
186
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
187
|
-
expect(r.valid).toBe(false);
|
|
188
|
-
expect(r.errors.some(e => e.code === 'CMAP-003')).toBe(true);
|
|
189
|
-
});
|
|
190
|
-
it('[blocker] tolerates a null child capability without throwing', () => {
|
|
191
|
-
const map = {
|
|
192
|
-
...VALID_MAP.capability_map,
|
|
193
|
-
capabilities: [{ id: 'V1', name: 'X', current_maturity: 2, children: [null] }],
|
|
194
|
-
};
|
|
195
|
-
const r = validateCapabilityMap({ ...VALID_MAP, capability_map: map });
|
|
196
|
-
expect(r.valid).toBe(false);
|
|
197
|
-
expect(r.errors.some(e => e.code === 'CMAP-003')).toBe(true);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
describe('capability-map examples (regression)', () => {
|
|
201
|
-
const files = fs.readdirSync(EXAMPLES_DIR).filter(f => f.endsWith('.yaml'));
|
|
202
|
-
expect(files.length).toBeGreaterThan(0);
|
|
203
|
-
for (const file of files) {
|
|
204
|
-
it(`validates tests/fixtures/notation-corpus/capability-map/${file}`, () => {
|
|
205
|
-
const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
|
|
206
|
-
const parsed = yaml.load(text);
|
|
207
|
-
const r = validateCapabilityMap(parsed);
|
|
208
|
-
expect(r.errors).toEqual([]);
|
|
209
|
-
expect(r.valid).toBe(true);
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateChange } from '../validate.js';
|
|
3
|
-
function valid() {
|
|
4
|
-
return {
|
|
5
|
-
notation: 'change',
|
|
6
|
-
id: 'CHANGE-EU-CRM-1',
|
|
7
|
-
name: 'Stand up EU-localised CRM and payment processing',
|
|
8
|
-
goals: ['GOAL-EU-1'],
|
|
9
|
-
description: 'The required delta to operate in EU markets.',
|
|
10
|
-
zone: 'canon',
|
|
11
|
-
admitted_at: '2026-05-29',
|
|
12
|
-
admitted_by: 'v.korobeinikov',
|
|
13
|
-
gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
|
|
14
|
-
valid_from: '2026-05-26',
|
|
15
|
-
valid_to: null,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const codes = (input, opts) => validateChange(input, opts).errors.map(e => e.code);
|
|
19
|
-
describe('validateChange — positive', () => {
|
|
20
|
-
it('accepts a well-formed change', () => {
|
|
21
|
-
const r = validateChange(valid());
|
|
22
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
23
|
-
});
|
|
24
|
-
it('accepts a minimal change with no optional fields', () => {
|
|
25
|
-
const c = valid();
|
|
26
|
-
delete c.goals;
|
|
27
|
-
delete c.description;
|
|
28
|
-
expect(validateChange(c).valid).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
it('accepts a child change with a CHANGE parent', () => {
|
|
31
|
-
const c = valid();
|
|
32
|
-
c.id = 'CHANGE-EU-CRM-2';
|
|
33
|
-
c.parent = 'CHANGE-EU-CRM-1';
|
|
34
|
-
expect(validateChange(c).valid).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe('validateChange — CHANGE-001 (shape / id grammar)', () => {
|
|
38
|
-
it('flags a missing required envelope field', () => {
|
|
39
|
-
const c = valid();
|
|
40
|
-
delete c.name;
|
|
41
|
-
expect(codes(c)).toContain('CHANGE-001');
|
|
42
|
-
});
|
|
43
|
-
it('flags an id that violates the grammar', () => {
|
|
44
|
-
expect(codes({ ...valid(), id: 'CHANGE-EU-CRM-001' })).toContain('CHANGE-001');
|
|
45
|
-
expect(codes({ ...valid(), id: 'CHG-1' })).toContain('CHANGE-001');
|
|
46
|
-
});
|
|
47
|
-
it('flags a wrong notation tag', () => {
|
|
48
|
-
expect(codes({ ...valid(), notation: 'gap' })).toContain('CHANGE-001');
|
|
49
|
-
});
|
|
50
|
-
it('flags a non-array goals', () => {
|
|
51
|
-
expect(codes({ ...valid(), goals: 'GOAL-EU-1' })).toContain('CHANGE-001');
|
|
52
|
-
});
|
|
53
|
-
it('rejects a non-object', () => {
|
|
54
|
-
expect(codes(null)).toEqual(['CHANGE-001']);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('validateChange — CHANGE-002 (goals references)', () => {
|
|
58
|
-
it('flags a malformed goals entry', () => {
|
|
59
|
-
expect(codes({ ...valid(), goals: ['not an id'] })).toContain('CHANGE-002');
|
|
60
|
-
});
|
|
61
|
-
it('flags a goals entry of the wrong TYPE', () => {
|
|
62
|
-
expect(codes({ ...valid(), goals: ['FACTOR-X-1'] })).toContain('CHANGE-002');
|
|
63
|
-
});
|
|
64
|
-
it('flags an unresolved id when a catalog is supplied', () => {
|
|
65
|
-
const catalog = { typeOf: () => undefined };
|
|
66
|
-
expect(codes(valid(), { catalog })).toContain('CHANGE-002');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('validateChange — CHANGE-003 (parent)', () => {
|
|
70
|
-
it('flags a parent of the wrong TYPE', () => {
|
|
71
|
-
expect(codes({ ...valid(), parent: 'GOAL-X-1' })).toContain('CHANGE-003');
|
|
72
|
-
});
|
|
73
|
-
it('flags a parent equal to self', () => {
|
|
74
|
-
expect(codes({ ...valid(), parent: 'CHANGE-EU-CRM-1' })).toContain('CHANGE-003');
|
|
75
|
-
});
|
|
76
|
-
it('flags a malformed parent', () => {
|
|
77
|
-
expect(codes({ ...valid(), parent: 'not an id' })).toContain('CHANGE-003');
|
|
78
|
-
});
|
|
79
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Conformance test for CODEX worked examples under
|
|
2
|
-
// `tests/fixtures/notation-corpus/codex/` — pins #518 Phase C2 corpus signal.
|
|
3
|
-
import { describe, it, expect } from 'vitest';
|
|
4
|
-
import { readFileSync, readdirSync } from 'node:fs';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import yaml from 'js-yaml';
|
|
8
|
-
import { validateCodex, folderJurisdictionFromPath } from '../validate.js';
|
|
9
|
-
const corpusRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus/codex');
|
|
10
|
-
function codexFixturePaths() {
|
|
11
|
-
const out = [];
|
|
12
|
-
for (const zone of ['external/EU', 'internal']) {
|
|
13
|
-
const dir = path.join(corpusRoot, zone);
|
|
14
|
-
for (const f of readdirSync(dir).filter((x) => x.endsWith('.yaml'))) {
|
|
15
|
-
const rel = path.join('codex', zone, f).replace(/\\/g, '/');
|
|
16
|
-
out.push({
|
|
17
|
-
rel,
|
|
18
|
-
folderJurisdiction: folderJurisdictionFromPath(rel),
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return out;
|
|
23
|
-
}
|
|
24
|
-
describe('codex worked examples (notation-corpus)', () => {
|
|
25
|
-
for (const { rel, folderJurisdiction } of codexFixturePaths()) {
|
|
26
|
-
it(`validates ${rel} without error`, () => {
|
|
27
|
-
const data = yaml.load(readFileSync(path.join(corpusRoot, rel.replace(/^codex\//, '')), 'utf-8'));
|
|
28
|
-
const v = validateCodex(data, { folderJurisdiction });
|
|
29
|
-
expect(v.valid, JSON.stringify(v.errors)).toBe(true);
|
|
30
|
-
expect(v.errors).toHaveLength(0);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateCodex, isCodexDoc, folderJurisdictionFromPath, } from '../validate.js';
|
|
3
|
-
const VALID_EXTERNAL = {
|
|
4
|
-
zone: 'codex',
|
|
5
|
-
id: 'LAW-GDPR-1',
|
|
6
|
-
name: 'General Data Protection Regulation',
|
|
7
|
-
type: 'LAW',
|
|
8
|
-
jurisdiction: 'eu',
|
|
9
|
-
effective_date: '2018-05-25',
|
|
10
|
-
admitted_at: '2026-06-01',
|
|
11
|
-
admitted_by: 'legal.team',
|
|
12
|
-
gate_checks: { uniqueness: 'pass' },
|
|
13
|
-
};
|
|
14
|
-
const VALID_INTERNAL = {
|
|
15
|
-
zone: 'codex',
|
|
16
|
-
id: 'INTERNAL_STANDARD-coding-conventions-1',
|
|
17
|
-
name: 'Engineering Coding Conventions',
|
|
18
|
-
type: 'INTERNAL_STANDARD',
|
|
19
|
-
issuing_authority: 'VP Engineering',
|
|
20
|
-
effective_date: '2026-01-01',
|
|
21
|
-
admitted_at: '2026-05-27',
|
|
22
|
-
admitted_by: 'vp.engineering',
|
|
23
|
-
gate_checks: { source_authority: 'VP Engineering' },
|
|
24
|
-
};
|
|
25
|
-
describe('validateCodex', () => {
|
|
26
|
-
it('accepts a valid external artefact', () => {
|
|
27
|
-
const r = validateCodex(VALID_EXTERNAL, { folderJurisdiction: 'eu' });
|
|
28
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
it('accepts a valid internal artefact', () => {
|
|
31
|
-
expect(validateCodex(VALID_INTERNAL).valid).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
it('CODEX-001 rejects non-mapping input', () => {
|
|
34
|
-
expect(validateCodex(null).errors.some((e) => e.code === 'CODEX-001')).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
it('CODEX-001 rejects wrong zone', () => {
|
|
37
|
-
const r = validateCodex({ ...VALID_EXTERNAL, zone: 'canon' });
|
|
38
|
-
expect(r.errors.some((e) => e.code === 'CODEX-001' && e.path === 'zone')).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
it('CODEX-002 rejects type/id prefix mismatch', () => {
|
|
41
|
-
const r = validateCodex({ ...VALID_EXTERNAL, type: 'REGULATION' });
|
|
42
|
-
expect(r.errors.some((e) => e.code === 'CODEX-002')).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
it('CODEX-003 requires jurisdiction on external artefacts', () => {
|
|
45
|
-
const r = validateCodex({ ...VALID_EXTERNAL, jurisdiction: '' });
|
|
46
|
-
expect(r.errors.some((e) => e.code === 'CODEX-003' && e.path === 'jurisdiction')).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
it('CODEX-005 enforces folder jurisdiction match', () => {
|
|
49
|
-
const r = validateCodex(VALID_EXTERNAL, { folderJurisdiction: 'ge' });
|
|
50
|
-
expect(r.errors.some((e) => e.code === 'CODEX-005')).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
it('CODEX-004 requires issuing_authority on internal artefacts', () => {
|
|
53
|
-
const r = validateCodex({ ...VALID_INTERNAL, issuing_authority: '' });
|
|
54
|
-
expect(r.errors.some((e) => e.code === 'CODEX-004')).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('isCodexDoc', () => {
|
|
58
|
-
it('detects zone: codex', () => {
|
|
59
|
-
expect(isCodexDoc({ zone: 'codex', id: 'LAW-1' })).toBe(true);
|
|
60
|
-
expect(isCodexDoc({ zone: 'canon' })).toBe(false);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe('folderJurisdictionFromPath', () => {
|
|
64
|
-
it('parses codex/external/<jurisdiction>/ paths', () => {
|
|
65
|
-
expect(folderJurisdictionFromPath('codex/external/eu/LAW-GDPR-1.yaml')).toBe('eu');
|
|
66
|
-
expect(folderJurisdictionFromPath('codex/internal/POLICY-1.yaml')).toBeUndefined();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|