@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,24 +0,0 @@
|
|
|
1
|
-
// Conformance test for the shipped REQUIREMENT worked examples — the
|
|
2
|
-
// acme_corp canon files mirrored under `tests/fixtures/notation-corpus/requirement/`. Pins the
|
|
3
|
-
// success signal of vkgeorgia/strategy#84 Phase 1: the library consumes the
|
|
4
|
-
// canonical example files without error.
|
|
5
|
-
|
|
6
|
-
import { describe, it, expect } from 'vitest';
|
|
7
|
-
import { readFileSync } from 'node:fs';
|
|
8
|
-
import { fileURLToPath } from 'node:url';
|
|
9
|
-
import path from 'node:path';
|
|
10
|
-
import yaml from 'js-yaml';
|
|
11
|
-
import { validateRequirement } from '../validate.js';
|
|
12
|
-
|
|
13
|
-
const dir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus/requirement');
|
|
14
|
-
const load = (f: string): unknown => yaml.load(readFileSync(path.join(dir, f), 'utf-8'));
|
|
15
|
-
|
|
16
|
-
describe('requirement worked examples (acme_corp)', () => {
|
|
17
|
-
for (const f of ['REQUIREMENT-DATA-ERASURE-1.yaml', 'REQUIREMENT-AUDIT-LOG-RETENTION-1.yaml']) {
|
|
18
|
-
it(`validates ${f} without error`, () => {
|
|
19
|
-
const v = validateRequirement(load(f));
|
|
20
|
-
expect(v.valid, JSON.stringify(v.errors)).toBe(true);
|
|
21
|
-
expect(v.errors).toHaveLength(0);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateRequirement } from '../validate.js';
|
|
3
|
-
import type { CanonCatalog } from '../../typed-id.js';
|
|
4
|
-
|
|
5
|
-
function valid(): Record<string, unknown> {
|
|
6
|
-
return {
|
|
7
|
-
notation: 'requirement',
|
|
8
|
-
id: 'REQUIREMENT-DATA-ERASURE-1',
|
|
9
|
-
name: 'Personal-data erasure within 30 days',
|
|
10
|
-
description: 'The controller must erase personal data within 30 days of a verified request.',
|
|
11
|
-
severity: 'high',
|
|
12
|
-
zone: 'canon',
|
|
13
|
-
admitted_at: '2026-05-28',
|
|
14
|
-
admitted_by: 'v.korobeinikov',
|
|
15
|
-
gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
|
|
16
|
-
valid_from: '2017-05-01',
|
|
17
|
-
valid_to: null,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const codes = (input: unknown, opts?: Parameters<typeof validateRequirement>[1]): string[] =>
|
|
22
|
-
validateRequirement(input, opts).errors.map(e => e.code);
|
|
23
|
-
|
|
24
|
-
describe('validateRequirement — positive', () => {
|
|
25
|
-
it('accepts a well-formed requirement', () => {
|
|
26
|
-
const r = validateRequirement(valid());
|
|
27
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
28
|
-
expect(r.errors).toHaveLength(0);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('accepts an internal-only requirement with no derived_from', () => {
|
|
32
|
-
const r = valid();
|
|
33
|
-
delete r.derived_from;
|
|
34
|
-
r.severity = 'medium';
|
|
35
|
-
expect(validateRequirement(r).valid).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('validateRequirement — REQ-001 (shape / id grammar)', () => {
|
|
40
|
-
it('flags a missing required field', () => {
|
|
41
|
-
const r = valid();
|
|
42
|
-
delete r.name;
|
|
43
|
-
expect(codes(r)).toContain('REQ-001');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('flags an id that violates the grammar', () => {
|
|
47
|
-
expect(codes({ ...valid(), id: 'REQUIREMENT-DATA-ERASURE-001' })).toContain('REQ-001'); // leading zero
|
|
48
|
-
expect(codes({ ...valid(), id: 'REQ-1' })).toContain('REQ-001'); // wrong TYPE
|
|
49
|
-
expect(codes({ ...valid(), id: 'requirement-data-1' })).toContain('REQ-001'); // lowercase TYPE
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('flags a wrong notation tag and a non-canon zone', () => {
|
|
53
|
-
expect(codes({ ...valid(), notation: 'req' })).toContain('REQ-001');
|
|
54
|
-
expect(codes({ ...valid(), zone: 'sandbox' })).toContain('REQ-001');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('flags a missing valid_to key (distinct from a null value)', () => {
|
|
58
|
-
const r = valid();
|
|
59
|
-
delete r.valid_to;
|
|
60
|
-
expect(codes(r)).toContain('REQ-001');
|
|
61
|
-
expect(validateRequirement({ ...valid(), valid_to: null }).valid).toBe(true);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('rejects a non-object', () => {
|
|
65
|
-
expect(codes(null)).toEqual(['REQ-001']);
|
|
66
|
-
expect(codes('x')).toEqual(['REQ-001']);
|
|
67
|
-
expect(codes(['a'])).toEqual(['REQ-001']);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('validateRequirement — REQ-002 (derived_from resolution)', () => {
|
|
72
|
-
it('flags a well-formed allowed-type ref that does not resolve in the catalog', () => {
|
|
73
|
-
const catalog: CanonCatalog = { typeOf: () => undefined };
|
|
74
|
-
expect(codes({ ...valid(), derived_from: ['LAW-PERSONAL-DATA-2017-1'] }, { catalog })).toContain('REQ-002');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('flags a malformed derived_from entry (cannot resolve)', () => {
|
|
78
|
-
expect(codes({ ...valid(), derived_from: ['not an id'] })).toContain('REQ-002');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('does not flag REQ-002 without a catalog for a well-formed allowed-type ref', () => {
|
|
82
|
-
expect(codes({ ...valid(), derived_from: ['LAW-PERSONAL-DATA-2017-1'] })).not.toContain('REQ-002');
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
describe('validateRequirement — REQ-003 (derived_from TYPE)', () => {
|
|
87
|
-
it('flags a derived_from TYPE outside LAW/REGULATION/POLICY/INTERNAL_STANDARD', () => {
|
|
88
|
-
expect(codes({ ...valid(), derived_from: ['PRODUCT-MOBILE-1'] })).toContain('REQ-003');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('accepts each permitted derived_from TYPE', () => {
|
|
92
|
-
for (const id of ['LAW-X-1', 'REGULATION-X-1', 'POLICY-X-1', 'INTERNAL_STANDARD-X-1']) {
|
|
93
|
-
expect(codes({ ...valid(), derived_from: [id] })).not.toContain('REQ-003');
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,209 +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 { validateScenario } from '../validate.js';
|
|
6
|
-
|
|
7
|
-
const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'scenarios');
|
|
8
|
-
|
|
9
|
-
const VALID_SCENARIO = {
|
|
10
|
-
notation: 'scenarios',
|
|
11
|
-
scenario: {
|
|
12
|
-
id: 'SCN-001',
|
|
13
|
-
name: 'Optimistic Growth 2027',
|
|
14
|
-
status: 'Active',
|
|
15
|
-
created_at: '2026-01-01',
|
|
16
|
-
vision: 'Aggressive expansion scenario.',
|
|
17
|
-
factors_view: [
|
|
18
|
-
{ factor_id: 'FAC-MARKET-001', relevance: 'High', impact: 'Revenue growth' },
|
|
19
|
-
{ factor_id: 'FAC-TECH-001', relevance: 'Medium' },
|
|
20
|
-
],
|
|
21
|
-
goals: [{ goal_id: 'GOAL-REV-001' }],
|
|
22
|
-
capabilities: [{ capability_id: 'CAP-ECOMM-001' }],
|
|
23
|
-
activities: [{ activity_id: 'ACT-EXPAND-001' }],
|
|
24
|
-
products: [{ product_id: 'PROD-PLATFORM-001' }],
|
|
25
|
-
processes: [{ process_id: 'PROC-DELIVERY-001' }],
|
|
26
|
-
applications: [{ app_id: 'APP-CRM-001' }, { app_id: 'APP-OMS-001' }],
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
describe('validateScenario', () => {
|
|
31
|
-
it('passes on valid input', () => {
|
|
32
|
-
const r = validateScenario(VALID_SCENARIO);
|
|
33
|
-
expect(r.valid).toBe(true);
|
|
34
|
-
expect(r.errors).toHaveLength(0);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('SCN-001: rejects non-object input', () => {
|
|
38
|
-
const r = validateScenario(null);
|
|
39
|
-
expect(r.errors[0].code).toBe('SCN-001');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('SCN-001: rejects missing notation', () => {
|
|
43
|
-
const { notation: _, ...rest } = VALID_SCENARIO;
|
|
44
|
-
const r = validateScenario(rest);
|
|
45
|
-
expect(r.errors.some(e => e.code === 'SCN-001')).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('SCN-001: rejects wrong notation value', () => {
|
|
49
|
-
const r = validateScenario({ ...VALID_SCENARIO, notation: 'goals' });
|
|
50
|
-
expect(r.errors.some(e => e.code === 'SCN-001')).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('SCN-002: rejects missing scenario', () => {
|
|
54
|
-
const r = validateScenario({ notation: 'scenarios' });
|
|
55
|
-
expect(r.errors.some(e => e.code === 'SCN-002')).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('SCN-002: rejects missing id/name/status', () => {
|
|
59
|
-
const r = validateScenario({ notation: 'scenarios', scenario: {} });
|
|
60
|
-
expect(r.errors.filter(e => e.code === 'SCN-002').length).toBeGreaterThanOrEqual(3);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('SCN-003: rejects invalid status', () => {
|
|
64
|
-
const scn = { ...VALID_SCENARIO.scenario, status: 'Retired' };
|
|
65
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
66
|
-
expect(r.errors.some(e => e.code === 'SCN-003')).toBe(true);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('SCN-003: accepts all valid statuses', () => {
|
|
70
|
-
for (const status of ['Draft', 'Active', 'Archived']) {
|
|
71
|
-
const scn = { ...VALID_SCENARIO.scenario, status };
|
|
72
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
73
|
-
expect(r.errors.some(e => e.code === 'SCN-003')).toBe(false);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('SCN-004: rejects malformed created_at', () => {
|
|
78
|
-
const scn = { ...VALID_SCENARIO.scenario, created_at: '01-01-2026' };
|
|
79
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
80
|
-
expect(r.errors.some(e => e.code === 'SCN-004')).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('SCN-004: accepts missing created_at', () => {
|
|
84
|
-
const { created_at: _, ...scn } = VALID_SCENARIO.scenario;
|
|
85
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
86
|
-
expect(r.errors.some(e => e.code === 'SCN-004')).toBe(false);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('SCN-005: rejects non-array factors_view', () => {
|
|
90
|
-
const scn = { ...VALID_SCENARIO.scenario, factors_view: 'oops' };
|
|
91
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
92
|
-
expect(r.errors.some(e => e.code === 'SCN-005')).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('SCN-005: rejects factor missing factor_id', () => {
|
|
96
|
-
const scn = { ...VALID_SCENARIO.scenario, factors_view: [{ relevance: 'High' }] };
|
|
97
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
98
|
-
expect(r.errors.some(e => e.code === 'SCN-005')).toBe(true);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('SCN-006: rejects invalid factor relevance', () => {
|
|
102
|
-
const scn = {
|
|
103
|
-
...VALID_SCENARIO.scenario,
|
|
104
|
-
factors_view: [{ factor_id: 'F1', relevance: 'Critical' }],
|
|
105
|
-
};
|
|
106
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
107
|
-
expect(r.errors.some(e => e.code === 'SCN-006')).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('SCN-013: rejects duplicate factor_id', () => {
|
|
111
|
-
const scn = {
|
|
112
|
-
...VALID_SCENARIO.scenario,
|
|
113
|
-
factors_view: [{ factor_id: 'F1' }, { factor_id: 'F1' }],
|
|
114
|
-
};
|
|
115
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
116
|
-
expect(r.errors.some(e => e.code === 'SCN-013')).toBe(true);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const refCases = [
|
|
120
|
-
{ field: 'goals', idField: 'goal_id', errorCode: 'SCN-007' },
|
|
121
|
-
{ field: 'capabilities', idField: 'capability_id', errorCode: 'SCN-008' },
|
|
122
|
-
{ field: 'activities', idField: 'activity_id', errorCode: 'SCN-009' },
|
|
123
|
-
{ field: 'products', idField: 'product_id', errorCode: 'SCN-010' },
|
|
124
|
-
{ field: 'processes', idField: 'process_id', errorCode: 'SCN-011' },
|
|
125
|
-
{ field: 'applications', idField: 'app_id', errorCode: 'SCN-012' },
|
|
126
|
-
];
|
|
127
|
-
|
|
128
|
-
for (const c of refCases) {
|
|
129
|
-
it(`${c.errorCode}: rejects ${c.field}[*] missing ${c.idField}`, () => {
|
|
130
|
-
const scn = { ...VALID_SCENARIO.scenario, [c.field]: [{}] };
|
|
131
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
132
|
-
expect(r.errors.some(e => e.code === c.errorCode)).toBe(true);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it(`${c.errorCode}: rejects non-array ${c.field}`, () => {
|
|
136
|
-
const scn = { ...VALID_SCENARIO.scenario, [c.field]: 'oops' };
|
|
137
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
138
|
-
expect(r.errors.some(e => e.code === c.errorCode)).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it(`${c.errorCode}: rejects duplicate ${c.idField}`, () => {
|
|
142
|
-
const scn = {
|
|
143
|
-
...VALID_SCENARIO.scenario,
|
|
144
|
-
[c.field]: [{ [c.idField]: 'X1' }, { [c.idField]: 'X1' }],
|
|
145
|
-
};
|
|
146
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
147
|
-
expect(r.errors.some(e => e.code === c.errorCode)).toBe(true);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
it('accepts minimal scenario (id+name+status only)', () => {
|
|
152
|
-
const r = validateScenario({
|
|
153
|
-
notation: 'scenarios',
|
|
154
|
-
scenario: { id: 'S1', name: 'Minimal', status: 'Draft' },
|
|
155
|
-
});
|
|
156
|
-
expect(r.valid).toBe(true);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it('accepts scenario with all reference lists empty', () => {
|
|
160
|
-
const scn = {
|
|
161
|
-
...VALID_SCENARIO.scenario,
|
|
162
|
-
factors_view: [],
|
|
163
|
-
goals: [],
|
|
164
|
-
capabilities: [],
|
|
165
|
-
activities: [],
|
|
166
|
-
products: [],
|
|
167
|
-
processes: [],
|
|
168
|
-
applications: [],
|
|
169
|
-
};
|
|
170
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
171
|
-
expect(r.valid).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// Pre-release blocker regression (orchestrator review 2026-05-21).
|
|
175
|
-
it('[blocker] tolerates a null element in factors_view[] without throwing', () => {
|
|
176
|
-
const scn = { ...VALID_SCENARIO.scenario, factors_view: [null] };
|
|
177
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
178
|
-
expect(r.valid).toBe(false);
|
|
179
|
-
expect(r.errors.some(e => e.code === 'SCN-005')).toBe(true);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('[blocker] tolerates a null element in goals[] without throwing', () => {
|
|
183
|
-
const scn = { ...VALID_SCENARIO.scenario, goals: [null] };
|
|
184
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
185
|
-
expect(r.valid).toBe(false);
|
|
186
|
-
expect(r.errors.some(e => e.code === 'SCN-007')).toBe(true);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('[blocker] tolerates a string element in applications[] without throwing', () => {
|
|
190
|
-
const scn = { ...VALID_SCENARIO.scenario, applications: ['x'] };
|
|
191
|
-
const r = validateScenario({ ...VALID_SCENARIO, scenario: scn });
|
|
192
|
-
expect(r.valid).toBe(false);
|
|
193
|
-
expect(r.errors.some(e => e.code === 'SCN-012')).toBe(true);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe('scenarios examples (regression)', () => {
|
|
198
|
-
const files = fs.readdirSync(EXAMPLES_DIR).filter(f => f.endsWith('.yaml'));
|
|
199
|
-
expect(files.length).toBeGreaterThan(0);
|
|
200
|
-
for (const file of files) {
|
|
201
|
-
it(`validates tests/fixtures/notation-corpus/scenarios/${file}`, () => {
|
|
202
|
-
const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
|
|
203
|
-
const parsed = yaml.load(text);
|
|
204
|
-
const r = validateScenario(parsed);
|
|
205
|
-
expect(r.errors).toEqual([]);
|
|
206
|
-
expect(r.valid).toBe(true);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateStakeholder } from '../validate.js';
|
|
3
|
-
import type { CanonCatalog } from '../../typed-id.js';
|
|
4
|
-
|
|
5
|
-
function valid(): Record<string, unknown> {
|
|
6
|
-
return {
|
|
7
|
-
notation: 'stakeholder',
|
|
8
|
-
id: 'STAKEHOLDER-DPA-1',
|
|
9
|
-
name: 'Data Protection Authority',
|
|
10
|
-
type: 'external',
|
|
11
|
-
actor: 'ACTOR-DPA-1',
|
|
12
|
-
concern: 'Lawful processing and timely erasure of personal data.',
|
|
13
|
-
interest: 'high',
|
|
14
|
-
influence: 'high',
|
|
15
|
-
description: 'External oversight stakeholder.',
|
|
16
|
-
zone: 'canon',
|
|
17
|
-
admitted_at: '2026-05-29',
|
|
18
|
-
admitted_by: 'v.korobeinikov',
|
|
19
|
-
gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
|
|
20
|
-
valid_from: '2018-05-25',
|
|
21
|
-
valid_to: null,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const codes = (input: unknown, opts?: Parameters<typeof validateStakeholder>[1]): string[] =>
|
|
26
|
-
validateStakeholder(input, opts).errors.map(e => e.code);
|
|
27
|
-
|
|
28
|
-
describe('validateStakeholder — positive', () => {
|
|
29
|
-
it('accepts a well-formed external stakeholder', () => {
|
|
30
|
-
const r = validateStakeholder(valid());
|
|
31
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('accepts a minimal internal stakeholder with no optional profile fields', () => {
|
|
35
|
-
const s = valid();
|
|
36
|
-
s.id = 'STAKEHOLDER-OPS-1';
|
|
37
|
-
s.name = 'Operations';
|
|
38
|
-
s.type = 'internal';
|
|
39
|
-
s.actor = 'ACTOR-OPS-1';
|
|
40
|
-
delete s.concern;
|
|
41
|
-
delete s.interest;
|
|
42
|
-
delete s.influence;
|
|
43
|
-
delete s.description;
|
|
44
|
-
expect(validateStakeholder(s).valid).toBe(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('accepts when the catalog resolves the actor', () => {
|
|
48
|
-
const catalog: CanonCatalog = { typeOf: id => (id === 'ACTOR-DPA-1' ? 'ACTOR' : undefined) };
|
|
49
|
-
expect(validateStakeholder(valid(), { catalog }).valid).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('validateStakeholder — STAKE-001 (shape / id grammar / levels)', () => {
|
|
54
|
-
it('flags a missing required envelope field', () => {
|
|
55
|
-
const s = valid();
|
|
56
|
-
delete s.name;
|
|
57
|
-
expect(codes(s)).toContain('STAKE-001');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('flags an id that violates the grammar', () => {
|
|
61
|
-
expect(codes({ ...valid(), id: 'STAKEHOLDER-DPA-001' })).toContain('STAKE-001');
|
|
62
|
-
expect(codes({ ...valid(), id: 'STAKE-1' })).toContain('STAKE-001');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('flags a wrong notation tag', () => {
|
|
66
|
-
expect(codes({ ...valid(), notation: 'stakeholders' })).toContain('STAKE-001');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('flags an interest / influence value outside {high, medium, low}', () => {
|
|
70
|
-
expect(codes({ ...valid(), interest: 'critical' })).toContain('STAKE-001');
|
|
71
|
-
expect(codes({ ...valid(), influence: 'none' })).toContain('STAKE-001');
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('rejects a non-object', () => {
|
|
75
|
-
expect(codes(null)).toEqual(['STAKE-001']);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('validateStakeholder — STAKE-002 (actor binding)', () => {
|
|
80
|
-
it('flags a missing actor', () => {
|
|
81
|
-
const s = valid();
|
|
82
|
-
delete s.actor;
|
|
83
|
-
expect(codes(s)).toContain('STAKE-002');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('flags an actor of the wrong TYPE', () => {
|
|
87
|
-
expect(codes({ ...valid(), actor: 'ROLE-OPS-1' })).toContain('STAKE-002');
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('flags an actor that does not resolve when a catalog is supplied', () => {
|
|
91
|
-
const catalog: CanonCatalog = { typeOf: () => undefined };
|
|
92
|
-
expect(codes(valid(), { catalog })).toContain('STAKE-002');
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('flags an actor whose catalog TYPE is not ACTOR', () => {
|
|
96
|
-
const catalog: CanonCatalog = { typeOf: () => 'ROLE' };
|
|
97
|
-
expect(codes(valid(), { catalog })).toContain('STAKE-002');
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('validateStakeholder — STAKE-003 (type enum)', () => {
|
|
102
|
-
it('flags a type outside {internal, external}', () => {
|
|
103
|
-
expect(codes({ ...valid(), type: 'partner' })).toContain('STAKE-003');
|
|
104
|
-
});
|
|
105
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateTargetState } from '../validate.js';
|
|
3
|
-
import type { CanonCatalog } from '../../typed-id.js';
|
|
4
|
-
|
|
5
|
-
function valid(): Record<string, unknown> {
|
|
6
|
-
return {
|
|
7
|
-
notation: 'target-state',
|
|
8
|
-
id: 'TARGET_STATE-EU-LIVE-1',
|
|
9
|
-
name: 'EU operations live — three markets, localised CRM and payments',
|
|
10
|
-
description: 'The structural end-state.',
|
|
11
|
-
capabilities: ['CAPABILITY-V1', 'CAPABILITY-V1.2', 'CAPABILITY-V2'],
|
|
12
|
-
processes: ['PROCESS-CUST-ONBOARD-1', 'PROCESS-ORD-FULFILL-1'],
|
|
13
|
-
applications: ['APPLICATION-CRM-1', 'APPLICATION-OMS-1'],
|
|
14
|
-
zone: 'canon',
|
|
15
|
-
admitted_at: '2026-05-31',
|
|
16
|
-
admitted_by: 'v.korobeinikov',
|
|
17
|
-
gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
|
|
18
|
-
valid_from: '2026-05-31',
|
|
19
|
-
valid_to: null,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const codes = (input: unknown, opts?: Parameters<typeof validateTargetState>[1]): string[] =>
|
|
24
|
-
validateTargetState(input, opts).errors.map(e => e.code);
|
|
25
|
-
|
|
26
|
-
describe('validateTargetState — positive', () => {
|
|
27
|
-
it('accepts a well-formed target state', () => {
|
|
28
|
-
const r = validateTargetState(valid());
|
|
29
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('accepts a target state with empty composition lists', () => {
|
|
33
|
-
const t = valid();
|
|
34
|
-
delete t.capabilities;
|
|
35
|
-
delete t.processes;
|
|
36
|
-
delete t.applications;
|
|
37
|
-
expect(validateTargetState(t).valid).toBe(true);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('accepts CAPABILITY V/H ids without integer terminal', () => {
|
|
41
|
-
const t = valid();
|
|
42
|
-
t.capabilities = ['CAPABILITY-V1.2.3', 'CAPABILITY-H1.2'];
|
|
43
|
-
expect(validateTargetState(t).valid).toBe(true);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('validateTargetState — TSTATE-001 (shape / id grammar)', () => {
|
|
48
|
-
it('flags a missing required envelope field', () => {
|
|
49
|
-
const t = valid();
|
|
50
|
-
delete t.name;
|
|
51
|
-
expect(codes(t)).toContain('TSTATE-001');
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('flags an id that violates the grammar', () => {
|
|
55
|
-
expect(codes({ ...valid(), id: 'TARGET_STATE-EU-LIVE-001' })).toContain('TSTATE-001');
|
|
56
|
-
expect(codes({ ...valid(), id: 'TS-1' })).toContain('TSTATE-001');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('flags a wrong notation tag', () => {
|
|
60
|
-
expect(codes({ ...valid(), notation: 'target_state' })).toContain('TSTATE-001');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('flags a non-array composition list', () => {
|
|
64
|
-
expect(codes({ ...valid(), capabilities: 'CAPABILITY-V1' })).toContain('TSTATE-001');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('rejects a non-object', () => {
|
|
68
|
-
expect(codes(null)).toEqual(['TSTATE-001']);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('validateTargetState — TSTATE-002 (composition TYPEs)', () => {
|
|
73
|
-
it('flags a capabilities entry of the wrong TYPE', () => {
|
|
74
|
-
expect(codes({ ...valid(), capabilities: ['PROCESS-X-1'] })).toContain('TSTATE-002');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('flags a processes entry of the wrong TYPE', () => {
|
|
78
|
-
expect(codes({ ...valid(), processes: ['APPLICATION-X-1'] })).toContain('TSTATE-002');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('flags an applications entry of the wrong TYPE', () => {
|
|
82
|
-
expect(codes({ ...valid(), applications: ['CAPABILITY-V1'] })).toContain('TSTATE-002');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('flags an unresolved id when a catalog is supplied', () => {
|
|
86
|
-
const catalog: CanonCatalog = { typeOf: () => undefined };
|
|
87
|
-
expect(codes(valid(), { catalog })).toContain('TSTATE-002');
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('validateTargetState — TSTATE-003 (forbidden inline goals)', () => {
|
|
92
|
-
it('flags an inline goals field', () => {
|
|
93
|
-
expect(codes({ ...valid(), goals: ['GOAL-EU-1'] })).toContain('TSTATE-003');
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateTechnologyService } from '../validate.js';
|
|
3
|
-
|
|
4
|
-
function valid(): Record<string, unknown> {
|
|
5
|
-
return {
|
|
6
|
-
notation: 'technology-service',
|
|
7
|
-
id: 'TECHNOLOGY_SERVICE-KAFKA-1',
|
|
8
|
-
name: 'Kafka Event Bus',
|
|
9
|
-
type: 'messaging',
|
|
10
|
-
description: 'Managed Kafka cluster for async event streaming.',
|
|
11
|
-
node: 'NODE-KAFKA-HOST-1',
|
|
12
|
-
endpoint: 'kafka.internal:9092',
|
|
13
|
-
zone: 'canon',
|
|
14
|
-
admitted_at: '2026-06-28',
|
|
15
|
-
admitted_by: 'v.korobeinikov',
|
|
16
|
-
gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
|
|
17
|
-
valid_from: '2024-01-01',
|
|
18
|
-
valid_to: null,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const codes = (input: unknown): string[] =>
|
|
23
|
-
validateTechnologyService(input).errors.map(e => e.code);
|
|
24
|
-
|
|
25
|
-
describe('validateTechnologyService — positive', () => {
|
|
26
|
-
it('accepts a well-formed messaging service with all optional fields', () => {
|
|
27
|
-
const r = validateTechnologyService(valid());
|
|
28
|
-
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('accepts a storage service with no optional fields', () => {
|
|
32
|
-
const a = valid();
|
|
33
|
-
a.id = 'TECHNOLOGY_SERVICE-S3-1';
|
|
34
|
-
a.name = 'Object Storage';
|
|
35
|
-
a.type = 'storage';
|
|
36
|
-
delete a.description;
|
|
37
|
-
delete a.node;
|
|
38
|
-
delete a.endpoint;
|
|
39
|
-
expect(validateTechnologyService(a).valid).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('accepts all five type values', () => {
|
|
43
|
-
for (const t of ['messaging', 'storage', 'api_gateway', 'database', 'compute']) {
|
|
44
|
-
expect(validateTechnologyService({ ...valid(), type: t }).valid).toBe(true);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('accepts valid_to as a date string', () => {
|
|
49
|
-
expect(validateTechnologyService({ ...valid(), valid_to: '2026-12-31' }).valid).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('accepts absent node without error', () => {
|
|
53
|
-
const a = valid();
|
|
54
|
-
delete a.node;
|
|
55
|
-
expect(validateTechnologyService(a).valid).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('validateTechnologyService — TSVC-001 (shape / id grammar)', () => {
|
|
60
|
-
it('flags a non-object input', () => {
|
|
61
|
-
expect(codes(null)).toEqual(['TSVC-001']);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('flags an id that violates the grammar', () => {
|
|
65
|
-
expect(codes({ ...valid(), id: 'TECHNOLOGY_SERVICE-001' })).toContain('TSVC-001');
|
|
66
|
-
expect(codes({ ...valid(), id: 'TSVC-1' })).toContain('TSVC-001');
|
|
67
|
-
expect(codes({ ...valid(), id: 'technology-service-kafka-1' })).toContain('TSVC-001');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('flags a wrong notation tag', () => {
|
|
71
|
-
expect(codes({ ...valid(), notation: 'technology_service' })).toContain('TSVC-001');
|
|
72
|
-
expect(codes({ ...valid(), notation: 'service' })).toContain('TSVC-001');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('flags a non-canon zone', () => {
|
|
76
|
-
expect(codes({ ...valid(), zone: 'sandbox' })).toContain('TSVC-001');
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('flags a missing zone', () => {
|
|
80
|
-
const a = valid();
|
|
81
|
-
delete a.zone;
|
|
82
|
-
expect(codes(a)).toContain('TSVC-001');
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('flags a missing name', () => {
|
|
86
|
-
const a = valid();
|
|
87
|
-
delete a.name;
|
|
88
|
-
expect(codes(a)).toContain('TSVC-001');
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('flags a missing valid_to key', () => {
|
|
92
|
-
const a = valid();
|
|
93
|
-
delete a.valid_to;
|
|
94
|
-
expect(codes(a)).toContain('TSVC-001');
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('flags missing gate_checks', () => {
|
|
98
|
-
const a = valid();
|
|
99
|
-
delete a.gate_checks;
|
|
100
|
-
expect(codes(a)).toContain('TSVC-001');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('flags a missing type', () => {
|
|
104
|
-
const a = valid();
|
|
105
|
-
delete a.type;
|
|
106
|
-
expect(codes(a)).toContain('TSVC-001');
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('validateTechnologyService — TSVC-002 (type enum)', () => {
|
|
111
|
-
it('flags a type outside the allowed enum', () => {
|
|
112
|
-
expect(codes({ ...valid(), type: 'queue' })).toContain('TSVC-002');
|
|
113
|
-
expect(codes({ ...valid(), type: 'event_streaming' })).toContain('TSVC-002');
|
|
114
|
-
expect(codes({ ...valid(), type: 'cache' })).toContain('TSVC-002');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('does not flag a missing type with TSVC-002 (TSVC-001 fires instead)', () => {
|
|
118
|
-
const a = valid();
|
|
119
|
-
delete a.type;
|
|
120
|
-
expect(codes(a)).not.toContain('TSVC-002');
|
|
121
|
-
expect(codes(a)).toContain('TSVC-001');
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
describe('validateTechnologyService — TSVC-003 (node grammar)', () => {
|
|
126
|
-
it('flags a node reference that is not a NODE-… id', () => {
|
|
127
|
-
expect(codes({ ...valid(), node: 'ACTOR-OPS-1' })).toContain('TSVC-003');
|
|
128
|
-
expect(codes({ ...valid(), node: 'not-an-id' })).toContain('TSVC-003');
|
|
129
|
-
expect(codes({ ...valid(), node: 'NODE-001' })).toContain('TSVC-003');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('accepts a null or absent node without error', () => {
|
|
133
|
-
expect(codes({ ...valid(), node: undefined })).not.toContain('TSVC-003');
|
|
134
|
-
const a = valid();
|
|
135
|
-
delete a.node;
|
|
136
|
-
expect(codes(a)).not.toContain('TSVC-003');
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('accepts a well-formed NODE-… id', () => {
|
|
140
|
-
expect(codes({ ...valid(), node: 'NODE-KAFKA-HOST-1' })).not.toContain('TSVC-003');
|
|
141
|
-
expect(codes({ ...valid(), node: 'NODE-K8S-CLUSTER-1' })).not.toContain('TSVC-003');
|
|
142
|
-
});
|
|
143
|
-
});
|