@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,112 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { layoutActivities } from '../layout.js';
|
|
3
|
-
import type { ActivityDoc } from '../types.js';
|
|
4
|
-
|
|
5
|
-
const diamondDoc: ActivityDoc = {
|
|
6
|
-
notation: 'activities',
|
|
7
|
-
activities: [
|
|
8
|
-
{ id: 'A', name: 'Start', duration: 3 },
|
|
9
|
-
{ id: 'B', name: 'Left', duration: 5, predecessors: ['A'] },
|
|
10
|
-
{ id: 'C', name: 'Right', duration: 2, predecessors: ['A'] },
|
|
11
|
-
{ id: 'D', name: 'Merge', duration: 4, predecessors: ['B', 'C'] },
|
|
12
|
-
],
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('layoutActivities', () => {
|
|
16
|
-
it('returns empty layout for empty activities', () => {
|
|
17
|
-
const layout = layoutActivities({ notation: 'activities', activities: [] });
|
|
18
|
-
expect(layout.nodes).toHaveLength(0);
|
|
19
|
-
expect(layout.edges).toHaveLength(0);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('assigns each node a unique position', () => {
|
|
23
|
-
const layout = layoutActivities(diamondDoc);
|
|
24
|
-
const positions = layout.nodes.map(n => `${n.x},${n.y}`);
|
|
25
|
-
const unique = new Set(positions);
|
|
26
|
-
expect(unique.size).toBe(layout.nodes.length);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('assigns predecessors to strictly lower column indices than successors', () => {
|
|
30
|
-
const layout = layoutActivities(diamondDoc);
|
|
31
|
-
const colOf = new Map(layout.nodes.map(n => [n.id, Math.round(n.x / 280)]));
|
|
32
|
-
// A is in col 0; B and C are in col 1; D is in col 2
|
|
33
|
-
expect(colOf.get('A')).toBeLessThan(colOf.get('B')!);
|
|
34
|
-
expect(colOf.get('A')).toBeLessThan(colOf.get('C')!);
|
|
35
|
-
expect(colOf.get('B')).toBeLessThan(colOf.get('D')!);
|
|
36
|
-
expect(colOf.get('C')).toBeLessThan(colOf.get('D')!);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('produces edges connecting predecessors to successors', () => {
|
|
40
|
-
const layout = layoutActivities(diamondDoc);
|
|
41
|
-
const edgePairs = layout.edges.map(e => `${e.sourceId}->${e.targetId}`);
|
|
42
|
-
expect(edgePairs).toContain('A->B');
|
|
43
|
-
expect(edgePairs).toContain('A->C');
|
|
44
|
-
expect(edgePairs).toContain('B->D');
|
|
45
|
-
expect(edgePairs).toContain('C->D');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('marks critical edges correctly', () => {
|
|
49
|
-
// A(3)→B(5)→D(4): critical path = 3+5+4=12; C(2) has slack
|
|
50
|
-
const layout = layoutActivities(diamondDoc);
|
|
51
|
-
const edgeMap = new Map(layout.edges.map(e => [`${e.sourceId}->${e.targetId}`, e.isCritical]));
|
|
52
|
-
expect(edgeMap.get('A->B')).toBe(true);
|
|
53
|
-
expect(edgeMap.get('B->D')).toBe(true);
|
|
54
|
-
expect(edgeMap.get('A->C')).toBe(false);
|
|
55
|
-
expect(edgeMap.get('C->D')).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('attaches CPM values to nodes', () => {
|
|
59
|
-
const layout = layoutActivities(diamondDoc);
|
|
60
|
-
const nodeA = layout.nodes.find(n => n.id === 'A')!;
|
|
61
|
-
expect(nodeA.cpm).toBeDefined();
|
|
62
|
-
expect(nodeA.cpm!.es).toBe(0);
|
|
63
|
-
expect(nodeA.cpm!.ef).toBe(3);
|
|
64
|
-
expect(nodeA.cpm!.isCritical).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('respects sort field for ordering within a column', () => {
|
|
68
|
-
const doc: ActivityDoc = {
|
|
69
|
-
notation: 'activities',
|
|
70
|
-
activities: [
|
|
71
|
-
{ id: 'A', name: 'Root', duration: 1 },
|
|
72
|
-
{ id: 'B', name: 'Second', duration: 1, predecessors: ['A'], sort: 20 },
|
|
73
|
-
{ id: 'C', name: 'First', duration: 1, predecessors: ['A'], sort: 10 },
|
|
74
|
-
],
|
|
75
|
-
};
|
|
76
|
-
const layout = layoutActivities(doc);
|
|
77
|
-
const col1Nodes = layout.nodes.filter(n => n.id === 'B' || n.id === 'C').sort((a, b) => a.y - b.y);
|
|
78
|
-
// C (sort=10) should appear above B (sort=20)
|
|
79
|
-
expect(col1Nodes[0].id).toBe('C');
|
|
80
|
-
expect(col1Nodes[1].id).toBe('B');
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('computes non-empty bounds for non-empty activities', () => {
|
|
84
|
-
const layout = layoutActivities(diamondDoc);
|
|
85
|
-
expect(layout.bounds.width).toBeGreaterThan(0);
|
|
86
|
-
expect(layout.bounds.height).toBeGreaterThan(0);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// vkgeorgia/strategy#75 — configurable spacing.
|
|
90
|
-
it('empty options reproduce the default no-arg layout', () => {
|
|
91
|
-
const a = layoutActivities(diamondDoc);
|
|
92
|
-
const b = layoutActivities(diamondDoc, {});
|
|
93
|
-
expect(b.nodes.map(n => `${n.id}:${n.x},${n.y}`)).toEqual(a.nodes.map(n => `${n.id}:${n.x},${n.y}`));
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('larger horizontalGap pushes downstream columns further right', () => {
|
|
97
|
-
const xOfD = (h: number) =>
|
|
98
|
-
layoutActivities(diamondDoc, { horizontalGap: h }).nodes.find(n => n.id === 'D')!.x;
|
|
99
|
-
expect(xOfD(200)).toBeGreaterThan(xOfD(80));
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('larger verticalGap increases the gap between stacked column nodes', () => {
|
|
103
|
-
const gapOf = (v: number) => {
|
|
104
|
-
const ys = layoutActivities(diamondDoc, { verticalGap: v })
|
|
105
|
-
.nodes.filter(n => n.id === 'B' || n.id === 'C')
|
|
106
|
-
.map(n => n.y)
|
|
107
|
-
.sort((a, b) => a - b);
|
|
108
|
-
return ys[1] - ys[0];
|
|
109
|
-
};
|
|
110
|
-
expect(gapOf(100)).toBeGreaterThan(gapOf(24));
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1,446 +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 { validateActivities } from '../validate.js';
|
|
6
|
-
|
|
7
|
-
const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'action');
|
|
8
|
-
|
|
9
|
-
const minimalValid = {
|
|
10
|
-
notation: 'action',
|
|
11
|
-
actions: [
|
|
12
|
-
{ id: 'A-001', name: 'Start', duration: 3 },
|
|
13
|
-
{ id: 'A-002', name: 'End', duration: 2, predecessors: ['A-001'] },
|
|
14
|
-
],
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe('validateActivities', () => {
|
|
18
|
-
it('ACT-001 — accepts notation: action (canonical)', () => {
|
|
19
|
-
const r = validateActivities(minimalValid);
|
|
20
|
-
expect(r.valid).toBe(true);
|
|
21
|
-
expect(r.warnings.some(w => w.code === 'DEPRECATED_NOTATION')).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('ACT-001 — rejects notation: activities (no longer accepted)', () => {
|
|
25
|
-
const r = validateActivities({
|
|
26
|
-
notation: 'activities',
|
|
27
|
-
activities: [
|
|
28
|
-
{ id: 'A-001', name: 'Start', duration: 3 },
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
expect(r.valid).toBe(false);
|
|
32
|
-
expect(r.errors.some(e => e.code === 'ACT-001')).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('ACT-001 — rejects activities: root key (only actions: accepted)', () => {
|
|
36
|
-
const r = validateActivities({
|
|
37
|
-
notation: 'action',
|
|
38
|
-
activities: [{ id: 'ACTION-001', name: 'Foo', duration: 1 }],
|
|
39
|
-
});
|
|
40
|
-
expect(r.valid).toBe(false);
|
|
41
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('ACT-001 — normalises action_type to activity_type for downstream layout', () => {
|
|
45
|
-
const input: Record<string, unknown> = {
|
|
46
|
-
notation: 'action',
|
|
47
|
-
actions: [{ id: 'ACTION-001', name: 'Foo', duration: 1, action_type: 'project' }],
|
|
48
|
-
};
|
|
49
|
-
const r = validateActivities(input);
|
|
50
|
-
expect(r.valid).toBe(true);
|
|
51
|
-
const entry = (input.actions as Array<Record<string, unknown>>)[0];
|
|
52
|
-
expect(entry['activity_type']).toBe('project');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('ACT-001 — rejects missing notation', () => {
|
|
56
|
-
const r = validateActivities({ activities: [] });
|
|
57
|
-
expect(r.valid).toBe(false);
|
|
58
|
-
expect(r.errors[0].code).toBe('ACT-001');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('ACT-001 — rejects wrong notation value', () => {
|
|
62
|
-
const r = validateActivities({ notation: 'bpmn', activities: [] });
|
|
63
|
-
expect(r.valid).toBe(false);
|
|
64
|
-
expect(r.errors[0].code).toBe('ACT-001');
|
|
65
|
-
expect(r.errors[0].message).toContain('"bpmn"');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('ACT-002 — rejects activity with missing id', () => {
|
|
69
|
-
const r = validateActivities({
|
|
70
|
-
notation: 'action',
|
|
71
|
-
actions: [{ name: 'No ID', duration: 1 }],
|
|
72
|
-
});
|
|
73
|
-
expect(r.valid).toBe(false);
|
|
74
|
-
expect(r.errors.some(e => e.code === 'ACT-002')).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('ACT-002 — rejects activity with empty id', () => {
|
|
78
|
-
const r = validateActivities({
|
|
79
|
-
notation: 'action',
|
|
80
|
-
actions: [{ id: ' ', name: 'Empty ID', duration: 1 }],
|
|
81
|
-
});
|
|
82
|
-
expect(r.valid).toBe(false);
|
|
83
|
-
expect(r.errors.some(e => e.code === 'ACT-002')).toBe(true);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('ACT-003 — rejects activity with missing name', () => {
|
|
87
|
-
const r = validateActivities({
|
|
88
|
-
notation: 'action',
|
|
89
|
-
actions: [{ id: 'A-001', duration: 1 }],
|
|
90
|
-
});
|
|
91
|
-
expect(r.valid).toBe(false);
|
|
92
|
-
expect(r.errors.some(e => e.code === 'ACT-003')).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('ACT-004 — rejects duplicate ids', () => {
|
|
96
|
-
const r = validateActivities({
|
|
97
|
-
notation: 'action',
|
|
98
|
-
actions: [
|
|
99
|
-
{ id: 'A-001', name: 'First', duration: 1 },
|
|
100
|
-
{ id: 'A-001', name: 'Duplicate', duration: 2 },
|
|
101
|
-
],
|
|
102
|
-
});
|
|
103
|
-
expect(r.valid).toBe(false);
|
|
104
|
-
expect(r.errors.some(e => e.code === 'ACT-004')).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('ACT-005 — rejects unknown predecessor reference', () => {
|
|
108
|
-
const r = validateActivities({
|
|
109
|
-
notation: 'action',
|
|
110
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, predecessors: ['MISSING'] }],
|
|
111
|
-
});
|
|
112
|
-
expect(r.valid).toBe(false);
|
|
113
|
-
expect(r.errors.some(e => e.code === 'ACT-005')).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('ACT-005 — passes when predecessor exists', () => {
|
|
117
|
-
const r = validateActivities(minimalValid);
|
|
118
|
-
expect(r.valid).toBe(true);
|
|
119
|
-
expect(r.errors.some(e => e.code === 'ACT-005')).toBe(false);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('ACT-006 — rejects cyclic dependency', () => {
|
|
123
|
-
const r = validateActivities({
|
|
124
|
-
notation: 'action',
|
|
125
|
-
actions: [
|
|
126
|
-
{ id: 'A-001', name: 'Task A', duration: 1, predecessors: ['A-002'] },
|
|
127
|
-
{ id: 'A-002', name: 'Task B', duration: 1, predecessors: ['A-001'] },
|
|
128
|
-
],
|
|
129
|
-
});
|
|
130
|
-
expect(r.valid).toBe(false);
|
|
131
|
-
expect(r.errors.some(e => e.code === 'ACT-006')).toBe(true);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('ACT-007 — rejects self-loop', () => {
|
|
135
|
-
const r = validateActivities({
|
|
136
|
-
notation: 'action',
|
|
137
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, predecessors: ['A-001'] }],
|
|
138
|
-
});
|
|
139
|
-
expect(r.valid).toBe(false);
|
|
140
|
-
expect(r.errors.some(e => e.code === 'ACT-007')).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('ACT-008 — rejects end_date before start_date', () => {
|
|
144
|
-
const r = validateActivities({
|
|
145
|
-
notation: 'action',
|
|
146
|
-
actions: [
|
|
147
|
-
{ id: 'A-001', name: 'Task', duration: 5, start_date: '2026-06-10', end_date: '2026-06-01' },
|
|
148
|
-
],
|
|
149
|
-
});
|
|
150
|
-
expect(r.valid).toBe(false);
|
|
151
|
-
expect(r.errors.some(e => e.code === 'ACT-008')).toBe(true);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('ACT-008 — accepts end_date equal to start_date', () => {
|
|
155
|
-
const r = validateActivities({
|
|
156
|
-
notation: 'action',
|
|
157
|
-
actions: [
|
|
158
|
-
{ id: 'A-001', name: 'Task', duration: 0, start_date: '2026-06-01', end_date: '2026-06-01' },
|
|
159
|
-
],
|
|
160
|
-
});
|
|
161
|
-
expect(r.errors.some(e => e.code === 'ACT-008')).toBe(false);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it('ACT-008 — rejects non-ISO start_date format', () => {
|
|
165
|
-
const r = validateActivities({
|
|
166
|
-
notation: 'action',
|
|
167
|
-
actions: [
|
|
168
|
-
{ id: 'A-001', name: 'Task', duration: 5, start_date: 'June 1 2026' },
|
|
169
|
-
],
|
|
170
|
-
});
|
|
171
|
-
expect(r.valid).toBe(false);
|
|
172
|
-
expect(r.errors.some(e => e.code === 'ACT-008' && /start_date/.test(e.message))).toBe(true);
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
it('ACT-008 — rejects non-ISO end_date format', () => {
|
|
176
|
-
const r = validateActivities({
|
|
177
|
-
notation: 'action',
|
|
178
|
-
actions: [
|
|
179
|
-
{ id: 'A-001', name: 'Task', duration: 5, end_date: '2026/06/30' },
|
|
180
|
-
],
|
|
181
|
-
});
|
|
182
|
-
expect(r.valid).toBe(false);
|
|
183
|
-
expect(r.errors.some(e => e.code === 'ACT-008' && /end_date/.test(e.message))).toBe(true);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('ACT-008 — does not raise the order-compare error when dates are malformed', () => {
|
|
187
|
-
// If start_date and end_date are both wrongly formatted, the file already
|
|
188
|
-
// has two ACT-008 format errors — adding a third "end < start" complaint
|
|
189
|
-
// on top would be misleading because the lexicographic compare is
|
|
190
|
-
// meaningless on non-ISO strings.
|
|
191
|
-
const r = validateActivities({
|
|
192
|
-
notation: 'action',
|
|
193
|
-
actions: [
|
|
194
|
-
{ id: 'A-001', name: 'Task', duration: 5, start_date: 'tomorrow', end_date: 'yesterday' },
|
|
195
|
-
],
|
|
196
|
-
});
|
|
197
|
-
expect(r.errors.filter(e => e.code === 'ACT-008').length).toBe(2);
|
|
198
|
-
expect(r.errors.every(e => /must be ISO 8601 YYYY-MM-DD/.test(e.message))).toBe(true);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it('ACT-009 — rejects negative duration', () => {
|
|
202
|
-
const r = validateActivities({
|
|
203
|
-
notation: 'action',
|
|
204
|
-
actions: [{ id: 'A-001', name: 'Task', duration: -1 }],
|
|
205
|
-
});
|
|
206
|
-
expect(r.valid).toBe(false);
|
|
207
|
-
expect(r.errors.some(e => e.code === 'ACT-009')).toBe(true);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('ACT-009 — accepts zero duration', () => {
|
|
211
|
-
const r = validateActivities({
|
|
212
|
-
notation: 'action',
|
|
213
|
-
actions: [{ id: 'A-001', name: 'Milestone', duration: 0 }],
|
|
214
|
-
});
|
|
215
|
-
expect(r.errors.some(e => e.code === 'ACT-009')).toBe(false);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('ACT-010 — rejects singular "goal:" field', () => {
|
|
219
|
-
const r = validateActivities({
|
|
220
|
-
notation: 'action',
|
|
221
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, goal: 'GOAL-001' } as any],
|
|
222
|
-
});
|
|
223
|
-
expect(r.valid).toBe(false);
|
|
224
|
-
expect(r.errors.some(e => e.code === 'ACT-010')).toBe(true);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('ACT-010 — rejects singular "predecessor:" field', () => {
|
|
228
|
-
const r = validateActivities({
|
|
229
|
-
notation: 'action',
|
|
230
|
-
actions: [
|
|
231
|
-
{ id: 'A-001', name: 'First', duration: 1 },
|
|
232
|
-
{ id: 'A-002', name: 'Task', duration: 1, predecessor: 'A-001' } as any,
|
|
233
|
-
],
|
|
234
|
-
});
|
|
235
|
-
expect(r.valid).toBe(false);
|
|
236
|
-
expect(r.errors.some(e => e.code === 'ACT-010')).toBe(true);
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
it('ACT-010 — rejects singular "tag:" field', () => {
|
|
240
|
-
const r = validateActivities({
|
|
241
|
-
notation: 'action',
|
|
242
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, tag: 'q3' } as any],
|
|
243
|
-
});
|
|
244
|
-
expect(r.valid).toBe(false);
|
|
245
|
-
expect(r.errors.some(e => e.code === 'ACT-010')).toBe(true);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
it('ACT-011 — warns when duration is absent', () => {
|
|
249
|
-
const r = validateActivities({
|
|
250
|
-
notation: 'action',
|
|
251
|
-
actions: [{ id: 'A-001', name: 'No duration' }],
|
|
252
|
-
});
|
|
253
|
-
expect(r.valid).toBe(true);
|
|
254
|
-
expect(r.warnings.some(w => w.code === 'ACT-011')).toBe(true);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('ACT-013 — warns on structurally orphan activity', () => {
|
|
258
|
-
const r = validateActivities({
|
|
259
|
-
notation: 'action',
|
|
260
|
-
actions: [
|
|
261
|
-
{ id: 'A-001', name: 'Connected', duration: 1 },
|
|
262
|
-
{ id: 'A-002', name: 'Orphan', duration: 1 },
|
|
263
|
-
{ id: 'A-003', name: 'End', duration: 1, predecessors: ['A-001'] },
|
|
264
|
-
],
|
|
265
|
-
});
|
|
266
|
-
expect(r.valid).toBe(true);
|
|
267
|
-
const orphanWarnings = r.warnings.filter(w => w.code === 'ACT-013');
|
|
268
|
-
expect(orphanWarnings.some(w => w.message.includes('A-002'))).toBe(true);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
it('full valid example passes with no errors', () => {
|
|
272
|
-
const r = validateActivities({
|
|
273
|
-
notation: 'action',
|
|
274
|
-
title: 'Test Project',
|
|
275
|
-
actions: [
|
|
276
|
-
{ id: 'A', name: 'Start', duration: 3 },
|
|
277
|
-
{ id: 'B', name: 'Middle', duration: 5, predecessors: ['A'] },
|
|
278
|
-
{ id: 'C', name: 'End', duration: 2, predecessors: ['B'] },
|
|
279
|
-
],
|
|
280
|
-
});
|
|
281
|
-
expect(r.valid).toBe(true);
|
|
282
|
-
expect(r.errors).toHaveLength(0);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
// ── Project block + calendar (ACT-014, ACT-015) ───────────────────────────
|
|
286
|
-
|
|
287
|
-
it('ACT-014 — rejects unknown weekday in working_days', () => {
|
|
288
|
-
const r = validateActivities({
|
|
289
|
-
...minimalValid,
|
|
290
|
-
project: { start_date: '2026-06-01', calendar: { working_days: ['mon', 'funday'] } },
|
|
291
|
-
});
|
|
292
|
-
expect(r.valid).toBe(false);
|
|
293
|
-
expect(r.errors.some(e => e.code === 'ACT-014' && /funday/.test(e.message))).toBe(true);
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
it('ACT-014 — rejects duplicate weekday entries', () => {
|
|
297
|
-
const r = validateActivities({
|
|
298
|
-
...minimalValid,
|
|
299
|
-
project: { calendar: { working_days: ['mon', 'tue', 'mon'] } },
|
|
300
|
-
});
|
|
301
|
-
expect(r.valid).toBe(false);
|
|
302
|
-
expect(r.errors.some(e => e.code === 'ACT-014' && /duplicate/i.test(e.message))).toBe(true);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it('ACT-014 — accepts mixed-case weekday names', () => {
|
|
306
|
-
const r = validateActivities({
|
|
307
|
-
...minimalValid,
|
|
308
|
-
project: { start_date: '2026-06-01', calendar: { working_days: ['MON', 'Tue', 'wed', 'thu', 'fri'] } },
|
|
309
|
-
});
|
|
310
|
-
expect(r.errors.some(e => e.code === 'ACT-014')).toBe(false);
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it('ACT-015 — rejects non-ISO holiday date', () => {
|
|
314
|
-
const r = validateActivities({
|
|
315
|
-
...minimalValid,
|
|
316
|
-
project: { start_date: '2026-06-01', calendar: { holidays: ['2026-07-04', 'July 4 2026'] } },
|
|
317
|
-
});
|
|
318
|
-
expect(r.valid).toBe(false);
|
|
319
|
-
expect(r.errors.some(e => e.code === 'ACT-015' && /July 4 2026/.test(e.message))).toBe(true);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
it('ACT-015 — accepts an array of ISO dates', () => {
|
|
323
|
-
const r = validateActivities({
|
|
324
|
-
...minimalValid,
|
|
325
|
-
project: { start_date: '2026-06-01', calendar: { holidays: ['2026-07-04', '2026-12-25'] } },
|
|
326
|
-
});
|
|
327
|
-
expect(r.errors.some(e => e.code === 'ACT-015')).toBe(false);
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
// ── Milestone date equality (ACT-016) ─────────────────────────────────────
|
|
331
|
-
|
|
332
|
-
it('ACT-016 — rejects milestone with mismatched start/end dates', () => {
|
|
333
|
-
const r = validateActivities({
|
|
334
|
-
notation: 'action',
|
|
335
|
-
actions: [
|
|
336
|
-
{ id: 'M-1', name: 'Launch', duration: 0, start_date: '2026-06-01', end_date: '2026-06-02' },
|
|
337
|
-
],
|
|
338
|
-
});
|
|
339
|
-
expect(r.valid).toBe(false);
|
|
340
|
-
expect(r.errors.some(e => e.code === 'ACT-016')).toBe(true);
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it('ACT-016 — accepts milestone with equal start/end dates', () => {
|
|
344
|
-
const r = validateActivities({
|
|
345
|
-
notation: 'action',
|
|
346
|
-
actions: [
|
|
347
|
-
{ id: 'M-1', name: 'Launch', duration: 0, start_date: '2026-06-01', end_date: '2026-06-01' },
|
|
348
|
-
],
|
|
349
|
-
});
|
|
350
|
-
expect(r.errors.some(e => e.code === 'ACT-016')).toBe(false);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// ── Phase warnings (ACT-017, ACT-018) ─────────────────────────────────────
|
|
354
|
-
|
|
355
|
-
it('ACT-017 — warns when a referenced-as-parent activity carries its own duration', () => {
|
|
356
|
-
const r = validateActivities({
|
|
357
|
-
notation: 'action',
|
|
358
|
-
actions: [
|
|
359
|
-
{ id: 'PHASE-1', name: 'Design', duration: 5 },
|
|
360
|
-
{ id: 'A-1', name: 'Child', duration: 3, parent: 'PHASE-1' },
|
|
361
|
-
],
|
|
362
|
-
});
|
|
363
|
-
expect(r.valid).toBe(true);
|
|
364
|
-
expect(r.warnings.some(w => w.code === 'ACT-017' && /PHASE-1/.test(w.message))).toBe(true);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('ACT-017 — no warning when phase omits duration/dates and rolls up from children', () => {
|
|
368
|
-
const r = validateActivities({
|
|
369
|
-
notation: 'action',
|
|
370
|
-
actions: [
|
|
371
|
-
{ id: 'PHASE-1', name: 'Design' },
|
|
372
|
-
{ id: 'A-1', name: 'Child', duration: 3, parent: 'PHASE-1' },
|
|
373
|
-
],
|
|
374
|
-
});
|
|
375
|
-
expect(r.warnings.some(w => w.code === 'ACT-017')).toBe(false);
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it('ACT-018 — warns when an activity with no duration is not referenced as parent', () => {
|
|
379
|
-
const r = validateActivities({
|
|
380
|
-
notation: 'action',
|
|
381
|
-
actions: [
|
|
382
|
-
{ id: 'A-1', name: 'Has duration', duration: 3 },
|
|
383
|
-
{ id: 'P-EMPTY', name: 'Looks like phase but no children' },
|
|
384
|
-
],
|
|
385
|
-
});
|
|
386
|
-
expect(r.warnings.some(w => w.code === 'ACT-018' && /P-EMPTY/.test(w.message))).toBe(true);
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
it('ACT-018 — no warning when the no-duration activity has at least one child', () => {
|
|
390
|
-
const r = validateActivities({
|
|
391
|
-
notation: 'action',
|
|
392
|
-
actions: [
|
|
393
|
-
{ id: 'PHASE-1', name: 'Phase' },
|
|
394
|
-
{ id: 'A-1', name: 'Child', duration: 3, parent: 'PHASE-1' },
|
|
395
|
-
],
|
|
396
|
-
});
|
|
397
|
-
expect(r.warnings.some(w => w.code === 'ACT-018')).toBe(false);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// ── Gantt-renderability notice (ACT-019) ──────────────────────────────────
|
|
401
|
-
|
|
402
|
-
it('ACT-019 — warns when neither project.start_date nor pinned dates exist', () => {
|
|
403
|
-
const r = validateActivities(minimalValid);
|
|
404
|
-
expect(r.warnings.some(w => w.code === 'ACT-019')).toBe(true);
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
it('ACT-019 — no warning when project.start_date is set', () => {
|
|
408
|
-
const r = validateActivities({ ...minimalValid, project: { start_date: '2026-06-01' } });
|
|
409
|
-
expect(r.warnings.some(w => w.code === 'ACT-019')).toBe(false);
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
it('ACT-019 — no warning when every activity has pinned dates', () => {
|
|
413
|
-
const r = validateActivities({
|
|
414
|
-
notation: 'action',
|
|
415
|
-
actions: [
|
|
416
|
-
{ id: 'A-1', name: 'A', duration: 3, start_date: '2026-06-01', end_date: '2026-06-04' },
|
|
417
|
-
],
|
|
418
|
-
});
|
|
419
|
-
expect(r.warnings.some(w => w.code === 'ACT-019')).toBe(false);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('[blocker] tolerates a null element in actions[] without throwing', () => {
|
|
423
|
-
// Do NOT spread minimalValid here: validateActivities mutates its input
|
|
424
|
-
// to normalise raw.activities, so a previously-called test that passed
|
|
425
|
-
// minimalValid directly would have set minimalValid.activities. Spreading
|
|
426
|
-
// that mutated object would cause the actions:[null] override to be masked
|
|
427
|
-
// by the pre-existing activities array.
|
|
428
|
-
const r = validateActivities({ notation: 'action', actions: [null] });
|
|
429
|
-
expect(r.valid).toBe(false);
|
|
430
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
describe('action examples (regression)', () => {
|
|
435
|
-
const files = fs.readdirSync(EXAMPLES_DIR).filter(f => f.endsWith('.yaml'));
|
|
436
|
-
expect(files.length).toBeGreaterThan(0);
|
|
437
|
-
for (const file of files) {
|
|
438
|
-
it(`validates tests/fixtures/notation-corpus/action/${file}`, () => {
|
|
439
|
-
const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
|
|
440
|
-
const parsed = yaml.load(text);
|
|
441
|
-
const r = validateActivities(parsed);
|
|
442
|
-
expect(r.errors).toEqual([]);
|
|
443
|
-
expect(r.valid).toBe(true);
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Conformance test for the shipped worked example. Exercises the full
|
|
2
|
-
// validate → resolve → layout pipeline against the real co-located example
|
|
3
|
-
// files under `tests/fixtures/notation-corpus/activity-card/`, so the success signal of #134 is
|
|
4
|
-
// pinned and any drift in the example or the resolver is caught by CI.
|
|
5
|
-
|
|
6
|
-
import { describe, it, expect } from 'vitest';
|
|
7
|
-
import { readFileSync, readdirSync } from 'node:fs';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import yaml from 'js-yaml';
|
|
11
|
-
import { validateActivityCard } from '../validate.js';
|
|
12
|
-
import { resolveActivityCard } from '../resolver.js';
|
|
13
|
-
import { layoutActivityCard } from '../layout.js';
|
|
14
|
-
import type { ActivityCardDoc } from '../types.js';
|
|
15
|
-
|
|
16
|
-
const dir = path.resolve(
|
|
17
|
-
path.dirname(fileURLToPath(import.meta.url)),
|
|
18
|
-
'../../../../../tests/fixtures/notation-corpus/action-card',
|
|
19
|
-
);
|
|
20
|
-
const load = (f: string): unknown => yaml.load(readFileSync(path.join(dir, f), 'utf-8'));
|
|
21
|
-
|
|
22
|
-
/** Recursively load every `*.yaml` doc under a canon subtree (mirrors the
|
|
23
|
-
* extension's element/relation walk). */
|
|
24
|
-
function loadYamlTree(root: string): unknown[] {
|
|
25
|
-
const out: unknown[] = [];
|
|
26
|
-
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
27
|
-
const full = path.join(root, entry.name);
|
|
28
|
-
if (entry.isDirectory()) out.push(...loadYamlTree(full));
|
|
29
|
-
else if (entry.name.endsWith('.yaml')) out.push(yaml.load(readFileSync(full, 'utf-8')));
|
|
30
|
-
}
|
|
31
|
-
return out;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
describe('activity-card worked example (eu-programme)', () => {
|
|
35
|
-
it('validates, resolves, and lays out the success-signal card', () => {
|
|
36
|
-
const card = load('eu-programme.action-card.transitrix.yaml');
|
|
37
|
-
const elements = loadYamlTree(path.join(dir, 'canon', 'elements'));
|
|
38
|
-
const relations = loadYamlTree(path.join(dir, 'canon', 'relations'));
|
|
39
|
-
|
|
40
|
-
const v = validateActivityCard(card);
|
|
41
|
-
expect(v.valid, JSON.stringify(v.errors)).toBe(true);
|
|
42
|
-
|
|
43
|
-
const r = resolveActivityCard(card as ActivityCardDoc, { elements, relations });
|
|
44
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
45
|
-
expect(r.warnings, JSON.stringify(r.warnings)).toHaveLength(0);
|
|
46
|
-
|
|
47
|
-
const c = r.resolved!;
|
|
48
|
-
expect(c.project.name).toBe('EU MDR conformity programme');
|
|
49
|
-
expect(c.project.valid_from).toBe('2026-04-01');
|
|
50
|
-
expect(c.project.start_date).toBe('2026-04-15');
|
|
51
|
-
expect(c.project.end_date).toBe('2027-03-15');
|
|
52
|
-
expect(c.milestones.map((m) => m.id)).toEqual([
|
|
53
|
-
'MILESTONE-EU-CONFORMITY-CERT-1',
|
|
54
|
-
'MILESTONE-EU-MARKET-LAUNCH-1',
|
|
55
|
-
]);
|
|
56
|
-
expect(c.motivation.drivers.map((d) => d.id)).toEqual(['FACTOR-EU-MDR-1']);
|
|
57
|
-
expect(c.motivation.goals.map((g) => g.id)).toEqual(['GOAL-EU-MARKET-1']);
|
|
58
|
-
expect(c.motivation.changes.map((x) => x.id)).toEqual(['CHANGE-EU-COMPLIANCE-1']);
|
|
59
|
-
expect(c.childActivities).toHaveLength(4);
|
|
60
|
-
// Project goal text field resolves to the directly-served goal name; the
|
|
61
|
-
// example links no stakeholders, so the card shows the field empty.
|
|
62
|
-
expect(c.goalNames).toEqual(['Maintain EU market access under MDR']);
|
|
63
|
-
expect(c.stakeholders).toEqual([]);
|
|
64
|
-
|
|
65
|
-
const layout = layoutActivityCard(c);
|
|
66
|
-
expect(layout.bounds.height).toBeGreaterThan(0);
|
|
67
|
-
// Header
|
|
68
|
-
expect(layout.titleRow.name).toBe('EU MDR conformity programme');
|
|
69
|
-
expect(layout.dateFields[0]).toMatchObject({ label: 'Initiation', value: '2026-04-01' });
|
|
70
|
-
expect(layout.stakeholderRoleSlots).toHaveLength(4);
|
|
71
|
-
// Description row
|
|
72
|
-
expect(layout.descriptionRow?.label).toBe('Description');
|
|
73
|
-
// Chain sections
|
|
74
|
-
expect(layout.chainSections.map((s) => s.type)).toEqual(['drivers', 'goals', 'changes']);
|
|
75
|
-
const driversSection = layout.chainSections.find((s) => s.type === 'drivers')!;
|
|
76
|
-
const goalsSection = layout.chainSections.find((s) => s.type === 'goals')!;
|
|
77
|
-
expect(driversSection.nodes.map((n) => n.id)).toContain('FACTOR-EU-MDR-1');
|
|
78
|
-
expect(goalsSection.nodes.map((n) => n.id)).toContain('GOAL-EU-MARKET-1');
|
|
79
|
-
// Chain edges
|
|
80
|
-
expect(layout.chainEdges).toContainEqual({ sourceId: 'FACTOR-EU-MDR-1', targetId: 'GOAL-EU-MARKET-1' });
|
|
81
|
-
expect(layout.chainEdges).toContainEqual({ sourceId: 'GOAL-EU-MARKET-1', targetId: 'CHANGE-EU-COMPLIANCE-1' });
|
|
82
|
-
});
|
|
83
|
-
});
|