@transitrix/diagrams 1.0.0 → 1.1.0
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/LICENSE +21 -21
- package/README.md +47 -47
- package/dist/__tests__/edge-path.test.js +8 -0
- package/dist/activities/cpm.js +11 -2
- package/dist/activities/gantt.js +6 -3
- package/dist/activities/types.d.ts +1 -0
- package/dist/activities/validate.js +3 -3
- package/dist/activity-card/__tests__/example.test.js +20 -1
- package/dist/activity-card/__tests__/layout.test.js +102 -11
- package/dist/activity-card/__tests__/resolver.test.js +161 -7
- package/dist/activity-card/index.d.ts +1 -1
- package/dist/activity-card/layout.d.ts +1 -1
- package/dist/activity-card/layout.js +220 -103
- package/dist/activity-card/resolver.js +115 -28
- package/dist/activity-card/types.d.ts +150 -27
- package/dist/activity-card/validate.js +3 -0
- package/dist/actor/__tests__/validate.test.js +63 -31
- package/dist/actor/index.d.ts +1 -1
- package/dist/actor/index.js +1 -1
- package/dist/actor/types.d.ts +7 -3
- package/dist/actor/types.js +17 -3
- package/dist/actor/validate.js +55 -26
- package/dist/assertion/types.d.ts +3 -1
- package/dist/assertion/types.js +1 -1
- package/dist/change/__tests__/validate.test.js +40 -34
- package/dist/change/index.d.ts +1 -0
- package/dist/change/types.d.ts +1 -1
- package/dist/change/types.js +2 -2
- package/dist/change/validate.d.ts +6 -1
- package/dist/change/validate.js +68 -41
- package/dist/compliance/__tests__/classify.test.js +34 -0
- package/dist/compliance/__tests__/coverage-metric.test.js +146 -46
- package/dist/compliance/__tests__/html.test.js +2 -2
- package/dist/compliance/__tests__/impact.test.js +509 -6
- package/dist/compliance/classify.d.ts +6 -0
- package/dist/compliance/classify.js +9 -1
- package/dist/compliance/coverage-metric.d.ts +31 -11
- package/dist/compliance/coverage-metric.js +149 -39
- package/dist/compliance/html.js +78 -81
- package/dist/compliance/impact.d.ts +100 -16
- package/dist/compliance/impact.js +272 -28
- package/dist/compliance/index.d.ts +2 -2
- package/dist/compliance/index.js +1 -1
- package/dist/compliance/markdown.js +1 -0
- package/dist/compliance/types.d.ts +25 -6
- package/dist/edge-path.d.ts +8 -4
- package/dist/edge-path.js +11 -6
- package/dist/factor/__tests__/validate.test.js +75 -46
- package/dist/factor/index.d.ts +3 -2
- package/dist/factor/index.js +1 -1
- package/dist/factor/types.d.ts +5 -8
- package/dist/factor/types.js +10 -5
- package/dist/factor/validate.d.ts +6 -1
- package/dist/factor/validate.js +68 -50
- package/dist/fgca/__tests__/chain-table.test.js +2 -2
- package/dist/fgca/__tests__/layout.test.js +11 -11
- package/dist/fgca/__tests__/preview-layout.test.js +7 -7
- package/dist/fgca/__tests__/resolver.test.js +185 -0
- package/dist/fgca/chain-table.d.ts +1 -1
- package/dist/fgca/chain-table.js +4 -4
- package/dist/fgca/index.d.ts +4 -2
- package/dist/fgca/index.js +2 -1
- package/dist/fgca/layout.d.ts +2 -2
- package/dist/fgca/layout.js +9 -9
- package/dist/fgca/nodeTypes.d.ts +1 -1
- package/dist/fgca/nodeTypes.js +2 -2
- package/dist/fgca/nodes/FGCAFactorNode.d.ts +3 -3
- package/dist/fgca/nodes/FGCAFactorNode.js +5 -5
- package/dist/fgca/parse-canonical.js +15 -10
- package/dist/fgca/preview-layout.d.ts +1 -1
- package/dist/fgca/preview-layout.js +4 -4
- package/dist/fgca/resolver.d.ts +49 -0
- package/dist/fgca/resolver.js +126 -0
- package/dist/fgca/types.d.ts +11 -11
- package/dist/fgca/types.js +2 -2
- package/dist/fgca/validate.d.ts +2 -2
- package/dist/fgca/validate.js +17 -14
- package/dist/goals/index.d.ts +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/process-blueprint/__tests__/layout.test.js +37 -0
- package/dist/process-blueprint/index.d.ts +1 -1
- package/dist/process-blueprint/layout.js +66 -35
- package/dist/process-blueprint/types.d.ts +36 -1
- package/dist/scenarios/index.d.ts +1 -1
- package/dist/scenarios/types.d.ts +4 -4
- package/dist/stakeholder/__tests__/validate.test.js +49 -47
- package/dist/stakeholder/index.d.ts +1 -0
- package/dist/stakeholder/types.d.ts +3 -4
- package/dist/stakeholder/types.js +2 -3
- package/dist/stakeholder/validate.d.ts +6 -1
- package/dist/stakeholder/validate.js +71 -50
- package/dist/target-state/__tests__/validate.test.js +43 -27
- package/dist/target-state/index.d.ts +2 -0
- package/dist/target-state/index.js +1 -0
- package/dist/target-state/types.d.ts +6 -1
- package/dist/target-state/types.js +8 -7
- package/dist/target-state/validate.d.ts +6 -1
- package/dist/target-state/validate.js +69 -45
- package/dist/theme/themes.js +71 -69
- package/dist/theme/tokens.d.ts +7 -1
- package/dist/theme/tokens.js +3 -1
- package/dist/webview/__tests__/entry-notations.test.js +2 -0
- package/dist/webview/__tests__/entry.test.js +11 -11
- package/dist/webview/__tests__/render-process.test.js +463 -0
- package/dist/webview/__tests__/render-util.test.d.ts +1 -0
- package/dist/webview/__tests__/render-util.test.js +54 -0
- package/dist/webview/entry.d.ts +1 -1
- package/dist/webview/entry.js +9 -5
- package/dist/webview/render-activities.d.ts +24 -2
- package/dist/webview/render-activities.js +92 -57
- package/dist/webview/render-activity-card.d.ts +11 -1
- package/dist/webview/render-activity-card.js +115 -79
- package/dist/webview/render-blocks.d.ts +24 -1
- package/dist/webview/render-blocks.js +58 -24
- package/dist/webview/render-fgca.d.ts +31 -0
- package/dist/webview/render-fgca.js +30 -19
- package/dist/webview/render-goals.d.ts +27 -1
- package/dist/webview/render-goals.js +42 -32
- package/dist/webview/render-process-blueprint.d.ts +11 -1
- package/dist/webview/render-process-blueprint.js +118 -53
- package/dist/webview/render-process.d.ts +95 -0
- package/dist/webview/render-process.js +392 -0
- package/dist/webview/render-scenarios.js +2 -2
- package/dist/webview/render-util.d.ts +19 -6
- package/dist/webview/render-util.js +23 -15
- package/package.json +54 -40
- package/src/__tests__/edge-path.test.ts +58 -46
- package/src/__tests__/scope.test.ts +27 -27
- package/src/__tests__/yaml-normalize.test.ts +158 -158
- package/src/activities/__tests__/cpm.test.ts +164 -164
- package/src/activities/__tests__/gantt.test.ts +245 -245
- package/src/activities/__tests__/layout.test.ts +112 -112
- package/src/activities/__tests__/validate.test.ts +409 -409
- package/src/activities/cpm.ts +107 -95
- package/src/activities/gantt.ts +277 -276
- package/src/activities/index.ts +28 -28
- package/src/activities/layout.ts +112 -112
- package/src/activities/types.ts +149 -148
- package/src/activities/validate.ts +357 -357
- package/src/activity-card/__tests__/example.test.ts +85 -66
- package/src/activity-card/__tests__/layout.test.ts +169 -63
- package/src/activity-card/__tests__/resolver.test.ts +330 -161
- package/src/activity-card/__tests__/validate.test.ts +131 -131
- package/src/activity-card/index.ts +38 -32
- package/src/activity-card/layout.ts +324 -194
- package/src/activity-card/resolver.ts +422 -337
- package/src/activity-card/types.ts +376 -237
- package/src/activity-card/validate.ts +162 -158
- package/src/actor/__tests__/validate.test.ts +70 -31
- package/src/actor/index.ts +1 -1
- package/src/actor/types.ts +21 -7
- package/src/actor/validate.ts +59 -27
- package/src/applications/__tests__/validate.test.ts +256 -256
- package/src/applications/index.ts +11 -11
- package/src/applications/types.ts +43 -43
- package/src/applications/validate.ts +131 -131
- package/src/assertion/__tests__/example.test.ts +37 -37
- package/src/assertion/__tests__/validate.test.ts +142 -142
- package/src/assertion/index.ts +12 -12
- package/src/assertion/types.ts +60 -58
- package/src/assertion/validate.ts +145 -145
- package/src/blocks/__tests__/layout.test.ts +169 -169
- package/src/blocks/__tests__/validate.test.ts +260 -260
- package/src/blocks/index.ts +17 -17
- package/src/blocks/layout.ts +186 -186
- package/src/blocks/types.ts +62 -62
- package/src/blocks/validate.ts +206 -206
- package/src/capability-map/__tests__/validate.test.ts +238 -238
- package/src/capability-map/index.ts +8 -8
- package/src/capability-map/types.ts +29 -29
- package/src/capability-map/validate.ts +127 -127
- package/src/change/__tests__/validate.test.ts +43 -34
- package/src/change/index.ts +1 -0
- package/src/change/types.ts +5 -3
- package/src/change/validate.ts +75 -43
- package/src/compliance/__tests__/classify.test.ts +64 -27
- package/src/compliance/__tests__/confidence.test.ts +98 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +300 -188
- package/src/compliance/__tests__/demo-scenario.test.ts +273 -273
- package/src/compliance/__tests__/example.test.ts +57 -57
- package/src/compliance/__tests__/gap-report.test.ts +128 -128
- package/src/compliance/__tests__/html.test.ts +141 -141
- package/src/compliance/__tests__/impact.test.ts +1059 -481
- package/src/compliance/__tests__/markdown.test.ts +94 -94
- package/src/compliance/__tests__/views.test.ts +64 -64
- package/src/compliance/classify.ts +100 -84
- package/src/compliance/confidence.ts +69 -69
- package/src/compliance/coverage-metric.ts +404 -263
- package/src/compliance/gap-report.ts +94 -94
- package/src/compliance/html.ts +291 -295
- package/src/compliance/impact.ts +979 -677
- package/src/compliance/index.ts +57 -56
- package/src/compliance/markdown.ts +136 -135
- package/src/compliance/reverse-index.ts +33 -33
- package/src/compliance/types.ts +136 -120
- package/src/compliance/views.ts +46 -46
- package/src/compliance-matrix/__tests__/build.test.ts +200 -200
- package/src/compliance-matrix/__tests__/example.test.ts +57 -57
- package/src/compliance-matrix/index.ts +11 -11
- package/src/compliance-matrix/types.ts +102 -102
- package/src/edge-path.ts +50 -44
- package/src/factor/__tests__/validate.test.ts +81 -46
- package/src/factor/index.ts +3 -7
- package/src/factor/types.ts +15 -19
- package/src/factor/validate.ts +77 -51
- package/src/fgca/__tests__/chain-table.test.ts +172 -172
- package/src/fgca/__tests__/layout.test.ts +179 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +248 -248
- package/src/fgca/__tests__/preview-layout.test.ts +124 -124
- package/src/fgca/__tests__/resolver.test.ts +209 -0
- package/src/fgca/__tests__/validate.test.ts +142 -142
- package/src/fgca/chain-table.ts +225 -225
- package/src/fgca/index.ts +47 -45
- package/src/fgca/layout.ts +204 -204
- package/src/fgca/nodeTypes.ts +11 -11
- package/src/fgca/nodes/FGCAActivityNode.tsx +65 -65
- package/src/fgca/nodes/FGCAChangeNode.tsx +64 -64
- package/src/fgca/nodes/FGCAFactorNode.tsx +64 -64
- package/src/fgca/nodes/FGCAGoalNode.tsx +72 -72
- package/src/fgca/parse-canonical.ts +405 -400
- package/src/fgca/preview-layout.ts +217 -217
- package/src/fgca/resolver.ts +159 -0
- package/src/fgca/types.ts +50 -50
- package/src/fgca/validate.ts +129 -126
- package/src/geometry.ts +9 -9
- package/src/goals/__tests__/layout.test.ts +175 -175
- package/src/goals/__tests__/mutations.test.ts +111 -111
- package/src/goals/__tests__/parse-canonical.test.ts +145 -145
- package/src/goals/__tests__/validate.test.ts +202 -202
- package/src/goals/index.ts +20 -21
- package/src/goals/layout.ts +172 -172
- package/src/goals/mutations.ts +123 -123
- package/src/goals/parse-canonical.ts +286 -286
- package/src/goals/types.ts +85 -85
- package/src/goals/validate.ts +136 -136
- package/src/index.ts +28 -23
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +320 -320
- package/src/process-blueprint/__tests__/layout.test.ts +240 -195
- package/src/process-blueprint/__tests__/validate.test.ts +310 -310
- package/src/process-blueprint/index.ts +32 -31
- package/src/process-blueprint/layout.ts +564 -531
- package/src/process-blueprint/types.ts +278 -242
- package/src/process-blueprint/validate.ts +181 -181
- package/src/process-map/__tests__/validate.test.ts +223 -223
- package/src/process-map/index.ts +10 -10
- package/src/process-map/types.ts +36 -36
- package/src/process-map/validate.ts +135 -135
- package/src/products/__tests__/validate.test.ts +239 -239
- package/src/products/index.ts +9 -9
- package/src/products/types.ts +31 -31
- package/src/products/validate.ts +112 -112
- package/src/repo-validate/__tests__/validate-repo.test.ts +149 -149
- package/src/repo-validate/index.ts +2 -2
- package/src/repo-validate/types.ts +50 -50
- package/src/repo-validate/validate-repo.ts +196 -196
- package/src/requirement/__tests__/example.test.ts +24 -24
- package/src/requirement/__tests__/validate.test.ts +96 -96
- package/src/requirement/index.ts +4 -4
- package/src/requirement/types.ts +35 -35
- package/src/requirement/validate.ts +92 -92
- package/src/scenarios/__tests__/validate.test.ts +209 -209
- package/src/scenarios/index.ts +15 -15
- package/src/scenarios/types.ts +37 -37
- package/src/scenarios/validate.ts +122 -122
- package/src/schema-version.ts +16 -16
- package/src/scope.ts +46 -46
- package/src/stakeholder/__tests__/validate.test.ts +51 -47
- package/src/stakeholder/index.ts +1 -0
- package/src/stakeholder/types.ts +7 -7
- package/src/stakeholder/validate.ts +79 -52
- package/src/target-state/__tests__/validate.test.ts +48 -27
- package/src/target-state/index.ts +2 -0
- package/src/target-state/types.ts +11 -7
- package/src/target-state/validate.ts +76 -46
- package/src/theme/index.ts +4 -4
- package/src/theme/themes.ts +239 -237
- package/src/theme/tokens.ts +135 -133
- package/src/typed-id.ts +56 -56
- package/src/validation-types.ts +36 -36
- package/src/webview/__tests__/entry-notations.test.ts +79 -77
- package/src/webview/__tests__/entry.test.ts +64 -64
- package/src/webview/__tests__/render-goals.test.ts +72 -72
- package/src/webview/__tests__/render-process.test.ts +538 -0
- package/src/webview/__tests__/render-util.test.ts +66 -0
- package/src/webview/entry.ts +298 -292
- package/src/webview/render-activities.ts +111 -69
- package/src/webview/render-activity-card.ts +275 -234
- package/src/webview/render-blocks.ts +78 -28
- package/src/webview/render-fgca.ts +53 -28
- package/src/webview/render-goals.ts +133 -110
- package/src/webview/render-process-blueprint.ts +281 -207
- package/src/webview/render-process.ts +507 -0
- package/src/webview/render-scenarios.ts +3 -3
- package/src/webview/render-util.ts +27 -14
- package/src/webview/styles.css +322 -323
- package/src/yaml-normalize.ts +56 -56
- package/dist/element-envelope.d.ts +0 -15
- package/dist/element-envelope.js +0 -55
- package/dist/issues/__tests__/layout.test.js +0 -62
- package/dist/issues/__tests__/validate.test.js +0 -82
- package/dist/issues/index.d.ts +0 -4
- package/dist/issues/index.js +0 -2
- package/dist/issues/layout.d.ts +0 -10
- package/dist/issues/layout.js +0 -82
- package/dist/issues/types.d.ts +0 -61
- package/dist/issues/types.js +0 -6
- package/dist/issues/validate.d.ts +0 -3
- package/dist/issues/validate.js +0 -143
- package/dist/webview/transitrix-render.css +0 -323
- package/dist/webview/transitrix-render.js +0 -6452
- package/dist/webview/transitrix-render.js.map +0 -7
- package/src/element-envelope.ts +0 -76
- /package/dist/{issues/__tests__/layout.test.d.ts → fgca/__tests__/resolver.test.d.ts} +0 -0
- /package/dist/{issues/__tests__/validate.test.d.ts → webview/__tests__/render-process.test.d.ts} +0 -0
|
@@ -1,482 +1,1060 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
canon
|
|
21
|
-
canon.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{ id: 'REQUIREMENT-
|
|
25
|
-
|
|
26
|
-
{ id: 'REQUIREMENT-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{ id: 'ASSERTION-
|
|
34
|
-
// (PRODUCT-
|
|
35
|
-
{ id: 'ASSERTION-
|
|
36
|
-
// (PRODUCT-B-1,
|
|
37
|
-
{ id: 'ASSERTION-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
expect(cellFor('REQUIREMENT-
|
|
69
|
-
expect(cellFor('REQUIREMENT-
|
|
70
|
-
expect(cellFor('REQUIREMENT-
|
|
71
|
-
expect(cellFor('REQUIREMENT-
|
|
72
|
-
expect(cellFor('REQUIREMENT-BAZ-1', 'PRODUCT-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
expect(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
expect(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
expect(md).toContain('
|
|
154
|
-
expect(md).toContain('
|
|
155
|
-
expect(md).toContain('
|
|
156
|
-
expect(md).toContain('
|
|
157
|
-
expect(md).toContain('
|
|
158
|
-
expect(md).toContain('
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
expect(md).
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
expect(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
expect(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
id: '
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
expect(matrix.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
{
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
);
|
|
328
|
-
expect(
|
|
329
|
-
expect(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
canon
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const matrix = buildImpactMatrix(
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
expect(
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
+
});
|
|
482
1060
|
});
|