@transitrix/diagrams 1.8.4 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edge-path.js +10 -1
- package/dist/webview/render-activities.d.ts +1 -1
- package/dist/webview/render-activities.js +2 -2
- package/dist/webview/render-fgca.js +1 -4
- package/package.json +7 -2
- package/src/edge-path.ts +15 -1
- package/src/webview/render-activities.ts +2 -2
- package/src/webview/render-fgca.ts +1 -4
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -47
- package/dist/__tests__/node-size-presets.test.d.ts +0 -1
- package/dist/__tests__/node-size-presets.test.js +0 -30
- package/dist/__tests__/scope.test.d.ts +0 -1
- package/dist/__tests__/scope.test.js +0 -23
- package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
- package/dist/__tests__/yaml-normalize.test.js +0 -148
- package/dist/activities/__tests__/cpm.test.d.ts +0 -1
- package/dist/activities/__tests__/cpm.test.js +0 -146
- package/dist/activities/__tests__/gantt.test.d.ts +0 -1
- package/dist/activities/__tests__/gantt.test.js +0 -263
- package/dist/activities/__tests__/layout.test.d.ts +0 -1
- package/dist/activities/__tests__/layout.test.js +0 -98
- package/dist/activities/__tests__/validate.test.d.ts +0 -1
- package/dist/activities/__tests__/validate.test.js +0 -397
- package/dist/activity-card/__tests__/example.test.d.ts +0 -1
- package/dist/activity-card/__tests__/example.test.js +0 -73
- package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
- package/dist/activity-card/__tests__/layout.test.js +0 -141
- package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
- package/dist/activity-card/__tests__/resolver.test.js +0 -325
- package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
- package/dist/activity-card/__tests__/validate.test.js +0 -149
- package/dist/actor/__tests__/validate.test.d.ts +0 -1
- package/dist/actor/__tests__/validate.test.js +0 -95
- package/dist/applications/__tests__/validate.test.d.ts +0 -1
- package/dist/applications/__tests__/validate.test.js +0 -223
- package/dist/assertion/__tests__/example.test.d.ts +0 -1
- package/dist/assertion/__tests__/example.test.js +0 -32
- package/dist/assertion/__tests__/validate.test.d.ts +0 -1
- package/dist/assertion/__tests__/validate.test.js +0 -130
- package/dist/blocks/__tests__/layout.test.d.ts +0 -1
- package/dist/blocks/__tests__/layout.test.js +0 -153
- package/dist/blocks/__tests__/validate.test.d.ts +0 -1
- package/dist/blocks/__tests__/validate.test.js +0 -235
- package/dist/business-service/__tests__/validate.test.d.ts +0 -1
- package/dist/business-service/__tests__/validate.test.js +0 -135
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
- package/dist/capability-map/__tests__/address.test.d.ts +0 -1
- package/dist/capability-map/__tests__/address.test.js +0 -49
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
- package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/validate.test.js +0 -212
- package/dist/change/__tests__/validate.test.d.ts +0 -1
- package/dist/change/__tests__/validate.test.js +0 -79
- package/dist/codex/__tests__/example.test.d.ts +0 -1
- package/dist/codex/__tests__/example.test.js +0 -33
- package/dist/codex/__tests__/validate.test.d.ts +0 -1
- package/dist/codex/__tests__/validate.test.js +0 -68
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
- package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
- package/dist/compliance/__tests__/classify.test.d.ts +0 -1
- package/dist/compliance/__tests__/classify.test.js +0 -58
- package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
- package/dist/compliance/__tests__/confidence.test.js +0 -78
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
- package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
- package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
- package/dist/compliance/__tests__/example.test.d.ts +0 -1
- package/dist/compliance/__tests__/example.test.js +0 -51
- package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
- package/dist/compliance/__tests__/gap-report.test.js +0 -113
- package/dist/compliance/__tests__/html.test.d.ts +0 -1
- package/dist/compliance/__tests__/html.test.js +0 -122
- package/dist/compliance/__tests__/impact.test.d.ts +0 -1
- package/dist/compliance/__tests__/impact.test.js +0 -913
- package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
- package/dist/compliance/__tests__/markdown.test.js +0 -85
- package/dist/compliance/__tests__/trace.test.d.ts +0 -1
- package/dist/compliance/__tests__/trace.test.js +0 -144
- package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
- package/dist/compliance/__tests__/view-resolution.test.js +0 -59
- package/dist/compliance/__tests__/views.test.d.ts +0 -1
- package/dist/compliance/__tests__/views.test.js +0 -59
- package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/build.test.js +0 -183
- package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/example.test.js +0 -49
- package/dist/confidence/__tests__/score.test.d.ts +0 -1
- package/dist/confidence/__tests__/score.test.js +0 -188
- package/dist/constraint/__tests__/example.test.d.ts +0 -1
- package/dist/constraint/__tests__/example.test.js +0 -14
- package/dist/constraint/__tests__/validate.test.d.ts +0 -1
- package/dist/constraint/__tests__/validate.test.js +0 -58
- package/dist/factor/__tests__/validate.test.d.ts +0 -1
- package/dist/factor/__tests__/validate.test.js +0 -112
- package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
- package/dist/fgca/__tests__/chain-table.test.js +0 -158
- package/dist/fgca/__tests__/layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/layout.test.js +0 -140
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
- package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/preview-layout.test.js +0 -106
- package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
- package/dist/fgca/__tests__/resolver.test.js +0 -185
- package/dist/fgca/__tests__/validate.test.d.ts +0 -1
- package/dist/fgca/__tests__/validate.test.js +0 -125
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
- package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
- package/dist/goals/__tests__/layout.test.d.ts +0 -1
- package/dist/goals/__tests__/layout.test.js +0 -153
- package/dist/goals/__tests__/mutations.test.d.ts +0 -1
- package/dist/goals/__tests__/mutations.test.js +0 -134
- package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/goals/__tests__/parse-canonical.test.js +0 -131
- package/dist/goals/__tests__/validate.test.d.ts +0 -1
- package/dist/goals/__tests__/validate.test.js +0 -183
- package/dist/integration/__tests__/validate.test.d.ts +0 -1
- package/dist/integration/__tests__/validate.test.js +0 -169
- package/dist/location/__tests__/validate.test.d.ts +0 -1
- package/dist/location/__tests__/validate.test.js +0 -107
- package/dist/node/__tests__/validate.test.d.ts +0 -1
- package/dist/node/__tests__/validate.test.js +0 -100
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
- package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/layout.test.js +0 -196
- package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/validate.test.js +0 -280
- package/dist/process-map/__tests__/validate.test.d.ts +0 -1
- package/dist/process-map/__tests__/validate.test.js +0 -199
- package/dist/products/__tests__/validate.test.d.ts +0 -1
- package/dist/products/__tests__/validate.test.js +0 -210
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
- package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
- package/dist/requirement/__tests__/example.test.d.ts +0 -1
- package/dist/requirement/__tests__/example.test.js +0 -21
- package/dist/requirement/__tests__/validate.test.d.ts +0 -1
- package/dist/requirement/__tests__/validate.test.js +0 -80
- package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
- package/dist/scenarios/__tests__/validate.test.js +0 -183
- package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
- package/dist/stakeholder/__tests__/validate.test.js +0 -88
- package/dist/target-state/__tests__/validate.test.d.ts +0 -1
- package/dist/target-state/__tests__/validate.test.js +0 -78
- package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
- package/dist/technology-service/__tests__/validate.test.js +0 -121
- package/dist/theme/__tests__/tokens.test.d.ts +0 -1
- package/dist/theme/__tests__/tokens.test.js +0 -159
- package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
- package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
- package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
- package/dist/webview/__tests__/entry-notations.test.js +0 -62
- package/dist/webview/__tests__/entry.test.d.ts +0 -1
- package/dist/webview/__tests__/entry.test.js +0 -56
- package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
- package/dist/webview/__tests__/render-activities.test.js +0 -91
- package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
- package/dist/webview/__tests__/render-blocks.test.js +0 -175
- package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
- package/dist/webview/__tests__/render-goals.test.js +0 -120
- package/dist/webview/__tests__/render-process.test.d.ts +0 -1
- package/dist/webview/__tests__/render-process.test.js +0 -463
- package/dist/webview/__tests__/render-util.test.d.ts +0 -1
- package/dist/webview/__tests__/render-util.test.js +0 -54
- package/src/__tests__/edge-path.test.ts +0 -58
- package/src/__tests__/node-size-presets.test.ts +0 -50
- package/src/__tests__/scope.test.ts +0 -27
- package/src/__tests__/yaml-normalize.test.ts +0 -158
- package/src/activities/__tests__/cpm.test.ts +0 -164
- package/src/activities/__tests__/gantt.test.ts +0 -290
- package/src/activities/__tests__/layout.test.ts +0 -112
- package/src/activities/__tests__/validate.test.ts +0 -446
- package/src/activity-card/__tests__/example.test.ts +0 -83
- package/src/activity-card/__tests__/layout.test.ts +0 -162
- package/src/activity-card/__tests__/resolver.test.ts +0 -357
- package/src/activity-card/__tests__/validate.test.ts +0 -167
- package/src/actor/__tests__/validate.test.ts +0 -114
- package/src/applications/__tests__/validate.test.ts +0 -256
- package/src/assertion/__tests__/example.test.ts +0 -37
- package/src/assertion/__tests__/validate.test.ts +0 -142
- package/src/blocks/__tests__/layout.test.ts +0 -169
- package/src/blocks/__tests__/validate.test.ts +0 -260
- package/src/business-service/__tests__/validate.test.ts +0 -160
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
- package/src/capability-map/__tests__/address.test.ts +0 -59
- package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
- package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
- package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
- package/src/capability-map/__tests__/validate.test.ts +0 -238
- package/src/change/__tests__/validate.test.ts +0 -97
- package/src/codex/__tests__/example.test.ts +0 -40
- package/src/codex/__tests__/validate.test.ts +0 -84
- package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
- package/src/compliance/__tests__/classify.test.ts +0 -64
- package/src/compliance/__tests__/confidence.test.ts +0 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
- package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
- package/src/compliance/__tests__/example.test.ts +0 -57
- package/src/compliance/__tests__/gap-report.test.ts +0 -129
- package/src/compliance/__tests__/html.test.ts +0 -142
- package/src/compliance/__tests__/impact.test.ts +0 -1060
- package/src/compliance/__tests__/markdown.test.ts +0 -95
- package/src/compliance/__tests__/trace.test.ts +0 -157
- package/src/compliance/__tests__/view-resolution.test.ts +0 -80
- package/src/compliance/__tests__/views.test.ts +0 -64
- package/src/compliance-matrix/__tests__/build.test.ts +0 -200
- package/src/compliance-matrix/__tests__/example.test.ts +0 -57
- package/src/confidence/__tests__/score.test.ts +0 -254
- package/src/constraint/__tests__/example.test.ts +0 -19
- package/src/constraint/__tests__/validate.test.ts +0 -68
- package/src/factor/__tests__/validate.test.ts +0 -133
- package/src/fgca/__tests__/chain-table.test.ts +0 -172
- package/src/fgca/__tests__/layout.test.ts +0 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
- package/src/fgca/__tests__/preview-layout.test.ts +0 -124
- package/src/fgca/__tests__/resolver.test.ts +0 -209
- package/src/fgca/__tests__/validate.test.ts +0 -142
- package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
- package/src/goals/__tests__/layout.test.ts +0 -175
- package/src/goals/__tests__/mutations.test.ts +0 -153
- package/src/goals/__tests__/parse-canonical.test.ts +0 -147
- package/src/goals/__tests__/validate.test.ts +0 -202
- package/src/integration/__tests__/validate.test.ts +0 -203
- package/src/location/__tests__/validate.test.ts +0 -127
- package/src/node/__tests__/validate.test.ts +0 -118
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
- package/src/process-blueprint/__tests__/layout.test.ts +0 -240
- package/src/process-blueprint/__tests__/validate.test.ts +0 -310
- package/src/process-map/__tests__/validate.test.ts +0 -223
- package/src/products/__tests__/validate.test.ts +0 -239
- package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
- package/src/requirement/__tests__/example.test.ts +0 -24
- package/src/requirement/__tests__/validate.test.ts +0 -96
- package/src/scenarios/__tests__/validate.test.ts +0 -209
- package/src/stakeholder/__tests__/validate.test.ts +0 -105
- package/src/target-state/__tests__/validate.test.ts +0 -95
- package/src/technology-service/__tests__/validate.test.ts +0 -143
- package/src/theme/__tests__/tokens.test.ts +0 -185
- package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
- package/src/webview/__tests__/entry-notations.test.ts +0 -77
- package/src/webview/__tests__/entry.test.ts +0 -64
- package/src/webview/__tests__/render-activities.test.ts +0 -100
- package/src/webview/__tests__/render-blocks.test.ts +0 -206
- package/src/webview/__tests__/render-goals.test.ts +0 -128
- package/src/webview/__tests__/render-process.test.ts +0 -538
- package/src/webview/__tests__/render-util.test.ts +0 -66
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for the host-neutral nested-blocks SVG renderer used by both the
|
|
3
|
-
* VS Code blocks preview and the IntelliJ JCEF webview bundle. These tests pin
|
|
4
|
-
* the per-node label rule (CLAUDE.md "Entity block layout"): leaf nodes wrap
|
|
5
|
-
* the name to at most 3 lines and the ID to at most 2 lines, with `…`
|
|
6
|
-
* truncation beyond that; container headers stack name + ID, each truncated
|
|
7
|
-
* with `…` to fit the block width. No label may extend past the rect.
|
|
8
|
-
*/
|
|
9
|
-
import { describe, expect, it } from 'vitest';
|
|
10
|
-
|
|
11
|
-
import type { BlocksFile } from '../../blocks/types.js';
|
|
12
|
-
import { renderBlocksSvg } from '../render-blocks.js';
|
|
13
|
-
import { CHAR_W_PRIMARY as CHAR_W, CHAR_W_ID, TEXT_MARGIN_X } from '../entity-text-layout.js';
|
|
14
|
-
import { ENTITY_NODE_SIZE } from '../../node-size-presets.js';
|
|
15
|
-
|
|
16
|
-
const LEAF_W = ENTITY_NODE_SIZE.normal.width;
|
|
17
|
-
const LEAF_H = ENTITY_NODE_SIZE.normal.height;
|
|
18
|
-
|
|
19
|
-
function leafDoc(name: string, id: string): BlocksFile {
|
|
20
|
-
return {
|
|
21
|
-
notation: 'blocks',
|
|
22
|
-
spec_version: '0.1',
|
|
23
|
-
nested_blocks: {
|
|
24
|
-
id: 'BLOCKS-T-1',
|
|
25
|
-
name: 'Test',
|
|
26
|
-
blocks: [{ id, name }],
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function containerDoc(name: string, id: string, childId = 'CHILD', childName = 'Child'): BlocksFile {
|
|
32
|
-
return {
|
|
33
|
-
notation: 'blocks',
|
|
34
|
-
spec_version: '0.1',
|
|
35
|
-
nested_blocks: {
|
|
36
|
-
id: 'BLOCKS-T-1',
|
|
37
|
-
name: 'Test',
|
|
38
|
-
blocks: [
|
|
39
|
-
{
|
|
40
|
-
id,
|
|
41
|
-
name,
|
|
42
|
-
children: [{ id: childId, name: childName }],
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Pull every text-primary / text-id line out of an SVG, in document order. */
|
|
50
|
-
function extractLabels(svg: string): Array<{ cls: string; text: string }> {
|
|
51
|
-
const re = /<text class="(text-(?:primary|id))"[^>]*>([^<]*)<\/text>/g;
|
|
52
|
-
const out: Array<{ cls: string; text: string }> = [];
|
|
53
|
-
let m: RegExpExecArray | null;
|
|
54
|
-
while ((m = re.exec(svg))) out.push({ cls: m[1], text: m[2] });
|
|
55
|
-
return out;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Extract {class, y} for each text element in SVG document order. */
|
|
59
|
-
function extractTextY(svg: string): Array<{ cls: string; y: number }> {
|
|
60
|
-
const re = /<text class="(text-(?:primary|id))"[^>]*\by="([^"]+)"/g;
|
|
61
|
-
const out: Array<{ cls: string; y: number }> = [];
|
|
62
|
-
let m: RegExpExecArray | null;
|
|
63
|
-
while ((m = re.exec(svg))) out.push({ cls: m[1], y: parseFloat(m[2]) });
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
describe('renderBlocksSvg — leaf labels', () => {
|
|
68
|
-
it('wraps a long name to at most 3 lines and truncates with …', () => {
|
|
69
|
-
const longName =
|
|
70
|
-
'Personal data records that linger after consent withdrawal across many systems and ' +
|
|
71
|
-
'archives — known erasure gap';
|
|
72
|
-
const svg = renderBlocksSvg(leafDoc(longName, 'PII'));
|
|
73
|
-
const nameLines = extractLabels(svg).filter((l) => l.cls === 'text-primary');
|
|
74
|
-
expect(nameLines.length).toBeGreaterThan(0);
|
|
75
|
-
expect(nameLines.length).toBeLessThanOrEqual(3);
|
|
76
|
-
// If the name needed truncation, the final visible line must end with `…`.
|
|
77
|
-
if (nameLines.length === 3) {
|
|
78
|
-
expect(nameLines[2].text.endsWith('…')).toBe(true);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('wraps a long ID to at most 2 lines and truncates with …', () => {
|
|
83
|
-
const longId =
|
|
84
|
-
'VERY_LONG_BLOCK_IDENTIFIER_WITH_MANY_SEGMENTS_AND_MORE_AND_MORE_EXTRA_TAIL_TO_FORCE_TRUNCATION';
|
|
85
|
-
const svg = renderBlocksSvg(leafDoc('Short name', longId));
|
|
86
|
-
const idLines = extractLabels(svg).filter((l) => l.cls === 'text-id');
|
|
87
|
-
expect(idLines.length).toBeGreaterThan(0);
|
|
88
|
-
expect(idLines.length).toBeLessThanOrEqual(2);
|
|
89
|
-
if (idLines.length === 2) {
|
|
90
|
-
expect(idLines[1].text.endsWith('…')).toBe(true);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it(`keeps every label inside the ${LEAF_W}px leaf width (approximated by CHAR_W * length)`, () => {
|
|
95
|
-
const svg = renderBlocksSvg(
|
|
96
|
-
leafDoc(
|
|
97
|
-
'Personal data records that linger after consent withdrawal across many systems',
|
|
98
|
-
'PII_RECORDS_WITH_A_FAIRLY_LONG_IDENTIFIER_HERE',
|
|
99
|
-
),
|
|
100
|
-
);
|
|
101
|
-
const labels = extractLabels(svg);
|
|
102
|
-
const inner = LEAF_W - TEXT_MARGIN_X * 2;
|
|
103
|
-
for (const l of labels) {
|
|
104
|
-
const cw = l.cls === 'text-primary' ? CHAR_W : CHAR_W_ID;
|
|
105
|
-
expect(l.text.length * cw).toBeLessThanOrEqual(inner);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
describe('renderBlocksSvg — container headers', () => {
|
|
111
|
-
it('renders the name and ID as two separate stacked text elements', () => {
|
|
112
|
-
const svg = renderBlocksSvg(containerDoc('Active systems', 'ACTIVE_SYSTEMS'));
|
|
113
|
-
const labels = extractLabels(svg);
|
|
114
|
-
// Container header contributes one text-primary (name) and one text-id (id);
|
|
115
|
-
// the leaf child contributes another pair. So 2 of each kind in total.
|
|
116
|
-
const primaries = labels.filter((l) => l.cls === 'text-primary').map((l) => l.text);
|
|
117
|
-
const ids = labels.filter((l) => l.cls === 'text-id').map((l) => l.text);
|
|
118
|
-
expect(primaries).toContain('Active systems');
|
|
119
|
-
expect(ids).toContain('ACTIVE_SYSTEMS');
|
|
120
|
-
// The legacy "(id)" suffix on the name line must not appear — id has its own row.
|
|
121
|
-
for (const t of primaries) expect(t).not.toContain('(');
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('truncates a long container ID so it does not overflow the block width', () => {
|
|
125
|
-
const svg = renderBlocksSvg(
|
|
126
|
-
containerDoc(
|
|
127
|
-
'Short name',
|
|
128
|
-
'VERY_LONG_CONTAINER_IDENTIFIER_THAT_WOULD_OTHERWISE_OVERFLOW',
|
|
129
|
-
'CHILD',
|
|
130
|
-
'Child',
|
|
131
|
-
),
|
|
132
|
-
);
|
|
133
|
-
const labels = extractLabels(svg);
|
|
134
|
-
// Container width derives from its single leaf child: leafW + 2×padding.
|
|
135
|
-
const containerW = LEAF_W + 24;
|
|
136
|
-
const inner = containerW - TEXT_MARGIN_X * 2;
|
|
137
|
-
for (const l of labels) {
|
|
138
|
-
const cw = l.cls === 'text-primary' ? CHAR_W : CHAR_W_ID;
|
|
139
|
-
expect(l.text.length * cw).toBeLessThanOrEqual(inner);
|
|
140
|
-
}
|
|
141
|
-
// The full ID was too long to fit on one line of `inner / CHAR_W_ID` chars, so
|
|
142
|
-
// the rendered ID must be the truncated form ending in `…`.
|
|
143
|
-
const renderedIds = labels.filter((l) => l.cls === 'text-id').map((l) => l.text);
|
|
144
|
-
expect(renderedIds.some((t) => t.endsWith('…'))).toBe(true);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('truncates a long container name with … to fit the block width', () => {
|
|
148
|
-
const longName =
|
|
149
|
-
'Active systems that are erasure-reachable within the standard 30-day operational window';
|
|
150
|
-
const svg = renderBlocksSvg(containerDoc(longName, 'ACTIVE'));
|
|
151
|
-
const labels = extractLabels(svg);
|
|
152
|
-
const containerW = LEAF_W + 24;
|
|
153
|
-
const inner = containerW - TEXT_MARGIN_X * 2;
|
|
154
|
-
const primaries = labels.filter((l) => l.cls === 'text-primary');
|
|
155
|
-
for (const l of primaries) {
|
|
156
|
-
expect(l.text.length * CHAR_W).toBeLessThanOrEqual(inner);
|
|
157
|
-
}
|
|
158
|
-
// At least one primary line must have been truncated.
|
|
159
|
-
expect(primaries.some((l) => l.text.endsWith('…'))).toBe(true);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('renderBlocksSvg — name/ID vertical overlap regression (follows-up on #419)', () => {
|
|
164
|
-
// Root cause: NAME_ID_GAP was 6 px. text-primary is 12 px tall (±6 px around
|
|
165
|
-
// centre) and text-id is 10 px tall (±5 px around centre). The minimum gap
|
|
166
|
-
// between centres to avoid overlap is 11 px; a gap of 6 caused 5 px of overlap.
|
|
167
|
-
// Fix: NAME_ID_GAP = 14 (3 px visual buffer, matching the gap between name lines).
|
|
168
|
-
|
|
169
|
-
const NAME_HALF_H = 6; // half of text-primary font size (12 px)
|
|
170
|
-
const ID_HALF_H = 5; // half of text-id font size (10 px)
|
|
171
|
-
|
|
172
|
-
it('leaf node: last name line bottom does not overlap first ID line top (1 name + 1 ID)', () => {
|
|
173
|
-
const svg = renderBlocksSvg(leafDoc('Short', 'BLK-1'));
|
|
174
|
-
const positions = extractTextY(svg);
|
|
175
|
-
const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
|
|
176
|
-
const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
|
|
177
|
-
expect(nameY.length).toBeGreaterThan(0);
|
|
178
|
-
expect(idY.length).toBeGreaterThan(0);
|
|
179
|
-
const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
|
|
180
|
-
const firstIdTop = Math.min(...idY) - ID_HALF_H;
|
|
181
|
-
expect(firstIdTop).toBeGreaterThan(lastNameBottom);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('leaf node: no overlap with a 3-word name (2 name lines + 1 ID)', () => {
|
|
185
|
-
const svg = renderBlocksSvg(leafDoc('Three Word Name', 'BLK-001'));
|
|
186
|
-
const positions = extractTextY(svg);
|
|
187
|
-
const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
|
|
188
|
-
const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
|
|
189
|
-
const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
|
|
190
|
-
const firstIdTop = Math.min(...idY) - ID_HALF_H;
|
|
191
|
-
expect(firstIdTop).toBeGreaterThan(lastNameBottom);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('leaf node: no overlap with a long name (3 name lines) and wrapped ID (2 lines)', () => {
|
|
195
|
-
const longName =
|
|
196
|
-
'Personal data records that linger after consent withdrawal across many systems and archives';
|
|
197
|
-
const longId = 'VERY_LONG_BLOCK_IDENTIFIER_WITH_MANY_SEGMENTS_AND_MORE';
|
|
198
|
-
const svg = renderBlocksSvg(leafDoc(longName, longId));
|
|
199
|
-
const positions = extractTextY(svg);
|
|
200
|
-
const nameY = positions.filter(p => p.cls === 'text-primary').map(p => p.y);
|
|
201
|
-
const idY = positions.filter(p => p.cls === 'text-id').map(p => p.y);
|
|
202
|
-
const lastNameBottom = Math.max(...nameY) + NAME_HALF_H;
|
|
203
|
-
const firstIdTop = Math.min(...idY) - ID_HALF_H;
|
|
204
|
-
expect(firstIdTop).toBeGreaterThan(lastNameBottom);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for the host-neutral goals SVG renderer used by the IntelliJ
|
|
3
|
-
* JCEF preview bundle. The IntelliJ build can't run inside Vitest, so these
|
|
4
|
-
* tests are the only place the goals rendering path is exercised on the
|
|
5
|
-
* webview-bundle side of the codebase.
|
|
6
|
-
*/
|
|
7
|
-
import { describe, expect, it } from 'vitest';
|
|
8
|
-
|
|
9
|
-
import type { GoalTree } from '../../goals/types.js';
|
|
10
|
-
import { renderGoalsSvg } from '../render-goals.js';
|
|
11
|
-
|
|
12
|
-
const SIMPLE_TREE: GoalTree = {
|
|
13
|
-
goal_types: [
|
|
14
|
-
{ name: 'Strategy', level: 0 },
|
|
15
|
-
{ name: 'Tactic', level: 1 },
|
|
16
|
-
],
|
|
17
|
-
goals: [
|
|
18
|
-
{ id: 1, name: 'Reach the moon', type: 'Strategy', level: 0, parent_id: 0 },
|
|
19
|
-
{ id: 2, name: 'Build a rocket', type: 'Tactic', level: 1, parent_id: 1 },
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe('renderGoalsSvg', () => {
|
|
24
|
-
it('produces a self-contained <svg> with embedded theme CSS', () => {
|
|
25
|
-
const svg = renderGoalsSvg(SIMPLE_TREE, { treeName: 'Apollo' });
|
|
26
|
-
expect(svg.startsWith('<svg ')).toBe(true);
|
|
27
|
-
expect(svg).toContain('xmlns="http://www.w3.org/2000/svg"');
|
|
28
|
-
expect(svg).toContain('<style>');
|
|
29
|
-
// The shared theme CSS contract: diagram classes are defined inline.
|
|
30
|
-
expect(svg).toContain('.diagram-node');
|
|
31
|
-
expect(svg).toContain('.diagram-edge');
|
|
32
|
-
// Both goal names made it into the output.
|
|
33
|
-
expect(svg).toContain('Reach the moon');
|
|
34
|
-
expect(svg).toContain('Build a rocket');
|
|
35
|
-
// The strategy → tactic parent link rendered as an edge with the arrow marker.
|
|
36
|
-
expect(svg).toContain('marker-end="url(#arrow)"');
|
|
37
|
-
// Title block is present when treeName is supplied.
|
|
38
|
-
expect(svg).toContain('Goal tree — Apollo');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('escapes user-controlled strings (XML safety)', () => {
|
|
42
|
-
const tree: GoalTree = {
|
|
43
|
-
goal_types: [{ name: 'Strategy', level: 0 }],
|
|
44
|
-
goals: [
|
|
45
|
-
{
|
|
46
|
-
id: 1,
|
|
47
|
-
name: 'Drop <script>alert(1)</script> & friends',
|
|
48
|
-
type: 'Strategy',
|
|
49
|
-
level: 0,
|
|
50
|
-
parent_id: 0,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
const svg = renderGoalsSvg(tree);
|
|
55
|
-
expect(svg).not.toContain('<script>alert(1)</script>');
|
|
56
|
-
expect(svg).toContain('<script>');
|
|
57
|
-
expect(svg).toContain('&');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('returns an empty SVG when the tree has no goals', () => {
|
|
61
|
-
const empty: GoalTree = { goal_types: [{ name: 'Strategy', level: 0 }], goals: [] };
|
|
62
|
-
const svg = renderGoalsSvg(empty);
|
|
63
|
-
expect(svg).toContain('<svg ');
|
|
64
|
-
expect(svg).toContain('width="0"');
|
|
65
|
-
expect(svg).toContain('height="0"');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('renders name, type, and id on separate lines without overlap', () => {
|
|
69
|
-
const tree: GoalTree = {
|
|
70
|
-
goal_types: [
|
|
71
|
-
{ name: 'Strategic', level: 0 },
|
|
72
|
-
{ name: 'Objective', level: 1 },
|
|
73
|
-
],
|
|
74
|
-
goals: [
|
|
75
|
-
{
|
|
76
|
-
id: 1,
|
|
77
|
-
canonical_id: 'GOAL-VALUE-1',
|
|
78
|
-
name: 'Grow enterprise value',
|
|
79
|
-
type: 'Strategic',
|
|
80
|
-
level: 0,
|
|
81
|
-
parent_id: 0,
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: 2,
|
|
85
|
-
canonical_id: 'GOAL-COST-1',
|
|
86
|
-
name: 'Reduce run cost 20%',
|
|
87
|
-
type: 'Objective',
|
|
88
|
-
level: 1,
|
|
89
|
-
parent_id: 1,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
};
|
|
93
|
-
const svg = renderGoalsSvg(tree);
|
|
94
|
-
expect(svg).toContain('Grow enterprise value');
|
|
95
|
-
expect(svg).toContain('Strategic');
|
|
96
|
-
expect(svg).toContain('GOAL-VALUE-1');
|
|
97
|
-
const typeMatches = [...svg.matchAll(/class="text-secondary"[^>]*y="(\d+)"/g)];
|
|
98
|
-
const nameMatches = [...svg.matchAll(/class="text-primary"[^>]*y="(\d+)"/g)];
|
|
99
|
-
expect(typeMatches.length).toBeGreaterThan(0);
|
|
100
|
-
for (const type of typeMatches) {
|
|
101
|
-
const typeY = Number(type[1]);
|
|
102
|
-
const nearestName = nameMatches
|
|
103
|
-
.map((m) => Number(m[1]))
|
|
104
|
-
.filter((y) => y < typeY)
|
|
105
|
-
.sort((a, b) => b - a)[0];
|
|
106
|
-
expect(typeY - nearestName).toBeGreaterThanOrEqual(18);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it('shows canonical goal ids in node labels when present', () => {
|
|
111
|
-
const tree: GoalTree = {
|
|
112
|
-
goal_types: [{ name: 'Strategy', level: 0 }],
|
|
113
|
-
goals: [
|
|
114
|
-
{
|
|
115
|
-
id: 1,
|
|
116
|
-
canonical_id: 'GOAL-REVENUE-1',
|
|
117
|
-
name: 'Triple revenue',
|
|
118
|
-
type: 'Strategy',
|
|
119
|
-
level: 0,
|
|
120
|
-
parent_id: 0,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
};
|
|
124
|
-
const svg = renderGoalsSvg(tree);
|
|
125
|
-
expect(svg).toContain('GOAL-REVENUE-1');
|
|
126
|
-
expect(svg).not.toMatch(/>\s*1\s*</);
|
|
127
|
-
});
|
|
128
|
-
});
|