@transitrix/diagrams 1.8.6 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fgca/index.js +10 -10
- package/dist/fgca/layout.js +1 -1
- package/dist/fgca/nodeTypes.js +4 -4
- package/dist/index.js +33 -33
- package/package.json +8 -2
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -55
- package/dist/__tests__/node-size-presets.test.d.ts +0 -1
- package/dist/__tests__/node-size-presets.test.js +0 -30
- package/dist/__tests__/scope.test.d.ts +0 -1
- package/dist/__tests__/scope.test.js +0 -23
- package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
- package/dist/__tests__/yaml-normalize.test.js +0 -148
- package/dist/activities/__tests__/cpm.test.d.ts +0 -1
- package/dist/activities/__tests__/cpm.test.js +0 -146
- package/dist/activities/__tests__/gantt.test.d.ts +0 -1
- package/dist/activities/__tests__/gantt.test.js +0 -263
- package/dist/activities/__tests__/layout.test.d.ts +0 -1
- package/dist/activities/__tests__/layout.test.js +0 -98
- package/dist/activities/__tests__/validate.test.d.ts +0 -1
- package/dist/activities/__tests__/validate.test.js +0 -397
- package/dist/activity-card/__tests__/example.test.d.ts +0 -1
- package/dist/activity-card/__tests__/example.test.js +0 -73
- package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
- package/dist/activity-card/__tests__/layout.test.js +0 -141
- package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
- package/dist/activity-card/__tests__/resolver.test.js +0 -325
- package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
- package/dist/activity-card/__tests__/validate.test.js +0 -149
- package/dist/actor/__tests__/validate.test.d.ts +0 -1
- package/dist/actor/__tests__/validate.test.js +0 -95
- package/dist/applications/__tests__/validate.test.d.ts +0 -1
- package/dist/applications/__tests__/validate.test.js +0 -223
- package/dist/assertion/__tests__/example.test.d.ts +0 -1
- package/dist/assertion/__tests__/example.test.js +0 -32
- package/dist/assertion/__tests__/validate.test.d.ts +0 -1
- package/dist/assertion/__tests__/validate.test.js +0 -130
- package/dist/blocks/__tests__/layout.test.d.ts +0 -1
- package/dist/blocks/__tests__/layout.test.js +0 -153
- package/dist/blocks/__tests__/validate.test.d.ts +0 -1
- package/dist/blocks/__tests__/validate.test.js +0 -235
- package/dist/business-service/__tests__/validate.test.d.ts +0 -1
- package/dist/business-service/__tests__/validate.test.js +0 -135
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
- package/dist/capability-map/__tests__/address.test.d.ts +0 -1
- package/dist/capability-map/__tests__/address.test.js +0 -49
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
- package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/validate.test.js +0 -212
- package/dist/change/__tests__/validate.test.d.ts +0 -1
- package/dist/change/__tests__/validate.test.js +0 -79
- package/dist/codex/__tests__/example.test.d.ts +0 -1
- package/dist/codex/__tests__/example.test.js +0 -33
- package/dist/codex/__tests__/validate.test.d.ts +0 -1
- package/dist/codex/__tests__/validate.test.js +0 -68
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
- package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
- package/dist/compliance/__tests__/classify.test.d.ts +0 -1
- package/dist/compliance/__tests__/classify.test.js +0 -58
- package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
- package/dist/compliance/__tests__/confidence.test.js +0 -78
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
- package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
- package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
- package/dist/compliance/__tests__/example.test.d.ts +0 -1
- package/dist/compliance/__tests__/example.test.js +0 -51
- package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
- package/dist/compliance/__tests__/gap-report.test.js +0 -113
- package/dist/compliance/__tests__/html.test.d.ts +0 -1
- package/dist/compliance/__tests__/html.test.js +0 -122
- package/dist/compliance/__tests__/impact.test.d.ts +0 -1
- package/dist/compliance/__tests__/impact.test.js +0 -913
- package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
- package/dist/compliance/__tests__/markdown.test.js +0 -85
- package/dist/compliance/__tests__/trace.test.d.ts +0 -1
- package/dist/compliance/__tests__/trace.test.js +0 -144
- package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
- package/dist/compliance/__tests__/view-resolution.test.js +0 -59
- package/dist/compliance/__tests__/views.test.d.ts +0 -1
- package/dist/compliance/__tests__/views.test.js +0 -59
- package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/build.test.js +0 -183
- package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/example.test.js +0 -49
- package/dist/confidence/__tests__/score.test.d.ts +0 -1
- package/dist/confidence/__tests__/score.test.js +0 -188
- package/dist/constraint/__tests__/example.test.d.ts +0 -1
- package/dist/constraint/__tests__/example.test.js +0 -14
- package/dist/constraint/__tests__/validate.test.d.ts +0 -1
- package/dist/constraint/__tests__/validate.test.js +0 -58
- package/dist/factor/__tests__/validate.test.d.ts +0 -1
- package/dist/factor/__tests__/validate.test.js +0 -112
- package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
- package/dist/fgca/__tests__/chain-table.test.js +0 -158
- package/dist/fgca/__tests__/layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/layout.test.js +0 -140
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
- package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/preview-layout.test.js +0 -106
- package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
- package/dist/fgca/__tests__/resolver.test.js +0 -185
- package/dist/fgca/__tests__/validate.test.d.ts +0 -1
- package/dist/fgca/__tests__/validate.test.js +0 -125
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
- package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
- package/dist/goals/__tests__/layout.test.d.ts +0 -1
- package/dist/goals/__tests__/layout.test.js +0 -153
- package/dist/goals/__tests__/mutations.test.d.ts +0 -1
- package/dist/goals/__tests__/mutations.test.js +0 -134
- package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/goals/__tests__/parse-canonical.test.js +0 -131
- package/dist/goals/__tests__/validate.test.d.ts +0 -1
- package/dist/goals/__tests__/validate.test.js +0 -183
- package/dist/integration/__tests__/validate.test.d.ts +0 -1
- package/dist/integration/__tests__/validate.test.js +0 -169
- package/dist/location/__tests__/validate.test.d.ts +0 -1
- package/dist/location/__tests__/validate.test.js +0 -107
- package/dist/node/__tests__/validate.test.d.ts +0 -1
- package/dist/node/__tests__/validate.test.js +0 -100
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
- package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/layout.test.js +0 -196
- package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/validate.test.js +0 -280
- package/dist/process-map/__tests__/validate.test.d.ts +0 -1
- package/dist/process-map/__tests__/validate.test.js +0 -199
- package/dist/products/__tests__/validate.test.d.ts +0 -1
- package/dist/products/__tests__/validate.test.js +0 -210
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
- package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
- package/dist/requirement/__tests__/example.test.d.ts +0 -1
- package/dist/requirement/__tests__/example.test.js +0 -21
- package/dist/requirement/__tests__/validate.test.d.ts +0 -1
- package/dist/requirement/__tests__/validate.test.js +0 -80
- package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
- package/dist/scenarios/__tests__/validate.test.js +0 -183
- package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
- package/dist/stakeholder/__tests__/validate.test.js +0 -88
- package/dist/target-state/__tests__/validate.test.d.ts +0 -1
- package/dist/target-state/__tests__/validate.test.js +0 -78
- package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
- package/dist/technology-service/__tests__/validate.test.js +0 -121
- package/dist/theme/__tests__/tokens.test.d.ts +0 -1
- package/dist/theme/__tests__/tokens.test.js +0 -159
- package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
- package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
- package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
- package/dist/webview/__tests__/entry-notations.test.js +0 -62
- package/dist/webview/__tests__/entry.test.d.ts +0 -1
- package/dist/webview/__tests__/entry.test.js +0 -56
- package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
- package/dist/webview/__tests__/render-activities.test.js +0 -91
- package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
- package/dist/webview/__tests__/render-blocks.test.js +0 -175
- package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
- package/dist/webview/__tests__/render-goals.test.js +0 -120
- package/dist/webview/__tests__/render-process.test.d.ts +0 -1
- package/dist/webview/__tests__/render-process.test.js +0 -463
- package/dist/webview/__tests__/render-util.test.d.ts +0 -1
- package/dist/webview/__tests__/render-util.test.js +0 -54
- package/src/__tests__/edge-path.test.ts +0 -67
- package/src/__tests__/node-size-presets.test.ts +0 -50
- package/src/__tests__/scope.test.ts +0 -27
- package/src/__tests__/yaml-normalize.test.ts +0 -158
- package/src/activities/__tests__/cpm.test.ts +0 -164
- package/src/activities/__tests__/gantt.test.ts +0 -290
- package/src/activities/__tests__/layout.test.ts +0 -112
- package/src/activities/__tests__/validate.test.ts +0 -446
- package/src/activity-card/__tests__/example.test.ts +0 -83
- package/src/activity-card/__tests__/layout.test.ts +0 -162
- package/src/activity-card/__tests__/resolver.test.ts +0 -357
- package/src/activity-card/__tests__/validate.test.ts +0 -167
- package/src/actor/__tests__/validate.test.ts +0 -114
- package/src/applications/__tests__/validate.test.ts +0 -256
- package/src/assertion/__tests__/example.test.ts +0 -37
- package/src/assertion/__tests__/validate.test.ts +0 -142
- package/src/blocks/__tests__/layout.test.ts +0 -169
- package/src/blocks/__tests__/validate.test.ts +0 -260
- package/src/business-service/__tests__/validate.test.ts +0 -160
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
- package/src/capability-map/__tests__/address.test.ts +0 -59
- package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
- package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
- package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
- package/src/capability-map/__tests__/validate.test.ts +0 -238
- package/src/change/__tests__/validate.test.ts +0 -97
- package/src/codex/__tests__/example.test.ts +0 -40
- package/src/codex/__tests__/validate.test.ts +0 -84
- package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
- package/src/compliance/__tests__/classify.test.ts +0 -64
- package/src/compliance/__tests__/confidence.test.ts +0 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
- package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
- package/src/compliance/__tests__/example.test.ts +0 -57
- package/src/compliance/__tests__/gap-report.test.ts +0 -129
- package/src/compliance/__tests__/html.test.ts +0 -142
- package/src/compliance/__tests__/impact.test.ts +0 -1060
- package/src/compliance/__tests__/markdown.test.ts +0 -95
- package/src/compliance/__tests__/trace.test.ts +0 -157
- package/src/compliance/__tests__/view-resolution.test.ts +0 -80
- package/src/compliance/__tests__/views.test.ts +0 -64
- package/src/compliance-matrix/__tests__/build.test.ts +0 -200
- package/src/compliance-matrix/__tests__/example.test.ts +0 -57
- package/src/confidence/__tests__/score.test.ts +0 -254
- package/src/constraint/__tests__/example.test.ts +0 -19
- package/src/constraint/__tests__/validate.test.ts +0 -68
- package/src/factor/__tests__/validate.test.ts +0 -133
- package/src/fgca/__tests__/chain-table.test.ts +0 -172
- package/src/fgca/__tests__/layout.test.ts +0 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
- package/src/fgca/__tests__/preview-layout.test.ts +0 -124
- package/src/fgca/__tests__/resolver.test.ts +0 -209
- package/src/fgca/__tests__/validate.test.ts +0 -142
- package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
- package/src/goals/__tests__/layout.test.ts +0 -175
- package/src/goals/__tests__/mutations.test.ts +0 -153
- package/src/goals/__tests__/parse-canonical.test.ts +0 -147
- package/src/goals/__tests__/validate.test.ts +0 -202
- package/src/integration/__tests__/validate.test.ts +0 -203
- package/src/location/__tests__/validate.test.ts +0 -127
- package/src/node/__tests__/validate.test.ts +0 -118
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
- package/src/process-blueprint/__tests__/layout.test.ts +0 -240
- package/src/process-blueprint/__tests__/validate.test.ts +0 -310
- package/src/process-map/__tests__/validate.test.ts +0 -223
- package/src/products/__tests__/validate.test.ts +0 -239
- package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
- package/src/requirement/__tests__/example.test.ts +0 -24
- package/src/requirement/__tests__/validate.test.ts +0 -96
- package/src/scenarios/__tests__/validate.test.ts +0 -209
- package/src/stakeholder/__tests__/validate.test.ts +0 -105
- package/src/target-state/__tests__/validate.test.ts +0 -95
- package/src/technology-service/__tests__/validate.test.ts +0 -143
- package/src/theme/__tests__/tokens.test.ts +0 -185
- package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
- package/src/webview/__tests__/entry-notations.test.ts +0 -77
- package/src/webview/__tests__/entry.test.ts +0 -64
- package/src/webview/__tests__/render-activities.test.ts +0 -100
- package/src/webview/__tests__/render-blocks.test.ts +0 -206
- package/src/webview/__tests__/render-goals.test.ts +0 -128
- package/src/webview/__tests__/render-process.test.ts +0 -538
- package/src/webview/__tests__/render-util.test.ts +0 -66
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
import { resolveFGCA, isFGCAViewDoc } from '../resolver.js';
|
|
6
|
-
import { parseCanonicalFGCA } from '../parse-canonical.js';
|
|
7
|
-
// ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
|
|
8
|
-
const ELEMENTS = [
|
|
9
|
-
{ notation: 'driver', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
|
|
10
|
-
{ notation: 'driver', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
|
|
11
|
-
{ notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
|
|
12
|
-
{ notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
|
|
13
|
-
{ notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
|
|
14
|
-
{ notation: 'change', id: 'CHANGE-1', name: 'Launch new product line', goals: ['GOAL-1'] },
|
|
15
|
-
{ notation: 'change', id: 'CHANGE-2', name: 'Automate manual processes', goals: ['GOAL-2'] },
|
|
16
|
-
{ notation: 'change', id: 'CHANGE-3', name: 'Enhance support platform', goals: ['GOAL-3'] },
|
|
17
|
-
{ notation: 'activity', id: 'ACTIVITY-1', name: 'Market research', changes: ['CHANGE-1'] },
|
|
18
|
-
{ notation: 'activity', id: 'ACTIVITY-2', name: 'MVP development', changes: ['CHANGE-1'] },
|
|
19
|
-
{ notation: 'activity', id: 'ACTIVITY-3', name: 'Process audit', changes: ['CHANGE-2'] },
|
|
20
|
-
{ notation: 'activity', id: 'ACTIVITY-4', name: 'RPA tooling rollout', changes: ['CHANGE-2'] },
|
|
21
|
-
{ notation: 'activity', id: 'ACTIVITY-5', name: 'CRM implementation', changes: ['CHANGE-3'] },
|
|
22
|
-
];
|
|
23
|
-
const SOURCES = { elements: ELEMENTS, relations: [] };
|
|
24
|
-
const VIEW_DOC = {
|
|
25
|
-
notation: 'dgca',
|
|
26
|
-
id: 'FGCA-STRAT-1',
|
|
27
|
-
name: 'Strategy 2026 — FGCA chain',
|
|
28
|
-
spec_version: '0.1',
|
|
29
|
-
view_config: {
|
|
30
|
-
goals: { filter: 'all' },
|
|
31
|
-
factors: { surface: 'derived' },
|
|
32
|
-
changes: { surface: 'derived' },
|
|
33
|
-
activities: { surface: 'derived' },
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
// ── isFGCAViewDoc ─────────────────────────────────────────────────────────────
|
|
37
|
-
describe('isFGCAViewDoc', () => {
|
|
38
|
-
it('returns true for a view_config-based doc', () => {
|
|
39
|
-
expect(isFGCAViewDoc(VIEW_DOC)).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
it('returns false for an inline doc with factors/goals arrays', () => {
|
|
42
|
-
expect(isFGCAViewDoc({
|
|
43
|
-
notation: 'dgca', id: 'FGCA-1', name: 'x',
|
|
44
|
-
factors: [], goals: [], changes: [], activities: [],
|
|
45
|
-
})).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
it('returns false for non-objects', () => {
|
|
48
|
-
expect(isFGCAViewDoc(null)).toBe(false);
|
|
49
|
-
expect(isFGCAViewDoc('string')).toBe(false);
|
|
50
|
-
expect(isFGCAViewDoc(42)).toBe(false);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
// ── resolveFGCA — goals.filter=all (default) ──────────────────────────────────
|
|
54
|
-
describe('resolveFGCA — goals.filter=all', () => {
|
|
55
|
-
it('includes all goals, changes, and activities', () => {
|
|
56
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
57
|
-
expect(doc['goals'].length).toBe(3);
|
|
58
|
-
expect(doc['changes'].length).toBe(3);
|
|
59
|
-
expect(doc['actions'].length).toBe(5);
|
|
60
|
-
});
|
|
61
|
-
it('derives factors from all goal.factors[] refs', () => {
|
|
62
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
63
|
-
const factorIds = doc['factors'].map((f) => f.id);
|
|
64
|
-
expect(factorIds).toContain('FACTOR-1');
|
|
65
|
-
expect(factorIds).toContain('FACTOR-2');
|
|
66
|
-
expect(factorIds.length).toBe(2);
|
|
67
|
-
});
|
|
68
|
-
it('passes parseCanonicalFGCA and produces a fully valid internal doc', () => {
|
|
69
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
70
|
-
const r = parseCanonicalFGCA(doc);
|
|
71
|
-
expect(r.valid).toBe(true);
|
|
72
|
-
expect(r.errors).toEqual([]);
|
|
73
|
-
expect(r.parsed?.goals).toHaveLength(3);
|
|
74
|
-
expect(r.parsed?.factors).toHaveLength(2);
|
|
75
|
-
expect(r.parsed?.changes).toHaveLength(3);
|
|
76
|
-
expect(r.parsed?.activities).toHaveLength(5);
|
|
77
|
-
});
|
|
78
|
-
it('carries view doc metadata (id, name, spec_version)', () => {
|
|
79
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
80
|
-
expect(doc['notation']).toBe('dgca');
|
|
81
|
-
expect(doc['id']).toBe('FGCA-STRAT-1');
|
|
82
|
-
expect(doc['name']).toBe('Strategy 2026 — FGCA chain');
|
|
83
|
-
expect(doc['spec_version']).toBe('0.1');
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
// ── resolveFGCA — goals.filter=ids ────────────────────────────────────────────
|
|
87
|
-
describe('resolveFGCA — goals.filter=ids', () => {
|
|
88
|
-
it('narrows to the specified goal and its derived changes + activities', () => {
|
|
89
|
-
const viewDoc = {
|
|
90
|
-
...VIEW_DOC,
|
|
91
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
|
|
92
|
-
};
|
|
93
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
94
|
-
const goalIds = doc['goals'].map((g) => g.id);
|
|
95
|
-
expect(goalIds).toEqual(['GOAL-1']);
|
|
96
|
-
const changeIds = doc['changes'].map((c) => c.id);
|
|
97
|
-
expect(changeIds).toEqual(['CHANGE-1']);
|
|
98
|
-
const actIds = doc['actions'].map((a) => a.id).sort();
|
|
99
|
-
expect(actIds).toEqual(['ACTIVITY-1', 'ACTIVITY-2']);
|
|
100
|
-
const r = parseCanonicalFGCA(doc);
|
|
101
|
-
expect(r.valid).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
it('returns empty arrays when none of the requested ids exist in canon', () => {
|
|
104
|
-
const viewDoc = {
|
|
105
|
-
...VIEW_DOC,
|
|
106
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-NONEXISTENT-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
|
|
107
|
-
};
|
|
108
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
109
|
-
expect(doc['goals'].length).toBe(0);
|
|
110
|
-
expect(doc['changes'].length).toBe(0);
|
|
111
|
-
expect(doc['factors'].length).toBe(0);
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
// ── resolveFGCA — surface=all ─────────────────────────────────────────────────
|
|
115
|
-
describe('resolveFGCA — surface=all', () => {
|
|
116
|
-
it('factors.surface=all includes every factor even when only some are referenced', () => {
|
|
117
|
-
const viewDoc = {
|
|
118
|
-
...VIEW_DOC,
|
|
119
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-3'] }, factors: { surface: 'all' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
|
|
120
|
-
};
|
|
121
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
122
|
-
// GOAL-3 only references FACTOR-1, but surface=all → both factors
|
|
123
|
-
expect(doc['factors'].length).toBe(2);
|
|
124
|
-
});
|
|
125
|
-
it('changes.surface=all includes every change', () => {
|
|
126
|
-
const viewDoc = {
|
|
127
|
-
...VIEW_DOC,
|
|
128
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'all' }, activities: { surface: 'derived' } },
|
|
129
|
-
};
|
|
130
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
131
|
-
expect(doc['changes'].length).toBe(3);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
// ── resolveFGCA — empty / degenerate inputs ───────────────────────────────────
|
|
135
|
-
describe('resolveFGCA — empty sources', () => {
|
|
136
|
-
it('returns empty arrays when canon has no elements', () => {
|
|
137
|
-
const doc = resolveFGCA(VIEW_DOC, { elements: [], relations: [] });
|
|
138
|
-
expect(doc['goals'].length).toBe(0);
|
|
139
|
-
expect(doc['factors'].length).toBe(0);
|
|
140
|
-
expect(doc['changes'].length).toBe(0);
|
|
141
|
-
expect(doc['actions'].length).toBe(0);
|
|
142
|
-
});
|
|
143
|
-
it('returns empty arrays for a non-object viewDoc', () => {
|
|
144
|
-
const doc = resolveFGCA(null, SOURCES);
|
|
145
|
-
expect(doc['goals'].length).toBe(0);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
// ── File-based regression — resolver + canon fixture + parseCanonicalFGCA ─────
|
|
149
|
-
describe('resolveFGCA — file-based regression against canon fixture', () => {
|
|
150
|
-
const CANON_ROOT = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dgca', 'canon');
|
|
151
|
-
const VIEW_DIR = path.join(CANON_ROOT, 'views');
|
|
152
|
-
const ELEM_DIR = path.join(CANON_ROOT, 'elements');
|
|
153
|
-
function loadYamlsUnder(dir) {
|
|
154
|
-
if (!fs.existsSync(dir))
|
|
155
|
-
return [];
|
|
156
|
-
const out = [];
|
|
157
|
-
function walk(d) {
|
|
158
|
-
for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
|
|
159
|
-
const full = path.join(d, entry.name);
|
|
160
|
-
if (entry.isDirectory()) {
|
|
161
|
-
walk(full);
|
|
162
|
-
}
|
|
163
|
-
else if (entry.name.endsWith('.yaml')) {
|
|
164
|
-
out.push(yaml.load(fs.readFileSync(full, 'utf8')));
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
walk(dir);
|
|
169
|
-
return out;
|
|
170
|
-
}
|
|
171
|
-
const viewFiles = fs.existsSync(VIEW_DIR)
|
|
172
|
-
? fs.readdirSync(VIEW_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
|
|
173
|
-
: [];
|
|
174
|
-
for (const file of viewFiles) {
|
|
175
|
-
it(`resolves ${file} against canon fixtures and passes parseCanonicalFGCA`, () => {
|
|
176
|
-
const viewDoc = yaml.load(fs.readFileSync(path.join(VIEW_DIR, file), 'utf8'));
|
|
177
|
-
expect(isFGCAViewDoc(viewDoc)).toBe(true);
|
|
178
|
-
const elements = loadYamlsUnder(ELEM_DIR);
|
|
179
|
-
const doc = resolveFGCA(viewDoc, { elements, relations: [] });
|
|
180
|
-
const r = parseCanonicalFGCA(doc);
|
|
181
|
-
expect(r.valid).toBe(true);
|
|
182
|
-
expect(r.errors).toEqual([]);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateFGCADoc } from '../validate.js';
|
|
3
|
-
const VALID_DOC = {
|
|
4
|
-
notation: 'dgca',
|
|
5
|
-
factors: [{ id: 1, name: 'Market pressure' }],
|
|
6
|
-
goals: [{ id: 1, name: 'Grow revenue', factor: [{ id: 1 }] }],
|
|
7
|
-
changes: [{ id: 1, name: 'Launch product', goal_id: 1, activity_ids: [1] }],
|
|
8
|
-
actions: [{ id: 1, name: 'Market research', goal_id: 1 }],
|
|
9
|
-
};
|
|
10
|
-
describe('validateFGCADoc', () => {
|
|
11
|
-
it('accepts a valid document', () => {
|
|
12
|
-
const result = validateFGCADoc(VALID_DOC);
|
|
13
|
-
expect(result.valid).toBe(true);
|
|
14
|
-
expect(result.errors).toHaveLength(0);
|
|
15
|
-
});
|
|
16
|
-
it('rejects non-object input', () => {
|
|
17
|
-
expect(validateFGCADoc('string').valid).toBe(false);
|
|
18
|
-
expect(validateFGCADoc(null).valid).toBe(false);
|
|
19
|
-
expect(validateFGCADoc(42).valid).toBe(false);
|
|
20
|
-
});
|
|
21
|
-
it('errors on missing notation field', () => {
|
|
22
|
-
const { notation: _, ...without } = VALID_DOC;
|
|
23
|
-
const result = validateFGCADoc(without);
|
|
24
|
-
expect(result.valid).toBe(false);
|
|
25
|
-
expect(result.errors[0].code).toBe('MISSING_NOTATION');
|
|
26
|
-
});
|
|
27
|
-
it('errors on wrong notation value', () => {
|
|
28
|
-
const result = validateFGCADoc({ ...VALID_DOC, notation: 'goals' });
|
|
29
|
-
expect(result.valid).toBe(false);
|
|
30
|
-
expect(result.errors[0].code).toBe('WRONG_NOTATION');
|
|
31
|
-
});
|
|
32
|
-
it('errors when factors array is missing', () => {
|
|
33
|
-
const { factors: _, ...without } = VALID_DOC;
|
|
34
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
35
|
-
expect(result.valid).toBe(false);
|
|
36
|
-
expect(result.errors.some(e => e.path === 'factors')).toBe(true);
|
|
37
|
-
});
|
|
38
|
-
it('errors when goals array is missing', () => {
|
|
39
|
-
const { goals: _, ...without } = VALID_DOC;
|
|
40
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
41
|
-
expect(result.valid).toBe(false);
|
|
42
|
-
expect(result.errors.some(e => e.path === 'goals')).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
it('errors when changes array is missing', () => {
|
|
45
|
-
const { changes: _, ...without } = VALID_DOC;
|
|
46
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
47
|
-
expect(result.valid).toBe(false);
|
|
48
|
-
expect(result.errors.some(e => e.path === 'changes')).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
it('errors when actions array is missing', () => {
|
|
51
|
-
const { actions: _, ...without } = VALID_DOC;
|
|
52
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
53
|
-
expect(result.valid).toBe(false);
|
|
54
|
-
expect(result.errors.some(e => e.path === 'actions')).toBe(true);
|
|
55
|
-
});
|
|
56
|
-
it('errors on empty factor name', () => {
|
|
57
|
-
const result = validateFGCADoc({ ...VALID_DOC, factors: [{ id: 1, name: '' }] });
|
|
58
|
-
expect(result.valid).toBe(false);
|
|
59
|
-
expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
it('errors on empty goal name', () => {
|
|
62
|
-
const result = validateFGCADoc({ ...VALID_DOC, goals: [{ id: 1, name: ' ', factor: [] }] });
|
|
63
|
-
expect(result.valid).toBe(false);
|
|
64
|
-
expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
|
|
65
|
-
});
|
|
66
|
-
it('warns on broken factor reference in goal', () => {
|
|
67
|
-
const result = validateFGCADoc({
|
|
68
|
-
...VALID_DOC,
|
|
69
|
-
goals: [{ id: 1, name: 'Goal', factor: [{ id: 99 }] }],
|
|
70
|
-
});
|
|
71
|
-
expect(result.valid).toBe(true);
|
|
72
|
-
expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('factor 99'))).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
it('warns on broken goal reference in change', () => {
|
|
75
|
-
const result = validateFGCADoc({
|
|
76
|
-
...VALID_DOC,
|
|
77
|
-
changes: [{ id: 1, name: 'Change', goal_id: 99, activity_ids: [] }],
|
|
78
|
-
});
|
|
79
|
-
expect(result.valid).toBe(true);
|
|
80
|
-
expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('goal 99'))).toBe(true);
|
|
81
|
-
});
|
|
82
|
-
it('warns on broken activity reference in change', () => {
|
|
83
|
-
const result = validateFGCADoc({
|
|
84
|
-
...VALID_DOC,
|
|
85
|
-
changes: [{ id: 1, name: 'Change', goal_id: 1, activity_ids: [99] }],
|
|
86
|
-
});
|
|
87
|
-
expect(result.valid).toBe(true);
|
|
88
|
-
expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('activity 99'))).toBe(true);
|
|
89
|
-
});
|
|
90
|
-
it('accepts a document with empty arrays', () => {
|
|
91
|
-
const result = validateFGCADoc({
|
|
92
|
-
notation: 'dgca',
|
|
93
|
-
factors: [],
|
|
94
|
-
goals: [],
|
|
95
|
-
changes: [],
|
|
96
|
-
actions: [],
|
|
97
|
-
});
|
|
98
|
-
expect(result.valid).toBe(true);
|
|
99
|
-
});
|
|
100
|
-
it('accepts optional spec_version field', () => {
|
|
101
|
-
const result = validateFGCADoc({ ...VALID_DOC, spec_version: '0.1' });
|
|
102
|
-
expect(result.valid).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
// Pre-release blocker regression (orchestrator review 2026-05-21).
|
|
105
|
-
it('[blocker] tolerates a null element in goals[] without throwing', () => {
|
|
106
|
-
const r = validateFGCADoc({ ...VALID_DOC, goals: [null] });
|
|
107
|
-
expect(r.valid).toBe(false);
|
|
108
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
109
|
-
});
|
|
110
|
-
it('[blocker] tolerates a string element in factors[] without throwing', () => {
|
|
111
|
-
const r = validateFGCADoc({ ...VALID_DOC, factors: ['x'] });
|
|
112
|
-
expect(r.valid).toBe(false);
|
|
113
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
it('[blocker] tolerates a null element in changes[] without throwing', () => {
|
|
116
|
-
const r = validateFGCADoc({ ...VALID_DOC, changes: [null] });
|
|
117
|
-
expect(r.valid).toBe(false);
|
|
118
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
it('[blocker] tolerates a null element in actions[] without throwing', () => {
|
|
121
|
-
const r = validateFGCADoc({ ...VALID_DOC, actions: [null] });
|
|
122
|
-
expect(r.valid).toBe(false);
|
|
123
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _MockResizeObserver_callback;
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
// @vitest-environment jsdom
|
|
15
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
16
|
-
import { render, screen, cleanup, waitFor } from '@testing-library/react';
|
|
17
|
-
import { GoalTreeView, computeDragOutcome } from '../GoalTreeView.js';
|
|
18
|
-
// jsdom has no ResizeObserver / layout engine. reactflow keeps a node's DOM
|
|
19
|
-
// wrapper `visibility: hidden` and excludes it from drag/intersection logic
|
|
20
|
-
// until it has been "measured" via ResizeObserver — so the mock must
|
|
21
|
-
// actually invoke its callback (with the mocked getBoundingClientRect below)
|
|
22
|
-
// for nodes to become interactive, not just satisfy the constructor call.
|
|
23
|
-
class MockResizeObserver {
|
|
24
|
-
constructor(callback) {
|
|
25
|
-
_MockResizeObserver_callback.set(this, void 0);
|
|
26
|
-
__classPrivateFieldSet(this, _MockResizeObserver_callback, callback, "f");
|
|
27
|
-
}
|
|
28
|
-
observe(target) {
|
|
29
|
-
queueMicrotask(() => {
|
|
30
|
-
const rect = target.getBoundingClientRect();
|
|
31
|
-
__classPrivateFieldGet(this, _MockResizeObserver_callback, "f").call(this, [{ target, contentRect: rect }], this);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
unobserve() { }
|
|
35
|
-
disconnect() { }
|
|
36
|
-
}
|
|
37
|
-
_MockResizeObserver_callback = new WeakMap();
|
|
38
|
-
// jsdom also has no DOMMatrixReadOnly, which reactflow's dimension-tracking
|
|
39
|
-
// uses to read the translateX/Y out of a node's computed transform. Only
|
|
40
|
-
// translate() (no scale/rotate) ever appears in this component's own CSS, so
|
|
41
|
-
// a minimal shim covering that one case is enough.
|
|
42
|
-
class MockDOMMatrixReadOnly {
|
|
43
|
-
constructor(transform) {
|
|
44
|
-
this.m41 = 0;
|
|
45
|
-
this.m42 = 0;
|
|
46
|
-
if (!transform || transform === 'none')
|
|
47
|
-
return;
|
|
48
|
-
const t = /translate\((-?[\d.]+)px,\s*(-?[\d.]+)px\)/.exec(transform);
|
|
49
|
-
if (t) {
|
|
50
|
-
this.m41 = Number(t[1]);
|
|
51
|
-
this.m42 = Number(t[2]);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const m = /matrix\(([^)]+)\)/.exec(transform);
|
|
55
|
-
if (m) {
|
|
56
|
-
const parts = m[1].split(',').map((p) => Number(p.trim()));
|
|
57
|
-
this.m41 = parts[4] ?? 0;
|
|
58
|
-
this.m42 = parts[5] ?? 0;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function makeTree() {
|
|
63
|
-
return {
|
|
64
|
-
goal_types: [
|
|
65
|
-
{ name: 'Strategy', level: 0 },
|
|
66
|
-
{ name: 'Business Goal', level: 1 },
|
|
67
|
-
],
|
|
68
|
-
goals: [
|
|
69
|
-
{ id: 1, name: 'Triple revenue', type: 'Strategy', level: 0, parent_id: 0 },
|
|
70
|
-
{ id: 2, name: 'Launch in EU', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
71
|
-
{
|
|
72
|
-
id: 3,
|
|
73
|
-
name: 'Cut churn',
|
|
74
|
-
type: 'Business Goal',
|
|
75
|
-
level: 1,
|
|
76
|
-
parent_id: 1,
|
|
77
|
-
factors: [
|
|
78
|
-
{ id: 10, name: 'Support backlog', impact_type: 'risk' },
|
|
79
|
-
{ id: 11, name: 'New pricing', impact_type: 'opportunity' },
|
|
80
|
-
],
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
global.ResizeObserver = MockResizeObserver;
|
|
87
|
-
window.DOMMatrixReadOnly = MockDOMMatrixReadOnly;
|
|
88
|
-
vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function () {
|
|
89
|
-
// Individual goal cards report their real 250x80 footprint (matters for
|
|
90
|
-
// reactflow's own drag/measurement bookkeeping); the flow container and
|
|
91
|
-
// everything else gets a generously large rect so viewport fitting has
|
|
92
|
-
// room to work with.
|
|
93
|
-
const isNode = this.classList?.contains('react-flow__node');
|
|
94
|
-
const width = isNode ? 250 : 1000;
|
|
95
|
-
const height = isNode ? 80 : 800;
|
|
96
|
-
return {
|
|
97
|
-
width, height, top: 0, left: 0, right: width, bottom: height, x: 0, y: 0,
|
|
98
|
-
toJSON() { return this; },
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
afterEach(() => {
|
|
103
|
-
cleanup();
|
|
104
|
-
vi.restoreAllMocks();
|
|
105
|
-
});
|
|
106
|
-
describe('GoalTreeView', () => {
|
|
107
|
-
it('renders without crashing and shows every canvas goal', async () => {
|
|
108
|
-
render(_jsx(GoalTreeView, { tree: makeTree() }));
|
|
109
|
-
await waitFor(() => {
|
|
110
|
-
expect(screen.getByText('Triple revenue')).toBeTruthy();
|
|
111
|
-
expect(screen.getByText('Launch in EU')).toBeTruthy();
|
|
112
|
-
expect(screen.getByText('Cut churn')).toBeTruthy();
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
it('renders factor indicators from goal.factors', async () => {
|
|
116
|
-
render(_jsx(GoalTreeView, { tree: makeTree() }));
|
|
117
|
-
await waitFor(() => {
|
|
118
|
-
expect(screen.getByText('Triple revenue')).toBeTruthy();
|
|
119
|
-
});
|
|
120
|
-
// One up-caret (opportunity) and one down-caret (risk) on "Cut churn".
|
|
121
|
-
expect(screen.getByLabelText('1 positive factor')).toBeTruthy();
|
|
122
|
-
expect(screen.getByLabelText('1 negative factor')).toBeTruthy();
|
|
123
|
-
});
|
|
124
|
-
it('puts a goal with a broken parent_id in the backlog, not on canvas', async () => {
|
|
125
|
-
const tree = {
|
|
126
|
-
goal_types: [
|
|
127
|
-
{ name: 'Strategy', level: 0 },
|
|
128
|
-
{ name: 'Business Goal', level: 1 },
|
|
129
|
-
],
|
|
130
|
-
goals: [
|
|
131
|
-
{ id: 1, name: 'Root goal', type: 'Strategy', level: 0, parent_id: 0 },
|
|
132
|
-
// level 1 + a parent_id that resolves to nothing — not a root by
|
|
133
|
-
// either "Roots: level === 0 || parent_id === 0" clause, and
|
|
134
|
-
// unreachable from goal 1 — must land in the backlog.
|
|
135
|
-
{ id: 2, name: 'Orphaned goal', type: 'Business Goal', level: 1, parent_id: 999 },
|
|
136
|
-
],
|
|
137
|
-
};
|
|
138
|
-
render(_jsx(GoalTreeView, { tree: tree, showBacklog: true }));
|
|
139
|
-
await waitFor(() => {
|
|
140
|
-
expect(screen.getByText('Root goal')).toBeTruthy();
|
|
141
|
-
});
|
|
142
|
-
expect(screen.getByText('Orphaned goal')).toBeTruthy();
|
|
143
|
-
expect(screen.queryByText('Backlog')).toBeTruthy();
|
|
144
|
-
});
|
|
145
|
-
it('does not render add/delete affordances when readOnly', async () => {
|
|
146
|
-
render(_jsx(GoalTreeView, { tree: makeTree(), readOnly: true }));
|
|
147
|
-
await waitFor(() => {
|
|
148
|
-
expect(screen.getByText('Triple revenue')).toBeTruthy();
|
|
149
|
-
});
|
|
150
|
-
expect(screen.queryByLabelText('Add child goal')).toBeNull();
|
|
151
|
-
expect(screen.queryByLabelText('Delete goal')).toBeNull();
|
|
152
|
-
});
|
|
153
|
-
it('fires onChange with kind "addChild" when the add-child button is clicked', async () => {
|
|
154
|
-
const onChange = vi.fn();
|
|
155
|
-
render(_jsx(GoalTreeView, { tree: makeTree(), onChange: onChange }));
|
|
156
|
-
await waitFor(() => {
|
|
157
|
-
expect(screen.getByText('Triple revenue')).toBeTruthy();
|
|
158
|
-
});
|
|
159
|
-
// Target the root (id 1, level 0) specifically — makeTree()'s goal_types
|
|
160
|
-
// only go up to level 1, so clicking "add child" on an existing level-1
|
|
161
|
-
// goal would be correctly refused (would exceed max level) and never
|
|
162
|
-
// fire onChange at all.
|
|
163
|
-
const rootNode = document.querySelector('.react-flow__node[data-id="1"]');
|
|
164
|
-
const addButton = rootNode.querySelector('[aria-label="Add child goal"]');
|
|
165
|
-
addButton.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
166
|
-
await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
|
|
167
|
-
const event = onChange.mock.calls[0][0];
|
|
168
|
-
expect(event.kind).toBe('addChild');
|
|
169
|
-
if (event.kind === 'addChild') {
|
|
170
|
-
expect(event.result.goals.length).toBe(4);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
it('fires onChange with kind "delete" when the delete button is clicked', async () => {
|
|
174
|
-
const onChange = vi.fn();
|
|
175
|
-
render(_jsx(GoalTreeView, { tree: makeTree(), onChange: onChange }));
|
|
176
|
-
await waitFor(() => {
|
|
177
|
-
expect(screen.getByText('Cut churn')).toBeTruthy();
|
|
178
|
-
});
|
|
179
|
-
const deleteButtons = screen.getAllByLabelText('Delete goal');
|
|
180
|
-
deleteButtons[deleteButtons.length - 1].dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
181
|
-
await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
|
|
182
|
-
const event = onChange.mock.calls[0][0];
|
|
183
|
-
expect(event.kind).toBe('delete');
|
|
184
|
-
});
|
|
185
|
-
it('fires onChange with kind "restoreFromBacklog" when a backlog card is dropped onto a canvas card', async () => {
|
|
186
|
-
const tree = {
|
|
187
|
-
goal_types: [
|
|
188
|
-
{ name: 'Strategy', level: 0 },
|
|
189
|
-
{ name: 'Business Goal', level: 1 },
|
|
190
|
-
],
|
|
191
|
-
goals: [
|
|
192
|
-
{ id: 1, name: 'Root goal', type: 'Strategy', level: 0, parent_id: 0 },
|
|
193
|
-
{ id: 2, name: 'Orphaned goal', type: 'Business Goal', level: 1, parent_id: 999 },
|
|
194
|
-
],
|
|
195
|
-
};
|
|
196
|
-
const onChange = vi.fn();
|
|
197
|
-
render(_jsx(GoalTreeView, { tree: tree, onChange: onChange, showBacklog: true }));
|
|
198
|
-
await waitFor(() => {
|
|
199
|
-
expect(screen.getByText('Orphaned goal')).toBeTruthy();
|
|
200
|
-
});
|
|
201
|
-
// jsdom has no native DataTransfer; stub the minimal setData/getData
|
|
202
|
-
// surface this component's native (non-reactflow) HTML5 drag path uses
|
|
203
|
-
// and attach it directly to the dispatched events.
|
|
204
|
-
const store = new Map();
|
|
205
|
-
const dataTransfer = {
|
|
206
|
-
setData: (k, v) => store.set(k, v),
|
|
207
|
-
getData: (k) => store.get(k) ?? '',
|
|
208
|
-
effectAllowed: 'move',
|
|
209
|
-
};
|
|
210
|
-
function fireDnd(el, type, coords) {
|
|
211
|
-
const event = new Event(type, { bubbles: true, cancelable: true });
|
|
212
|
-
Object.defineProperty(event, 'dataTransfer', { value: dataTransfer });
|
|
213
|
-
Object.assign(event, coords);
|
|
214
|
-
el.dispatchEvent(event);
|
|
215
|
-
}
|
|
216
|
-
const backlogItem = screen.getByText('Orphaned goal').closest('div[draggable]');
|
|
217
|
-
const rootNode = document.querySelector('.react-flow__node[data-id="1"]');
|
|
218
|
-
// jsdom doesn't implement elementFromPoint at all (not just "returns null").
|
|
219
|
-
document.elementFromPoint = vi.fn().mockReturnValue(rootNode);
|
|
220
|
-
fireDnd(backlogItem, 'dragstart', { clientX: 0, clientY: 0 });
|
|
221
|
-
fireDnd(rootNode, 'drop', { clientX: 10, clientY: 10 });
|
|
222
|
-
await waitFor(() => expect(onChange).toHaveBeenCalledTimes(1));
|
|
223
|
-
const event = onChange.mock.calls[0][0];
|
|
224
|
-
expect(event.kind).toBe('restoreFromBacklog');
|
|
225
|
-
if (event.kind === 'restoreFromBacklog') {
|
|
226
|
-
expect(event.id).toBe(2);
|
|
227
|
-
expect(event.newParentId).toBe(1);
|
|
228
|
-
expect(event.result.goals.find((g) => g.id === 2)?.parent_id).toBe(1);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
// Dragging a card is choreographed by reactflow's own pointer/DOM-measurement
|
|
232
|
-
// machinery (ResizeObserver-gated node "readiness", d3-drag pointer capture,
|
|
233
|
-
// viewport transform math) — faithfully simulating that in jsdom means
|
|
234
|
-
// re-implementing reactflow's internals rather than testing this component.
|
|
235
|
-
// computeDragOutcome() is the pure decision GoalTreeView's onNodeDragStop
|
|
236
|
-
// calls once reactflow reports a drag: given where a card was dropped, which
|
|
237
|
-
// mutation fires and what onChange payload it produces. Testing it directly
|
|
238
|
-
// covers the actual reparent/moveToBacklog logic without that DOM coupling.
|
|
239
|
-
describe('computeDragOutcome (reparent / moveToBacklog decision logic)', () => {
|
|
240
|
-
const tree = {
|
|
241
|
-
goal_types: [
|
|
242
|
-
{ name: 'Strategy', level: 0 },
|
|
243
|
-
{ name: 'Business Goal', level: 1 },
|
|
244
|
-
],
|
|
245
|
-
goals: [
|
|
246
|
-
{ id: 1, name: 'Goal A', type: 'Strategy', level: 0, parent_id: 0 },
|
|
247
|
-
{ id: 2, name: 'Goal C', type: 'Strategy', level: 0, parent_id: 0 },
|
|
248
|
-
{ id: 3, name: 'Goal B', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
249
|
-
],
|
|
250
|
-
};
|
|
251
|
-
it('fires a "reparent" change when dropped onto another card', () => {
|
|
252
|
-
const change = computeDragOutcome(tree, 3, { kind: 'node', id: 2 });
|
|
253
|
-
expect(change?.kind).toBe('reparent');
|
|
254
|
-
if (change?.kind === 'reparent') {
|
|
255
|
-
expect(change.sourceId).toBe(3);
|
|
256
|
-
expect(change.targetId).toBe(2);
|
|
257
|
-
expect(change.result.goals.find((g) => g.id === 3)?.parent_id).toBe(2);
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
it('fires a "moveToBacklog" change when dropped on the backlog zone', () => {
|
|
261
|
-
const change = computeDragOutcome(tree, 3, { kind: 'backlog' });
|
|
262
|
-
expect(change?.kind).toBe('moveToBacklog');
|
|
263
|
-
if (change?.kind === 'moveToBacklog') {
|
|
264
|
-
expect(change.id).toBe(3);
|
|
265
|
-
expect(change.result.goals.find((g) => g.id === 3)?.parent_id).toBe(0);
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
it('is a no-op when dropped nowhere in particular', () => {
|
|
269
|
-
expect(computeDragOutcome(tree, 3, null)).toBeNull();
|
|
270
|
-
});
|
|
271
|
-
it('is a no-op when dropped on itself', () => {
|
|
272
|
-
expect(computeDragOutcome(tree, 3, { kind: 'node', id: 3 })).toBeNull();
|
|
273
|
-
});
|
|
274
|
-
it('is a no-op when the reparent would exceed the schema max level', () => {
|
|
275
|
-
// Goal 3 is already level 1 (max); reparenting it under itself-sibling
|
|
276
|
-
// level-1 goal would push it to level 2.
|
|
277
|
-
const deeper = {
|
|
278
|
-
...tree,
|
|
279
|
-
goals: [...tree.goals, { id: 4, name: 'Goal D', type: 'Business Goal', level: 1, parent_id: 1 }],
|
|
280
|
-
};
|
|
281
|
-
expect(computeDragOutcome(deeper, 3, { kind: 'node', id: 4 })).toBeNull();
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
it('fires onFactorClick with the clicked factor when a popover item is clicked', async () => {
|
|
285
|
-
const onFactorClick = vi.fn();
|
|
286
|
-
render(_jsx(GoalTreeView, { tree: makeTree(), onFactorClick: onFactorClick }));
|
|
287
|
-
await waitFor(() => {
|
|
288
|
-
expect(screen.getByText('Cut churn')).toBeTruthy();
|
|
289
|
-
});
|
|
290
|
-
// Open the negative-factor panel on "Cut churn" (id=3, has risk factor "Support backlog")
|
|
291
|
-
const negativeBadge = screen.getByLabelText('1 negative factor');
|
|
292
|
-
negativeBadge.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
293
|
-
// The popover item for the risk factor should now be in the DOM
|
|
294
|
-
const factorItem = await waitFor(() => screen.getByText('Support backlog'));
|
|
295
|
-
factorItem.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
296
|
-
await waitFor(() => expect(onFactorClick).toHaveBeenCalledTimes(1));
|
|
297
|
-
expect(onFactorClick.mock.calls[0][0]).toMatchObject({ id: 10, name: 'Support backlog', impact_type: 'risk' });
|
|
298
|
-
});
|
|
299
|
-
it('backlog panel is collapsible — toggle hides and restores content', async () => {
|
|
300
|
-
const tree = {
|
|
301
|
-
goal_types: [
|
|
302
|
-
{ name: 'Strategy', level: 0 },
|
|
303
|
-
{ name: 'Business Goal', level: 1 },
|
|
304
|
-
],
|
|
305
|
-
goals: [
|
|
306
|
-
{ id: 1, name: 'Root goal', type: 'Strategy', level: 0, parent_id: 0 },
|
|
307
|
-
{ id: 2, name: 'Orphaned goal', type: 'Business Goal', level: 1, parent_id: 999 },
|
|
308
|
-
],
|
|
309
|
-
};
|
|
310
|
-
render(_jsx(GoalTreeView, { tree: tree, showBacklog: true }));
|
|
311
|
-
await waitFor(() => {
|
|
312
|
-
expect(screen.getByText('Backlog')).toBeTruthy();
|
|
313
|
-
});
|
|
314
|
-
// Collapse
|
|
315
|
-
screen.getByLabelText('Collapse backlog').dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
316
|
-
await waitFor(() => {
|
|
317
|
-
expect(screen.queryByText('Backlog')).toBeNull();
|
|
318
|
-
});
|
|
319
|
-
// Expand again
|
|
320
|
-
screen.getByLabelText('Expand backlog').dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
321
|
-
await waitFor(() => {
|
|
322
|
-
expect(screen.getByText('Backlog')).toBeTruthy();
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
it('fires onEditRequest on double-click', async () => {
|
|
326
|
-
const onEditRequest = vi.fn();
|
|
327
|
-
render(_jsx(GoalTreeView, { tree: makeTree(), onEditRequest: onEditRequest }));
|
|
328
|
-
await waitFor(() => {
|
|
329
|
-
expect(screen.getByText('Triple revenue')).toBeTruthy();
|
|
330
|
-
});
|
|
331
|
-
const nodeEl = document.querySelector('.react-flow__node[data-id="1"]');
|
|
332
|
-
expect(nodeEl).toBeTruthy();
|
|
333
|
-
nodeEl.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }));
|
|
334
|
-
await waitFor(() => expect(onEditRequest).toHaveBeenCalledTimes(1));
|
|
335
|
-
expect(onEditRequest.mock.calls[0][0]).toMatchObject({ id: 1, name: 'Triple revenue' });
|
|
336
|
-
});
|
|
337
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|