@principal-ai/subsystems-react 0.44.4 → 0.46.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 +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/pierre/{PierreWalkthroughCodeView.d.ts → PierreTrailCodeView.d.ts} +11 -11
- package/dist/pierre/PierreTrailCodeView.d.ts.map +1 -0
- package/dist/pierre/{PierreWalkthroughCodeView.js → PierreTrailCodeView.js} +36 -36
- package/dist/pierre/PierreTrailCodeView.js.map +1 -0
- package/dist/pierre/index.d.ts +2 -2
- package/dist/pierre/index.d.ts.map +1 -1
- package/dist/pierre/index.js +1 -1
- package/dist/pierre/index.js.map +1 -1
- package/dist/stories/Subsystem/AggregateGraph/aggregateViewFixture.d.ts.map +1 -1
- package/dist/stories/Subsystem/AggregateGraph/aggregateViewFixture.js +1 -1
- package/dist/stories/Subsystem/AggregateGraph/aggregateViewFixture.js.map +1 -1
- package/dist/stories/Subsystem/C4Graph/c4Fixture.js +1 -1
- package/dist/stories/Subsystem/C4Graph/c4Fixture.js.map +1 -1
- package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts +7 -11
- package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts.map +1 -1
- package/dist/stories/Subsystem/ComponentGraph/fixtures.js +10 -26
- package/dist/stories/Subsystem/ComponentGraph/fixtures.js.map +1 -1
- package/dist/subsystem/C4Graph.d.ts +2 -2
- package/dist/subsystem/C4Graph.js +2 -2
- package/dist/subsystem/ConstructsCatalog.d.ts +2 -3
- package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
- package/dist/subsystem/ConstructsCatalog.js +3 -14
- package/dist/subsystem/ConstructsCatalog.js.map +1 -1
- package/dist/subsystem/DiagnosticToggle.d.ts +1 -1
- package/dist/subsystem/DiagnosticToggle.js +1 -1
- package/dist/subsystem/FileDrawer.d.ts +2 -2
- package/dist/subsystem/FileDrawer.js +2 -2
- package/dist/subsystem/IssueList.d.ts +6 -6
- package/dist/subsystem/IssueList.d.ts.map +1 -1
- package/dist/subsystem/IssueList.js +9 -9
- package/dist/subsystem/IssueList.js.map +1 -1
- package/dist/subsystem/SubsystemAggregateGraph.d.ts +3 -3
- package/dist/subsystem/SubsystemAggregateGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemAggregateGraph.js +2 -2
- package/dist/subsystem/SubsystemComponentGraph.d.ts +45 -51
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +288 -292
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/SubsystemModelTransition.d.ts +10 -10
- package/dist/subsystem/SubsystemModelTransition.d.ts.map +1 -1
- package/dist/subsystem/SubsystemModelTransition.js +42 -42
- package/dist/subsystem/SubsystemModelTransition.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +55 -0
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -0
- package/dist/subsystem/{WalkthroughsPanel.js → TrailsPanel.js} +51 -51
- package/dist/subsystem/TrailsPanel.js.map +1 -0
- package/dist/subsystem/declarationRef.d.ts +1 -1
- package/dist/subsystem/declarationRef.d.ts.map +1 -1
- package/dist/subsystem/model.d.ts +40 -40
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +17 -17
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts +1 -1
- package/dist/subsystem/nodes.js +1 -1
- package/dist/subsystem/toC4.d.ts +2 -2
- package/dist/subsystem/toC4.d.ts.map +1 -1
- package/dist/subsystem/toC4.js +2 -2
- package/dist/subsystem/toC4.js.map +1 -1
- package/dist/subsystem/trailBrief.d.ts +18 -0
- package/dist/subsystem/trailBrief.d.ts.map +1 -0
- package/dist/subsystem/{walkthroughBrief.js → trailBrief.js} +8 -8
- package/dist/subsystem/trailBrief.js.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +15 -15
- package/src/pierre/{PierreWalkthroughCodeView.tsx → PierreTrailCodeView.tsx} +56 -56
- package/src/pierre/index.ts +2 -2
- package/src/stories/Pierre/CodeView.stories.tsx +3 -3
- package/src/stories/Subsystem/AggregateGraph/AggregateFrameGraph.stories.tsx +1 -1
- package/src/stories/Subsystem/AggregateGraph/aggregateViewFixture.ts +1 -1
- package/src/stories/Subsystem/C4Graph/c4Fixture.ts +1 -1
- package/src/stories/Subsystem/ComponentDeclarationAudit.stories.tsx +8 -8
- package/src/stories/Subsystem/ComponentGraph/AnimatedProgression.stories.tsx +13 -13
- package/src/stories/Subsystem/ComponentGraph/Appearance.stories.tsx +2 -2
- package/src/stories/Subsystem/ComponentGraph/Basics.stories.tsx +5 -5
- package/src/stories/Subsystem/ComponentGraph/Captures.stories.tsx +8 -8
- package/src/stories/Subsystem/ComponentGraph/CustomEntities.stories.tsx +3 -3
- package/src/stories/Subsystem/ComponentGraph/Diagnostics.stories.tsx +6 -6
- package/src/stories/Subsystem/ComponentGraph/EdgeViews.stories.tsx +12 -12
- package/src/stories/Subsystem/ComponentGraph/Flows.stories.tsx +36 -36
- package/src/stories/Subsystem/ComponentGraph/FrameworkStereotype.stories.tsx +7 -7
- package/src/stories/Subsystem/ComponentGraph/GraphTitle.stories.tsx +4 -4
- package/src/stories/Subsystem/ComponentGraph/IssueOverlay.stories.tsx +8 -8
- package/src/stories/Subsystem/ComponentGraph/Issues.stories.tsx +4 -4
- package/src/stories/Subsystem/ComponentGraph/ModuleBadges.stories.tsx +3 -3
- package/src/stories/Subsystem/ComponentGraph/Modules.stories.tsx +5 -5
- package/src/stories/Subsystem/ComponentGraph/Packages.stories.tsx +6 -6
- package/src/stories/Subsystem/ComponentGraph/Processes.stories.tsx +3 -3
- package/src/stories/Subsystem/ComponentGraph/Proposed.stories.tsx +4 -4
- package/src/stories/Subsystem/ComponentGraph/{ProposedWalkthroughs.stories.tsx → ProposedTrails.stories.tsx} +9 -9
- package/src/stories/Subsystem/ComponentGraph/Reorder.stories.tsx +19 -19
- package/src/stories/Subsystem/ComponentGraph/Scenarios.stories.tsx +21 -21
- package/src/stories/Subsystem/ComponentGraph/{WalkthroughAutoplay.stories.tsx → TrailAutoplay.stories.tsx} +22 -22
- package/src/stories/Subsystem/ComponentGraph/WorkspacePackageFrames.stories.tsx +3 -3
- package/src/stories/Subsystem/ComponentGraph/fixtures.ts +17 -37
- package/src/subsystem/C4Graph.tsx +2 -2
- package/src/subsystem/ConstructsCatalog.tsx +2 -16
- package/src/subsystem/DiagnosticToggle.tsx +1 -1
- package/src/subsystem/FileDrawer.tsx +2 -2
- package/src/subsystem/IssueList.focus.test.tsx +4 -4
- package/src/subsystem/IssueList.icon.test.tsx +3 -3
- package/src/subsystem/IssueList.tsx +14 -14
- package/src/subsystem/SubsystemAggregateGraph.tsx +3 -3
- package/src/subsystem/SubsystemComponentGraph.tsx +380 -393
- package/src/subsystem/SubsystemModelTransition.tsx +61 -61
- package/src/subsystem/{WalkthroughsPanel.test.tsx → TrailsPanel.test.tsx} +16 -16
- package/src/subsystem/{WalkthroughsPanel.tsx → TrailsPanel.tsx} +81 -81
- package/src/subsystem/declarationRef.ts +1 -1
- package/src/subsystem/formatDeclaration.test.ts +6 -6
- package/src/subsystem/model.test.ts +25 -25
- package/src/subsystem/model.ts +51 -51
- package/src/subsystem/nodes.tsx +1 -1
- package/src/subsystem/toC4.test.ts +1 -1
- package/src/subsystem/toC4.ts +3 -3
- package/src/subsystem/{walkthroughBrief.test.ts → trailBrief.test.ts} +10 -10
- package/src/subsystem/{walkthroughBrief.ts → trailBrief.ts} +8 -8
- package/dist/pierre/PierreWalkthroughCodeView.d.ts.map +0 -1
- package/dist/pierre/PierreWalkthroughCodeView.js.map +0 -1
- package/dist/subsystem/WalkthroughsPanel.d.ts +0 -55
- package/dist/subsystem/WalkthroughsPanel.d.ts.map +0 -1
- package/dist/subsystem/WalkthroughsPanel.js.map +0 -1
- package/dist/subsystem/walkthroughBrief.d.ts +0 -18
- package/dist/subsystem/walkthroughBrief.d.ts.map +0 -1
- package/dist/subsystem/walkthroughBrief.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SubsystemModelTransition — a sibling of `SubsystemComponentGraph` that
|
|
3
3
|
* presents ONE subsystem as a sequence of steps (e.g. constructs → static
|
|
4
|
-
* topology → dynamic topology →
|
|
4
|
+
* topology → dynamic topology → trail) and animates between them.
|
|
5
5
|
*
|
|
6
6
|
* Same look as the component graph: it reuses the same node / frame / edge
|
|
7
7
|
* components and the edge-label chrome, so only the motion is new. Each step is
|
|
@@ -31,11 +31,11 @@ import {
|
|
|
31
31
|
buildSubsystemGraph,
|
|
32
32
|
edgeColor,
|
|
33
33
|
MECHANISM_DESCRIPTIONS,
|
|
34
|
-
|
|
34
|
+
trailStepGraphEdgeId,
|
|
35
35
|
type SubsystemEdgeProvenance,
|
|
36
36
|
type SubsystemGraphNode,
|
|
37
37
|
type SubsystemModelDocument,
|
|
38
|
-
type
|
|
38
|
+
type SubsystemTrail,
|
|
39
39
|
} from './model';
|
|
40
40
|
import {
|
|
41
41
|
hexWithAlpha,
|
|
@@ -63,12 +63,12 @@ export interface SubsystemTransitionStep {
|
|
|
63
63
|
/** Explicit boundary frame colors (region key → hex); host override. */
|
|
64
64
|
boundaryColors?: Record<string, string>;
|
|
65
65
|
/**
|
|
66
|
-
* Cycle this step's
|
|
67
|
-
* number the labels, frame the step). Typically only the
|
|
66
|
+
* Cycle this step's trail steps: focus each step (dim non-participants,
|
|
67
|
+
* number the labels, frame the step). Typically only the trail layer.
|
|
68
68
|
*/
|
|
69
|
-
|
|
70
|
-
/** Show the focused
|
|
71
|
-
|
|
69
|
+
autoPlayTrails?: boolean;
|
|
70
|
+
/** Show the focused trail's title chip (with step ticks). */
|
|
71
|
+
showTrailTitle?: boolean;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
export interface SubsystemModelTransitionProps {
|
|
@@ -81,10 +81,10 @@ export interface SubsystemModelTransitionProps {
|
|
|
81
81
|
fitPadding?: number;
|
|
82
82
|
/** Called when a node is clicked. */
|
|
83
83
|
onSelect?: (componentAlias: string) => void;
|
|
84
|
-
/** How an autoplayed
|
|
85
|
-
|
|
86
|
-
/** Dwell per
|
|
87
|
-
|
|
84
|
+
/** How an autoplayed trail step reads. @default 'focus' */
|
|
85
|
+
trailStepMode?: 'focus' | 'dim';
|
|
86
|
+
/** Dwell per trail step while autoplaying, ms. @default 4000 */
|
|
87
|
+
trailAutoPlayIntervalMs?: number;
|
|
88
88
|
className?: string;
|
|
89
89
|
style?: CSSProperties;
|
|
90
90
|
}
|
|
@@ -238,8 +238,8 @@ function TransitionInner({
|
|
|
238
238
|
durationMs = 950,
|
|
239
239
|
fitPadding = 0.18,
|
|
240
240
|
onSelect,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
trailStepMode = 'focus',
|
|
242
|
+
trailAutoPlayIntervalMs = 4000,
|
|
243
243
|
className,
|
|
244
244
|
style,
|
|
245
245
|
}: SubsystemModelTransitionProps) {
|
|
@@ -361,69 +361,69 @@ function TransitionInner({
|
|
|
361
361
|
|
|
362
362
|
const activeLayout = layouts?.[activeIndex];
|
|
363
363
|
|
|
364
|
-
//
|
|
364
|
+
// Trail step focus: cycle the active step's steps, dim non-participants,
|
|
365
365
|
// number the labels, and (in `focus` mode) frame the step.
|
|
366
366
|
const activeStepDef = steps[activeIndex];
|
|
367
|
-
const
|
|
367
|
+
const activeTrails = activeStepDef?.model.trails;
|
|
368
368
|
const autoPlaySteps =
|
|
369
|
-
activeStepDef?.
|
|
370
|
-
const
|
|
369
|
+
activeStepDef?.autoPlayTrails === true && (activeTrails?.length ?? 0) > 0;
|
|
370
|
+
const stepList = useMemo(() => {
|
|
371
371
|
const out: Array<{
|
|
372
372
|
edgeId: string;
|
|
373
373
|
from: string;
|
|
374
374
|
to: string;
|
|
375
375
|
stepNo: number;
|
|
376
376
|
total: number;
|
|
377
|
-
|
|
378
|
-
|
|
377
|
+
trailId: string;
|
|
378
|
+
trailTitle: string;
|
|
379
379
|
}> = [];
|
|
380
|
-
for (const wt of (
|
|
380
|
+
for (const wt of (activeTrails ?? []) as SubsystemTrail[]) {
|
|
381
381
|
wt.steps.forEach((s, i) => {
|
|
382
382
|
out.push({
|
|
383
|
-
edgeId:
|
|
383
|
+
edgeId: trailStepGraphEdgeId(s),
|
|
384
384
|
from: s.from,
|
|
385
385
|
to: s.to,
|
|
386
386
|
stepNo: i + 1,
|
|
387
387
|
total: wt.steps.length,
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
trailId: wt.id,
|
|
389
|
+
trailTitle: wt.title,
|
|
390
390
|
});
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
return out;
|
|
394
|
-
}, [
|
|
394
|
+
}, [activeTrails]);
|
|
395
395
|
const [stepPointer, setStepPointer] = useState(0);
|
|
396
396
|
useEffect(() => {
|
|
397
397
|
setStepPointer(0);
|
|
398
|
-
}, [activeIndex,
|
|
398
|
+
}, [activeIndex, stepList.length]);
|
|
399
399
|
useEffect(() => {
|
|
400
|
-
if (!autoPlaySteps ||
|
|
401
|
-
// Pointer 0 = whole flow (no step focus); 1..N = each
|
|
400
|
+
if (!autoPlaySteps || stepList.length === 0) return;
|
|
401
|
+
// Pointer 0 = whole flow (no step focus); 1..N = each step, then wraps.
|
|
402
402
|
const t = window.setInterval(
|
|
403
|
-
() => setStepPointer((p) => (p + 1) % (
|
|
404
|
-
Math.max(600,
|
|
403
|
+
() => setStepPointer((p) => (p + 1) % (stepList.length + 1)),
|
|
404
|
+
Math.max(600, trailAutoPlayIntervalMs),
|
|
405
405
|
);
|
|
406
406
|
return () => window.clearInterval(t);
|
|
407
|
-
}, [autoPlaySteps,
|
|
408
|
-
const
|
|
409
|
-
autoPlaySteps &&
|
|
410
|
-
?
|
|
407
|
+
}, [autoPlaySteps, stepList.length, trailAutoPlayIntervalMs]);
|
|
408
|
+
const focusedStep =
|
|
409
|
+
autoPlaySteps && stepList.length > 0 && stepPointer > 0
|
|
410
|
+
? stepList[(stepPointer - 1) % stepList.length]
|
|
411
411
|
: undefined;
|
|
412
412
|
const stepNoByEdge = useMemo(() => {
|
|
413
|
-
// Unique step numbers per edge — a
|
|
413
|
+
// Unique step numbers per edge — a step reused across trails (e.g. a
|
|
414
414
|
// shared `capture-event` call) would otherwise stack `4: 4: 4:`.
|
|
415
415
|
const m = new Map<string, number[]>();
|
|
416
|
-
for (const h of
|
|
416
|
+
for (const h of stepList) {
|
|
417
417
|
const arr = m.get(h.edgeId) ?? [];
|
|
418
418
|
if (!arr.includes(h.stepNo)) arr.push(h.stepNo);
|
|
419
419
|
m.set(h.edgeId, arr);
|
|
420
420
|
}
|
|
421
421
|
for (const arr of m.values()) arr.sort((a, b) => a - b);
|
|
422
422
|
return m;
|
|
423
|
-
}, [
|
|
423
|
+
}, [stepList]);
|
|
424
424
|
const focusParticipants = useMemo(
|
|
425
|
-
() => (
|
|
426
|
-
[
|
|
425
|
+
() => (focusedStep ? new Set([focusedStep.from, focusedStep.to]) : null),
|
|
426
|
+
[focusedStep],
|
|
427
427
|
);
|
|
428
428
|
|
|
429
429
|
const nodes: Node[] = useMemo(() => {
|
|
@@ -459,34 +459,34 @@ function TransitionInner({
|
|
|
459
459
|
return out;
|
|
460
460
|
}, [display, activeLayout, unionMeta, focusParticipants]);
|
|
461
461
|
|
|
462
|
-
// Real graph edges once settled; step focus adds
|
|
463
|
-
// non-focused
|
|
462
|
+
// Real graph edges once settled; step focus adds step numbers and dims the
|
|
463
|
+
// non-focused steps.
|
|
464
464
|
const edges: Edge[] = useMemo(() => {
|
|
465
465
|
if (!settled) return [];
|
|
466
466
|
const list = activeLayout?.edges ?? [];
|
|
467
|
-
const numbering = autoPlaySteps &&
|
|
468
|
-
if (!numbering && !
|
|
467
|
+
const numbering = autoPlaySteps && stepList.length > 0;
|
|
468
|
+
if (!numbering && !focusedStep) return list;
|
|
469
469
|
return list.map((e) => {
|
|
470
|
-
// Number every
|
|
471
|
-
//
|
|
470
|
+
// Number every step while autoplaying (whole view included); dim only the
|
|
471
|
+
// steps other than the focused one.
|
|
472
472
|
const stepNos = numbering ? stepNoByEdge.get(e.id) : undefined;
|
|
473
|
-
const dimmed =
|
|
473
|
+
const dimmed = focusedStep ? e.id !== focusedStep.edgeId : false;
|
|
474
474
|
if (!stepNos && !dimmed) return e;
|
|
475
475
|
return {
|
|
476
476
|
...e,
|
|
477
477
|
data: { ...(e.data as object), stepNos, dimmed },
|
|
478
478
|
} as Edge;
|
|
479
479
|
});
|
|
480
|
-
}, [settled, activeLayout,
|
|
480
|
+
}, [settled, activeLayout, focusedStep, stepNoByEdge, autoPlaySteps, stepList.length]);
|
|
481
481
|
|
|
482
|
-
// Camera: frame a focused
|
|
482
|
+
// Camera: frame a focused step's endpoints, or the whole graph during the
|
|
483
483
|
// "whole flow" phase.
|
|
484
484
|
useEffect(() => {
|
|
485
|
-
if (
|
|
485
|
+
if (trailStepMode !== 'focus' || !settled || !sized || !rfSized || !autoPlaySteps)
|
|
486
486
|
return;
|
|
487
487
|
if (!activeLayout) return;
|
|
488
|
-
const rects =
|
|
489
|
-
? [
|
|
488
|
+
const rects = focusedStep
|
|
489
|
+
? [focusedStep.from, focusedStep.to]
|
|
490
490
|
.map((id) => activeLayout.rects.get(id))
|
|
491
491
|
.filter((r): r is Rect => !!r)
|
|
492
492
|
: [...activeLayout.rects.values()];
|
|
@@ -497,11 +497,11 @@ function TransitionInner({
|
|
|
497
497
|
const maxY = Math.max(...rects.map((r) => r.y + r.h));
|
|
498
498
|
fitBounds(
|
|
499
499
|
{ x: minX, y: minY, width: maxX - minX, height: maxY - minY },
|
|
500
|
-
{ padding:
|
|
500
|
+
{ padding: focusedStep ? 0.3 : fitPadding, duration: durationMs },
|
|
501
501
|
);
|
|
502
502
|
}, [
|
|
503
|
-
|
|
504
|
-
|
|
503
|
+
trailStepMode,
|
|
504
|
+
focusedStep,
|
|
505
505
|
settled,
|
|
506
506
|
sized,
|
|
507
507
|
rfSized,
|
|
@@ -546,9 +546,9 @@ function TransitionInner({
|
|
|
546
546
|
</ReactFlow>
|
|
547
547
|
</SubsystemCallbacksProvider>
|
|
548
548
|
)}
|
|
549
|
-
{activeStepDef?.
|
|
549
|
+
{activeStepDef?.showTrailTitle && focusedStep && (
|
|
550
550
|
<div
|
|
551
|
-
aria-label={`${
|
|
551
|
+
aria-label={`${focusedStep.trailTitle}, step ${focusedStep.stepNo} of ${focusedStep.total}`}
|
|
552
552
|
style={{
|
|
553
553
|
position: 'absolute',
|
|
554
554
|
top: 12,
|
|
@@ -581,14 +581,14 @@ function TransitionInner({
|
|
|
581
581
|
textAlign: 'center',
|
|
582
582
|
}}
|
|
583
583
|
>
|
|
584
|
-
{
|
|
584
|
+
{focusedStep.trailTitle}
|
|
585
585
|
</div>
|
|
586
|
-
{
|
|
586
|
+
{focusedStep.total > 0 && (
|
|
587
587
|
<div style={{ display: 'flex', gap: 3, padding: '0 6px 5px' }} aria-hidden="true">
|
|
588
|
-
{Array.from({ length:
|
|
588
|
+
{Array.from({ length: focusedStep.total }, (_, i) => {
|
|
589
589
|
const n = i + 1;
|
|
590
|
-
const active = n ===
|
|
591
|
-
const done = n <
|
|
590
|
+
const active = n === focusedStep.stepNo;
|
|
591
|
+
const done = n < focusedStep.stepNo;
|
|
592
592
|
return (
|
|
593
593
|
<span
|
|
594
594
|
key={n}
|
|
@@ -4,11 +4,11 @@ import { cleanup, fireEvent, render, waitFor } from '@testing-library/react/pure
|
|
|
4
4
|
import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
|
|
5
5
|
import {
|
|
6
6
|
STEP_COPY_FEEDBACK_MS,
|
|
7
|
-
|
|
8
|
-
type
|
|
9
|
-
} from './
|
|
10
|
-
import type {
|
|
11
|
-
import { buildStepBrief } from './
|
|
7
|
+
TrailsPanel,
|
|
8
|
+
type TrailsPanelProps,
|
|
9
|
+
} from './TrailsPanel';
|
|
10
|
+
import type { SubsystemTrail } from './model';
|
|
11
|
+
import { buildStepBrief } from './trailBrief';
|
|
12
12
|
|
|
13
13
|
// Bun's happy-dom test environment needs `@happy-dom/global-registrator`, which
|
|
14
14
|
// isn't installed here, so wire the DOM primitives React DOM + Testing Library
|
|
@@ -33,7 +33,7 @@ globals.sessionStorage = dom.sessionStorage;
|
|
|
33
33
|
globals.matchMedia = dom.matchMedia.bind(dom);
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const trails: SubsystemTrail[] = [
|
|
37
37
|
{
|
|
38
38
|
id: 'auth-flow',
|
|
39
39
|
title: 'Auth flow',
|
|
@@ -63,13 +63,13 @@ beforeEach(() => {
|
|
|
63
63
|
|
|
64
64
|
afterEach(cleanup);
|
|
65
65
|
|
|
66
|
-
function renderPanel(overrides: Partial<
|
|
67
|
-
const props:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
function renderPanel(overrides: Partial<TrailsPanelProps> = {}) {
|
|
67
|
+
const props: TrailsPanelProps = {
|
|
68
|
+
trails,
|
|
69
|
+
expandedTrails: new Set(['auth-flow']),
|
|
70
|
+
focusedTrailId: null,
|
|
71
71
|
focusedStepIndex: null,
|
|
72
|
-
|
|
72
|
+
hoveredTrailStep: null,
|
|
73
73
|
onToggleCollapsed: () => {},
|
|
74
74
|
onFocusFlow: () => {},
|
|
75
75
|
onClearFocus: () => {},
|
|
@@ -81,14 +81,14 @@ function renderPanel(overrides: Partial<WalkthroughsPanelProps> = {}) {
|
|
|
81
81
|
};
|
|
82
82
|
return render(
|
|
83
83
|
<ThemeProvider theme={defaultEditorTheme}>
|
|
84
|
-
<
|
|
84
|
+
<TrailsPanel {...props} />
|
|
85
85
|
</ThemeProvider>,
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
const COPY_LABEL = 'Copy step 1 of Auth flow for an agent';
|
|
90
90
|
|
|
91
|
-
describe('
|
|
91
|
+
describe('TrailsPanel step copy', () => {
|
|
92
92
|
test('copy icon is hidden until the step row is hovered', () => {
|
|
93
93
|
const { getByText, queryByLabelText } = renderPanel();
|
|
94
94
|
expect(queryByLabelText(COPY_LABEL)).toBeNull();
|
|
@@ -111,7 +111,7 @@ describe('WalkthroughsPanel step copy', () => {
|
|
|
111
111
|
fireEvent.mouseDown(copy);
|
|
112
112
|
fireEvent.click(copy);
|
|
113
113
|
await waitFor(() => expect(writeText).toHaveBeenCalledTimes(1));
|
|
114
|
-
expect(writeText).toHaveBeenCalledWith(buildStepBrief(
|
|
114
|
+
expect(writeText).toHaveBeenCalledWith(buildStepBrief(trails[0]!, 0));
|
|
115
115
|
expect(copy.getAttribute('title')).toBe('Copied');
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -121,7 +121,7 @@ describe('WalkthroughsPanel step copy', () => {
|
|
|
121
121
|
const row = getByText('Login.submit').closest('button')!;
|
|
122
122
|
fireEvent.mouseEnter(row);
|
|
123
123
|
fireEvent.click(row);
|
|
124
|
-
expect(onFocusStep).toHaveBeenCalledWith(
|
|
124
|
+
expect(onFocusStep).toHaveBeenCalledWith(trails[0]!, 0);
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
test('the copied checkmark clears after the feedback window', async () => {
|