@principal-ai/subsystems-react 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -85
- package/dist/index.d.ts +7 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -32
- package/dist/index.js.map +1 -1
- package/dist/subsystem/SubsystemCarousel.d.ts +36 -0
- package/dist/subsystem/SubsystemCarousel.d.ts.map +1 -0
- package/dist/subsystem/SubsystemCarousel.js +163 -0
- package/dist/subsystem/SubsystemCarousel.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts +25 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +329 -68
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +9 -199
- package/src/subsystem/SubsystemComponentGraph.tsx +396 -50
- package/src/components/ConfigurationSelector.tsx +0 -133
- package/src/components/GraphRenderer.tsx +0 -3195
- package/src/components/MultiCanvasRenderer.tsx +0 -295
- package/src/components/NodeTooltip.tsx +0 -279
- package/src/components/PendingChanges.test.tsx +0 -375
- package/src/components/SelectionSidebar.tsx +0 -352
- package/src/components/SequenceDiagramRenderer.tsx +0 -1156
- package/src/components/WorkflowSequenceDiagram.tsx +0 -270
- package/src/components/dashboard/DashboardRenderer.tsx +0 -317
- package/src/components/dashboard/MetricPanel.tsx +0 -254
- package/src/components/dashboard/MockDataProvider.ts +0 -330
- package/src/components/dashboard/components/BarChart.tsx +0 -299
- package/src/components/dashboard/components/LineChart.tsx +0 -279
- package/src/components/dashboard/components/MetricCard.tsx +0 -270
- package/src/components/dashboard/components/SourceLink.tsx +0 -63
- package/src/components/dashboard/components/TimeRangeSelector.tsx +0 -280
- package/src/components/dashboard/components/index.ts +0 -5
- package/src/components/dashboard/index.ts +0 -47
- package/src/components/dashboard/types.ts +0 -126
- package/src/components/state-view/PipelineView.tsx +0 -347
- package/src/components/state-view/index.ts +0 -14
- package/src/components/state-view/types.ts +0 -261
- package/src/components/state-view/useStateView.ts +0 -205
- package/src/contexts/GraphEditContext.tsx +0 -27
- package/src/contexts/TooltipPortalContext.ts +0 -8
- package/src/edges/CustomEdge.tsx +0 -402
- package/src/edges/GenericEdge.tsx +0 -36
- package/src/hooks/usePathBasedEvents.ts +0 -192
- package/src/hooks/useSequenceLayout.ts +0 -543
- package/src/hooks/useUndoRedo.ts +0 -144
- package/src/nodes/CustomNode.tsx +0 -1231
- package/src/nodes/GenericNode.tsx +0 -55
- package/src/nodes/otel/OtelBoundaryNode.tsx +0 -224
- package/src/nodes/otel/OtelEventNode.tsx +0 -225
- package/src/nodes/otel/OtelResourceNode.tsx +0 -251
- package/src/nodes/otel/OtelScopeNode.tsx +0 -221
- package/src/nodes/otel/OtelSpanConventionNode.tsx +0 -295
- package/src/nodes/otel/index.ts +0 -23
- package/src/nodes/otel/shared/NodeBadges.tsx +0 -295
- package/src/nodes/otel/shared/NodeContent.tsx +0 -204
- package/src/nodes/otel/shared/index.ts +0 -8
- package/src/nodes/otel/shared/types.ts +0 -138
- package/src/nodes/otel/shared/useNodeBehavior.ts +0 -114
- package/src/stories/Audit/BoundaryNodes.stories.tsx +0 -385
- package/src/stories/Audit/CanvasEdgeTypes.stories.tsx +0 -1448
- package/src/stories/Audit/CanvasNodeTypes.stories.tsx +0 -1049
- package/src/stories/Audit/ColorPriority.stories.tsx +0 -895
- package/src/stories/Audit/DiamondBadges.stories.tsx +0 -629
- package/src/stories/Audit/NodeDimensionsTesting.stories.tsx +0 -724
- package/src/stories/Audit/NodeFieldsAudit.stories.tsx +0 -996
- package/src/stories/Audit/NodeFontSizeTesting.stories.tsx +0 -715
- package/src/stories/Audit/NodeShapes.stories.tsx +0 -1208
- package/src/stories/Audit/WideNodesTesting.stories.tsx +0 -1045
- package/src/stories/Components/DashboardRenderer.stories.tsx +0 -263
- package/src/stories/Components/GraphRenderer.stories.tsx +0 -3236
- package/src/stories/Components/MultiCanvasRenderer.stories.tsx +0 -370
- package/src/stories/Components/SequenceDiagram.stories.tsx +0 -255
- package/src/stories/Components/StateView.stories.tsx +0 -417
- package/src/stories/Components/TraceViewer.stories.tsx +0 -442
- package/src/stories/Components/WorkflowSequenceDiagram.stories.tsx +0 -802
- package/src/stories/Features/AnimationWorkshop.stories.tsx +0 -727
- package/src/stories/Features/ChangeTypeVisual.stories.tsx +0 -67
- package/src/stories/Features/EventDrivenAnimations.stories.tsx +0 -513
- package/src/stories/Features/MultiConfig.stories.tsx +0 -539
- package/src/stories/Layout/ElkEdgeRouting.stories.tsx +0 -539
- package/src/stories/Layout/GraphOrientation.stories.tsx +0 -500
- package/src/stories/Layout/MultiDirectionalConnections.stories.tsx +0 -352
- package/src/stories/Nodes/NodeDefinitionComparison.stories.tsx +0 -560
- package/src/stories/Nodes/NodeNameFallbacks.stories.tsx +0 -491
- package/src/stories/Nodes/NumericColors.stories.tsx +0 -440
- package/src/stories/OTEL/EventNameDisplay.stories.tsx +0 -694
- package/src/stories/OTEL/EventNameFallback.stories.tsx +0 -578
- package/src/stories/OTEL/OtelComponents.stories.tsx +0 -422
- package/src/stories/OTEL/OtelNodeTypesPrototype.stories.tsx +0 -806
- package/src/stories/OTEL/RawEventCards.stories.tsx +0 -57
- package/src/stories/OTEL/SpanBadges.stories.tsx +0 -840
- package/src/stories/OTEL/ValidationEventsCanvas.stories.tsx +0 -209
- package/src/stories/RealWorld/BacklogMdCanvases.stories.tsx +0 -721
- package/src/stories/RealWorld/FileCitySequence.stories.tsx +0 -516
- package/src/stories/RealWorld/RealCanvasFiles.stories.tsx +0 -336
- package/src/stories/__traces__/test-run.canvas.json +0 -241
- package/src/stories/data/activity-feed-analytics.dashboard.json +0 -300
- package/src/stories/data/file-city-images-transformed.otel.canvas.json +0 -295
- package/src/stories/data/file-city-workflows.json +0 -269
- package/src/stories/data/graph-converter-test-execution.json +0 -443
- package/src/stories/data/graph-converter-test.workflow.json +0 -105
- package/src/stories/data/graph-converter-validated-execution.json +0 -58
- package/src/utils/animationMapping.ts +0 -166
- package/src/utils/canvasBounds.ts +0 -146
- package/src/utils/graphConverter.ts +0 -148
- package/src/utils/iconResolver.tsx +0 -53
- package/src/utils/orientationUtils.ts +0 -73
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test, mock } from 'bun:test';
|
|
2
|
-
import React, { createRef } from 'react';
|
|
3
|
-
import { render } from '@testing-library/react';
|
|
4
|
-
import { GraphRenderer, type GraphRendererHandle } from './GraphRenderer';
|
|
5
|
-
import type { ExtendedCanvas } from '@principal-ai/subsystems-core';
|
|
6
|
-
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
7
|
-
import { Window } from 'happy-dom';
|
|
8
|
-
|
|
9
|
-
// Setup DOM environment
|
|
10
|
-
const window = new Window();
|
|
11
|
-
const document = window.document;
|
|
12
|
-
|
|
13
|
-
// Set up global DOM objects
|
|
14
|
-
globalThis.document = document as unknown as Document;
|
|
15
|
-
globalThis.window = window as unknown as Window & typeof globalThis;
|
|
16
|
-
globalThis.navigator = window.navigator as unknown as Navigator;
|
|
17
|
-
globalThis.HTMLElement = window.HTMLElement as unknown as typeof HTMLElement;
|
|
18
|
-
globalThis.Element = window.Element as unknown as typeof Element;
|
|
19
|
-
globalThis.Node = window.Node as unknown as typeof Node;
|
|
20
|
-
globalThis.Text = window.Text as unknown as typeof Text;
|
|
21
|
-
globalThis.DocumentFragment = window.DocumentFragment as unknown as typeof DocumentFragment;
|
|
22
|
-
globalThis.Event = window.Event as unknown as typeof Event;
|
|
23
|
-
globalThis.CustomEvent = window.CustomEvent as unknown as typeof CustomEvent;
|
|
24
|
-
globalThis.MouseEvent = window.MouseEvent as unknown as typeof MouseEvent;
|
|
25
|
-
globalThis.KeyboardEvent = window.KeyboardEvent as unknown as typeof KeyboardEvent;
|
|
26
|
-
globalThis.getComputedStyle = window.getComputedStyle.bind(window) as unknown as typeof getComputedStyle;
|
|
27
|
-
globalThis.localStorage = window.localStorage as unknown as Storage;
|
|
28
|
-
globalThis.sessionStorage = window.sessionStorage as unknown as Storage;
|
|
29
|
-
|
|
30
|
-
// Mock ResizeObserver for ReactFlow
|
|
31
|
-
globalThis.ResizeObserver = class ResizeObserver {
|
|
32
|
-
observe() {}
|
|
33
|
-
unobserve() {}
|
|
34
|
-
disconnect() {}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Polyfill rAF/cancel for @testing-library/react act-compat cleanup
|
|
38
|
-
if (typeof (window as unknown as Record<string, unknown>).requestAnimationFrame === 'function') {
|
|
39
|
-
globalThis.requestAnimationFrame = (window as unknown as typeof globalThis).requestAnimationFrame.bind(window);
|
|
40
|
-
globalThis.cancelAnimationFrame = (window as unknown as typeof globalThis).cancelAnimationFrame.bind(window);
|
|
41
|
-
} else {
|
|
42
|
-
globalThis.requestAnimationFrame = ((cb: FrameRequestCallback): number =>
|
|
43
|
-
setTimeout(() => cb(Date.now()), 0) as unknown as number) as typeof requestAnimationFrame;
|
|
44
|
-
globalThis.cancelAnimationFrame = ((id: number): void => {
|
|
45
|
-
clearTimeout(id);
|
|
46
|
-
}) as typeof cancelAnimationFrame;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Mock matchMedia
|
|
50
|
-
globalThis.matchMedia = mock(() => ({
|
|
51
|
-
matches: false,
|
|
52
|
-
addListener: () => {},
|
|
53
|
-
removeListener: () => {},
|
|
54
|
-
addEventListener: () => {},
|
|
55
|
-
removeEventListener: () => {},
|
|
56
|
-
dispatchEvent: () => false,
|
|
57
|
-
})) as unknown as typeof matchMedia;
|
|
58
|
-
|
|
59
|
-
// Helper to wrap component with ThemeProvider
|
|
60
|
-
const renderWithTheme = (ui: React.ReactElement) => {
|
|
61
|
-
return render(<ThemeProvider theme={defaultEditorTheme}>{ui}</ThemeProvider>);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
describe('PendingChanges', () => {
|
|
65
|
-
// Sample canvas for testing
|
|
66
|
-
const createTestCanvas = (): ExtendedCanvas => ({
|
|
67
|
-
nodes: [
|
|
68
|
-
{
|
|
69
|
-
id: 'node-1',
|
|
70
|
-
type: 'text',
|
|
71
|
-
x: 100,
|
|
72
|
-
y: 100,
|
|
73
|
-
width: 150,
|
|
74
|
-
height: 80,
|
|
75
|
-
text: 'Node 1',
|
|
76
|
-
pv: {
|
|
77
|
-
nodeType: 'service',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: 'node-2',
|
|
82
|
-
type: 'text',
|
|
83
|
-
x: 300,
|
|
84
|
-
y: 100,
|
|
85
|
-
width: 150,
|
|
86
|
-
height: 80,
|
|
87
|
-
text: 'Node 2',
|
|
88
|
-
pv: {
|
|
89
|
-
nodeType: 'database',
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'node-3',
|
|
94
|
-
type: 'text',
|
|
95
|
-
x: 200,
|
|
96
|
-
y: 300,
|
|
97
|
-
width: 150,
|
|
98
|
-
height: 80,
|
|
99
|
-
text: 'Node 3',
|
|
100
|
-
pv: {
|
|
101
|
-
nodeType: 'service',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
edges: [
|
|
106
|
-
{
|
|
107
|
-
id: 'edge-1',
|
|
108
|
-
fromNode: 'node-1',
|
|
109
|
-
toNode: 'node-2',
|
|
110
|
-
pv: {
|
|
111
|
-
edgeType: 'connection',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
pv: {
|
|
116
|
-
name: 'Test Canvas',
|
|
117
|
-
version: '1.0.0',
|
|
118
|
-
nodeTypes: {
|
|
119
|
-
service: {
|
|
120
|
-
shape: 'rectangle',
|
|
121
|
-
color: '#4CAF50',
|
|
122
|
-
},
|
|
123
|
-
database: {
|
|
124
|
-
shape: 'circle',
|
|
125
|
-
color: '#2196F3',
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
edgeTypes: {
|
|
129
|
-
connection: {
|
|
130
|
-
style: 'solid',
|
|
131
|
-
directed: true,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe('PendingChanges Interface', () => {
|
|
138
|
-
test('should have correct structure with all required fields', () => {
|
|
139
|
-
const ref = createRef<GraphRendererHandle>();
|
|
140
|
-
|
|
141
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
142
|
-
|
|
143
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
144
|
-
|
|
145
|
-
expect(pendingChanges).toBeDefined();
|
|
146
|
-
expect(pendingChanges).toHaveProperty('positionChanges');
|
|
147
|
-
expect(pendingChanges).toHaveProperty('dimensionChanges');
|
|
148
|
-
expect(pendingChanges).toHaveProperty('nodeUpdates');
|
|
149
|
-
expect(pendingChanges).toHaveProperty('deletedNodeIds');
|
|
150
|
-
expect(pendingChanges).toHaveProperty('createdEdges');
|
|
151
|
-
expect(pendingChanges).toHaveProperty('deletedEdges');
|
|
152
|
-
expect(pendingChanges).toHaveProperty('hasChanges');
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
test('should return empty arrays/false when no changes made', () => {
|
|
156
|
-
const ref = createRef<GraphRendererHandle>();
|
|
157
|
-
|
|
158
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
159
|
-
|
|
160
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
161
|
-
|
|
162
|
-
expect(pendingChanges?.positionChanges).toEqual([]);
|
|
163
|
-
expect(pendingChanges?.dimensionChanges).toEqual([]);
|
|
164
|
-
expect(pendingChanges?.nodeUpdates).toEqual([]);
|
|
165
|
-
expect(pendingChanges?.deletedNodeIds).toEqual([]);
|
|
166
|
-
expect(pendingChanges?.createdEdges).toEqual([]);
|
|
167
|
-
expect(pendingChanges?.deletedEdges).toEqual([]);
|
|
168
|
-
expect(pendingChanges?.hasChanges).toBe(false);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('hasUnsavedChanges should return false initially', () => {
|
|
172
|
-
const ref = createRef<GraphRendererHandle>();
|
|
173
|
-
|
|
174
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
175
|
-
|
|
176
|
-
expect(ref.current?.hasUnsavedChanges()).toBe(false);
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
describe('Position Changes', () => {
|
|
181
|
-
test('positionChanges should have correct structure', () => {
|
|
182
|
-
const ref = createRef<GraphRendererHandle>();
|
|
183
|
-
|
|
184
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
185
|
-
|
|
186
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
187
|
-
|
|
188
|
-
// positionChanges should be an array
|
|
189
|
-
expect(Array.isArray(pendingChanges?.positionChanges)).toBe(true);
|
|
190
|
-
|
|
191
|
-
// Each position change should have nodeId and position
|
|
192
|
-
// (empty array initially, but structure is correct)
|
|
193
|
-
expect(pendingChanges?.positionChanges).toEqual([]);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe('Dimension Changes', () => {
|
|
198
|
-
test('dimensionChanges should have correct structure', () => {
|
|
199
|
-
const ref = createRef<GraphRendererHandle>();
|
|
200
|
-
|
|
201
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
202
|
-
|
|
203
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
204
|
-
|
|
205
|
-
// dimensionChanges should be an array
|
|
206
|
-
expect(Array.isArray(pendingChanges?.dimensionChanges)).toBe(true);
|
|
207
|
-
|
|
208
|
-
// Each dimension change should have nodeId and dimensions
|
|
209
|
-
// (empty array initially, but structure is correct)
|
|
210
|
-
expect(pendingChanges?.dimensionChanges).toEqual([]);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
test('dimensionChanges array items should have nodeId and dimensions fields', () => {
|
|
214
|
-
// This test validates the type structure
|
|
215
|
-
const exampleDimensionChange = {
|
|
216
|
-
nodeId: 'node-1',
|
|
217
|
-
dimensions: { width: 200, height: 100 },
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
expect(exampleDimensionChange).toHaveProperty('nodeId');
|
|
221
|
-
expect(exampleDimensionChange).toHaveProperty('dimensions');
|
|
222
|
-
expect(exampleDimensionChange.dimensions).toHaveProperty('width');
|
|
223
|
-
expect(exampleDimensionChange.dimensions).toHaveProperty('height');
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
describe('Reset Edit State', () => {
|
|
228
|
-
test('resetEditState should clear all pending changes', () => {
|
|
229
|
-
const ref = createRef<GraphRendererHandle>();
|
|
230
|
-
|
|
231
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
232
|
-
|
|
233
|
-
// Reset should work even when there are no changes
|
|
234
|
-
ref.current?.resetEditState();
|
|
235
|
-
|
|
236
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
237
|
-
expect(pendingChanges?.hasChanges).toBe(false);
|
|
238
|
-
expect(ref.current?.hasUnsavedChanges()).toBe(false);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe('onPendingChangesChange Callback', () => {
|
|
243
|
-
test('should call onPendingChangesChange with false initially', () => {
|
|
244
|
-
const ref = createRef<GraphRendererHandle>();
|
|
245
|
-
const onPendingChangesChange = mock(() => {});
|
|
246
|
-
|
|
247
|
-
renderWithTheme(
|
|
248
|
-
<GraphRenderer
|
|
249
|
-
ref={ref}
|
|
250
|
-
canvas={createTestCanvas()}
|
|
251
|
-
editable={true}
|
|
252
|
-
onPendingChangesChange={onPendingChangesChange}
|
|
253
|
-
/>
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
// Initially should not have changes
|
|
257
|
-
expect(ref.current?.hasUnsavedChanges()).toBe(false);
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
describe('Non-Editable Mode', () => {
|
|
262
|
-
test('should still provide getPendingChanges in non-editable mode', () => {
|
|
263
|
-
const ref = createRef<GraphRendererHandle>();
|
|
264
|
-
|
|
265
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={false} />);
|
|
266
|
-
|
|
267
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
268
|
-
|
|
269
|
-
expect(pendingChanges).toBeDefined();
|
|
270
|
-
expect(pendingChanges?.hasChanges).toBe(false);
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
describe('Node Updates', () => {
|
|
275
|
-
test('nodeUpdates should have correct structure', () => {
|
|
276
|
-
const ref = createRef<GraphRendererHandle>();
|
|
277
|
-
|
|
278
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
279
|
-
|
|
280
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
281
|
-
|
|
282
|
-
// nodeUpdates should be an array
|
|
283
|
-
expect(Array.isArray(pendingChanges?.nodeUpdates)).toBe(true);
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
describe('Edge Operations', () => {
|
|
288
|
-
test('createdEdges should have correct structure', () => {
|
|
289
|
-
const ref = createRef<GraphRendererHandle>();
|
|
290
|
-
|
|
291
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
292
|
-
|
|
293
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
294
|
-
|
|
295
|
-
// createdEdges should be an array
|
|
296
|
-
expect(Array.isArray(pendingChanges?.createdEdges)).toBe(true);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
test('deletedEdges should have correct structure', () => {
|
|
300
|
-
const ref = createRef<GraphRendererHandle>();
|
|
301
|
-
|
|
302
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
303
|
-
|
|
304
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
305
|
-
|
|
306
|
-
// deletedEdges should be an array
|
|
307
|
-
expect(Array.isArray(pendingChanges?.deletedEdges)).toBe(true);
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
describe('Deleted Nodes', () => {
|
|
312
|
-
test('deletedNodeIds should have correct structure', () => {
|
|
313
|
-
const ref = createRef<GraphRendererHandle>();
|
|
314
|
-
|
|
315
|
-
renderWithTheme(<GraphRenderer ref={ref} canvas={createTestCanvas()} editable={true} />);
|
|
316
|
-
|
|
317
|
-
const pendingChanges = ref.current?.getPendingChanges();
|
|
318
|
-
|
|
319
|
-
// deletedNodeIds should be an array
|
|
320
|
-
expect(Array.isArray(pendingChanges?.deletedNodeIds)).toBe(true);
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
describe('PendingChanges Type Validation', () => {
|
|
326
|
-
test('NodePositionChange should have correct shape', () => {
|
|
327
|
-
const positionChange = {
|
|
328
|
-
nodeId: 'test-node',
|
|
329
|
-
position: { x: 100, y: 200 },
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
expect(positionChange.nodeId).toBe('test-node');
|
|
333
|
-
expect(positionChange.position.x).toBe(100);
|
|
334
|
-
expect(positionChange.position.y).toBe(200);
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
test('NodeDimensionChange should have correct shape', () => {
|
|
338
|
-
const dimensionChange = {
|
|
339
|
-
nodeId: 'test-node',
|
|
340
|
-
dimensions: { width: 150, height: 100 },
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
expect(dimensionChange.nodeId).toBe('test-node');
|
|
344
|
-
expect(dimensionChange.dimensions.width).toBe(150);
|
|
345
|
-
expect(dimensionChange.dimensions.height).toBe(100);
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
test('CreatedEdge should have correct shape', () => {
|
|
349
|
-
const createdEdge = {
|
|
350
|
-
from: 'node-1',
|
|
351
|
-
to: 'node-2',
|
|
352
|
-
type: 'connection',
|
|
353
|
-
sourceHandle: 'right-out',
|
|
354
|
-
targetHandle: 'left',
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
expect(createdEdge.from).toBe('node-1');
|
|
358
|
-
expect(createdEdge.to).toBe('node-2');
|
|
359
|
-
expect(createdEdge.type).toBe('connection');
|
|
360
|
-
expect(createdEdge.sourceHandle).toBe('right-out');
|
|
361
|
-
expect(createdEdge.targetHandle).toBe('left');
|
|
362
|
-
});
|
|
363
|
-
|
|
364
|
-
test('DeletedEdge should have correct shape', () => {
|
|
365
|
-
const deletedEdge = {
|
|
366
|
-
from: 'node-1',
|
|
367
|
-
to: 'node-2',
|
|
368
|
-
type: 'connection',
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
expect(deletedEdge.from).toBe('node-1');
|
|
372
|
-
expect(deletedEdge.to).toBe('node-2');
|
|
373
|
-
expect(deletedEdge.type).toBe('connection');
|
|
374
|
-
});
|
|
375
|
-
});
|