@transitrix/diagrams 1.8.6 → 1.8.8
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/fgca/index.js +10 -10
- package/dist/fgca/layout.js +1 -1
- package/dist/fgca/nodeTypes.js +4 -4
- package/dist/index.js +33 -33
- package/package.json +8 -2
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -55
- package/dist/__tests__/node-size-presets.test.d.ts +0 -1
- package/dist/__tests__/node-size-presets.test.js +0 -30
- package/dist/__tests__/scope.test.d.ts +0 -1
- package/dist/__tests__/scope.test.js +0 -23
- package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
- package/dist/__tests__/yaml-normalize.test.js +0 -148
- package/dist/activities/__tests__/cpm.test.d.ts +0 -1
- package/dist/activities/__tests__/cpm.test.js +0 -146
- package/dist/activities/__tests__/gantt.test.d.ts +0 -1
- package/dist/activities/__tests__/gantt.test.js +0 -263
- package/dist/activities/__tests__/layout.test.d.ts +0 -1
- package/dist/activities/__tests__/layout.test.js +0 -98
- package/dist/activities/__tests__/validate.test.d.ts +0 -1
- package/dist/activities/__tests__/validate.test.js +0 -397
- package/dist/activity-card/__tests__/example.test.d.ts +0 -1
- package/dist/activity-card/__tests__/example.test.js +0 -73
- package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
- package/dist/activity-card/__tests__/layout.test.js +0 -141
- package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
- package/dist/activity-card/__tests__/resolver.test.js +0 -325
- package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
- package/dist/activity-card/__tests__/validate.test.js +0 -149
- package/dist/actor/__tests__/validate.test.d.ts +0 -1
- package/dist/actor/__tests__/validate.test.js +0 -95
- package/dist/applications/__tests__/validate.test.d.ts +0 -1
- package/dist/applications/__tests__/validate.test.js +0 -223
- package/dist/assertion/__tests__/example.test.d.ts +0 -1
- package/dist/assertion/__tests__/example.test.js +0 -32
- package/dist/assertion/__tests__/validate.test.d.ts +0 -1
- package/dist/assertion/__tests__/validate.test.js +0 -130
- package/dist/blocks/__tests__/layout.test.d.ts +0 -1
- package/dist/blocks/__tests__/layout.test.js +0 -153
- package/dist/blocks/__tests__/validate.test.d.ts +0 -1
- package/dist/blocks/__tests__/validate.test.js +0 -235
- package/dist/business-service/__tests__/validate.test.d.ts +0 -1
- package/dist/business-service/__tests__/validate.test.js +0 -135
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
- package/dist/capability-map/__tests__/address.test.d.ts +0 -1
- package/dist/capability-map/__tests__/address.test.js +0 -49
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
- package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/validate.test.js +0 -212
- package/dist/change/__tests__/validate.test.d.ts +0 -1
- package/dist/change/__tests__/validate.test.js +0 -79
- package/dist/codex/__tests__/example.test.d.ts +0 -1
- package/dist/codex/__tests__/example.test.js +0 -33
- package/dist/codex/__tests__/validate.test.d.ts +0 -1
- package/dist/codex/__tests__/validate.test.js +0 -68
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
- package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
- package/dist/compliance/__tests__/classify.test.d.ts +0 -1
- package/dist/compliance/__tests__/classify.test.js +0 -58
- package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
- package/dist/compliance/__tests__/confidence.test.js +0 -78
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
- package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
- package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
- package/dist/compliance/__tests__/example.test.d.ts +0 -1
- package/dist/compliance/__tests__/example.test.js +0 -51
- package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
- package/dist/compliance/__tests__/gap-report.test.js +0 -113
- package/dist/compliance/__tests__/html.test.d.ts +0 -1
- package/dist/compliance/__tests__/html.test.js +0 -122
- package/dist/compliance/__tests__/impact.test.d.ts +0 -1
- package/dist/compliance/__tests__/impact.test.js +0 -913
- package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
- package/dist/compliance/__tests__/markdown.test.js +0 -85
- package/dist/compliance/__tests__/trace.test.d.ts +0 -1
- package/dist/compliance/__tests__/trace.test.js +0 -144
- package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
- package/dist/compliance/__tests__/view-resolution.test.js +0 -59
- package/dist/compliance/__tests__/views.test.d.ts +0 -1
- package/dist/compliance/__tests__/views.test.js +0 -59
- package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/build.test.js +0 -183
- package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/example.test.js +0 -49
- package/dist/confidence/__tests__/score.test.d.ts +0 -1
- package/dist/confidence/__tests__/score.test.js +0 -188
- package/dist/constraint/__tests__/example.test.d.ts +0 -1
- package/dist/constraint/__tests__/example.test.js +0 -14
- package/dist/constraint/__tests__/validate.test.d.ts +0 -1
- package/dist/constraint/__tests__/validate.test.js +0 -58
- package/dist/factor/__tests__/validate.test.d.ts +0 -1
- package/dist/factor/__tests__/validate.test.js +0 -112
- package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
- package/dist/fgca/__tests__/chain-table.test.js +0 -158
- package/dist/fgca/__tests__/layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/layout.test.js +0 -140
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
- package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/preview-layout.test.js +0 -106
- package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
- package/dist/fgca/__tests__/resolver.test.js +0 -185
- package/dist/fgca/__tests__/validate.test.d.ts +0 -1
- package/dist/fgca/__tests__/validate.test.js +0 -125
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
- package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
- package/dist/goals/__tests__/layout.test.d.ts +0 -1
- package/dist/goals/__tests__/layout.test.js +0 -153
- package/dist/goals/__tests__/mutations.test.d.ts +0 -1
- package/dist/goals/__tests__/mutations.test.js +0 -134
- package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/goals/__tests__/parse-canonical.test.js +0 -131
- package/dist/goals/__tests__/validate.test.d.ts +0 -1
- package/dist/goals/__tests__/validate.test.js +0 -183
- package/dist/integration/__tests__/validate.test.d.ts +0 -1
- package/dist/integration/__tests__/validate.test.js +0 -169
- package/dist/location/__tests__/validate.test.d.ts +0 -1
- package/dist/location/__tests__/validate.test.js +0 -107
- package/dist/node/__tests__/validate.test.d.ts +0 -1
- package/dist/node/__tests__/validate.test.js +0 -100
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
- package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/layout.test.js +0 -196
- package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/validate.test.js +0 -280
- package/dist/process-map/__tests__/validate.test.d.ts +0 -1
- package/dist/process-map/__tests__/validate.test.js +0 -199
- package/dist/products/__tests__/validate.test.d.ts +0 -1
- package/dist/products/__tests__/validate.test.js +0 -210
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
- package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
- package/dist/requirement/__tests__/example.test.d.ts +0 -1
- package/dist/requirement/__tests__/example.test.js +0 -21
- package/dist/requirement/__tests__/validate.test.d.ts +0 -1
- package/dist/requirement/__tests__/validate.test.js +0 -80
- package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
- package/dist/scenarios/__tests__/validate.test.js +0 -183
- package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
- package/dist/stakeholder/__tests__/validate.test.js +0 -88
- package/dist/target-state/__tests__/validate.test.d.ts +0 -1
- package/dist/target-state/__tests__/validate.test.js +0 -78
- package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
- package/dist/technology-service/__tests__/validate.test.js +0 -121
- package/dist/theme/__tests__/tokens.test.d.ts +0 -1
- package/dist/theme/__tests__/tokens.test.js +0 -159
- package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
- package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
- package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
- package/dist/webview/__tests__/entry-notations.test.js +0 -62
- package/dist/webview/__tests__/entry.test.d.ts +0 -1
- package/dist/webview/__tests__/entry.test.js +0 -56
- package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
- package/dist/webview/__tests__/render-activities.test.js +0 -91
- package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
- package/dist/webview/__tests__/render-blocks.test.js +0 -175
- package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
- package/dist/webview/__tests__/render-goals.test.js +0 -120
- package/dist/webview/__tests__/render-process.test.d.ts +0 -1
- package/dist/webview/__tests__/render-process.test.js +0 -463
- package/dist/webview/__tests__/render-util.test.d.ts +0 -1
- package/dist/webview/__tests__/render-util.test.js +0 -54
- package/src/__tests__/edge-path.test.ts +0 -67
- package/src/__tests__/node-size-presets.test.ts +0 -50
- package/src/__tests__/scope.test.ts +0 -27
- package/src/__tests__/yaml-normalize.test.ts +0 -158
- package/src/activities/__tests__/cpm.test.ts +0 -164
- package/src/activities/__tests__/gantt.test.ts +0 -290
- package/src/activities/__tests__/layout.test.ts +0 -112
- package/src/activities/__tests__/validate.test.ts +0 -446
- package/src/activity-card/__tests__/example.test.ts +0 -83
- package/src/activity-card/__tests__/layout.test.ts +0 -162
- package/src/activity-card/__tests__/resolver.test.ts +0 -357
- package/src/activity-card/__tests__/validate.test.ts +0 -167
- package/src/actor/__tests__/validate.test.ts +0 -114
- package/src/applications/__tests__/validate.test.ts +0 -256
- package/src/assertion/__tests__/example.test.ts +0 -37
- package/src/assertion/__tests__/validate.test.ts +0 -142
- package/src/blocks/__tests__/layout.test.ts +0 -169
- package/src/blocks/__tests__/validate.test.ts +0 -260
- package/src/business-service/__tests__/validate.test.ts +0 -160
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
- package/src/capability-map/__tests__/address.test.ts +0 -59
- package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
- package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
- package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
- package/src/capability-map/__tests__/validate.test.ts +0 -238
- package/src/change/__tests__/validate.test.ts +0 -97
- package/src/codex/__tests__/example.test.ts +0 -40
- package/src/codex/__tests__/validate.test.ts +0 -84
- package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
- package/src/compliance/__tests__/classify.test.ts +0 -64
- package/src/compliance/__tests__/confidence.test.ts +0 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
- package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
- package/src/compliance/__tests__/example.test.ts +0 -57
- package/src/compliance/__tests__/gap-report.test.ts +0 -129
- package/src/compliance/__tests__/html.test.ts +0 -142
- package/src/compliance/__tests__/impact.test.ts +0 -1060
- package/src/compliance/__tests__/markdown.test.ts +0 -95
- package/src/compliance/__tests__/trace.test.ts +0 -157
- package/src/compliance/__tests__/view-resolution.test.ts +0 -80
- package/src/compliance/__tests__/views.test.ts +0 -64
- package/src/compliance-matrix/__tests__/build.test.ts +0 -200
- package/src/compliance-matrix/__tests__/example.test.ts +0 -57
- package/src/confidence/__tests__/score.test.ts +0 -254
- package/src/constraint/__tests__/example.test.ts +0 -19
- package/src/constraint/__tests__/validate.test.ts +0 -68
- package/src/factor/__tests__/validate.test.ts +0 -133
- package/src/fgca/__tests__/chain-table.test.ts +0 -172
- package/src/fgca/__tests__/layout.test.ts +0 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
- package/src/fgca/__tests__/preview-layout.test.ts +0 -124
- package/src/fgca/__tests__/resolver.test.ts +0 -209
- package/src/fgca/__tests__/validate.test.ts +0 -142
- package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
- package/src/goals/__tests__/layout.test.ts +0 -175
- package/src/goals/__tests__/mutations.test.ts +0 -153
- package/src/goals/__tests__/parse-canonical.test.ts +0 -147
- package/src/goals/__tests__/validate.test.ts +0 -202
- package/src/integration/__tests__/validate.test.ts +0 -203
- package/src/location/__tests__/validate.test.ts +0 -127
- package/src/node/__tests__/validate.test.ts +0 -118
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
- package/src/process-blueprint/__tests__/layout.test.ts +0 -240
- package/src/process-blueprint/__tests__/validate.test.ts +0 -310
- package/src/process-map/__tests__/validate.test.ts +0 -223
- package/src/products/__tests__/validate.test.ts +0 -239
- package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
- package/src/requirement/__tests__/example.test.ts +0 -24
- package/src/requirement/__tests__/validate.test.ts +0 -96
- package/src/scenarios/__tests__/validate.test.ts +0 -209
- package/src/stakeholder/__tests__/validate.test.ts +0 -105
- package/src/target-state/__tests__/validate.test.ts +0 -95
- package/src/technology-service/__tests__/validate.test.ts +0 -143
- package/src/theme/__tests__/tokens.test.ts +0 -185
- package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
- package/src/webview/__tests__/entry-notations.test.ts +0 -77
- package/src/webview/__tests__/entry.test.ts +0 -64
- package/src/webview/__tests__/render-activities.test.ts +0 -100
- package/src/webview/__tests__/render-blocks.test.ts +0 -206
- package/src/webview/__tests__/render-goals.test.ts +0 -128
- package/src/webview/__tests__/render-process.test.ts +0 -538
- package/src/webview/__tests__/render-util.test.ts +0 -66
|
@@ -1,1060 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { emptyCanon } from '../classify.js';
|
|
3
|
-
import {
|
|
4
|
-
buildImpactMatrix,
|
|
5
|
-
renderImpactMarkdown,
|
|
6
|
-
parseImpactViewConfig,
|
|
7
|
-
COMPLIANCE_IMPACT_DEFAULTS,
|
|
8
|
-
extractObjectDetails,
|
|
9
|
-
extractProcessFlowTasks,
|
|
10
|
-
mergeStageTaskDetails,
|
|
11
|
-
computeDeadlineStatus,
|
|
12
|
-
type ImpactViewConfig,
|
|
13
|
-
} from '../impact.js';
|
|
14
|
-
import type { ComplianceCanon } from '../classify.js';
|
|
15
|
-
|
|
16
|
-
// Industry- and regime-agnostic synthetic fixture: opaque ids only, no real
|
|
17
|
-
// regulator / product names, per #166 acceptance ("Output is aggregates only —
|
|
18
|
-
// no subject/obligation names tied to any real corpus").
|
|
19
|
-
function buildCanon(): ComplianceCanon {
|
|
20
|
-
const canon = emptyCanon();
|
|
21
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
22
|
-
canon.products.push({ id: 'PRODUCT-B-1', name: 'Product B' });
|
|
23
|
-
canon.requirements.push(
|
|
24
|
-
{ id: 'REQUIREMENT-FOO-1', name: 'Foo', derived_from: ['LAW-X-1'] },
|
|
25
|
-
{ id: 'REQUIREMENT-BAR-1', name: 'Bar', derived_from: ['LAW-X-1', 'REGULATION-Y-1'] },
|
|
26
|
-
{ id: 'REQUIREMENT-BAZ-1', name: 'Baz', derived_from: ['REGULATION-Y-1'] },
|
|
27
|
-
// Internal-only requirement, no codex derivation:
|
|
28
|
-
{ id: 'REQUIREMENT-INT-1', name: 'Internal-only' },
|
|
29
|
-
);
|
|
30
|
-
canon.assertions.push(
|
|
31
|
-
// (PRODUCT-A-1, FOO) — two assertions; partial wins over compliant per §5.2 step 4.
|
|
32
|
-
{ id: 'ASSERTION-1', about: 'REQUIREMENT-FOO-1', subject: 'PRODUCT-A-1', status: 'compliant' },
|
|
33
|
-
{ id: 'ASSERTION-2', about: 'REQUIREMENT-FOO-1', subject: 'PRODUCT-A-1', status: 'partial' },
|
|
34
|
-
// (PRODUCT-A-1, BAR) — single n_a → modelled fact ("No obligation applies").
|
|
35
|
-
{ id: 'ASSERTION-3', about: 'REQUIREMENT-BAR-1', subject: 'PRODUCT-A-1', status: 'n_a' },
|
|
36
|
-
// (PRODUCT-B-1, BAR) — non_compliant.
|
|
37
|
-
{ id: 'ASSERTION-4', about: 'REQUIREMENT-BAR-1', subject: 'PRODUCT-B-1', status: 'non_compliant' },
|
|
38
|
-
// (PRODUCT-B-1, BAZ) — under_review beats compliant.
|
|
39
|
-
{ id: 'ASSERTION-5', about: 'REQUIREMENT-BAZ-1', subject: 'PRODUCT-B-1', status: 'under_review' },
|
|
40
|
-
{ id: 'ASSERTION-6', about: 'REQUIREMENT-BAZ-1', subject: 'PRODUCT-B-1', status: 'compliant' },
|
|
41
|
-
);
|
|
42
|
-
return canon;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const baseConfig: ImpactViewConfig = {
|
|
46
|
-
id: 'COMPLIANCE_IMPACT-FIXTURE-1',
|
|
47
|
-
name: 'Fixture matrix',
|
|
48
|
-
subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1'] },
|
|
49
|
-
obligations: {},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
describe('buildImpactMatrix', () => {
|
|
53
|
-
it('aggregates statuses per §5.2 step 4 — non_compliant > partial > under_review > compliant', () => {
|
|
54
|
-
const canon = buildCanon();
|
|
55
|
-
const matrix = buildImpactMatrix(canon, {
|
|
56
|
-
...baseConfig,
|
|
57
|
-
obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1'] },
|
|
58
|
-
});
|
|
59
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
|
|
60
|
-
expect(matrix.rows.map(r => r.id)).toEqual(['REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1', 'REQUIREMENT-FOO-1']);
|
|
61
|
-
|
|
62
|
-
const cellFor = (req: string, subject: string) => {
|
|
63
|
-
const r = matrix.rows.findIndex(x => x.id === req);
|
|
64
|
-
const c = matrix.columns.findIndex(col => col.label === subject);
|
|
65
|
-
return matrix.cells[r][c];
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
expect(cellFor('REQUIREMENT-FOO-1', 'PRODUCT-A-1').status).toBe('partial');
|
|
69
|
-
expect(cellFor('REQUIREMENT-FOO-1', 'PRODUCT-A-1').kind).toBe('bound');
|
|
70
|
-
expect(cellFor('REQUIREMENT-BAR-1', 'PRODUCT-A-1').kind).toBe('n_a_only');
|
|
71
|
-
expect(cellFor('REQUIREMENT-BAR-1', 'PRODUCT-B-1').status).toBe('non_compliant');
|
|
72
|
-
expect(cellFor('REQUIREMENT-BAZ-1', 'PRODUCT-B-1').status).toBe('under_review');
|
|
73
|
-
expect(cellFor('REQUIREMENT-FOO-1', 'PRODUCT-B-1').kind).toBe('gap');
|
|
74
|
-
expect(cellFor('REQUIREMENT-BAZ-1', 'PRODUCT-A-1').kind).toBe('gap');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('selects obligations by `filter.derived_from_codex`', () => {
|
|
78
|
-
const canon = buildCanon();
|
|
79
|
-
const matrix = buildImpactMatrix(canon, {
|
|
80
|
-
...baseConfig,
|
|
81
|
-
obligations: { filter: { derived_from_codex: ['REGULATION-Y-1'] } },
|
|
82
|
-
});
|
|
83
|
-
expect(matrix.rows.map(r => r.id)).toEqual(['REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1']);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('`include` wins when both `include` and `filter` are present (COMPIMP-007)', () => {
|
|
87
|
-
const canon = buildCanon();
|
|
88
|
-
const matrix = buildImpactMatrix(canon, {
|
|
89
|
-
...baseConfig,
|
|
90
|
-
obligations: {
|
|
91
|
-
include: ['REQUIREMENT-INT-1'],
|
|
92
|
-
filter: { derived_from_codex: ['LAW-X-1'] },
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
expect(matrix.rows.map(r => r.id)).toEqual(['REQUIREMENT-INT-1']);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('distinguishes modelling gap from n_a-only per §5.3', () => {
|
|
99
|
-
const canon = buildCanon();
|
|
100
|
-
const matrix = buildImpactMatrix(canon, {
|
|
101
|
-
...baseConfig,
|
|
102
|
-
obligations: { include: ['REQUIREMENT-BAR-1'] },
|
|
103
|
-
});
|
|
104
|
-
const aCell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-A-1')];
|
|
105
|
-
const bCell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-B-1')];
|
|
106
|
-
expect(aCell.kind).toBe('n_a_only');
|
|
107
|
-
expect(bCell.kind).toBe('bound');
|
|
108
|
-
expect(bCell.status).toBe('non_compliant');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('respects `status_display.show` — filtered-out statuses leave the cell as a gap', () => {
|
|
112
|
-
const canon = buildCanon();
|
|
113
|
-
const matrix = buildImpactMatrix(canon, {
|
|
114
|
-
...baseConfig,
|
|
115
|
-
obligations: { include: ['REQUIREMENT-BAZ-1'] },
|
|
116
|
-
status_display: { show: ['non_compliant'] }, // under_review + compliant filtered out
|
|
117
|
-
});
|
|
118
|
-
const cell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-B-1')];
|
|
119
|
-
expect(cell.kind).toBe('gap');
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it('keeps subjects with no binding obligation as columns so the gap is visible', () => {
|
|
123
|
-
const canon = buildCanon();
|
|
124
|
-
const matrix = buildImpactMatrix(canon, {
|
|
125
|
-
...baseConfig,
|
|
126
|
-
subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1', 'PRODUCT-NONE-1'] },
|
|
127
|
-
obligations: { include: ['REQUIREMENT-FOO-1'] },
|
|
128
|
-
});
|
|
129
|
-
expect(matrix.columns.map(c => c.label)).toContain('PRODUCT-NONE-1');
|
|
130
|
-
const cell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-NONE-1')];
|
|
131
|
-
expect(cell.kind).toBe('gap');
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('orders rows alphabetically by name when `order_rows_by: name`', () => {
|
|
135
|
-
const canon = buildCanon();
|
|
136
|
-
const matrix = buildImpactMatrix(canon, {
|
|
137
|
-
...baseConfig,
|
|
138
|
-
obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1'] },
|
|
139
|
-
order_rows_by: 'name',
|
|
140
|
-
});
|
|
141
|
-
expect(matrix.rows.map(r => r.name)).toEqual(['Bar', 'Baz', 'Foo']);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
describe('renderImpactMarkdown', () => {
|
|
146
|
-
it('renders a header, table, and §5.3 legend', () => {
|
|
147
|
-
const canon = buildCanon();
|
|
148
|
-
const matrix = buildImpactMatrix(canon, {
|
|
149
|
-
...baseConfig,
|
|
150
|
-
obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1'] },
|
|
151
|
-
});
|
|
152
|
-
const md = renderImpactMarkdown(matrix);
|
|
153
|
-
expect(md).toContain('# Fixture matrix');
|
|
154
|
-
expect(md).toContain('View ID: `COMPLIANCE_IMPACT-FIXTURE-1`');
|
|
155
|
-
expect(md).toContain('| Obligation | PRODUCT-A-1 | PRODUCT-B-1 |');
|
|
156
|
-
expect(md).toContain('PARTIAL');
|
|
157
|
-
expect(md).toContain('FAIL');
|
|
158
|
-
expect(md).toContain('No mapped obligation (current model)');
|
|
159
|
-
expect(md).toContain('No obligation applies');
|
|
160
|
-
expect(md).toContain('## Legend');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('honours custom empty-cell labels', () => {
|
|
164
|
-
const canon = buildCanon();
|
|
165
|
-
const matrix = buildImpactMatrix(canon, {
|
|
166
|
-
...baseConfig,
|
|
167
|
-
obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1'] },
|
|
168
|
-
empty_cells: {
|
|
169
|
-
no_obligation_label: 'GAP',
|
|
170
|
-
no_obligation_applies_label: 'EXCLUDED',
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
const md = renderImpactMarkdown(matrix);
|
|
174
|
-
expect(md).toContain('GAP');
|
|
175
|
-
expect(md).toContain('EXCLUDED');
|
|
176
|
-
expect(md).not.toContain('No mapped obligation (current model)');
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('renders a placeholder when zero obligations are selected', () => {
|
|
180
|
-
const canon = buildCanon();
|
|
181
|
-
const matrix = buildImpactMatrix(canon, {
|
|
182
|
-
...baseConfig,
|
|
183
|
-
obligations: { include: ['REQUIREMENT-DOES-NOT-EXIST-1'] },
|
|
184
|
-
});
|
|
185
|
-
const md = renderImpactMarkdown(matrix);
|
|
186
|
-
expect(md).toContain('No obligations in scope');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('propagates snapshot_at into the matrix and renders it', () => {
|
|
190
|
-
const canon = buildCanon();
|
|
191
|
-
const matrix = buildImpactMatrix(canon, { ...baseConfig, snapshot_at: '2026-06-09' });
|
|
192
|
-
expect(matrix.snapshotAt).toBe('2026-06-09');
|
|
193
|
-
const md = renderImpactMarkdown(matrix);
|
|
194
|
-
expect(md).toContain('Report snapshot: 2026-06-09');
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
it('resolves capability subject names from canon.subjects', () => {
|
|
198
|
-
const canon = emptyCanon();
|
|
199
|
-
canon.subjects.push({ id: 'CAPABILITY-CRM-1', name: 'CRM Platform' });
|
|
200
|
-
canon.requirements.push({ id: 'REQUIREMENT-FOO-1', name: 'Foo' });
|
|
201
|
-
canon.assertions.push({
|
|
202
|
-
id: 'ASSERTION-1',
|
|
203
|
-
about: 'REQUIREMENT-FOO-1',
|
|
204
|
-
subject: 'CAPABILITY-CRM-1',
|
|
205
|
-
status: 'compliant',
|
|
206
|
-
});
|
|
207
|
-
const matrix = buildImpactMatrix(canon, {
|
|
208
|
-
id: 'V-1', name: 'Test',
|
|
209
|
-
subjects: { capabilities: ['CAPABILITY-CRM-1'] },
|
|
210
|
-
obligations: {},
|
|
211
|
-
});
|
|
212
|
-
expect(matrix.columns[0].subjectId).toBe('CAPABILITY-CRM-1');
|
|
213
|
-
expect(matrix.columns[0].subjectName).toBe('CRM Platform');
|
|
214
|
-
expect(matrix.cells[0][0].status).toBe('compliant');
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it('resolves process subject names from canon.subjects', () => {
|
|
218
|
-
const canon = emptyCanon();
|
|
219
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
220
|
-
canon.requirements.push({ id: 'REQUIREMENT-BAR-1', name: 'Bar' });
|
|
221
|
-
canon.assertions.push({
|
|
222
|
-
id: 'ASSERTION-P1',
|
|
223
|
-
about: 'REQUIREMENT-BAR-1',
|
|
224
|
-
subject: 'PROCESS-CS-1',
|
|
225
|
-
status: 'partial',
|
|
226
|
-
});
|
|
227
|
-
const matrix = buildImpactMatrix(canon, {
|
|
228
|
-
id: 'V-2', name: 'Test',
|
|
229
|
-
subjects: { processes: ['PROCESS-CS-1'] },
|
|
230
|
-
obligations: {},
|
|
231
|
-
});
|
|
232
|
-
expect(matrix.columns[0].subjectName).toBe('Customer Support');
|
|
233
|
-
expect(matrix.cells[0][0].status).toBe('partial');
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('mixed product + capability columns — names resolved from respective buckets', () => {
|
|
237
|
-
const canon = buildCanon();
|
|
238
|
-
canon.subjects.push({ id: 'CAPABILITY-CRM-1', name: 'CRM' });
|
|
239
|
-
canon.requirements.push({ id: 'REQUIREMENT-CRM-1', name: 'CRM req' });
|
|
240
|
-
canon.assertions.push({
|
|
241
|
-
id: 'ASSERTION-CRM-1',
|
|
242
|
-
about: 'REQUIREMENT-CRM-1',
|
|
243
|
-
subject: 'CAPABILITY-CRM-1',
|
|
244
|
-
status: 'under_review',
|
|
245
|
-
});
|
|
246
|
-
const matrix = buildImpactMatrix(canon, {
|
|
247
|
-
id: 'V-3', name: 'Mixed',
|
|
248
|
-
subjects: { products: ['PRODUCT-A-1'], capabilities: ['CAPABILITY-CRM-1'] },
|
|
249
|
-
obligations: {},
|
|
250
|
-
});
|
|
251
|
-
expect(matrix.columns.map(c => c.subjectId)).toEqual(['PRODUCT-A-1', 'CAPABILITY-CRM-1']);
|
|
252
|
-
expect(matrix.columns[0].subjectName).toBe('Product A');
|
|
253
|
-
expect(matrix.columns[1].subjectName).toBe('CRM');
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('pending_owner cell renders as bound with PENDING status', () => {
|
|
257
|
-
const canon = emptyCanon();
|
|
258
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
259
|
-
canon.requirements.push({ id: 'REQUIREMENT-PO-1', name: 'PO req' });
|
|
260
|
-
canon.assertions.push({
|
|
261
|
-
id: 'ASSERTION-PO-1',
|
|
262
|
-
about: 'REQUIREMENT-PO-1',
|
|
263
|
-
subject: 'PRODUCT-A-1',
|
|
264
|
-
status: 'pending_owner',
|
|
265
|
-
owner_to_confirm: 'alice@example.com',
|
|
266
|
-
});
|
|
267
|
-
const matrix = buildImpactMatrix(canon, {
|
|
268
|
-
id: 'V-PO', name: 'PO Test',
|
|
269
|
-
subjects: { products: ['PRODUCT-A-1'] },
|
|
270
|
-
obligations: {},
|
|
271
|
-
});
|
|
272
|
-
expect(matrix.cells[0][0].kind).toBe('bound');
|
|
273
|
-
expect(matrix.cells[0][0].status).toBe('pending_owner');
|
|
274
|
-
expect(matrix.cells[0][0].assertions[0].owner_to_confirm).toBe('alice@example.com');
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('pending_owner loses to partial in aggregation', () => {
|
|
278
|
-
const canon = emptyCanon();
|
|
279
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
280
|
-
canon.requirements.push({ id: 'REQUIREMENT-PO-2', name: 'PO req 2' });
|
|
281
|
-
canon.assertions.push(
|
|
282
|
-
{ id: 'ASSERTION-PO-2a', about: 'REQUIREMENT-PO-2', subject: 'PRODUCT-A-1', status: 'partial' },
|
|
283
|
-
{ id: 'ASSERTION-PO-2b', about: 'REQUIREMENT-PO-2', subject: 'PRODUCT-A-1', status: 'pending_owner' },
|
|
284
|
-
);
|
|
285
|
-
const matrix = buildImpactMatrix(canon, {
|
|
286
|
-
id: 'V-PO2', name: 'PO Agg',
|
|
287
|
-
subjects: { products: ['PRODUCT-A-1'] },
|
|
288
|
-
obligations: {},
|
|
289
|
-
});
|
|
290
|
-
expect(matrix.cells[0][0].status).toBe('partial');
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
// ── parseImpactViewConfig ───────────────────────────────────────────────────
|
|
295
|
-
|
|
296
|
-
describe('parseImpactViewConfig', () => {
|
|
297
|
-
it('returns ok:false for a non-object', () => {
|
|
298
|
-
const r = parseImpactViewConfig(null);
|
|
299
|
-
expect(r.ok).toBe(false);
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('returns ok:false when id is missing', () => {
|
|
303
|
-
const r = parseImpactViewConfig({ name: 'X', subjects: {} });
|
|
304
|
-
expect(r.ok).toBe(false);
|
|
305
|
-
if (!r.ok) expect(r.errors.some(e => e.includes('id'))).toBe(true);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it('returns ok:false when name is missing', () => {
|
|
309
|
-
const r = parseImpactViewConfig({ id: 'X', subjects: {} });
|
|
310
|
-
expect(r.ok).toBe(false);
|
|
311
|
-
if (!r.ok) expect(r.errors.some(e => e.includes('name'))).toBe(true);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('unwraps the top-level view: wrapper', () => {
|
|
315
|
-
const r = parseImpactViewConfig({ view: { id: 'V-1', name: 'My view', subjects: {} } });
|
|
316
|
-
expect(r.ok).toBe(true);
|
|
317
|
-
if (r.ok) expect(r.config.id).toBe('V-1');
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('fills all optional fields from COMPLIANCE_IMPACT_DEFAULTS', () => {
|
|
321
|
-
const r = parseImpactViewConfig({ id: 'V-1', name: 'My view', subjects: {} });
|
|
322
|
-
expect(r.ok).toBe(true);
|
|
323
|
-
if (!r.ok) return;
|
|
324
|
-
const c = r.config;
|
|
325
|
-
expect(c.subjects.products).toEqual([]);
|
|
326
|
-
expect(c.subjects.processes).toEqual([]);
|
|
327
|
-
expect(c.subjects.capabilities).toEqual([]);
|
|
328
|
-
expect(c.status_display?.show).toEqual(COMPLIANCE_IMPACT_DEFAULTS.status_display.show);
|
|
329
|
-
expect(c.order_rows_by).toBe('id');
|
|
330
|
-
expect(c.empty_cells?.no_obligation_label).toBe(
|
|
331
|
-
COMPLIANCE_IMPACT_DEFAULTS.empty_cells.no_obligation_label,
|
|
332
|
-
);
|
|
333
|
-
expect(c.empty_cells?.no_obligation_applies_label).toBe(
|
|
334
|
-
COMPLIANCE_IMPACT_DEFAULTS.empty_cells.no_obligation_applies_label,
|
|
335
|
-
);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it('preserves explicit subject lists and snapshot_at', () => {
|
|
339
|
-
const r = parseImpactViewConfig({
|
|
340
|
-
id: 'V-2',
|
|
341
|
-
name: 'View 2',
|
|
342
|
-
snapshot_at: '2026-01-01',
|
|
343
|
-
subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1'] },
|
|
344
|
-
});
|
|
345
|
-
expect(r.ok).toBe(true);
|
|
346
|
-
if (!r.ok) return;
|
|
347
|
-
expect(r.config.subjects.products).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
|
|
348
|
-
expect(r.config.snapshot_at).toBe('2026-01-01');
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
it('applies custom order_rows_by:name', () => {
|
|
352
|
-
const r = parseImpactViewConfig({ id: 'V-3', name: 'V', subjects: {}, order_rows_by: 'name' });
|
|
353
|
-
expect(r.ok).toBe(true);
|
|
354
|
-
if (r.ok) expect(r.config.order_rows_by).toBe('name');
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
it('parses obligation filter correctly', () => {
|
|
358
|
-
const r = parseImpactViewConfig({
|
|
359
|
-
id: 'V-4',
|
|
360
|
-
name: 'V',
|
|
361
|
-
subjects: {},
|
|
362
|
-
obligations: { filter: { derived_from_codex: ['LAW-X-1'] } },
|
|
363
|
-
});
|
|
364
|
-
expect(r.ok).toBe(true);
|
|
365
|
-
if (r.ok) expect(r.config.obligations.filter?.derived_from_codex).toEqual(['LAW-X-1']);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
describe('CV-3a — stage grouping (ImpactColumn, extractObjectDetails, buildImpactMatrix stage grain)', () => {
|
|
370
|
-
it('default product grain: columns are plain ImpactColumn with label=subjectId', () => {
|
|
371
|
-
const canon = buildCanon();
|
|
372
|
-
const matrix = buildImpactMatrix(canon, baseConfig);
|
|
373
|
-
expect(matrix.columns.map(c => c.subjectId)).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
|
|
374
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
|
|
375
|
-
expect(matrix.columns.every(c => !c.stageId)).toBe(true);
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it('product-stage grain: expands columns by stage, label is subjectId:stageId', () => {
|
|
379
|
-
const canon = buildCanon();
|
|
380
|
-
const matrix = buildImpactMatrix(
|
|
381
|
-
canon,
|
|
382
|
-
{ ...baseConfig, subjects: { products: ['PRODUCT-A-1'] }, grouping: { columns: 'product-stage' } },
|
|
383
|
-
[{ objectId: 'PRODUCT-A-1', details: [{ id: 'STAGE-1', name: 'Stage One' }, { id: 'STAGE-2', name: 'Stage Two' }] }],
|
|
384
|
-
);
|
|
385
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1:STAGE-1', 'PRODUCT-A-1:STAGE-2']);
|
|
386
|
-
expect(matrix.columns.map(c => c.stageId)).toEqual(['STAGE-1', 'STAGE-2']);
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
it('assertion without realised_via fills every stage column for its subject', () => {
|
|
390
|
-
const canon = emptyCanon();
|
|
391
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
392
|
-
// Assertion with no realised_via — covers the whole subject.
|
|
393
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
394
|
-
const matrix = buildImpactMatrix(
|
|
395
|
-
canon,
|
|
396
|
-
{
|
|
397
|
-
id: 'V', name: 'V',
|
|
398
|
-
subjects: { products: ['PROD-1'] },
|
|
399
|
-
obligations: {},
|
|
400
|
-
grouping: { columns: 'product-stage' },
|
|
401
|
-
},
|
|
402
|
-
[{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1' }, { id: 'S2', name: 's2' }] }],
|
|
403
|
-
);
|
|
404
|
-
// Both stage columns should be bound (no realised_via means all stages inherit).
|
|
405
|
-
expect(matrix.cells[0][0].kind).toBe('bound');
|
|
406
|
-
expect(matrix.cells[0][1].kind).toBe('bound');
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
it('assertion with realised_via fills only the matching stage column', () => {
|
|
410
|
-
const canon = emptyCanon();
|
|
411
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
412
|
-
// Assertion only covers STAGE-A.
|
|
413
|
-
canon.assertions.push({
|
|
414
|
-
id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant',
|
|
415
|
-
realised_via: ['STAGE-A'],
|
|
416
|
-
});
|
|
417
|
-
const matrix = buildImpactMatrix(
|
|
418
|
-
canon,
|
|
419
|
-
{
|
|
420
|
-
id: 'V', name: 'V',
|
|
421
|
-
subjects: { products: ['PROD-1'] },
|
|
422
|
-
obligations: {},
|
|
423
|
-
grouping: { columns: 'product-stage' },
|
|
424
|
-
},
|
|
425
|
-
[{ objectId: 'PROD-1', details: [{ id: 'STAGE-A', name: 'a' }, { id: 'STAGE-B', name: 'b' }] }],
|
|
426
|
-
);
|
|
427
|
-
expect(matrix.cells[0][0].kind).toBe('bound'); // STAGE-A: covered
|
|
428
|
-
expect(matrix.cells[0][1].kind).toBe('gap'); // STAGE-B: gap
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
it('subject with no stage mapping falls back to single product-grain column', () => {
|
|
432
|
-
const canon = buildCanon();
|
|
433
|
-
const matrix = buildImpactMatrix(
|
|
434
|
-
canon,
|
|
435
|
-
{
|
|
436
|
-
...baseConfig,
|
|
437
|
-
subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1'] },
|
|
438
|
-
grouping: { columns: 'product-stage' },
|
|
439
|
-
},
|
|
440
|
-
// Only provide stages for A — B falls back to a single column.
|
|
441
|
-
[{ objectId: 'PRODUCT-A-1', details: [{ id: 'S1', name: 's1' }] }],
|
|
442
|
-
);
|
|
443
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1:S1', 'PRODUCT-B-1']);
|
|
444
|
-
// PRODUCT-B-1 fallback column: no stageId.
|
|
445
|
-
expect(matrix.columns[1].stageId).toBeUndefined();
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
it('extractObjectDetails — returns null for non-blueprint docs', () => {
|
|
449
|
-
expect(extractObjectDetails(null)).toBeNull();
|
|
450
|
-
expect(extractObjectDetails({ notation: 'requirement', id: 'R1' })).toBeNull();
|
|
451
|
-
expect(extractObjectDetails({ process_blueprint: { details: [{ id: 'S1' }] } })).toBeNull(); // missing id
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
it('extractObjectDetails — extracts subjectId and stages from process_blueprint wrapper', () => {
|
|
455
|
-
const doc = { process_blueprint: { id: 'PROC-1', notation: 'process_blueprint', stages: [{ id: 'S1', name: 'Stage One' }, { id: 'S2', name: 'Stage Two' }] } };
|
|
456
|
-
const sg = extractObjectDetails(doc);
|
|
457
|
-
expect(sg).not.toBeNull();
|
|
458
|
-
expect(sg!.objectId).toBe('PROC-1');
|
|
459
|
-
expect(sg!.details.map((s: { id: string }) => s.id)).toEqual(['S1', 'S2']);
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
it('renderImpactMarkdown uses column labels in the table header', () => {
|
|
463
|
-
const canon = emptyCanon();
|
|
464
|
-
canon.requirements.push({ id: 'REQ-1', name: 'Req' });
|
|
465
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
466
|
-
const matrix = buildImpactMatrix(
|
|
467
|
-
canon,
|
|
468
|
-
{
|
|
469
|
-
id: 'V', name: 'Stage Report',
|
|
470
|
-
subjects: { products: ['PROD-1'] },
|
|
471
|
-
obligations: {},
|
|
472
|
-
grouping: { columns: 'product-stage' },
|
|
473
|
-
},
|
|
474
|
-
[{ objectId: 'PROD-1', details: [{ id: 'S1', name: 'Stage One' }] }],
|
|
475
|
-
);
|
|
476
|
-
const md = renderImpactMarkdown(matrix);
|
|
477
|
-
expect(md).toContain('PROD-1:S1');
|
|
478
|
-
});
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
describe('CV-3 -- blueprint-lane decorations + obligations lane', () => {
|
|
482
|
-
it('computeDeadlineStatus function is available', () => {
|
|
483
|
-
expect(typeof computeDeadlineStatus).toBe('function');
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
it('cell.decoration.isNew = false when no snapshot_at', () => {
|
|
487
|
-
const canon = emptyCanon();
|
|
488
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1', admitted_at: '2026-01-01' });
|
|
489
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
490
|
-
const matrix = buildImpactMatrix(canon, {
|
|
491
|
-
id: 'V', name: 'V',
|
|
492
|
-
subjects: { products: ['PROD-1'] },
|
|
493
|
-
obligations: {},
|
|
494
|
-
});
|
|
495
|
-
expect(matrix.cells[0][0].decoration.isNew).toBe(false);
|
|
496
|
-
});
|
|
497
|
-
|
|
498
|
-
it('cell.decoration.isNew = true when req admitted after snapshot_at', () => {
|
|
499
|
-
const canon = emptyCanon();
|
|
500
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1', admitted_at: '2026-06-01' });
|
|
501
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
502
|
-
const matrix = buildImpactMatrix(canon, {
|
|
503
|
-
id: 'V', name: 'V',
|
|
504
|
-
snapshot_at: '2026-05-01',
|
|
505
|
-
subjects: { products: ['PROD-1'] },
|
|
506
|
-
obligations: {},
|
|
507
|
-
});
|
|
508
|
-
// admitted_at (2026-06-01) > snapshot_at (2026-05-01) -> isNew
|
|
509
|
-
expect(matrix.cells[0][0].decoration.isNew).toBe(true);
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
it('cell.decoration.isUrgent = true when gap + past_due deadline', () => {
|
|
513
|
-
const canon = emptyCanon();
|
|
514
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1', deadline: '2000-01-01' });
|
|
515
|
-
// No assertion -> gap cell
|
|
516
|
-
const matrix = buildImpactMatrix(canon, {
|
|
517
|
-
id: 'V', name: 'V',
|
|
518
|
-
subjects: { products: ['PROD-1'] },
|
|
519
|
-
obligations: {},
|
|
520
|
-
});
|
|
521
|
-
expect(matrix.cells[0][0].kind).toBe('gap');
|
|
522
|
-
expect(matrix.cells[0][0].decoration.isUrgent).toBe(true);
|
|
523
|
-
expect(matrix.cells[0][0].decoration.deadlineStatus).toBe('past_due');
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
it('cell.decoration.isUrgent = false on bound cell even with past deadline', () => {
|
|
527
|
-
const canon = emptyCanon();
|
|
528
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1', deadline: '2000-01-01' });
|
|
529
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
530
|
-
const matrix = buildImpactMatrix(canon, {
|
|
531
|
-
id: 'V', name: 'V',
|
|
532
|
-
subjects: { products: ['PROD-1'] },
|
|
533
|
-
obligations: {},
|
|
534
|
-
});
|
|
535
|
-
expect(matrix.cells[0][0].kind).toBe('bound');
|
|
536
|
-
// Not urgent: cell is bound, not a gap
|
|
537
|
-
expect(matrix.cells[0][0].decoration.isUrgent).toBe(false);
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
it('obligationsLane lists derived_from codex IDs for non-gap columns', () => {
|
|
541
|
-
const canon = emptyCanon();
|
|
542
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1', derived_from: ['LAW-X', 'REG-Y'] });
|
|
543
|
-
canon.requirements.push({ id: 'REQ-2', name: 'R2', derived_from: ['LAW-X'] });
|
|
544
|
-
// Only REQ-1 is bound in PROD-1 column; REQ-2 is a gap
|
|
545
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
546
|
-
const matrix = buildImpactMatrix(canon, {
|
|
547
|
-
id: 'V', name: 'V',
|
|
548
|
-
subjects: { products: ['PROD-1'] },
|
|
549
|
-
obligations: {},
|
|
550
|
-
});
|
|
551
|
-
// obligationsLane[0] (PROD-1 column): REQ-1 is bound -> derived_from -> LAW-X, REG-Y sorted
|
|
552
|
-
expect(matrix.obligationsLane[0]).toEqual(['LAW-X', 'REG-Y']);
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
it('obligationsLane is empty for columns with only gap cells', () => {
|
|
556
|
-
const canon = emptyCanon();
|
|
557
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1', derived_from: ['LAW-X'] });
|
|
558
|
-
// No assertions -> all gaps
|
|
559
|
-
const matrix = buildImpactMatrix(canon, {
|
|
560
|
-
id: 'V', name: 'V',
|
|
561
|
-
subjects: { products: ['PROD-1'] },
|
|
562
|
-
obligations: {},
|
|
563
|
-
});
|
|
564
|
-
expect(matrix.obligationsLane[0]).toEqual([]);
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
|
|
568
|
-
describe('computeDeadlineStatus', () => {
|
|
569
|
-
it('returns none for missing deadline', () => {
|
|
570
|
-
expect(computeDeadlineStatus(undefined, '2026-06-01')).toBe('none');
|
|
571
|
-
});
|
|
572
|
-
it('returns past_due when deadline < today', () => {
|
|
573
|
-
expect(computeDeadlineStatus('2026-01-01', '2026-06-01')).toBe('past_due');
|
|
574
|
-
});
|
|
575
|
-
it('returns in_force within 30 days', () => {
|
|
576
|
-
expect(computeDeadlineStatus('2026-06-20', '2026-06-01')).toBe('in_force');
|
|
577
|
-
});
|
|
578
|
-
it('returns upcoming more than 30 days away', () => {
|
|
579
|
-
expect(computeDeadlineStatus('2026-12-31', '2026-06-01')).toBe('upcoming');
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
// ── parseImpactViewConfig — grouping field ────────────────────────────────────
|
|
584
|
-
|
|
585
|
-
describe('parseImpactViewConfig — grouping field', () => {
|
|
586
|
-
it('parses grouping.columns: product-stage', () => {
|
|
587
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'product-stage' } });
|
|
588
|
-
expect(r.ok).toBe(true);
|
|
589
|
-
if (r.ok) expect(r.config.grouping?.columns).toBe('product-stage');
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
it('parses grouping.columns: product-stage-task', () => {
|
|
593
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'product-stage-task' } });
|
|
594
|
-
expect(r.ok).toBe(true);
|
|
595
|
-
if (r.ok) expect(r.config.grouping?.columns).toBe('product-stage-task');
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
it('parses grouping.columns: product (coarsest grain)', () => {
|
|
599
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'product' } });
|
|
600
|
-
expect(r.ok).toBe(true);
|
|
601
|
-
if (r.ok) expect(r.config.grouping?.columns).toBe('product');
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
it('normalises backward-compat alias object-details → product-stage', () => {
|
|
605
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'object-details' } });
|
|
606
|
-
expect(r.ok).toBe(true);
|
|
607
|
-
if (r.ok) expect(r.config.grouping?.columns).toBe('product-stage');
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
it('normalises backward-compat alias object → product', () => {
|
|
611
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'object' } });
|
|
612
|
-
expect(r.ok).toBe(true);
|
|
613
|
-
if (r.ok) expect(r.config.grouping?.columns).toBe('product');
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
it('leaves grouping undefined when the field is absent', () => {
|
|
617
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {} });
|
|
618
|
-
expect(r.ok).toBe(true);
|
|
619
|
-
if (r.ok) expect(r.config.grouping).toBeUndefined();
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
it('leaves grouping undefined for an unrecognised columns value', () => {
|
|
623
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'unknown-grain' } });
|
|
624
|
-
expect(r.ok).toBe(true);
|
|
625
|
-
if (r.ok) expect(r.config.grouping).toBeUndefined();
|
|
626
|
-
});
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
// ── CV-3a — product-stage-task grain ─────────────────────────────────────────
|
|
630
|
-
|
|
631
|
-
describe('CV-3a — product-stage-task grain (buildImpactMatrix, buildTaskColumns)', () => {
|
|
632
|
-
it('expands columns to (subject, stage, task) triples; label is subjectId:stageId:taskId', () => {
|
|
633
|
-
const canon = emptyCanon();
|
|
634
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
635
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
636
|
-
const matrix = buildImpactMatrix(
|
|
637
|
-
canon,
|
|
638
|
-
{
|
|
639
|
-
id: 'V', name: 'V',
|
|
640
|
-
subjects: { products: ['PROD-1'] },
|
|
641
|
-
obligations: {},
|
|
642
|
-
grouping: { columns: 'product-stage-task' },
|
|
643
|
-
},
|
|
644
|
-
[{
|
|
645
|
-
objectId: 'PROD-1',
|
|
646
|
-
details: [
|
|
647
|
-
{ id: 'STAGE-A', name: 'Stage A', tasks: [{ id: 'TASK-1', name: 'Task 1' }, { id: 'TASK-2', name: 'Task 2' }] },
|
|
648
|
-
],
|
|
649
|
-
}],
|
|
650
|
-
);
|
|
651
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PROD-1:STAGE-A:TASK-1', 'PROD-1:STAGE-A:TASK-2']);
|
|
652
|
-
expect(matrix.columns[0]).toMatchObject({ subjectId: 'PROD-1', stageId: 'STAGE-A', taskId: 'TASK-1' });
|
|
653
|
-
expect(matrix.columns[1]).toMatchObject({ subjectId: 'PROD-1', stageId: 'STAGE-A', taskId: 'TASK-2' });
|
|
654
|
-
});
|
|
655
|
-
|
|
656
|
-
it('assertion without realised_via fills every task column for its subject', () => {
|
|
657
|
-
const canon = emptyCanon();
|
|
658
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
659
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
|
|
660
|
-
const matrix = buildImpactMatrix(
|
|
661
|
-
canon,
|
|
662
|
-
{
|
|
663
|
-
id: 'V', name: 'V',
|
|
664
|
-
subjects: { products: ['PROD-1'] },
|
|
665
|
-
obligations: {},
|
|
666
|
-
grouping: { columns: 'product-stage-task' },
|
|
667
|
-
},
|
|
668
|
-
[{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1', tasks: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] }] }],
|
|
669
|
-
);
|
|
670
|
-
expect(matrix.cells[0][0].kind).toBe('bound');
|
|
671
|
-
expect(matrix.cells[0][1].kind).toBe('bound');
|
|
672
|
-
});
|
|
673
|
-
|
|
674
|
-
it('assertion with realised_via: [taskId] fills only the matching task column', () => {
|
|
675
|
-
const canon = emptyCanon();
|
|
676
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
677
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant', realised_via: ['T1'] });
|
|
678
|
-
const matrix = buildImpactMatrix(
|
|
679
|
-
canon,
|
|
680
|
-
{
|
|
681
|
-
id: 'V', name: 'V',
|
|
682
|
-
subjects: { products: ['PROD-1'] },
|
|
683
|
-
obligations: {},
|
|
684
|
-
grouping: { columns: 'product-stage-task' },
|
|
685
|
-
},
|
|
686
|
-
[{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1', tasks: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] }] }],
|
|
687
|
-
);
|
|
688
|
-
expect(matrix.cells[0][0].kind).toBe('bound'); // T1: covered
|
|
689
|
-
expect(matrix.cells[0][1].kind).toBe('gap'); // T2: not covered
|
|
690
|
-
});
|
|
691
|
-
|
|
692
|
-
it('assertion with realised_via: [stageId] fills all task columns in that stage', () => {
|
|
693
|
-
const canon = emptyCanon();
|
|
694
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
695
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant', realised_via: ['S1'] });
|
|
696
|
-
const matrix = buildImpactMatrix(
|
|
697
|
-
canon,
|
|
698
|
-
{
|
|
699
|
-
id: 'V', name: 'V',
|
|
700
|
-
subjects: { products: ['PROD-1'] },
|
|
701
|
-
obligations: {},
|
|
702
|
-
grouping: { columns: 'product-stage-task' },
|
|
703
|
-
},
|
|
704
|
-
[{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1', tasks: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] }] }],
|
|
705
|
-
);
|
|
706
|
-
expect(matrix.cells[0][0].kind).toBe('bound');
|
|
707
|
-
expect(matrix.cells[0][1].kind).toBe('bound');
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
it('stage with no tasks falls back to stage-grain column', () => {
|
|
711
|
-
const canon = emptyCanon();
|
|
712
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
713
|
-
const matrix = buildImpactMatrix(
|
|
714
|
-
canon,
|
|
715
|
-
{
|
|
716
|
-
id: 'V', name: 'V',
|
|
717
|
-
subjects: { products: ['PROD-1'] },
|
|
718
|
-
obligations: {},
|
|
719
|
-
grouping: { columns: 'product-stage-task' },
|
|
720
|
-
},
|
|
721
|
-
[{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1' }] }],
|
|
722
|
-
);
|
|
723
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PROD-1:S1']);
|
|
724
|
-
expect(matrix.columns[0].taskId).toBeUndefined();
|
|
725
|
-
expect(matrix.columns[0].stageId).toBe('S1');
|
|
726
|
-
});
|
|
727
|
-
|
|
728
|
-
it('subject with no objectDetails falls back to product-grain column', () => {
|
|
729
|
-
const canon = emptyCanon();
|
|
730
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
731
|
-
const matrix = buildImpactMatrix(
|
|
732
|
-
canon,
|
|
733
|
-
{
|
|
734
|
-
id: 'V', name: 'V',
|
|
735
|
-
subjects: { products: ['PROD-1'] },
|
|
736
|
-
obligations: {},
|
|
737
|
-
grouping: { columns: 'product-stage-task' },
|
|
738
|
-
},
|
|
739
|
-
);
|
|
740
|
-
expect(matrix.columns.map(c => c.label)).toEqual(['PROD-1']);
|
|
741
|
-
expect(matrix.columns[0].stageId).toBeUndefined();
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
// ── extractProcessFlowTasks ───────────────────────────────────────────────────
|
|
746
|
-
|
|
747
|
-
describe('extractProcessFlowTasks', () => {
|
|
748
|
-
it('returns null for non-process documents', () => {
|
|
749
|
-
expect(extractProcessFlowTasks(null)).toBeNull();
|
|
750
|
-
expect(extractProcessFlowTasks({ notation: 'requirement', id: 'R1' })).toBeNull();
|
|
751
|
-
expect(extractProcessFlowTasks({ notation: 'process_blueprint', id: 'BP-1' })).toBeNull();
|
|
752
|
-
});
|
|
753
|
-
|
|
754
|
-
it('returns null when process has no flow.steps', () => {
|
|
755
|
-
expect(extractProcessFlowTasks({ notation: 'process', id: 'PROC-1' })).toBeNull();
|
|
756
|
-
expect(extractProcessFlowTasks({ notation: 'process', id: 'PROC-1', flow: { sequence: [] } })).toBeNull();
|
|
757
|
-
});
|
|
758
|
-
|
|
759
|
-
it('returns null when no task-type steps exist', () => {
|
|
760
|
-
const doc = {
|
|
761
|
-
notation: 'process', id: 'PROC-1',
|
|
762
|
-
flow: { steps: [
|
|
763
|
-
{ id: 'S-1', type: 'startEvent' },
|
|
764
|
-
{ id: 'G-1', type: 'exclusiveGateway' },
|
|
765
|
-
{ id: 'E-1', type: 'endEvent' },
|
|
766
|
-
] },
|
|
767
|
-
};
|
|
768
|
-
expect(extractProcessFlowTasks(doc)).toBeNull();
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
it('extracts task-type steps and skips events/gateways', () => {
|
|
772
|
-
const doc = {
|
|
773
|
-
notation: 'process', id: 'PROC-1',
|
|
774
|
-
flow: { steps: [
|
|
775
|
-
{ id: 'S-1', type: 'startEvent' },
|
|
776
|
-
{ id: 'STEP-T1', type: 'task', name: 'Task One' },
|
|
777
|
-
{ id: 'G-1', type: 'exclusiveGateway', name: 'Branch?' },
|
|
778
|
-
{ id: 'STEP-T2', type: 'userTask', name: 'User Task' },
|
|
779
|
-
{ id: 'E-1', type: 'endEvent' },
|
|
780
|
-
] },
|
|
781
|
-
};
|
|
782
|
-
const result = extractProcessFlowTasks(doc);
|
|
783
|
-
expect(result).not.toBeNull();
|
|
784
|
-
expect(result!.objectId).toBe('PROC-1');
|
|
785
|
-
expect(result!.details.map(d => d.id)).toEqual(['STEP-T1', 'STEP-T2']);
|
|
786
|
-
expect(result!.details[0].name).toBe('Task One');
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
it('falls back to step id as name when name is absent', () => {
|
|
790
|
-
const doc = {
|
|
791
|
-
notation: 'process', id: 'PROC-1',
|
|
792
|
-
flow: { steps: [{ id: 'STEP-T1', type: 'serviceTask' }] },
|
|
793
|
-
};
|
|
794
|
-
const result = extractProcessFlowTasks(doc);
|
|
795
|
-
expect(result!.details[0].name).toBe('STEP-T1');
|
|
796
|
-
});
|
|
797
|
-
});
|
|
798
|
-
|
|
799
|
-
// ── mergeStageTaskDetails ─────────────────────────────────────────────────────
|
|
800
|
-
|
|
801
|
-
describe('mergeStageTaskDetails', () => {
|
|
802
|
-
const stages = {
|
|
803
|
-
objectId: 'PROC-1',
|
|
804
|
-
details: [
|
|
805
|
-
{ id: 'S1', name: 'Stage 1' },
|
|
806
|
-
{ id: 'S2', name: 'Stage 2' },
|
|
807
|
-
],
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
it('returns stageInput unchanged when taskInput is null', () => {
|
|
811
|
-
expect(mergeStageTaskDetails(stages, null)).toBe(stages);
|
|
812
|
-
});
|
|
813
|
-
|
|
814
|
-
it('returns stageInput unchanged when objectIds do not match', () => {
|
|
815
|
-
const other = { objectId: 'PROC-99', details: [{ id: 'T1', name: 't1' }] };
|
|
816
|
-
expect(mergeStageTaskDetails(stages, other)).toBe(stages);
|
|
817
|
-
});
|
|
818
|
-
|
|
819
|
-
it('embeds all tasks into every stage when no stageOwner map is provided', () => {
|
|
820
|
-
const tasks = { objectId: 'PROC-1', details: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] };
|
|
821
|
-
const merged = mergeStageTaskDetails(stages, tasks);
|
|
822
|
-
expect(merged.objectId).toBe('PROC-1');
|
|
823
|
-
expect(merged.details[0].tasks?.map(t => t.id)).toEqual(['T1', 'T2']);
|
|
824
|
-
expect(merged.details[1].tasks?.map(t => t.id)).toEqual(['T1', 'T2']);
|
|
825
|
-
});
|
|
826
|
-
|
|
827
|
-
it('distributes tasks by stageOwner map', () => {
|
|
828
|
-
const tasks = { objectId: 'PROC-1', details: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] };
|
|
829
|
-
const merged = mergeStageTaskDetails(stages, tasks, { S1: ['T1'], S2: ['T2'] });
|
|
830
|
-
expect(merged.details[0].tasks?.map(t => t.id)).toEqual(['T1']);
|
|
831
|
-
expect(merged.details[1].tasks?.map(t => t.id)).toEqual(['T2']);
|
|
832
|
-
});
|
|
833
|
-
|
|
834
|
-
it('leaves stages without matching stageOwner entries task-free', () => {
|
|
835
|
-
const tasks = { objectId: 'PROC-1', details: [{ id: 'T1', name: 't1' }] };
|
|
836
|
-
const merged = mergeStageTaskDetails(stages, tasks, { S1: ['T1'], S2: [] });
|
|
837
|
-
expect(merged.details[0].tasks?.map(t => t.id)).toEqual(['T1']);
|
|
838
|
-
// S2 has no tasks in stageOwner, filter returns [] → no tasks embedded
|
|
839
|
-
expect(merged.details[1].tasks).toBeUndefined();
|
|
840
|
-
});
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
// ── COMPIMP-010 — subject type label invariant (#345) ────────────────────────
|
|
844
|
-
|
|
845
|
-
describe('COMPIMP-010 — subject type label invariant (#345)', () => {
|
|
846
|
-
it('process-only view: columns carry subjectType=process and plain ID labels (regression)', () => {
|
|
847
|
-
const canon = emptyCanon();
|
|
848
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
849
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
850
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROCESS-CS-1', status: 'compliant' });
|
|
851
|
-
const matrix = buildImpactMatrix(canon, {
|
|
852
|
-
id: 'V', name: 'Process-only',
|
|
853
|
-
subjects: { processes: ['PROCESS-CS-1'] },
|
|
854
|
-
obligations: {},
|
|
855
|
-
});
|
|
856
|
-
expect(matrix.columns).toHaveLength(1);
|
|
857
|
-
expect(matrix.columns[0].subjectType).toBe('process');
|
|
858
|
-
// Process-only: label is just the ID — no [PRODUCT] prefix (regression)
|
|
859
|
-
expect(matrix.columns[0].label).toBe('PROCESS-CS-1');
|
|
860
|
-
expect(matrix.columns[0].label).not.toContain('[PRODUCT]');
|
|
861
|
-
expect(matrix.cells[0][0].status).toBe('compliant');
|
|
862
|
-
});
|
|
863
|
-
|
|
864
|
-
it('product-only view: columns carry subjectType=product and plain ID labels', () => {
|
|
865
|
-
const canon = emptyCanon();
|
|
866
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
867
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
868
|
-
canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PRODUCT-A-1', status: 'compliant' });
|
|
869
|
-
const matrix = buildImpactMatrix(canon, {
|
|
870
|
-
id: 'V', name: 'Product-only',
|
|
871
|
-
subjects: { products: ['PRODUCT-A-1'] },
|
|
872
|
-
obligations: {},
|
|
873
|
-
});
|
|
874
|
-
expect(matrix.columns[0].subjectType).toBe('product');
|
|
875
|
-
expect(matrix.columns[0].label).toBe('PRODUCT-A-1');
|
|
876
|
-
expect(matrix.columns[0].label).not.toContain('[PROCESS]');
|
|
877
|
-
expect(matrix.findings).toHaveLength(0);
|
|
878
|
-
});
|
|
879
|
-
|
|
880
|
-
it('combined view: product columns carry [PRODUCT] badge; process columns carry [PROCESS] badge', () => {
|
|
881
|
-
const canon = emptyCanon();
|
|
882
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
883
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
884
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
885
|
-
const matrix = buildImpactMatrix(canon, {
|
|
886
|
-
id: 'V', name: 'Combined',
|
|
887
|
-
subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
|
|
888
|
-
obligations: {},
|
|
889
|
-
});
|
|
890
|
-
expect(matrix.columns).toHaveLength(2);
|
|
891
|
-
const prodCol = matrix.columns.find(c => c.subjectId === 'PRODUCT-A-1')!;
|
|
892
|
-
const procCol = matrix.columns.find(c => c.subjectId === 'PROCESS-CS-1')!;
|
|
893
|
-
expect(prodCol.subjectType).toBe('product');
|
|
894
|
-
expect(prodCol.label).toBe('[PRODUCT] PRODUCT-A-1');
|
|
895
|
-
expect(procCol.subjectType).toBe('process');
|
|
896
|
-
expect(procCol.label).toBe('[PROCESS] PROCESS-CS-1');
|
|
897
|
-
});
|
|
898
|
-
|
|
899
|
-
it('combined view: markdown renders [PRODUCT] / [PROCESS] column headers', () => {
|
|
900
|
-
const canon = emptyCanon();
|
|
901
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
902
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
903
|
-
canon.requirements.push({ id: 'REQ-1', name: 'R1' });
|
|
904
|
-
const matrix = buildImpactMatrix(canon, {
|
|
905
|
-
id: 'V', name: 'Combined',
|
|
906
|
-
subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
|
|
907
|
-
obligations: {},
|
|
908
|
-
});
|
|
909
|
-
const md = renderImpactMarkdown(matrix);
|
|
910
|
-
expect(md).toContain('[PRODUCT] PRODUCT-A-1');
|
|
911
|
-
expect(md).toContain('[PROCESS] PROCESS-CS-1');
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
it('capability column always has subjectType=capability', () => {
|
|
915
|
-
const canon = emptyCanon();
|
|
916
|
-
canon.subjects.push({ id: 'CAPABILITY-CRM-1', name: 'CRM' });
|
|
917
|
-
const matrix = buildImpactMatrix(canon, {
|
|
918
|
-
id: 'V', name: 'Cap',
|
|
919
|
-
subjects: { capabilities: ['CAPABILITY-CRM-1'] },
|
|
920
|
-
obligations: {},
|
|
921
|
-
});
|
|
922
|
-
expect(matrix.columns[0].subjectType).toBe('capability');
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
it('COMPIMP-009 warning: product-* grouping with process-only subjects', () => {
|
|
926
|
-
const canon = emptyCanon();
|
|
927
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'CS' });
|
|
928
|
-
const matrix = buildImpactMatrix(canon, {
|
|
929
|
-
id: 'V', name: 'V',
|
|
930
|
-
subjects: { processes: ['PROCESS-CS-1'] },
|
|
931
|
-
obligations: {},
|
|
932
|
-
grouping: { columns: 'product' },
|
|
933
|
-
});
|
|
934
|
-
const c009 = matrix.findings.find(f => f.code === 'COMPIMP-009');
|
|
935
|
-
expect(c009).toBeDefined();
|
|
936
|
-
expect(c009!.severity).toBe('warning');
|
|
937
|
-
expect(c009!.message).toContain('process');
|
|
938
|
-
});
|
|
939
|
-
|
|
940
|
-
it('COMPIMP-010 error: product-stage grouping with process subjects', () => {
|
|
941
|
-
const canon = emptyCanon();
|
|
942
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'CS' });
|
|
943
|
-
const matrix = buildImpactMatrix(
|
|
944
|
-
canon,
|
|
945
|
-
{
|
|
946
|
-
id: 'V', name: 'V',
|
|
947
|
-
subjects: { processes: ['PROCESS-CS-1'] },
|
|
948
|
-
obligations: {},
|
|
949
|
-
grouping: { columns: 'product-stage' },
|
|
950
|
-
},
|
|
951
|
-
[{ objectId: 'PROCESS-CS-1', details: [{ id: 'STAGE-A', name: 'Stage A' }] }],
|
|
952
|
-
);
|
|
953
|
-
const c010 = matrix.findings.find(f => f.code === 'COMPIMP-010');
|
|
954
|
-
expect(c010).toBeDefined();
|
|
955
|
-
expect(c010!.severity).toBe('error');
|
|
956
|
-
expect(c010!.message).toContain('process-stage');
|
|
957
|
-
});
|
|
958
|
-
|
|
959
|
-
it('no COMPIMP-010 when process-stage grouping is used for process subjects', () => {
|
|
960
|
-
const canon = emptyCanon();
|
|
961
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'CS' });
|
|
962
|
-
const matrix = buildImpactMatrix(
|
|
963
|
-
canon,
|
|
964
|
-
{
|
|
965
|
-
id: 'V', name: 'V',
|
|
966
|
-
subjects: { processes: ['PROCESS-CS-1'] },
|
|
967
|
-
obligations: {},
|
|
968
|
-
grouping: { columns: 'process-stage' },
|
|
969
|
-
},
|
|
970
|
-
[{ objectId: 'PROCESS-CS-1', details: [{ id: 'STAGE-A', name: 'Stage A' }] }],
|
|
971
|
-
);
|
|
972
|
-
expect(matrix.findings.some(f => f.code === 'COMPIMP-010')).toBe(false);
|
|
973
|
-
});
|
|
974
|
-
|
|
975
|
-
it('parseImpactViewConfig accepts process-centric column values', () => {
|
|
976
|
-
for (const col of ['process', 'process-stage', 'process-stage-task'] as const) {
|
|
977
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: col } });
|
|
978
|
-
expect(r.ok).toBe(true);
|
|
979
|
-
if (r.ok) expect(r.config.grouping?.columns).toBe(col);
|
|
980
|
-
}
|
|
981
|
-
});
|
|
982
|
-
|
|
983
|
-
it('matrix.findings is empty for a conformant product-only view', () => {
|
|
984
|
-
const canon = emptyCanon();
|
|
985
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
986
|
-
const matrix = buildImpactMatrix(canon, {
|
|
987
|
-
id: 'V', name: 'V',
|
|
988
|
-
subjects: { products: ['PRODUCT-A-1'] },
|
|
989
|
-
obligations: {},
|
|
990
|
-
});
|
|
991
|
-
expect(matrix.findings).toEqual([]);
|
|
992
|
-
});
|
|
993
|
-
|
|
994
|
-
it('COMPIMP-011 error: report_type=product with subjects.processes strips process columns', () => {
|
|
995
|
-
const canon = emptyCanon();
|
|
996
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
997
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
998
|
-
const matrix = buildImpactMatrix(canon, {
|
|
999
|
-
id: 'V', name: 'V',
|
|
1000
|
-
report_type: 'product',
|
|
1001
|
-
subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
|
|
1002
|
-
obligations: {},
|
|
1003
|
-
});
|
|
1004
|
-
// COMPIMP-011 fires
|
|
1005
|
-
const c011 = matrix.findings.find(f => f.code === 'COMPIMP-011');
|
|
1006
|
-
expect(c011).toBeDefined();
|
|
1007
|
-
expect(c011!.severity).toBe('error');
|
|
1008
|
-
// Spurious PROCESS column is stripped
|
|
1009
|
-
expect(matrix.columns).toHaveLength(1);
|
|
1010
|
-
expect(matrix.columns[0].subjectType).toBe('product');
|
|
1011
|
-
expect(matrix.columns[0].subjectId).toBe('PRODUCT-A-1');
|
|
1012
|
-
});
|
|
1013
|
-
|
|
1014
|
-
it('COMPIMP-011 error: report_type=process with subjects.products strips product columns', () => {
|
|
1015
|
-
const canon = emptyCanon();
|
|
1016
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
1017
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
1018
|
-
const matrix = buildImpactMatrix(canon, {
|
|
1019
|
-
id: 'V', name: 'V',
|
|
1020
|
-
report_type: 'process',
|
|
1021
|
-
subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
|
|
1022
|
-
obligations: {},
|
|
1023
|
-
});
|
|
1024
|
-
const c011 = matrix.findings.find(f => f.code === 'COMPIMP-011');
|
|
1025
|
-
expect(c011).toBeDefined();
|
|
1026
|
-
expect(c011!.severity).toBe('error');
|
|
1027
|
-
// Spurious PRODUCT column is stripped
|
|
1028
|
-
expect(matrix.columns).toHaveLength(1);
|
|
1029
|
-
expect(matrix.columns[0].subjectType).toBe('process');
|
|
1030
|
-
expect(matrix.columns[0].subjectId).toBe('PROCESS-CS-1');
|
|
1031
|
-
});
|
|
1032
|
-
|
|
1033
|
-
it('report_type=combined allows both product and process columns without COMPIMP-011', () => {
|
|
1034
|
-
const canon = emptyCanon();
|
|
1035
|
-
canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
|
|
1036
|
-
canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
|
|
1037
|
-
const matrix = buildImpactMatrix(canon, {
|
|
1038
|
-
id: 'V', name: 'V',
|
|
1039
|
-
report_type: 'combined',
|
|
1040
|
-
subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
|
|
1041
|
-
obligations: {},
|
|
1042
|
-
});
|
|
1043
|
-
expect(matrix.findings.some(f => f.code === 'COMPIMP-011')).toBe(false);
|
|
1044
|
-
expect(matrix.columns).toHaveLength(2);
|
|
1045
|
-
});
|
|
1046
|
-
|
|
1047
|
-
it('parseImpactViewConfig round-trips report_type', () => {
|
|
1048
|
-
for (const rt of ['product', 'process', 'combined'] as const) {
|
|
1049
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', report_type: rt, subjects: {}, obligations: {} });
|
|
1050
|
-
expect(r.ok).toBe(true);
|
|
1051
|
-
if (r.ok) expect(r.config.report_type).toBe(rt);
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
|
|
1055
|
-
it('parseImpactViewConfig ignores unknown report_type values', () => {
|
|
1056
|
-
const r = parseImpactViewConfig({ id: 'V', name: 'V', report_type: 'unknown-type', subjects: {}, obligations: {} });
|
|
1057
|
-
expect(r.ok).toBe(true);
|
|
1058
|
-
if (r.ok) expect(r.config.report_type).toBeUndefined();
|
|
1059
|
-
});
|
|
1060
|
-
});
|