@principal-ai/subsystems-react 0.56.24 → 0.56.25
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/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts +4 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.d.ts.map +1 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.js +189 -0
- package/dist/stories/Canvases/Subsystem/issuesFixtures.js.map +1 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts +8 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.d.ts.map +1 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.js +103 -0
- package/dist/stories/Canvases/Subsystem/reorderFixtures.js.map +1 -0
- package/dist/subsystem/C4ContainersPanel.d.ts +35 -0
- package/dist/subsystem/C4ContainersPanel.d.ts.map +1 -0
- package/dist/subsystem/C4ContainersPanel.js +165 -0
- package/dist/subsystem/C4ContainersPanel.js.map +1 -0
- package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
- package/dist/subsystem/C4NodeCard.js +10 -4
- package/dist/subsystem/C4NodeCard.js.map +1 -1
- package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
- package/dist/subsystem/C4ProjectionView.js +81 -27
- package/dist/subsystem/C4ProjectionView.js.map +1 -1
- package/dist/subsystem/C4SketchView.d.ts.map +1 -1
- package/dist/subsystem/C4SketchView.js +53 -34
- package/dist/subsystem/C4SketchView.js.map +1 -1
- package/dist/subsystem/DescriptionOverlay.d.ts +10 -2
- package/dist/subsystem/DescriptionOverlay.d.ts.map +1 -1
- package/dist/subsystem/DescriptionOverlay.js +4 -4
- package/dist/subsystem/DescriptionOverlay.js.map +1 -1
- package/dist/subsystem/DescriptionPreview.d.ts +31 -0
- package/dist/subsystem/DescriptionPreview.d.ts.map +1 -0
- package/dist/subsystem/DescriptionPreview.js +31 -0
- package/dist/subsystem/DescriptionPreview.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +3 -19
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.d.ts.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.js +1 -0
- package/dist/subsystem/__fixtures__/c4Sketch.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +27 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js +312 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -0
- package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +777 -0
- package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +886 -0
- package/dist/subsystem/c4Sketch.d.ts +12 -0
- package/dist/subsystem/c4Sketch.d.ts.map +1 -1
- package/dist/subsystem/c4Sketch.js +2 -1
- package/dist/subsystem/c4Sketch.js.map +1 -1
- package/dist/subsystem/containerCard.d.ts +3 -1
- package/dist/subsystem/containerCard.d.ts.map +1 -1
- package/dist/subsystem/containerCard.js +2 -2
- package/dist/subsystem/containerCard.js.map +1 -1
- package/dist/subsystem/techIcons/index.d.ts +3 -1
- package/dist/subsystem/techIcons/index.d.ts.map +1 -1
- package/dist/subsystem/techIcons/index.js +2 -2
- package/dist/subsystem/techIcons/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/stories/Canvases/C4/C4CardGrow.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Component.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Container.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Draft.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4NodeGallery.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Sketch.stories.tsx +56 -4
- package/src/stories/Canvases/C4/C4ToComponentDrill.stories.tsx +1 -1
- package/src/stories/Canvases/C4/C4Transition.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/AnimatedProgression.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Appearance.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Basics.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Captures.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Constructs.stories.tsx +3 -7
- package/src/stories/Canvases/Subsystem/ConstructsEmbed.stories.tsx +27 -0
- package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +2 -100
- package/src/stories/Canvases/Subsystem/DeprecatedGraph.stories.tsx +124 -0
- package/src/stories/Canvases/Subsystem/DetailPanel.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Diagnostics.stories.tsx +1 -43
- package/src/stories/Canvases/Subsystem/DiagnosticsStates.stories.tsx +63 -0
- package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/FrameworkStereotype.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/GraphTitle.stories.tsx +1 -19
- package/src/stories/Canvases/Subsystem/GraphTitleGraph.stories.tsx +51 -0
- package/src/stories/Canvases/Subsystem/Issues.stories.tsx +3 -228
- package/src/stories/Canvases/Subsystem/IssuesList.stories.tsx +60 -0
- package/src/stories/Canvases/Subsystem/LayoutDirection.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +3 -61
- package/src/stories/Canvases/Subsystem/ModuleBadgesNode.stories.tsx +81 -0
- package/src/stories/Canvases/Subsystem/ModulePathNesting.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Modules.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Packages.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Presentation.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Processes.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +3 -153
- package/src/stories/Canvases/Subsystem/ReorderPanel.stories.tsx +75 -0
- package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/StepEmphasis.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/StoreValueType.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/TrailSidebarViews.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/Trails.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/WorkspacePackageFrames.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/issuesFixtures.ts +192 -0
- package/src/stories/Canvases/Subsystem/reorderFixtures.tsx +125 -0
- package/src/subsystem/C4ContainersPanel.test.tsx +151 -0
- package/src/subsystem/C4ContainersPanel.tsx +315 -0
- package/src/subsystem/C4NodeCard.tsx +12 -4
- package/src/subsystem/C4ProjectionView.tsx +107 -37
- package/src/subsystem/C4SketchView.tsx +96 -74
- package/src/subsystem/DescriptionOverlay.test.tsx +2 -0
- package/src/subsystem/DescriptionOverlay.tsx +20 -5
- package/src/subsystem/DescriptionPreview.tsx +96 -0
- package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +1 -1
- package/src/subsystem/SubsystemComponentGraph.tsx +14 -43
- package/src/subsystem/__fixtures__/c4Sketch.ts +2 -0
- package/src/subsystem/__fixtures__/c4SketchGallery.test.ts +65 -0
- package/src/subsystem/__fixtures__/c4SketchGallery.ts +351 -0
- package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +777 -0
- package/src/subsystem/__fixtures__/c4Sketches/openbot.json +886 -0
- package/src/subsystem/c4Sketch.ts +13 -0
- package/src/subsystem/containerCard.tsx +4 -1
- package/src/subsystem/techIcons/index.tsx +11 -2
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { SubsystemIssue } from '../../../subsystem/IssueList';
|
|
2
|
+
|
|
3
|
+
export const ISSUES: SubsystemIssue[] = [
|
|
4
|
+
{
|
|
5
|
+
id: 'i1',
|
|
6
|
+
severity: 'error',
|
|
7
|
+
kind: 'missing_file',
|
|
8
|
+
message: 'File src/checkout/cartStore.ts is not present on disk (repo pkg:github/you/your-app).',
|
|
9
|
+
target: { kind: 'component', id: 'store', label: 'cartStore' },
|
|
10
|
+
fix: { label: 'Use graphify file' },
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'i2',
|
|
14
|
+
severity: 'error',
|
|
15
|
+
kind: 'construct_mismatch',
|
|
16
|
+
message: 'Claimed function but graphify infers class.',
|
|
17
|
+
target: { kind: 'component', id: 'entry', label: 'checkoutApi' },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: 'i3',
|
|
21
|
+
severity: 'info',
|
|
22
|
+
kind: 'signature_unconfirmed',
|
|
23
|
+
message: 'Named parameter types are not present in the graphify cache.',
|
|
24
|
+
target: { kind: 'component', id: 'entry', label: 'checkoutApi' },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'i5',
|
|
28
|
+
severity: 'info',
|
|
29
|
+
kind: 'boundary_module_file_mismatch',
|
|
30
|
+
message: 'Module "src/checkout" contains a file outside its declared root.',
|
|
31
|
+
target: { kind: 'module', id: 'src/checkout', label: 'src/checkout' },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'i6',
|
|
35
|
+
severity: 'info',
|
|
36
|
+
kind: 'trail',
|
|
37
|
+
message: 'Step 2 references a line that moved (was :42).',
|
|
38
|
+
target: {
|
|
39
|
+
kind: 'step',
|
|
40
|
+
id: 'story-steps',
|
|
41
|
+
label: 'Story steps',
|
|
42
|
+
detail: 'step 2',
|
|
43
|
+
stepIndex: 1,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'i20',
|
|
48
|
+
severity: 'error',
|
|
49
|
+
kind: 'step_span_unconfirmed',
|
|
50
|
+
message: 'Trail "Story steps" step 1: step span not captured (entry → store via writes)',
|
|
51
|
+
target: {
|
|
52
|
+
kind: 'step',
|
|
53
|
+
id: 'story-steps',
|
|
54
|
+
label: 'Story steps',
|
|
55
|
+
detail: 'step 1',
|
|
56
|
+
stepIndex: 0,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'i21',
|
|
61
|
+
severity: 'info',
|
|
62
|
+
kind: 'step_span_stale',
|
|
63
|
+
message: 'Trail "Story steps" step 2: step span changed since verification (lines 42-44 in src/checkout/api.ts)',
|
|
64
|
+
target: {
|
|
65
|
+
kind: 'step',
|
|
66
|
+
id: 'story-steps',
|
|
67
|
+
label: 'Story steps',
|
|
68
|
+
detail: 'step 2',
|
|
69
|
+
stepIndex: 1,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'i7',
|
|
74
|
+
severity: 'info',
|
|
75
|
+
kind: 'boundary_process_nest_disagree',
|
|
76
|
+
message:
|
|
77
|
+
'module "src/host/main.ts" members claim different processes: "host", "renderer"',
|
|
78
|
+
target: { kind: 'module', id: 'src/host/main.ts', label: 'src/host/main.ts' },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'i17',
|
|
82
|
+
severity: 'error',
|
|
83
|
+
kind: 'symbol_ambiguous',
|
|
84
|
+
message: 'Multiple Graphify nodes match readSession (3 candidates)',
|
|
85
|
+
target: { kind: 'component', id: 'session-reader', label: 'SessionReader' },
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'i18',
|
|
89
|
+
severity: 'error',
|
|
90
|
+
kind: 'symbol_unmatched',
|
|
91
|
+
message: 'No Graphify node matches symbol persistSession in src/session/SessionStore.ts',
|
|
92
|
+
target: { kind: 'component', id: 'session-store', label: 'SessionStore' },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'i9',
|
|
96
|
+
severity: 'info',
|
|
97
|
+
kind: 'construct_span_stale',
|
|
98
|
+
message: 'Declaration moved since capture — recorded start line 42, now 57.',
|
|
99
|
+
target: { kind: 'component', id: 'session-store', label: 'SessionStore' },
|
|
100
|
+
fix: { label: 'Re-pin declaration' },
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'i10',
|
|
104
|
+
severity: 'info',
|
|
105
|
+
kind: 'construct_unconfirmed',
|
|
106
|
+
message: 'Graphify anchored the node but left the construct unclassified (interface vs type alias).',
|
|
107
|
+
target: { kind: 'component', id: 'host-info', label: 'HostInfo' },
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'i22',
|
|
111
|
+
severity: 'error',
|
|
112
|
+
kind: 'construct_span_unconfirmed',
|
|
113
|
+
message: 'HostInfo has no captured source span — its declaration extent is unpinned until an agent proposes start/end lines.',
|
|
114
|
+
target: { kind: 'component', id: 'host-info', label: 'HostInfo' },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'i11',
|
|
118
|
+
severity: 'error',
|
|
119
|
+
kind: 'signature_mismatch',
|
|
120
|
+
message: 'Claimed (req: HostInfo) => Session; Graphify has (string) => void.',
|
|
121
|
+
target: { kind: 'component', id: 'entry', label: 'checkoutApi' },
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'i13',
|
|
125
|
+
severity: 'info',
|
|
126
|
+
kind: 'repo_unresolved',
|
|
127
|
+
message: 'Repo pkg:github/acme/worker is not available locally — clone it to verify its components',
|
|
128
|
+
target: { kind: 'repo', id: 'pkg:github/acme/worker', label: 'pkg:github/acme/worker' },
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'i19',
|
|
132
|
+
severity: 'info',
|
|
133
|
+
kind: 'graphify_unavailable',
|
|
134
|
+
message: 'Graphify cache missing for pkg:github/you/your-app — build it to verify constructs and anchors',
|
|
135
|
+
target: { kind: 'repo', id: 'pkg:github/you/your-app', label: 'pkg:github/you/your-app' },
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
|
|
139
|
+
export const TRAIL_STEP_ISSUES: SubsystemIssue[] = [
|
|
140
|
+
{
|
|
141
|
+
id: 'ts1',
|
|
142
|
+
severity: 'info',
|
|
143
|
+
kind: 'step_span_unconfirmed',
|
|
144
|
+
message: 'Trail "Add to Cart" step 1: call site not verified (addToCart → cartStore via writes)',
|
|
145
|
+
target: {
|
|
146
|
+
kind: 'step',
|
|
147
|
+
id: 'add-to-cart',
|
|
148
|
+
label: 'Add to Cart',
|
|
149
|
+
detail: 'step 1',
|
|
150
|
+
stepIndex: 0,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'ts2',
|
|
155
|
+
severity: 'info',
|
|
156
|
+
kind: 'step_span_unconfirmed',
|
|
157
|
+
message: 'Trail "Add to Cart" step 2: call site not verified (cartStore → inventoryService via calls)',
|
|
158
|
+
target: {
|
|
159
|
+
kind: 'step',
|
|
160
|
+
id: 'add-to-cart',
|
|
161
|
+
label: 'Add to Cart',
|
|
162
|
+
detail: 'step 2',
|
|
163
|
+
stepIndex: 1,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: 'ts3',
|
|
168
|
+
severity: 'info',
|
|
169
|
+
kind: 'step_span_stale',
|
|
170
|
+
message: 'Trail "Checkout" step 1: call site changed since verification (lines 42-44 in src/checkout/api.ts)',
|
|
171
|
+
target: {
|
|
172
|
+
kind: 'step',
|
|
173
|
+
id: 'checkout',
|
|
174
|
+
label: 'Checkout',
|
|
175
|
+
detail: 'step 1',
|
|
176
|
+
stepIndex: 0,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 'ts4',
|
|
181
|
+
severity: 'info',
|
|
182
|
+
kind: 'step_span_stale',
|
|
183
|
+
message: 'Trail "Checkout" step 3: call site changed since verification (lines 78-82 in src/checkout/api.ts)',
|
|
184
|
+
target: {
|
|
185
|
+
kind: 'step',
|
|
186
|
+
id: 'checkout',
|
|
187
|
+
label: 'Checkout',
|
|
188
|
+
detail: 'step 3',
|
|
189
|
+
stepIndex: 2,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
];
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SubsystemComponent,
|
|
3
|
+
SubsystemTrail,
|
|
4
|
+
SubsystemTrailMechanism,
|
|
5
|
+
SubsystemTrailStep,
|
|
6
|
+
} from '../../../subsystem/model';
|
|
7
|
+
|
|
8
|
+
/** One authored trail step; `line` becomes the seam span the viewers read. */
|
|
9
|
+
function step(
|
|
10
|
+
from: string,
|
|
11
|
+
to: string,
|
|
12
|
+
mechanism: SubsystemTrailMechanism,
|
|
13
|
+
file: string,
|
|
14
|
+
line: number,
|
|
15
|
+
symbol: string,
|
|
16
|
+
): SubsystemTrailStep {
|
|
17
|
+
return {
|
|
18
|
+
from,
|
|
19
|
+
to,
|
|
20
|
+
mechanism,
|
|
21
|
+
file,
|
|
22
|
+
span: { startLine: line, endLine: line, contentHash: 'fixture' },
|
|
23
|
+
purl: `pkg:github/storybook/fixture#${file}`,
|
|
24
|
+
symbol,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const components: SubsystemComponent[] = [
|
|
29
|
+
{
|
|
30
|
+
alias: 'panel',
|
|
31
|
+
name: 'DrawingsLeftPanel',
|
|
32
|
+
construct: 'class',
|
|
33
|
+
file: 'src/panels/DrawingsLeftPanel.tsx',
|
|
34
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
35
|
+
purpose: 'lists drawings; emits open/delete intents',
|
|
36
|
+
symbol: 'DrawingsLeftPanel',
|
|
37
|
+
process: 'draw-list',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
alias: 'host',
|
|
41
|
+
name: 'useDrawingsHost',
|
|
42
|
+
construct: 'function',
|
|
43
|
+
file: 'src/hooks/useDrawingsHost.ts',
|
|
44
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
45
|
+
purpose: 'hosts drawing CRUD; dispatches to storage and shell',
|
|
46
|
+
symbol: 'useDrawingsHost',
|
|
47
|
+
process: 'draw-list',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
alias: 'storage',
|
|
51
|
+
name: 'DrawingsStorage',
|
|
52
|
+
construct: 'class',
|
|
53
|
+
file: 'src/storage/drawingsStorage.ts',
|
|
54
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
55
|
+
purpose: 'persists drawings as files',
|
|
56
|
+
symbol: 'DrawingsStorage',
|
|
57
|
+
process: 'draw-host',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
alias: 'fs',
|
|
61
|
+
name: 'FileSystemService',
|
|
62
|
+
construct: 'external',
|
|
63
|
+
file: 'src/services/fileSystem.ts',
|
|
64
|
+
purl: 'pkg:github/principal-ai/desktop-app',
|
|
65
|
+
purpose: 'sandboxed host fd/fs access',
|
|
66
|
+
symbol: 'FileSystemService',
|
|
67
|
+
role: 'service',
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export const initialTrails: SubsystemTrail[] = [
|
|
72
|
+
{
|
|
73
|
+
id: 'tl-open-drawing',
|
|
74
|
+
title: 'Open drawing',
|
|
75
|
+
steps: [
|
|
76
|
+
step('panel', 'storage', 'calls', 'src/panels/DrawingsLeftPanel.tsx', 56, 'DrawingsLeftPanel.scan'),
|
|
77
|
+
step('panel', 'host', 'produces', 'src/panels/DrawingsLeftPanel.tsx', 85, 'DrawingsLeftPanel.openDrawing'),
|
|
78
|
+
step('host', 'storage', 'calls', 'src/hooks/useDrawingsHost.ts', 45, 'useDrawingsHost.openDrawing'),
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'tl-save-drawing',
|
|
83
|
+
title: 'Save drawing',
|
|
84
|
+
steps: [
|
|
85
|
+
step('host', 'storage', 'calls', 'src/hooks/useDrawingsHost.ts', 64, 'useDrawingsHost.saveDrawing'),
|
|
86
|
+
step('storage', 'fs', 'calls', 'src/storage/drawingsStorage.ts', 90, 'DrawingsStorage.write'),
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'tl-delete-drawing',
|
|
91
|
+
title: 'Delete drawing',
|
|
92
|
+
steps: [
|
|
93
|
+
step('host', 'fs', 'calls', 'src/hooks/useDrawingsHost.ts', 66, 'useDrawingsHost.deleteDrawing'),
|
|
94
|
+
step('host', 'panel', 'produces', 'src/hooks/useDrawingsHost.ts', 64, 'useDrawingsHost.refreshList'),
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'tl-refresh-list',
|
|
99
|
+
title: 'Refresh list',
|
|
100
|
+
steps: [
|
|
101
|
+
step('panel', 'storage', 'calls', 'src/panels/DrawingsLeftPanel.tsx', 56, 'DrawingsLeftPanel.scan'),
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const orderLabel = (list: SubsystemTrail[]) => list.map((w) => w.title).join(' → ');
|
|
107
|
+
|
|
108
|
+
export function OrderHeader({ list }: { list: SubsystemTrail[] }) {
|
|
109
|
+
return (
|
|
110
|
+
<div
|
|
111
|
+
style={{
|
|
112
|
+
padding: '8px 12px',
|
|
113
|
+
borderBottom: '1px solid #2a2a2a',
|
|
114
|
+
fontFamily: 'monospace',
|
|
115
|
+
fontSize: 12,
|
|
116
|
+
color: '#9aa4b2',
|
|
117
|
+
whiteSpace: 'nowrap',
|
|
118
|
+
overflow: 'hidden',
|
|
119
|
+
textOverflow: 'ellipsis',
|
|
120
|
+
}}
|
|
121
|
+
>
|
|
122
|
+
array order: {orderLabel(list)}
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { Window } from 'happy-dom';
|
|
4
|
+
import { cleanup, fireEvent, render } from '@testing-library/react/pure';
|
|
5
|
+
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
6
|
+
import { C4ContainersPanel, type C4ContainerListItem } from './C4ContainersPanel';
|
|
7
|
+
|
|
8
|
+
// Bun's happy-dom test environment isn't registered (no @happy-dom/global-
|
|
9
|
+
// registrator), so wire the DOM primitives React DOM needs before rendering.
|
|
10
|
+
const dom = new Window();
|
|
11
|
+
const globals = globalThis as unknown as Record<string, unknown>;
|
|
12
|
+
globals.window = dom;
|
|
13
|
+
globals.document = dom.document;
|
|
14
|
+
globals.navigator = dom.navigator;
|
|
15
|
+
globals.HTMLElement = dom.HTMLElement;
|
|
16
|
+
globals.customElements = dom.customElements;
|
|
17
|
+
globals.Node = dom.Node;
|
|
18
|
+
globals.Element = dom.Element;
|
|
19
|
+
globals.Event = dom.Event;
|
|
20
|
+
globals.getComputedStyle = dom.getComputedStyle.bind(dom);
|
|
21
|
+
globals.requestAnimationFrame = dom.requestAnimationFrame.bind(dom);
|
|
22
|
+
globals.cancelAnimationFrame = dom.cancelAnimationFrame.bind(dom);
|
|
23
|
+
globals.localStorage = dom.localStorage;
|
|
24
|
+
globals.matchMedia = dom.matchMedia.bind(dom);
|
|
25
|
+
|
|
26
|
+
afterEach(cleanup);
|
|
27
|
+
|
|
28
|
+
const ITEMS: C4ContainerListItem[] = [
|
|
29
|
+
{
|
|
30
|
+
container: {
|
|
31
|
+
kind: 'container',
|
|
32
|
+
id: 'container:host',
|
|
33
|
+
label: 'Host',
|
|
34
|
+
containerKind: 'application',
|
|
35
|
+
technology: 'Bun',
|
|
36
|
+
state: 'accepted',
|
|
37
|
+
},
|
|
38
|
+
open: false,
|
|
39
|
+
members: [
|
|
40
|
+
{
|
|
41
|
+
kind: 'component',
|
|
42
|
+
id: 'component:host-api',
|
|
43
|
+
label: 'Host API',
|
|
44
|
+
container: 'container:host',
|
|
45
|
+
technology: 'Bun',
|
|
46
|
+
state: 'accepted',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
container: {
|
|
52
|
+
kind: 'container',
|
|
53
|
+
id: 'container:store',
|
|
54
|
+
label: 'Session store',
|
|
55
|
+
containerKind: 'data-store',
|
|
56
|
+
technology: 'SQLite',
|
|
57
|
+
state: 'proposed',
|
|
58
|
+
},
|
|
59
|
+
open: true,
|
|
60
|
+
members: [],
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
function renderPanel(items: C4ContainerListItem[], handlers = {}) {
|
|
65
|
+
const props = {
|
|
66
|
+
containers: items,
|
|
67
|
+
activeId: null,
|
|
68
|
+
onActivate: () => {},
|
|
69
|
+
onSelect: () => {},
|
|
70
|
+
onOpenAll: () => {},
|
|
71
|
+
onCloseAll: () => {},
|
|
72
|
+
...handlers,
|
|
73
|
+
};
|
|
74
|
+
return render(
|
|
75
|
+
createElement(
|
|
76
|
+
ThemeProvider,
|
|
77
|
+
{ theme: defaultEditorTheme },
|
|
78
|
+
createElement(C4ContainersPanel as never, props as never),
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
describe('C4ContainersPanel', () => {
|
|
84
|
+
test('lists every container and its state', () => {
|
|
85
|
+
const view = renderPanel(ITEMS);
|
|
86
|
+
expect(view.getByText('2 containers')).toBeTruthy();
|
|
87
|
+
expect(view.getByText('Host')).toBeTruthy();
|
|
88
|
+
expect(view.getByText('Session store')).toBeTruthy();
|
|
89
|
+
expect(view.getByText('proposed')).toBeTruthy();
|
|
90
|
+
expect(view.queryByText('Host API')).toBeNull();
|
|
91
|
+
const row = view.getByText('Host').closest('li');
|
|
92
|
+
expect(row?.className).toContain('c4-containers-row');
|
|
93
|
+
expect(row?.hasAttribute('title')).toBe(false);
|
|
94
|
+
expect(row?.querySelector('button')?.hasAttribute('title')).toBe(false);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('an open container lists its components', () => {
|
|
98
|
+
const view = renderPanel([{ ...ITEMS[0]!, open: true }]);
|
|
99
|
+
expect(view.getByText('Host API')).toBeTruthy();
|
|
100
|
+
expect(view.queryByText('No components')).toBeNull();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('activating a row opens/frames that container', () => {
|
|
104
|
+
const activated: string[] = [];
|
|
105
|
+
const view = renderPanel(ITEMS, { onActivate: (id: string) => activated.push(id) });
|
|
106
|
+
fireEvent.click(view.getByRole('button', { name: /^Host/ }));
|
|
107
|
+
expect(activated).toEqual(['container:host']);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('rows with members are dropdowns; empty rows are select-only', () => {
|
|
111
|
+
const view = renderPanel(ITEMS);
|
|
112
|
+
const closed = view.getByRole('button', { name: /^Host/ });
|
|
113
|
+
expect(closed.getAttribute('aria-expanded')).toBe('false');
|
|
114
|
+
const empty = view.getByRole('button', { name: /^Session store/ });
|
|
115
|
+
expect(empty.hasAttribute('aria-expanded')).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('selecting an empty container frames it without toggling', () => {
|
|
119
|
+
let selected = '';
|
|
120
|
+
let activated = 0;
|
|
121
|
+
const view = renderPanel(ITEMS, {
|
|
122
|
+
onSelect: (id: string) => {
|
|
123
|
+
selected = id;
|
|
124
|
+
},
|
|
125
|
+
onActivate: () => {
|
|
126
|
+
activated += 1;
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
fireEvent.click(view.getByRole('button', { name: /^Session store/ }));
|
|
130
|
+
expect(selected).toBe('container:store');
|
|
131
|
+
expect(activated).toBe(0);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('bulk controls reflect the open set and invoke their handlers', () => {
|
|
135
|
+
const opened: string[] = [];
|
|
136
|
+
const closed: string[] = [];
|
|
137
|
+
const view = renderPanel(ITEMS, {
|
|
138
|
+
onOpenAll: () => opened.push('open'),
|
|
139
|
+
onCloseAll: () => closed.push('close'),
|
|
140
|
+
});
|
|
141
|
+
fireEvent.click(view.getByRole('button', { name: 'Open all' }));
|
|
142
|
+
fireEvent.click(view.getByRole('button', { name: 'Close all' }));
|
|
143
|
+
expect(opened).toEqual(['open']);
|
|
144
|
+
expect(closed).toEqual(['close']);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
test('an empty model says so instead of drawing an empty list', () => {
|
|
148
|
+
const view = renderPanel([]);
|
|
149
|
+
expect(view.getByText('No containers.')).toBeTruthy();
|
|
150
|
+
});
|
|
151
|
+
});
|