@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,209 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import * as fs from 'node:fs';
|
|
3
|
-
import * as path from 'node:path';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
import { resolveFGCA, isFGCAViewDoc } from '../resolver.js';
|
|
6
|
-
import { parseCanonicalFGCA } from '../parse-canonical.js';
|
|
7
|
-
|
|
8
|
-
// ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
|
|
9
|
-
|
|
10
|
-
const ELEMENTS = [
|
|
11
|
-
{ notation: 'driver', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
|
|
12
|
-
{ notation: 'driver', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
|
|
13
|
-
{ notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
|
|
14
|
-
{ notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
|
|
15
|
-
{ notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
|
|
16
|
-
{ notation: 'change', id: 'CHANGE-1', name: 'Launch new product line', goals: ['GOAL-1'] },
|
|
17
|
-
{ notation: 'change', id: 'CHANGE-2', name: 'Automate manual processes', goals: ['GOAL-2'] },
|
|
18
|
-
{ notation: 'change', id: 'CHANGE-3', name: 'Enhance support platform', goals: ['GOAL-3'] },
|
|
19
|
-
{ notation: 'activity', id: 'ACTIVITY-1', name: 'Market research', changes: ['CHANGE-1'] },
|
|
20
|
-
{ notation: 'activity', id: 'ACTIVITY-2', name: 'MVP development', changes: ['CHANGE-1'] },
|
|
21
|
-
{ notation: 'activity', id: 'ACTIVITY-3', name: 'Process audit', changes: ['CHANGE-2'] },
|
|
22
|
-
{ notation: 'activity', id: 'ACTIVITY-4', name: 'RPA tooling rollout', changes: ['CHANGE-2'] },
|
|
23
|
-
{ notation: 'activity', id: 'ACTIVITY-5', name: 'CRM implementation', changes: ['CHANGE-3'] },
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
const SOURCES = { elements: ELEMENTS, relations: [] };
|
|
27
|
-
|
|
28
|
-
const VIEW_DOC = {
|
|
29
|
-
notation: 'dgca',
|
|
30
|
-
id: 'FGCA-STRAT-1',
|
|
31
|
-
name: 'Strategy 2026 — FGCA chain',
|
|
32
|
-
spec_version: '0.1',
|
|
33
|
-
view_config: {
|
|
34
|
-
goals: { filter: 'all' },
|
|
35
|
-
factors: { surface: 'derived' },
|
|
36
|
-
changes: { surface: 'derived' },
|
|
37
|
-
activities: { surface: 'derived' },
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// ── isFGCAViewDoc ─────────────────────────────────────────────────────────────
|
|
42
|
-
|
|
43
|
-
describe('isFGCAViewDoc', () => {
|
|
44
|
-
it('returns true for a view_config-based doc', () => {
|
|
45
|
-
expect(isFGCAViewDoc(VIEW_DOC)).toBe(true);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('returns false for an inline doc with factors/goals arrays', () => {
|
|
49
|
-
expect(isFGCAViewDoc({
|
|
50
|
-
notation: 'dgca', id: 'FGCA-1', name: 'x',
|
|
51
|
-
factors: [], goals: [], changes: [], activities: [],
|
|
52
|
-
})).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('returns false for non-objects', () => {
|
|
56
|
-
expect(isFGCAViewDoc(null)).toBe(false);
|
|
57
|
-
expect(isFGCAViewDoc('string')).toBe(false);
|
|
58
|
-
expect(isFGCAViewDoc(42)).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// ── resolveFGCA — goals.filter=all (default) ──────────────────────────────────
|
|
63
|
-
|
|
64
|
-
describe('resolveFGCA — goals.filter=all', () => {
|
|
65
|
-
it('includes all goals, changes, and activities', () => {
|
|
66
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
67
|
-
expect((doc['goals'] as unknown[]).length).toBe(3);
|
|
68
|
-
expect((doc['changes'] as unknown[]).length).toBe(3);
|
|
69
|
-
expect((doc['actions'] as unknown[]).length).toBe(5);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('derives factors from all goal.factors[] refs', () => {
|
|
73
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
74
|
-
const factorIds = (doc['factors'] as Array<{ id: string }>).map((f) => f.id);
|
|
75
|
-
expect(factorIds).toContain('FACTOR-1');
|
|
76
|
-
expect(factorIds).toContain('FACTOR-2');
|
|
77
|
-
expect(factorIds.length).toBe(2);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('passes parseCanonicalFGCA and produces a fully valid internal doc', () => {
|
|
81
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
82
|
-
const r = parseCanonicalFGCA(doc);
|
|
83
|
-
expect(r.valid).toBe(true);
|
|
84
|
-
expect(r.errors).toEqual([]);
|
|
85
|
-
expect(r.parsed?.goals).toHaveLength(3);
|
|
86
|
-
expect(r.parsed?.factors).toHaveLength(2);
|
|
87
|
-
expect(r.parsed?.changes).toHaveLength(3);
|
|
88
|
-
expect(r.parsed?.activities).toHaveLength(5);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('carries view doc metadata (id, name, spec_version)', () => {
|
|
92
|
-
const doc = resolveFGCA(VIEW_DOC, SOURCES);
|
|
93
|
-
expect(doc['notation']).toBe('dgca');
|
|
94
|
-
expect(doc['id']).toBe('FGCA-STRAT-1');
|
|
95
|
-
expect(doc['name']).toBe('Strategy 2026 — FGCA chain');
|
|
96
|
-
expect(doc['spec_version']).toBe('0.1');
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// ── resolveFGCA — goals.filter=ids ────────────────────────────────────────────
|
|
101
|
-
|
|
102
|
-
describe('resolveFGCA — goals.filter=ids', () => {
|
|
103
|
-
it('narrows to the specified goal and its derived changes + activities', () => {
|
|
104
|
-
const viewDoc = {
|
|
105
|
-
...VIEW_DOC,
|
|
106
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
|
|
107
|
-
};
|
|
108
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
109
|
-
const goalIds = (doc['goals'] as Array<{ id: string }>).map((g) => g.id);
|
|
110
|
-
expect(goalIds).toEqual(['GOAL-1']);
|
|
111
|
-
const changeIds = (doc['changes'] as Array<{ id: string }>).map((c) => c.id);
|
|
112
|
-
expect(changeIds).toEqual(['CHANGE-1']);
|
|
113
|
-
const actIds = (doc['actions'] as Array<{ id: string }>).map((a) => a.id).sort();
|
|
114
|
-
expect(actIds).toEqual(['ACTIVITY-1', 'ACTIVITY-2']);
|
|
115
|
-
const r = parseCanonicalFGCA(doc);
|
|
116
|
-
expect(r.valid).toBe(true);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('returns empty arrays when none of the requested ids exist in canon', () => {
|
|
120
|
-
const viewDoc = {
|
|
121
|
-
...VIEW_DOC,
|
|
122
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-NONEXISTENT-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
|
|
123
|
-
};
|
|
124
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
125
|
-
expect((doc['goals'] as unknown[]).length).toBe(0);
|
|
126
|
-
expect((doc['changes'] as unknown[]).length).toBe(0);
|
|
127
|
-
expect((doc['factors'] as unknown[]).length).toBe(0);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// ── resolveFGCA — surface=all ─────────────────────────────────────────────────
|
|
132
|
-
|
|
133
|
-
describe('resolveFGCA — surface=all', () => {
|
|
134
|
-
it('factors.surface=all includes every factor even when only some are referenced', () => {
|
|
135
|
-
const viewDoc = {
|
|
136
|
-
...VIEW_DOC,
|
|
137
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-3'] }, factors: { surface: 'all' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
|
|
138
|
-
};
|
|
139
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
140
|
-
// GOAL-3 only references FACTOR-1, but surface=all → both factors
|
|
141
|
-
expect((doc['factors'] as unknown[]).length).toBe(2);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('changes.surface=all includes every change', () => {
|
|
145
|
-
const viewDoc = {
|
|
146
|
-
...VIEW_DOC,
|
|
147
|
-
view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'all' }, activities: { surface: 'derived' } },
|
|
148
|
-
};
|
|
149
|
-
const doc = resolveFGCA(viewDoc, SOURCES);
|
|
150
|
-
expect((doc['changes'] as unknown[]).length).toBe(3);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// ── resolveFGCA — empty / degenerate inputs ───────────────────────────────────
|
|
155
|
-
|
|
156
|
-
describe('resolveFGCA — empty sources', () => {
|
|
157
|
-
it('returns empty arrays when canon has no elements', () => {
|
|
158
|
-
const doc = resolveFGCA(VIEW_DOC, { elements: [], relations: [] });
|
|
159
|
-
expect((doc['goals'] as unknown[]).length).toBe(0);
|
|
160
|
-
expect((doc['factors'] as unknown[]).length).toBe(0);
|
|
161
|
-
expect((doc['changes'] as unknown[]).length).toBe(0);
|
|
162
|
-
expect((doc['actions'] as unknown[]).length).toBe(0);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('returns empty arrays for a non-object viewDoc', () => {
|
|
166
|
-
const doc = resolveFGCA(null, SOURCES);
|
|
167
|
-
expect((doc['goals'] as unknown[]).length).toBe(0);
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// ── File-based regression — resolver + canon fixture + parseCanonicalFGCA ─────
|
|
172
|
-
|
|
173
|
-
describe('resolveFGCA — file-based regression against canon fixture', () => {
|
|
174
|
-
const CANON_ROOT = path.resolve(
|
|
175
|
-
process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dgca', 'canon',
|
|
176
|
-
);
|
|
177
|
-
const VIEW_DIR = path.join(CANON_ROOT, 'views');
|
|
178
|
-
const ELEM_DIR = path.join(CANON_ROOT, 'elements');
|
|
179
|
-
|
|
180
|
-
function loadYamlsUnder(dir: string): unknown[] {
|
|
181
|
-
if (!fs.existsSync(dir)) return [];
|
|
182
|
-
const out: unknown[] = [];
|
|
183
|
-
function walk(d: string) {
|
|
184
|
-
for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
|
|
185
|
-
const full = path.join(d, entry.name);
|
|
186
|
-
if (entry.isDirectory()) { walk(full); }
|
|
187
|
-
else if (entry.name.endsWith('.yaml')) { out.push(yaml.load(fs.readFileSync(full, 'utf8'))); }
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
walk(dir);
|
|
191
|
-
return out;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const viewFiles = fs.existsSync(VIEW_DIR)
|
|
195
|
-
? fs.readdirSync(VIEW_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
|
|
196
|
-
: [];
|
|
197
|
-
|
|
198
|
-
for (const file of viewFiles) {
|
|
199
|
-
it(`resolves ${file} against canon fixtures and passes parseCanonicalFGCA`, () => {
|
|
200
|
-
const viewDoc = yaml.load(fs.readFileSync(path.join(VIEW_DIR, file), 'utf8'));
|
|
201
|
-
expect(isFGCAViewDoc(viewDoc)).toBe(true);
|
|
202
|
-
const elements = loadYamlsUnder(ELEM_DIR);
|
|
203
|
-
const doc = resolveFGCA(viewDoc, { elements, relations: [] });
|
|
204
|
-
const r = parseCanonicalFGCA(doc);
|
|
205
|
-
expect(r.valid).toBe(true);
|
|
206
|
-
expect(r.errors).toEqual([]);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { validateFGCADoc } from '../validate.js';
|
|
3
|
-
|
|
4
|
-
const VALID_DOC = {
|
|
5
|
-
notation: 'dgca',
|
|
6
|
-
factors: [{ id: 1, name: 'Market pressure' }],
|
|
7
|
-
goals: [{ id: 1, name: 'Grow revenue', factor: [{ id: 1 }] }],
|
|
8
|
-
changes: [{ id: 1, name: 'Launch product', goal_id: 1, activity_ids: [1] }],
|
|
9
|
-
actions: [{ id: 1, name: 'Market research', goal_id: 1 }],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
describe('validateFGCADoc', () => {
|
|
13
|
-
it('accepts a valid document', () => {
|
|
14
|
-
const result = validateFGCADoc(VALID_DOC);
|
|
15
|
-
expect(result.valid).toBe(true);
|
|
16
|
-
expect(result.errors).toHaveLength(0);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('rejects non-object input', () => {
|
|
20
|
-
expect(validateFGCADoc('string').valid).toBe(false);
|
|
21
|
-
expect(validateFGCADoc(null).valid).toBe(false);
|
|
22
|
-
expect(validateFGCADoc(42).valid).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('errors on missing notation field', () => {
|
|
26
|
-
const { notation: _, ...without } = VALID_DOC;
|
|
27
|
-
const result = validateFGCADoc(without);
|
|
28
|
-
expect(result.valid).toBe(false);
|
|
29
|
-
expect(result.errors[0].code).toBe('MISSING_NOTATION');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('errors on wrong notation value', () => {
|
|
33
|
-
const result = validateFGCADoc({ ...VALID_DOC, notation: 'goals' });
|
|
34
|
-
expect(result.valid).toBe(false);
|
|
35
|
-
expect(result.errors[0].code).toBe('WRONG_NOTATION');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('errors when factors array is missing', () => {
|
|
39
|
-
const { factors: _, ...without } = VALID_DOC;
|
|
40
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
41
|
-
expect(result.valid).toBe(false);
|
|
42
|
-
expect(result.errors.some(e => e.path === 'factors')).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('errors when goals array is missing', () => {
|
|
46
|
-
const { goals: _, ...without } = VALID_DOC;
|
|
47
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
48
|
-
expect(result.valid).toBe(false);
|
|
49
|
-
expect(result.errors.some(e => e.path === 'goals')).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('errors when changes array is missing', () => {
|
|
53
|
-
const { changes: _, ...without } = VALID_DOC;
|
|
54
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
55
|
-
expect(result.valid).toBe(false);
|
|
56
|
-
expect(result.errors.some(e => e.path === 'changes')).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('errors when actions array is missing', () => {
|
|
60
|
-
const { actions: _, ...without } = VALID_DOC;
|
|
61
|
-
const result = validateFGCADoc({ ...without, notation: 'dgca' });
|
|
62
|
-
expect(result.valid).toBe(false);
|
|
63
|
-
expect(result.errors.some(e => e.path === 'actions')).toBe(true);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('errors on empty factor name', () => {
|
|
67
|
-
const result = validateFGCADoc({ ...VALID_DOC, factors: [{ id: 1, name: '' }] });
|
|
68
|
-
expect(result.valid).toBe(false);
|
|
69
|
-
expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('errors on empty goal name', () => {
|
|
73
|
-
const result = validateFGCADoc({ ...VALID_DOC, goals: [{ id: 1, name: ' ', factor: [] }] });
|
|
74
|
-
expect(result.valid).toBe(false);
|
|
75
|
-
expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('warns on broken factor reference in goal', () => {
|
|
79
|
-
const result = validateFGCADoc({
|
|
80
|
-
...VALID_DOC,
|
|
81
|
-
goals: [{ id: 1, name: 'Goal', factor: [{ id: 99 }] }],
|
|
82
|
-
});
|
|
83
|
-
expect(result.valid).toBe(true);
|
|
84
|
-
expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('factor 99'))).toBe(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('warns on broken goal reference in change', () => {
|
|
88
|
-
const result = validateFGCADoc({
|
|
89
|
-
...VALID_DOC,
|
|
90
|
-
changes: [{ id: 1, name: 'Change', goal_id: 99, activity_ids: [] }],
|
|
91
|
-
});
|
|
92
|
-
expect(result.valid).toBe(true);
|
|
93
|
-
expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('goal 99'))).toBe(true);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('warns on broken activity reference in change', () => {
|
|
97
|
-
const result = validateFGCADoc({
|
|
98
|
-
...VALID_DOC,
|
|
99
|
-
changes: [{ id: 1, name: 'Change', goal_id: 1, activity_ids: [99] }],
|
|
100
|
-
});
|
|
101
|
-
expect(result.valid).toBe(true);
|
|
102
|
-
expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('activity 99'))).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('accepts a document with empty arrays', () => {
|
|
106
|
-
const result = validateFGCADoc({
|
|
107
|
-
notation: 'dgca',
|
|
108
|
-
factors: [],
|
|
109
|
-
goals: [],
|
|
110
|
-
changes: [],
|
|
111
|
-
actions: [],
|
|
112
|
-
});
|
|
113
|
-
expect(result.valid).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('accepts optional spec_version field', () => {
|
|
117
|
-
const result = validateFGCADoc({ ...VALID_DOC, spec_version: '0.1' });
|
|
118
|
-
expect(result.valid).toBe(true);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// Pre-release blocker regression (orchestrator review 2026-05-21).
|
|
122
|
-
it('[blocker] tolerates a null element in goals[] without throwing', () => {
|
|
123
|
-
const r = validateFGCADoc({ ...VALID_DOC, goals: [null] });
|
|
124
|
-
expect(r.valid).toBe(false);
|
|
125
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
126
|
-
});
|
|
127
|
-
it('[blocker] tolerates a string element in factors[] without throwing', () => {
|
|
128
|
-
const r = validateFGCADoc({ ...VALID_DOC, factors: ['x'] });
|
|
129
|
-
expect(r.valid).toBe(false);
|
|
130
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
131
|
-
});
|
|
132
|
-
it('[blocker] tolerates a null element in changes[] without throwing', () => {
|
|
133
|
-
const r = validateFGCADoc({ ...VALID_DOC, changes: [null] });
|
|
134
|
-
expect(r.valid).toBe(false);
|
|
135
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
136
|
-
});
|
|
137
|
-
it('[blocker] tolerates a null element in actions[] without throwing', () => {
|
|
138
|
-
const r = validateFGCADoc({ ...VALID_DOC, actions: [null] });
|
|
139
|
-
expect(r.valid).toBe(false);
|
|
140
|
-
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
141
|
-
});
|
|
142
|
-
});
|