@principal-ai/subsystems-react 0.56.35 → 0.56.36
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/subsystem/SubsystemComponentGraph.d.ts +50 -8
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +291 -50
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +2 -1
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +5 -5
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +23 -43
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/dist/subsystem/model.d.ts +21 -6
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +48 -45
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodeIconography.d.ts +25 -0
- package/dist/subsystem/nodeIconography.d.ts.map +1 -0
- package/dist/subsystem/nodeIconography.js +55 -0
- package/dist/subsystem/nodeIconography.js.map +1 -0
- package/dist/subsystem/nodes.d.ts +4 -3
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +125 -211
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/subsystem/stepEmphasis.d.ts +5 -0
- package/dist/subsystem/stepEmphasis.d.ts.map +1 -1
- package/dist/subsystem/stepEmphasis.js +7 -0
- package/dist/subsystem/stepEmphasis.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Canvases/Subsystem/AgentDrivenWalkthrough.stories.tsx +229 -157
- package/src/stories/Canvases/Subsystem/Deprecated.stories.tsx +1 -1
- package/src/stories/Canvases/Subsystem/NodeAnatomy.stories.tsx +17 -21
- package/src/stories/Canvases/Subsystem/NodeIconography.stories.tsx +791 -21
- package/src/stories/Canvases/Subsystem/Spotlights.stories.tsx +1 -1
- package/src/subsystem/SubsystemComponentGraph.tsx +359 -62
- package/src/subsystem/TrailStepsNav.tsx +2 -2
- package/src/subsystem/TrailsPanel.tsx +35 -89
- package/src/subsystem/model.test.ts +17 -13
- package/src/subsystem/model.ts +60 -48
- package/src/subsystem/nodeIconography.ts +88 -0
- package/src/subsystem/nodes.component.test.tsx +177 -0
- package/src/subsystem/nodes.tsx +225 -268
- package/src/subsystem/stepEmphasis.ts +8 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { cleanup, fireEvent, render } from '@testing-library/react/pure';
|
|
4
|
+
import { ReactFlowProvider, type Node, type NodeProps } from '@xyflow/react';
|
|
5
|
+
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
6
|
+
import { Window } from 'happy-dom';
|
|
7
|
+
import { HOST_PROPOSAL_COLOR, type SubsystemComponent, type SubsystemGraphNodeData } from './model';
|
|
8
|
+
import { SubsystemCallbacksProvider, SubsystemComponentNode } from './nodes';
|
|
9
|
+
|
|
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.Node = dom.Node;
|
|
17
|
+
globals.Element = dom.Element;
|
|
18
|
+
globals.Event = dom.Event;
|
|
19
|
+
globals.getComputedStyle = dom.getComputedStyle.bind(dom);
|
|
20
|
+
globals.requestAnimationFrame = dom.requestAnimationFrame.bind(dom);
|
|
21
|
+
globals.cancelAnimationFrame = dom.cancelAnimationFrame.bind(dom);
|
|
22
|
+
globals.localStorage = dom.localStorage;
|
|
23
|
+
globals.matchMedia = dom.matchMedia.bind(dom);
|
|
24
|
+
|
|
25
|
+
afterEach(cleanup);
|
|
26
|
+
|
|
27
|
+
const PURL = 'pkg:github/story/node-iconography';
|
|
28
|
+
|
|
29
|
+
function component(overrides: Partial<SubsystemComponent> = {}): SubsystemComponent {
|
|
30
|
+
return {
|
|
31
|
+
alias: 'entry',
|
|
32
|
+
name: 'submitOrder',
|
|
33
|
+
construct: 'function',
|
|
34
|
+
file: 'src/orders/submit.ts',
|
|
35
|
+
purl: PURL,
|
|
36
|
+
symbol: 'submitOrder',
|
|
37
|
+
...overrides,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function renderNode(
|
|
42
|
+
c: SubsystemComponent,
|
|
43
|
+
data: Partial<SubsystemGraphNodeData> = {},
|
|
44
|
+
) {
|
|
45
|
+
const props = {
|
|
46
|
+
data: { component: c, ...data },
|
|
47
|
+
selected: false,
|
|
48
|
+
width: 250,
|
|
49
|
+
height: 96,
|
|
50
|
+
} as unknown as NodeProps<Node<SubsystemGraphNodeData, 'subsystem-component'>>;
|
|
51
|
+
return render(
|
|
52
|
+
createElement(
|
|
53
|
+
ReactFlowProvider,
|
|
54
|
+
null,
|
|
55
|
+
createElement(
|
|
56
|
+
ThemeProvider,
|
|
57
|
+
{ theme: defaultEditorTheme },
|
|
58
|
+
createElement(
|
|
59
|
+
SubsystemCallbacksProvider,
|
|
60
|
+
{ value: {} },
|
|
61
|
+
createElement(SubsystemComponentNode, props),
|
|
62
|
+
),
|
|
63
|
+
),
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
describe('SubsystemComponentNode iconography', () => {
|
|
69
|
+
test('renders the construct icon and uppercase label above the name', () => {
|
|
70
|
+
const { container, getByText } = renderNode(component({ construct: 'class', name: 'OrderService', symbol: undefined }));
|
|
71
|
+
expect(getByText('CLASS')).not.toBeNull();
|
|
72
|
+
expect(container.textContent?.replace(/\u200b/g, '')).toContain('OrderService');
|
|
73
|
+
expect(container.querySelector('.lucide-class-glyph')).not.toBeNull();
|
|
74
|
+
const root = container.firstElementChild as HTMLElement;
|
|
75
|
+
expect(root.style.justifyContent).toBe('flex-start');
|
|
76
|
+
expect(root.style.padding).toContain('14px');
|
|
77
|
+
expect(root.style.gap).toBe('8px');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('uses the reviewed glyphs for function, interface, store, and external', () => {
|
|
81
|
+
const fn = renderNode(component());
|
|
82
|
+
expect(fn.container.querySelector('.lucide-function-letter')).not.toBeNull();
|
|
83
|
+
cleanup();
|
|
84
|
+
|
|
85
|
+
const iface = renderNode(component({ construct: 'interface', name: 'OrderRepository' }));
|
|
86
|
+
expect(iface.container.querySelector('.lucide-unplug')).not.toBeNull();
|
|
87
|
+
cleanup();
|
|
88
|
+
|
|
89
|
+
const store = renderNode(component({ construct: 'store', name: 'orderStore' }));
|
|
90
|
+
expect(store.container.querySelector('.lucide-layers')).not.toBeNull();
|
|
91
|
+
cleanup();
|
|
92
|
+
|
|
93
|
+
const external = renderNode(component({ construct: 'external', name: 'PaymentProvider', file: '' }));
|
|
94
|
+
expect(external.container.querySelector('.lucide-network')).not.toBeNull();
|
|
95
|
+
expect((external.container.firstElementChild as HTMLElement).style.borderRadius).toBe('0px');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('framework stereotypes use the official mark and authored label', () => {
|
|
99
|
+
const { container, getByText } = renderNode(component({
|
|
100
|
+
name: 'CheckoutButton',
|
|
101
|
+
framework: 'react',
|
|
102
|
+
stereotype: 'component',
|
|
103
|
+
}));
|
|
104
|
+
expect(container.querySelector('[aria-label="React"]')).not.toBeNull();
|
|
105
|
+
expect(getByText('REACT · COMPONENT')).not.toBeNull();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test('custom entities use their kind glyph and label', () => {
|
|
109
|
+
const { container, getByText } = renderNode(component({
|
|
110
|
+
name: 'ReviewAgent',
|
|
111
|
+
construct: 'custom_entity',
|
|
112
|
+
entityKind: 'agent',
|
|
113
|
+
file: '',
|
|
114
|
+
}));
|
|
115
|
+
expect(container.querySelector('.lucide-bot')).not.toBeNull();
|
|
116
|
+
expect(getByText('AGENT')).not.toBeNull();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('secondary role and storage badges keep icon plus label on the bottom cluster', () => {
|
|
120
|
+
const { getByLabelText } = renderNode(component({
|
|
121
|
+
name: 'orderStore',
|
|
122
|
+
construct: 'store',
|
|
123
|
+
role: 'service',
|
|
124
|
+
declaration: { kind: 'store', storage: 'memory', properties: [] },
|
|
125
|
+
}));
|
|
126
|
+
const memory = getByLabelText('memory');
|
|
127
|
+
const service = getByLabelText('service');
|
|
128
|
+
expect(memory.querySelector('.lucide-memory-stick')).not.toBeNull();
|
|
129
|
+
expect(service.querySelector('.lucide-workflow')).not.toBeNull();
|
|
130
|
+
expect(memory.parentElement).toBe(service.parentElement);
|
|
131
|
+
expect((memory.parentElement as HTMLElement).style.transform).toBe('translateX(-50%)');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
test('working, proposed, and removed markers sit above the top-right corner', () => {
|
|
135
|
+
const working = renderNode(component(), { working: true });
|
|
136
|
+
const workingMarker = working.getByLabelText('working') as HTMLElement;
|
|
137
|
+
expect(workingMarker.style.top).toBe('-10px');
|
|
138
|
+
expect(workingMarker.style.right).toBe('-8px');
|
|
139
|
+
expect(workingMarker.style.width).toBe('26px');
|
|
140
|
+
cleanup();
|
|
141
|
+
|
|
142
|
+
const proposed = renderNode(component({ name: 'newOrderFlow', symbol: undefined }), { proposed: true });
|
|
143
|
+
const proposedMarker = proposed.getByLabelText('proposed') as HTMLElement;
|
|
144
|
+
expect(proposedMarker.querySelector('.lucide-circle-plus')).not.toBeNull();
|
|
145
|
+
expect(proposedMarker.style.top).toBe('-10px');
|
|
146
|
+
const root = proposed.container.firstElementChild as HTMLElement;
|
|
147
|
+
const primary = proposed.getByLabelText('function') as HTMLElement;
|
|
148
|
+
expect(root.style.border).toContain(primary.style.color);
|
|
149
|
+
expect(root.style.border).not.toContain(HOST_PROPOSAL_COLOR);
|
|
150
|
+
const proposedName = root.children[2] as HTMLElement;
|
|
151
|
+
expect(proposedName.textContent?.replace(/\u200b/g, '')).toBe('newOrderFlow()');
|
|
152
|
+
expect(proposedName.style.color).toBe(HOST_PROPOSAL_COLOR);
|
|
153
|
+
cleanup();
|
|
154
|
+
|
|
155
|
+
const removed = renderNode(component({ name: 'legacyCheckout' }), { removed: true });
|
|
156
|
+
const removedMarker = removed.getByLabelText('removed') as HTMLElement;
|
|
157
|
+
expect(removedMarker.querySelector('.lucide-circle-x')).not.toBeNull();
|
|
158
|
+
expect(removedMarker.style.top).toBe('-10px');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test('issue marker stays bottom-right without changing the border style', () => {
|
|
162
|
+
const { container, getByLabelText } = renderNode(component({ construct: 'interface' }), {
|
|
163
|
+
issue: { severity: 'error', rung: 'type', count: 1 },
|
|
164
|
+
});
|
|
165
|
+
const marker = getByLabelText('issue') as HTMLElement;
|
|
166
|
+
expect(marker.style.bottom).toBe('-8px');
|
|
167
|
+
expect(marker.style.right).toBe('-8px');
|
|
168
|
+
expect(marker.querySelector('.lucide-triangle-alert')).not.toBeNull();
|
|
169
|
+
expect((container.firstElementChild as HTMLElement).style.border).toContain('solid');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('deprecated badge remains interactive and opens removal provenance', () => {
|
|
173
|
+
const { getByRole } = renderNode(component({ deprecated: true, removedIn: { commit: 'abc1234' } }));
|
|
174
|
+
fireEvent.click(getByRole('button', { name: /Deprecated/ }));
|
|
175
|
+
expect(getByRole('dialog', { name: 'Removal provenance' })).not.toBeNull();
|
|
176
|
+
});
|
|
177
|
+
});
|