@transitrix/diagrams 1.8.4 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edge-path.js +10 -1
- package/dist/webview/render-activities.d.ts +1 -1
- package/dist/webview/render-activities.js +2 -2
- package/dist/webview/render-fgca.js +1 -4
- package/package.json +7 -2
- package/src/edge-path.ts +15 -1
- package/src/webview/render-activities.ts +2 -2
- package/src/webview/render-fgca.ts +1 -4
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -47
- 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 -58
- 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,397 +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
|
-
const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'action');
|
|
7
|
-
const minimalValid = {
|
|
8
|
-
notation: 'action',
|
|
9
|
-
actions: [
|
|
10
|
-
{ id: 'A-001', name: 'Start', duration: 3 },
|
|
11
|
-
{ id: 'A-002', name: 'End', duration: 2, predecessors: ['A-001'] },
|
|
12
|
-
],
|
|
13
|
-
};
|
|
14
|
-
describe('validateActivities', () => {
|
|
15
|
-
it('ACT-001 — accepts notation: action (canonical)', () => {
|
|
16
|
-
const r = validateActivities(minimalValid);
|
|
17
|
-
expect(r.valid).toBe(true);
|
|
18
|
-
expect(r.warnings.some(w => w.code === 'DEPRECATED_NOTATION')).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
it('ACT-001 — rejects notation: activities (no longer accepted)', () => {
|
|
21
|
-
const r = validateActivities({
|
|
22
|
-
notation: 'activities',
|
|
23
|
-
activities: [
|
|
24
|
-
{ id: 'A-001', name: 'Start', duration: 3 },
|
|
25
|
-
],
|
|
26
|
-
});
|
|
27
|
-
expect(r.valid).toBe(false);
|
|
28
|
-
expect(r.errors.some(e => e.code === 'ACT-001')).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
it('ACT-001 — rejects activities: root key (only actions: accepted)', () => {
|
|
31
|
-
const r = validateActivities({
|
|
32
|
-
notation: 'action',
|
|
33
|
-
activities: [{ id: 'ACTION-001', name: 'Foo', duration: 1 }],
|
|
34
|
-
});
|
|
35
|
-
expect(r.valid).toBe(false);
|
|
36
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
37
|
-
});
|
|
38
|
-
it('ACT-001 — normalises action_type to activity_type for downstream layout', () => {
|
|
39
|
-
const input = {
|
|
40
|
-
notation: 'action',
|
|
41
|
-
actions: [{ id: 'ACTION-001', name: 'Foo', duration: 1, action_type: 'project' }],
|
|
42
|
-
};
|
|
43
|
-
const r = validateActivities(input);
|
|
44
|
-
expect(r.valid).toBe(true);
|
|
45
|
-
const entry = input.actions[0];
|
|
46
|
-
expect(entry['activity_type']).toBe('project');
|
|
47
|
-
});
|
|
48
|
-
it('ACT-001 — rejects missing notation', () => {
|
|
49
|
-
const r = validateActivities({ activities: [] });
|
|
50
|
-
expect(r.valid).toBe(false);
|
|
51
|
-
expect(r.errors[0].code).toBe('ACT-001');
|
|
52
|
-
});
|
|
53
|
-
it('ACT-001 — rejects wrong notation value', () => {
|
|
54
|
-
const r = validateActivities({ notation: 'bpmn', activities: [] });
|
|
55
|
-
expect(r.valid).toBe(false);
|
|
56
|
-
expect(r.errors[0].code).toBe('ACT-001');
|
|
57
|
-
expect(r.errors[0].message).toContain('"bpmn"');
|
|
58
|
-
});
|
|
59
|
-
it('ACT-002 — rejects activity with missing id', () => {
|
|
60
|
-
const r = validateActivities({
|
|
61
|
-
notation: 'action',
|
|
62
|
-
actions: [{ name: 'No ID', duration: 1 }],
|
|
63
|
-
});
|
|
64
|
-
expect(r.valid).toBe(false);
|
|
65
|
-
expect(r.errors.some(e => e.code === 'ACT-002')).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it('ACT-002 — rejects activity with empty id', () => {
|
|
68
|
-
const r = validateActivities({
|
|
69
|
-
notation: 'action',
|
|
70
|
-
actions: [{ id: ' ', name: 'Empty ID', duration: 1 }],
|
|
71
|
-
});
|
|
72
|
-
expect(r.valid).toBe(false);
|
|
73
|
-
expect(r.errors.some(e => e.code === 'ACT-002')).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
it('ACT-003 — rejects activity with missing name', () => {
|
|
76
|
-
const r = validateActivities({
|
|
77
|
-
notation: 'action',
|
|
78
|
-
actions: [{ id: 'A-001', duration: 1 }],
|
|
79
|
-
});
|
|
80
|
-
expect(r.valid).toBe(false);
|
|
81
|
-
expect(r.errors.some(e => e.code === 'ACT-003')).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
it('ACT-004 — rejects duplicate ids', () => {
|
|
84
|
-
const r = validateActivities({
|
|
85
|
-
notation: 'action',
|
|
86
|
-
actions: [
|
|
87
|
-
{ id: 'A-001', name: 'First', duration: 1 },
|
|
88
|
-
{ id: 'A-001', name: 'Duplicate', duration: 2 },
|
|
89
|
-
],
|
|
90
|
-
});
|
|
91
|
-
expect(r.valid).toBe(false);
|
|
92
|
-
expect(r.errors.some(e => e.code === 'ACT-004')).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
it('ACT-005 — rejects unknown predecessor reference', () => {
|
|
95
|
-
const r = validateActivities({
|
|
96
|
-
notation: 'action',
|
|
97
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, predecessors: ['MISSING'] }],
|
|
98
|
-
});
|
|
99
|
-
expect(r.valid).toBe(false);
|
|
100
|
-
expect(r.errors.some(e => e.code === 'ACT-005')).toBe(true);
|
|
101
|
-
});
|
|
102
|
-
it('ACT-005 — passes when predecessor exists', () => {
|
|
103
|
-
const r = validateActivities(minimalValid);
|
|
104
|
-
expect(r.valid).toBe(true);
|
|
105
|
-
expect(r.errors.some(e => e.code === 'ACT-005')).toBe(false);
|
|
106
|
-
});
|
|
107
|
-
it('ACT-006 — rejects cyclic dependency', () => {
|
|
108
|
-
const r = validateActivities({
|
|
109
|
-
notation: 'action',
|
|
110
|
-
actions: [
|
|
111
|
-
{ id: 'A-001', name: 'Task A', duration: 1, predecessors: ['A-002'] },
|
|
112
|
-
{ id: 'A-002', name: 'Task B', duration: 1, predecessors: ['A-001'] },
|
|
113
|
-
],
|
|
114
|
-
});
|
|
115
|
-
expect(r.valid).toBe(false);
|
|
116
|
-
expect(r.errors.some(e => e.code === 'ACT-006')).toBe(true);
|
|
117
|
-
});
|
|
118
|
-
it('ACT-007 — rejects self-loop', () => {
|
|
119
|
-
const r = validateActivities({
|
|
120
|
-
notation: 'action',
|
|
121
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, predecessors: ['A-001'] }],
|
|
122
|
-
});
|
|
123
|
-
expect(r.valid).toBe(false);
|
|
124
|
-
expect(r.errors.some(e => e.code === 'ACT-007')).toBe(true);
|
|
125
|
-
});
|
|
126
|
-
it('ACT-008 — rejects end_date before start_date', () => {
|
|
127
|
-
const r = validateActivities({
|
|
128
|
-
notation: 'action',
|
|
129
|
-
actions: [
|
|
130
|
-
{ id: 'A-001', name: 'Task', duration: 5, start_date: '2026-06-10', end_date: '2026-06-01' },
|
|
131
|
-
],
|
|
132
|
-
});
|
|
133
|
-
expect(r.valid).toBe(false);
|
|
134
|
-
expect(r.errors.some(e => e.code === 'ACT-008')).toBe(true);
|
|
135
|
-
});
|
|
136
|
-
it('ACT-008 — accepts end_date equal to start_date', () => {
|
|
137
|
-
const r = validateActivities({
|
|
138
|
-
notation: 'action',
|
|
139
|
-
actions: [
|
|
140
|
-
{ id: 'A-001', name: 'Task', duration: 0, start_date: '2026-06-01', end_date: '2026-06-01' },
|
|
141
|
-
],
|
|
142
|
-
});
|
|
143
|
-
expect(r.errors.some(e => e.code === 'ACT-008')).toBe(false);
|
|
144
|
-
});
|
|
145
|
-
it('ACT-008 — rejects non-ISO start_date format', () => {
|
|
146
|
-
const r = validateActivities({
|
|
147
|
-
notation: 'action',
|
|
148
|
-
actions: [
|
|
149
|
-
{ id: 'A-001', name: 'Task', duration: 5, start_date: 'June 1 2026' },
|
|
150
|
-
],
|
|
151
|
-
});
|
|
152
|
-
expect(r.valid).toBe(false);
|
|
153
|
-
expect(r.errors.some(e => e.code === 'ACT-008' && /start_date/.test(e.message))).toBe(true);
|
|
154
|
-
});
|
|
155
|
-
it('ACT-008 — rejects non-ISO end_date format', () => {
|
|
156
|
-
const r = validateActivities({
|
|
157
|
-
notation: 'action',
|
|
158
|
-
actions: [
|
|
159
|
-
{ id: 'A-001', name: 'Task', duration: 5, end_date: '2026/06/30' },
|
|
160
|
-
],
|
|
161
|
-
});
|
|
162
|
-
expect(r.valid).toBe(false);
|
|
163
|
-
expect(r.errors.some(e => e.code === 'ACT-008' && /end_date/.test(e.message))).toBe(true);
|
|
164
|
-
});
|
|
165
|
-
it('ACT-008 — does not raise the order-compare error when dates are malformed', () => {
|
|
166
|
-
// If start_date and end_date are both wrongly formatted, the file already
|
|
167
|
-
// has two ACT-008 format errors — adding a third "end < start" complaint
|
|
168
|
-
// on top would be misleading because the lexicographic compare is
|
|
169
|
-
// meaningless on non-ISO strings.
|
|
170
|
-
const r = validateActivities({
|
|
171
|
-
notation: 'action',
|
|
172
|
-
actions: [
|
|
173
|
-
{ id: 'A-001', name: 'Task', duration: 5, start_date: 'tomorrow', end_date: 'yesterday' },
|
|
174
|
-
],
|
|
175
|
-
});
|
|
176
|
-
expect(r.errors.filter(e => e.code === 'ACT-008').length).toBe(2);
|
|
177
|
-
expect(r.errors.every(e => /must be ISO 8601 YYYY-MM-DD/.test(e.message))).toBe(true);
|
|
178
|
-
});
|
|
179
|
-
it('ACT-009 — rejects negative duration', () => {
|
|
180
|
-
const r = validateActivities({
|
|
181
|
-
notation: 'action',
|
|
182
|
-
actions: [{ id: 'A-001', name: 'Task', duration: -1 }],
|
|
183
|
-
});
|
|
184
|
-
expect(r.valid).toBe(false);
|
|
185
|
-
expect(r.errors.some(e => e.code === 'ACT-009')).toBe(true);
|
|
186
|
-
});
|
|
187
|
-
it('ACT-009 — accepts zero duration', () => {
|
|
188
|
-
const r = validateActivities({
|
|
189
|
-
notation: 'action',
|
|
190
|
-
actions: [{ id: 'A-001', name: 'Milestone', duration: 0 }],
|
|
191
|
-
});
|
|
192
|
-
expect(r.errors.some(e => e.code === 'ACT-009')).toBe(false);
|
|
193
|
-
});
|
|
194
|
-
it('ACT-010 — rejects singular "goal:" field', () => {
|
|
195
|
-
const r = validateActivities({
|
|
196
|
-
notation: 'action',
|
|
197
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, goal: 'GOAL-001' }],
|
|
198
|
-
});
|
|
199
|
-
expect(r.valid).toBe(false);
|
|
200
|
-
expect(r.errors.some(e => e.code === 'ACT-010')).toBe(true);
|
|
201
|
-
});
|
|
202
|
-
it('ACT-010 — rejects singular "predecessor:" field', () => {
|
|
203
|
-
const r = validateActivities({
|
|
204
|
-
notation: 'action',
|
|
205
|
-
actions: [
|
|
206
|
-
{ id: 'A-001', name: 'First', duration: 1 },
|
|
207
|
-
{ id: 'A-002', name: 'Task', duration: 1, predecessor: 'A-001' },
|
|
208
|
-
],
|
|
209
|
-
});
|
|
210
|
-
expect(r.valid).toBe(false);
|
|
211
|
-
expect(r.errors.some(e => e.code === 'ACT-010')).toBe(true);
|
|
212
|
-
});
|
|
213
|
-
it('ACT-010 — rejects singular "tag:" field', () => {
|
|
214
|
-
const r = validateActivities({
|
|
215
|
-
notation: 'action',
|
|
216
|
-
actions: [{ id: 'A-001', name: 'Task', duration: 1, tag: 'q3' }],
|
|
217
|
-
});
|
|
218
|
-
expect(r.valid).toBe(false);
|
|
219
|
-
expect(r.errors.some(e => e.code === 'ACT-010')).toBe(true);
|
|
220
|
-
});
|
|
221
|
-
it('ACT-011 — warns when duration is absent', () => {
|
|
222
|
-
const r = validateActivities({
|
|
223
|
-
notation: 'action',
|
|
224
|
-
actions: [{ id: 'A-001', name: 'No duration' }],
|
|
225
|
-
});
|
|
226
|
-
expect(r.valid).toBe(true);
|
|
227
|
-
expect(r.warnings.some(w => w.code === 'ACT-011')).toBe(true);
|
|
228
|
-
});
|
|
229
|
-
it('ACT-013 — warns on structurally orphan activity', () => {
|
|
230
|
-
const r = validateActivities({
|
|
231
|
-
notation: 'action',
|
|
232
|
-
actions: [
|
|
233
|
-
{ id: 'A-001', name: 'Connected', duration: 1 },
|
|
234
|
-
{ id: 'A-002', name: 'Orphan', duration: 1 },
|
|
235
|
-
{ id: 'A-003', name: 'End', duration: 1, predecessors: ['A-001'] },
|
|
236
|
-
],
|
|
237
|
-
});
|
|
238
|
-
expect(r.valid).toBe(true);
|
|
239
|
-
const orphanWarnings = r.warnings.filter(w => w.code === 'ACT-013');
|
|
240
|
-
expect(orphanWarnings.some(w => w.message.includes('A-002'))).toBe(true);
|
|
241
|
-
});
|
|
242
|
-
it('full valid example passes with no errors', () => {
|
|
243
|
-
const r = validateActivities({
|
|
244
|
-
notation: 'action',
|
|
245
|
-
title: 'Test Project',
|
|
246
|
-
actions: [
|
|
247
|
-
{ id: 'A', name: 'Start', duration: 3 },
|
|
248
|
-
{ id: 'B', name: 'Middle', duration: 5, predecessors: ['A'] },
|
|
249
|
-
{ id: 'C', name: 'End', duration: 2, predecessors: ['B'] },
|
|
250
|
-
],
|
|
251
|
-
});
|
|
252
|
-
expect(r.valid).toBe(true);
|
|
253
|
-
expect(r.errors).toHaveLength(0);
|
|
254
|
-
});
|
|
255
|
-
// ── Project block + calendar (ACT-014, ACT-015) ───────────────────────────
|
|
256
|
-
it('ACT-014 — rejects unknown weekday in working_days', () => {
|
|
257
|
-
const r = validateActivities({
|
|
258
|
-
...minimalValid,
|
|
259
|
-
project: { start_date: '2026-06-01', calendar: { working_days: ['mon', 'funday'] } },
|
|
260
|
-
});
|
|
261
|
-
expect(r.valid).toBe(false);
|
|
262
|
-
expect(r.errors.some(e => e.code === 'ACT-014' && /funday/.test(e.message))).toBe(true);
|
|
263
|
-
});
|
|
264
|
-
it('ACT-014 — rejects duplicate weekday entries', () => {
|
|
265
|
-
const r = validateActivities({
|
|
266
|
-
...minimalValid,
|
|
267
|
-
project: { calendar: { working_days: ['mon', 'tue', 'mon'] } },
|
|
268
|
-
});
|
|
269
|
-
expect(r.valid).toBe(false);
|
|
270
|
-
expect(r.errors.some(e => e.code === 'ACT-014' && /duplicate/i.test(e.message))).toBe(true);
|
|
271
|
-
});
|
|
272
|
-
it('ACT-014 — accepts mixed-case weekday names', () => {
|
|
273
|
-
const r = validateActivities({
|
|
274
|
-
...minimalValid,
|
|
275
|
-
project: { start_date: '2026-06-01', calendar: { working_days: ['MON', 'Tue', 'wed', 'thu', 'fri'] } },
|
|
276
|
-
});
|
|
277
|
-
expect(r.errors.some(e => e.code === 'ACT-014')).toBe(false);
|
|
278
|
-
});
|
|
279
|
-
it('ACT-015 — rejects non-ISO holiday date', () => {
|
|
280
|
-
const r = validateActivities({
|
|
281
|
-
...minimalValid,
|
|
282
|
-
project: { start_date: '2026-06-01', calendar: { holidays: ['2026-07-04', 'July 4 2026'] } },
|
|
283
|
-
});
|
|
284
|
-
expect(r.valid).toBe(false);
|
|
285
|
-
expect(r.errors.some(e => e.code === 'ACT-015' && /July 4 2026/.test(e.message))).toBe(true);
|
|
286
|
-
});
|
|
287
|
-
it('ACT-015 — accepts an array of ISO dates', () => {
|
|
288
|
-
const r = validateActivities({
|
|
289
|
-
...minimalValid,
|
|
290
|
-
project: { start_date: '2026-06-01', calendar: { holidays: ['2026-07-04', '2026-12-25'] } },
|
|
291
|
-
});
|
|
292
|
-
expect(r.errors.some(e => e.code === 'ACT-015')).toBe(false);
|
|
293
|
-
});
|
|
294
|
-
// ── Milestone date equality (ACT-016) ─────────────────────────────────────
|
|
295
|
-
it('ACT-016 — rejects milestone with mismatched start/end dates', () => {
|
|
296
|
-
const r = validateActivities({
|
|
297
|
-
notation: 'action',
|
|
298
|
-
actions: [
|
|
299
|
-
{ id: 'M-1', name: 'Launch', duration: 0, start_date: '2026-06-01', end_date: '2026-06-02' },
|
|
300
|
-
],
|
|
301
|
-
});
|
|
302
|
-
expect(r.valid).toBe(false);
|
|
303
|
-
expect(r.errors.some(e => e.code === 'ACT-016')).toBe(true);
|
|
304
|
-
});
|
|
305
|
-
it('ACT-016 — accepts milestone with equal start/end dates', () => {
|
|
306
|
-
const r = validateActivities({
|
|
307
|
-
notation: 'action',
|
|
308
|
-
actions: [
|
|
309
|
-
{ id: 'M-1', name: 'Launch', duration: 0, start_date: '2026-06-01', end_date: '2026-06-01' },
|
|
310
|
-
],
|
|
311
|
-
});
|
|
312
|
-
expect(r.errors.some(e => e.code === 'ACT-016')).toBe(false);
|
|
313
|
-
});
|
|
314
|
-
// ── Phase warnings (ACT-017, ACT-018) ─────────────────────────────────────
|
|
315
|
-
it('ACT-017 — warns when a referenced-as-parent activity carries its own duration', () => {
|
|
316
|
-
const r = validateActivities({
|
|
317
|
-
notation: 'action',
|
|
318
|
-
actions: [
|
|
319
|
-
{ id: 'PHASE-1', name: 'Design', duration: 5 },
|
|
320
|
-
{ id: 'A-1', name: 'Child', duration: 3, parent: 'PHASE-1' },
|
|
321
|
-
],
|
|
322
|
-
});
|
|
323
|
-
expect(r.valid).toBe(true);
|
|
324
|
-
expect(r.warnings.some(w => w.code === 'ACT-017' && /PHASE-1/.test(w.message))).toBe(true);
|
|
325
|
-
});
|
|
326
|
-
it('ACT-017 — no warning when phase omits duration/dates and rolls up from children', () => {
|
|
327
|
-
const r = validateActivities({
|
|
328
|
-
notation: 'action',
|
|
329
|
-
actions: [
|
|
330
|
-
{ id: 'PHASE-1', name: 'Design' },
|
|
331
|
-
{ id: 'A-1', name: 'Child', duration: 3, parent: 'PHASE-1' },
|
|
332
|
-
],
|
|
333
|
-
});
|
|
334
|
-
expect(r.warnings.some(w => w.code === 'ACT-017')).toBe(false);
|
|
335
|
-
});
|
|
336
|
-
it('ACT-018 — warns when an activity with no duration is not referenced as parent', () => {
|
|
337
|
-
const r = validateActivities({
|
|
338
|
-
notation: 'action',
|
|
339
|
-
actions: [
|
|
340
|
-
{ id: 'A-1', name: 'Has duration', duration: 3 },
|
|
341
|
-
{ id: 'P-EMPTY', name: 'Looks like phase but no children' },
|
|
342
|
-
],
|
|
343
|
-
});
|
|
344
|
-
expect(r.warnings.some(w => w.code === 'ACT-018' && /P-EMPTY/.test(w.message))).toBe(true);
|
|
345
|
-
});
|
|
346
|
-
it('ACT-018 — no warning when the no-duration activity has at least one child', () => {
|
|
347
|
-
const r = validateActivities({
|
|
348
|
-
notation: 'action',
|
|
349
|
-
actions: [
|
|
350
|
-
{ id: 'PHASE-1', name: 'Phase' },
|
|
351
|
-
{ id: 'A-1', name: 'Child', duration: 3, parent: 'PHASE-1' },
|
|
352
|
-
],
|
|
353
|
-
});
|
|
354
|
-
expect(r.warnings.some(w => w.code === 'ACT-018')).toBe(false);
|
|
355
|
-
});
|
|
356
|
-
// ── Gantt-renderability notice (ACT-019) ──────────────────────────────────
|
|
357
|
-
it('ACT-019 — warns when neither project.start_date nor pinned dates exist', () => {
|
|
358
|
-
const r = validateActivities(minimalValid);
|
|
359
|
-
expect(r.warnings.some(w => w.code === 'ACT-019')).toBe(true);
|
|
360
|
-
});
|
|
361
|
-
it('ACT-019 — no warning when project.start_date is set', () => {
|
|
362
|
-
const r = validateActivities({ ...minimalValid, project: { start_date: '2026-06-01' } });
|
|
363
|
-
expect(r.warnings.some(w => w.code === 'ACT-019')).toBe(false);
|
|
364
|
-
});
|
|
365
|
-
it('ACT-019 — no warning when every activity has pinned dates', () => {
|
|
366
|
-
const r = validateActivities({
|
|
367
|
-
notation: 'action',
|
|
368
|
-
actions: [
|
|
369
|
-
{ id: 'A-1', name: 'A', duration: 3, start_date: '2026-06-01', end_date: '2026-06-04' },
|
|
370
|
-
],
|
|
371
|
-
});
|
|
372
|
-
expect(r.warnings.some(w => w.code === 'ACT-019')).toBe(false);
|
|
373
|
-
});
|
|
374
|
-
it('[blocker] tolerates a null element in actions[] without throwing', () => {
|
|
375
|
-
// Do NOT spread minimalValid here: validateActivities mutates its input
|
|
376
|
-
// to normalise raw.activities, so a previously-called test that passed
|
|
377
|
-
// minimalValid directly would have set minimalValid.activities. Spreading
|
|
378
|
-
// that mutated object would cause the actions:[null] override to be masked
|
|
379
|
-
// by the pre-existing activities array.
|
|
380
|
-
const r = validateActivities({ notation: 'action', actions: [null] });
|
|
381
|
-
expect(r.valid).toBe(false);
|
|
382
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
383
|
-
});
|
|
384
|
-
});
|
|
385
|
-
describe('action examples (regression)', () => {
|
|
386
|
-
const files = fs.readdirSync(EXAMPLES_DIR).filter(f => f.endsWith('.yaml'));
|
|
387
|
-
expect(files.length).toBeGreaterThan(0);
|
|
388
|
-
for (const file of files) {
|
|
389
|
-
it(`validates tests/fixtures/notation-corpus/action/${file}`, () => {
|
|
390
|
-
const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
|
|
391
|
-
const parsed = yaml.load(text);
|
|
392
|
-
const r = validateActivities(parsed);
|
|
393
|
-
expect(r.errors).toEqual([]);
|
|
394
|
-
expect(r.valid).toBe(true);
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,73 +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
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { readFileSync, readdirSync } from 'node:fs';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import yaml from 'js-yaml';
|
|
10
|
-
import { validateActivityCard } from '../validate.js';
|
|
11
|
-
import { resolveActivityCard } from '../resolver.js';
|
|
12
|
-
import { layoutActivityCard } from '../layout.js';
|
|
13
|
-
const dir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus/action-card');
|
|
14
|
-
const load = (f) => yaml.load(readFileSync(path.join(dir, f), 'utf-8'));
|
|
15
|
-
/** Recursively load every `*.yaml` doc under a canon subtree (mirrors the
|
|
16
|
-
* extension's element/relation walk). */
|
|
17
|
-
function loadYamlTree(root) {
|
|
18
|
-
const out = [];
|
|
19
|
-
for (const entry of readdirSync(root, { withFileTypes: true })) {
|
|
20
|
-
const full = path.join(root, entry.name);
|
|
21
|
-
if (entry.isDirectory())
|
|
22
|
-
out.push(...loadYamlTree(full));
|
|
23
|
-
else if (entry.name.endsWith('.yaml'))
|
|
24
|
-
out.push(yaml.load(readFileSync(full, 'utf-8')));
|
|
25
|
-
}
|
|
26
|
-
return out;
|
|
27
|
-
}
|
|
28
|
-
describe('activity-card worked example (eu-programme)', () => {
|
|
29
|
-
it('validates, resolves, and lays out the success-signal card', () => {
|
|
30
|
-
const card = load('eu-programme.action-card.transitrix.yaml');
|
|
31
|
-
const elements = loadYamlTree(path.join(dir, 'canon', 'elements'));
|
|
32
|
-
const relations = loadYamlTree(path.join(dir, 'canon', 'relations'));
|
|
33
|
-
const v = validateActivityCard(card);
|
|
34
|
-
expect(v.valid, JSON.stringify(v.errors)).toBe(true);
|
|
35
|
-
const r = resolveActivityCard(card, { elements, relations });
|
|
36
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
37
|
-
expect(r.warnings, JSON.stringify(r.warnings)).toHaveLength(0);
|
|
38
|
-
const c = r.resolved;
|
|
39
|
-
expect(c.project.name).toBe('EU MDR conformity programme');
|
|
40
|
-
expect(c.project.valid_from).toBe('2026-04-01');
|
|
41
|
-
expect(c.project.start_date).toBe('2026-04-15');
|
|
42
|
-
expect(c.project.end_date).toBe('2027-03-15');
|
|
43
|
-
expect(c.milestones.map((m) => m.id)).toEqual([
|
|
44
|
-
'MILESTONE-EU-CONFORMITY-CERT-1',
|
|
45
|
-
'MILESTONE-EU-MARKET-LAUNCH-1',
|
|
46
|
-
]);
|
|
47
|
-
expect(c.motivation.drivers.map((d) => d.id)).toEqual(['FACTOR-EU-MDR-1']);
|
|
48
|
-
expect(c.motivation.goals.map((g) => g.id)).toEqual(['GOAL-EU-MARKET-1']);
|
|
49
|
-
expect(c.motivation.changes.map((x) => x.id)).toEqual(['CHANGE-EU-COMPLIANCE-1']);
|
|
50
|
-
expect(c.childActivities).toHaveLength(4);
|
|
51
|
-
// Project goal text field resolves to the directly-served goal name; the
|
|
52
|
-
// example links no stakeholders, so the card shows the field empty.
|
|
53
|
-
expect(c.goalNames).toEqual(['Maintain EU market access under MDR']);
|
|
54
|
-
expect(c.stakeholders).toEqual([]);
|
|
55
|
-
const layout = layoutActivityCard(c);
|
|
56
|
-
expect(layout.bounds.height).toBeGreaterThan(0);
|
|
57
|
-
// Header
|
|
58
|
-
expect(layout.titleRow.name).toBe('EU MDR conformity programme');
|
|
59
|
-
expect(layout.dateFields[0]).toMatchObject({ label: 'Initiation', value: '2026-04-01' });
|
|
60
|
-
expect(layout.stakeholderRoleSlots).toHaveLength(4);
|
|
61
|
-
// Description row
|
|
62
|
-
expect(layout.descriptionRow?.label).toBe('Description');
|
|
63
|
-
// Chain sections
|
|
64
|
-
expect(layout.chainSections.map((s) => s.type)).toEqual(['drivers', 'goals', 'changes']);
|
|
65
|
-
const driversSection = layout.chainSections.find((s) => s.type === 'drivers');
|
|
66
|
-
const goalsSection = layout.chainSections.find((s) => s.type === 'goals');
|
|
67
|
-
expect(driversSection.nodes.map((n) => n.id)).toContain('FACTOR-EU-MDR-1');
|
|
68
|
-
expect(goalsSection.nodes.map((n) => n.id)).toContain('GOAL-EU-MARKET-1');
|
|
69
|
-
// Chain edges
|
|
70
|
-
expect(layout.chainEdges).toContainEqual({ sourceId: 'FACTOR-EU-MDR-1', targetId: 'GOAL-EU-MARKET-1' });
|
|
71
|
-
expect(layout.chainEdges).toContainEqual({ sourceId: 'GOAL-EU-MARKET-1', targetId: 'CHANGE-EU-COMPLIANCE-1' });
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { layoutActivityCard, ARCHIMATE_CLASS } from '../layout.js';
|
|
3
|
-
const RESOLVED = {
|
|
4
|
-
cardId: 'ACTIVITY_CARD-EU-PROGRAMME-1',
|
|
5
|
-
cardDescription: 'Summary',
|
|
6
|
-
project: {
|
|
7
|
-
id: 'ACTIVITY-EU-PROGRAMME-1',
|
|
8
|
-
name: 'EU MDR conformity programme',
|
|
9
|
-
activity_type: 'programme',
|
|
10
|
-
status: 'in_progress',
|
|
11
|
-
valid_from: '2026-04-01',
|
|
12
|
-
start_date: '2026-04-15',
|
|
13
|
-
end_date: '2027-03-15',
|
|
14
|
-
},
|
|
15
|
-
milestones: [
|
|
16
|
-
{ id: 'MILESTONE-CERT-1', name: 'Cert', date: '2027-01-31', deliversChanges: ['CHANGE-EU-COMPLIANCE-1'] },
|
|
17
|
-
],
|
|
18
|
-
motivation: {
|
|
19
|
-
drivers: [{ id: 'FACTOR-EU-MDR-1', name: 'EU MDR regulation' }],
|
|
20
|
-
goals: [{ id: 'GOAL-EU-MARKET-1', name: 'Access EU market', driverIds: ['FACTOR-EU-MDR-1'] }],
|
|
21
|
-
changes: [{ id: 'CHANGE-EU-COMPLIANCE-1', name: 'Achieve MDR compliance', goalIds: ['GOAL-EU-MARKET-1'] }],
|
|
22
|
-
},
|
|
23
|
-
assessments: [
|
|
24
|
-
{ id: 'ASSESSMENT-MDR-1', name: 'NB capacity constrained', driverId: 'FACTOR-EU-MDR-1', observed_at: '2026-03-01' },
|
|
25
|
-
],
|
|
26
|
-
childActivities: [
|
|
27
|
-
{ id: 'ACTIVITY-EU-CHILD-1', name: 'Notified-body engagement', start_date: '2026-05-01', end_date: '2026-12-01', owner: 'UNIT-REGULATORY' },
|
|
28
|
-
],
|
|
29
|
-
goalNames: ['Access EU market'],
|
|
30
|
-
stakeholders: [
|
|
31
|
-
{ id: 'STAKEHOLDER-OPS-1', name: 'Operations', role: 'owner' },
|
|
32
|
-
{ id: 'STAKEHOLDER-CEO-1', name: 'CEO', role: 'sponsor' },
|
|
33
|
-
],
|
|
34
|
-
notes: 'Pre-audit scheduled for October 2026.',
|
|
35
|
-
};
|
|
36
|
-
describe('layoutActivityCard', () => {
|
|
37
|
-
it('produces positive bounds', () => {
|
|
38
|
-
const l = layoutActivityCard(RESOLVED);
|
|
39
|
-
expect(l.bounds.width).toBeGreaterThan(0);
|
|
40
|
-
expect(l.bounds.height).toBeGreaterThan(0);
|
|
41
|
-
});
|
|
42
|
-
it('title row carries the project name', () => {
|
|
43
|
-
const l = layoutActivityCard(RESOLVED);
|
|
44
|
-
expect(l.titleRow.name).toBe('EU MDR conformity programme');
|
|
45
|
-
});
|
|
46
|
-
it('renders activity type and status badges when present', () => {
|
|
47
|
-
const l = layoutActivityCard(RESOLVED);
|
|
48
|
-
expect(l.activityTypeBadge?.label).toBe('programme');
|
|
49
|
-
expect(l.statusBadge?.label).toBe('in progress');
|
|
50
|
-
});
|
|
51
|
-
it('badges are absent when project fields are unset', () => {
|
|
52
|
-
const l = layoutActivityCard({ ...RESOLVED, project: { id: 'A', name: 'n' } });
|
|
53
|
-
expect(l.activityTypeBadge).toBeUndefined();
|
|
54
|
-
expect(l.statusBadge).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
it('three date fields with correct labels and values', () => {
|
|
57
|
-
const l = layoutActivityCard(RESOLVED);
|
|
58
|
-
expect(l.dateFields).toHaveLength(3);
|
|
59
|
-
expect(l.dateFields[0]).toMatchObject({ label: 'Initiation', value: '2026-04-01' });
|
|
60
|
-
expect(l.dateFields[1]).toMatchObject({ label: 'Planned start', value: '2026-04-15' });
|
|
61
|
-
expect(l.dateFields[2]).toMatchObject({ label: 'Planned end', value: '2027-03-15' });
|
|
62
|
-
});
|
|
63
|
-
it('renders "—" for absent dates', () => {
|
|
64
|
-
const l = layoutActivityCard({ ...RESOLVED, project: { id: 'A', name: 'n' } });
|
|
65
|
-
expect(l.dateFields.map((d) => d.value)).toEqual(['—', '—', '—']);
|
|
66
|
-
});
|
|
67
|
-
it('four stakeholder role slots always rendered', () => {
|
|
68
|
-
const l = layoutActivityCard(RESOLVED);
|
|
69
|
-
expect(l.stakeholderRoleSlots).toHaveLength(4);
|
|
70
|
-
expect(l.stakeholderRoleSlots.map((s) => s.role)).toEqual(['Initiator', 'Owner', 'Sponsor', 'PM']);
|
|
71
|
-
expect(l.stakeholderRoleSlots[0].name).toBe('—'); // no initiator
|
|
72
|
-
expect(l.stakeholderRoleSlots[1].name).toBe('Operations'); // owner
|
|
73
|
-
expect(l.stakeholderRoleSlots[2].name).toBe('CEO'); // sponsor
|
|
74
|
-
expect(l.stakeholderRoleSlots[3].name).toBe('—'); // no PM
|
|
75
|
-
});
|
|
76
|
-
it('description row present when cardDescription is set', () => {
|
|
77
|
-
const l = layoutActivityCard(RESOLVED);
|
|
78
|
-
expect(l.descriptionRow?.label).toBe('Description');
|
|
79
|
-
expect(l.descriptionRow?.valueLines.join(' ')).toContain('Summary');
|
|
80
|
-
});
|
|
81
|
-
it('description row absent when cardDescription is empty', () => {
|
|
82
|
-
const l = layoutActivityCard({ ...RESOLVED, cardDescription: undefined });
|
|
83
|
-
expect(l.descriptionRow).toBeUndefined();
|
|
84
|
-
});
|
|
85
|
-
it('three chain sections in order: drivers, goals, changes', () => {
|
|
86
|
-
const l = layoutActivityCard(RESOLVED);
|
|
87
|
-
expect(l.chainSections.map((s) => s.type)).toEqual(['drivers', 'goals', 'changes']);
|
|
88
|
-
});
|
|
89
|
-
it('chain sections carry the resolved nodes', () => {
|
|
90
|
-
const l = layoutActivityCard(RESOLVED);
|
|
91
|
-
const drivers = l.chainSections.find((s) => s.type === 'drivers');
|
|
92
|
-
const goals = l.chainSections.find((s) => s.type === 'goals');
|
|
93
|
-
const changes = l.chainSections.find((s) => s.type === 'changes');
|
|
94
|
-
expect(drivers.nodes.map((n) => n.id)).toEqual(['FACTOR-EU-MDR-1']);
|
|
95
|
-
expect(goals.nodes.map((n) => n.id)).toEqual(['GOAL-EU-MARKET-1']);
|
|
96
|
-
expect(changes.nodes.map((n) => n.id)).toEqual(['CHANGE-EU-COMPLIANCE-1']);
|
|
97
|
-
});
|
|
98
|
-
it('empty chain sections have isEmpty=true', () => {
|
|
99
|
-
const l = layoutActivityCard({
|
|
100
|
-
...RESOLVED,
|
|
101
|
-
motivation: { drivers: [], goals: [], changes: [] },
|
|
102
|
-
assessments: [],
|
|
103
|
-
});
|
|
104
|
-
expect(l.chainSections.every((s) => s.isEmpty)).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
it('builds driver→goal and goal→change edges', () => {
|
|
107
|
-
const l = layoutActivityCard(RESOLVED);
|
|
108
|
-
expect(l.chainEdges).toContainEqual({ sourceId: 'FACTOR-EU-MDR-1', targetId: 'GOAL-EU-MARKET-1' });
|
|
109
|
-
expect(l.chainEdges).toContainEqual({ sourceId: 'GOAL-EU-MARKET-1', targetId: 'CHANGE-EU-COMPLIANCE-1' });
|
|
110
|
-
});
|
|
111
|
-
it('milestone ArchiMate class is set', () => {
|
|
112
|
-
const l = layoutActivityCard(RESOLVED);
|
|
113
|
-
expect(l.milestones).toHaveLength(1);
|
|
114
|
-
expect(l.milestones[0].archimateClass).toBe(ARCHIMATE_CLASS.MILESTONE);
|
|
115
|
-
});
|
|
116
|
-
it('child activity ArchiMate class is set', () => {
|
|
117
|
-
const l = layoutActivityCard(RESOLVED);
|
|
118
|
-
expect(l.childActivities[0].archimateClass).toBe(ARCHIMATE_CLASS.ACTIVITY);
|
|
119
|
-
});
|
|
120
|
-
it('footer row present when notes is set', () => {
|
|
121
|
-
const l = layoutActivityCard(RESOLVED);
|
|
122
|
-
expect(l.footerRow?.label).toBe('Notes');
|
|
123
|
-
expect(l.footerRow?.valueLines.join(' ')).toContain('Pre-audit');
|
|
124
|
-
});
|
|
125
|
-
it('footer row absent when notes is empty', () => {
|
|
126
|
-
const l = layoutActivityCard({ ...RESOLVED, notes: undefined });
|
|
127
|
-
expect(l.footerRow).toBeUndefined();
|
|
128
|
-
});
|
|
129
|
-
it('handles an empty card without throwing', () => {
|
|
130
|
-
const l = layoutActivityCard({
|
|
131
|
-
cardId: 'ACTIVITY_CARD-X-1',
|
|
132
|
-
project: { id: 'ACTIVITY-X-1', name: 'Empty' },
|
|
133
|
-
milestones: [],
|
|
134
|
-
motivation: { drivers: [], goals: [], changes: [] },
|
|
135
|
-
assessments: [],
|
|
136
|
-
childActivities: [],
|
|
137
|
-
});
|
|
138
|
-
expect(l.milestones).toHaveLength(0);
|
|
139
|
-
expect(l.bounds.height).toBeGreaterThan(0);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|