@principal-ai/subsystems-react 0.56.25 → 0.56.27
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/C4ProjectionView.d.ts +12 -2
- package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
- package/dist/subsystem/C4ProjectionView.js +22 -9
- package/dist/subsystem/C4ProjectionView.js.map +1 -1
- package/dist/subsystem/ConstructsCatalog.d.ts +18 -11
- package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
- package/dist/subsystem/ConstructsCatalog.js +25 -27
- package/dist/subsystem/ConstructsCatalog.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +13 -3
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +81 -27
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts +2 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.d.ts.map +1 -1
- package/dist/subsystem/__fixtures__/c4SketchGallery.js +8 -0
- package/dist/subsystem/__fixtures__/c4SketchGallery.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +2 -1
- package/dist/subsystem/__fixtures__/c4Sketches/openbot.json +2 -1
- package/dist/subsystem/model.d.ts +7 -0
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +27 -0
- package/dist/subsystem/model.js.map +1 -1
- package/package.json +1 -1
- package/src/stories/Canvases/C4/C4Sketch.stories.tsx +6 -0
- package/src/stories/Canvases/Subsystem/ContainerFrames.stories.tsx +6 -3
- package/src/stories/Canvases/Subsystem/CustomEntities.stories.tsx +2 -1
- package/src/stories/Canvases/Subsystem/EdgeViews.stories.tsx +2 -1
- package/src/stories/Canvases/Subsystem/Issues.stories.tsx +2 -1
- package/src/stories/Canvases/Subsystem/ModuleBadges.stories.tsx +3 -2
- package/src/stories/Canvases/Subsystem/Processes.stories.tsx +2 -1
- package/src/stories/Canvases/Subsystem/Reorder.stories.tsx +2 -1
- package/src/stories/Canvases/Subsystem/Scenarios.stories.tsx +6 -3
- package/src/stories/Canvases/Subsystem/TrailAutoplay.stories.tsx +2 -1
- package/src/stories/Canvases/Subsystem/Trails.stories.tsx +4 -2
- package/src/stories/Components/ConstructsCatalog.stories.tsx +2 -1
- package/src/subsystem/C4ProjectionView.tsx +44 -16
- package/src/subsystem/ConstructsCatalog.tsx +59 -58
- package/src/subsystem/DescriptionOverlay.test.tsx +16 -8
- package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +27 -7
- package/src/subsystem/SubsystemComponentGraph.tsx +140 -54
- package/src/subsystem/__fixtures__/c4SketchGallery.ts +10 -0
- package/src/subsystem/__fixtures__/c4Sketches/maintenance-bridge.json +2 -1
- package/src/subsystem/__fixtures__/c4Sketches/openbot.json +2 -1
- package/src/subsystem/model.collapse.test.ts +35 -1
- package/src/subsystem/model.ts +28 -0
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
15
15
|
import type { CSSProperties, ReactNode } from 'react';
|
|
16
16
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
17
|
-
import {
|
|
17
|
+
import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
|
|
18
18
|
import { C4Graph } from './C4Graph';
|
|
19
19
|
import type { C4ConstructGraph, C4GraphProps } from './C4Graph';
|
|
20
20
|
import { C4ContainersPanel } from './C4ContainersPanel';
|
|
21
|
+
import { DescriptionOverlay } from './DescriptionOverlay';
|
|
22
|
+
import { DescriptionPreview } from './DescriptionPreview';
|
|
21
23
|
import { GraphWithSidebar } from './GraphWithSidebar';
|
|
22
24
|
import { TrailStepsNav } from './TrailStepsNav';
|
|
23
25
|
import {
|
|
@@ -40,8 +42,18 @@ export interface C4ProjectionViewProps {
|
|
|
40
42
|
memberships: Readonly<Record<string, readonly string[]>>;
|
|
41
43
|
/** Sidebar heading. Falls back to the system label. */
|
|
42
44
|
title?: string;
|
|
43
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Short description shown under the heading. At most 200 characters;
|
|
47
|
+
* extended detail belongs in `notes`.
|
|
48
|
+
*/
|
|
44
49
|
description?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Extended Markdown notes about the model. When set, the description's
|
|
52
|
+
* `Show more` link opens the full document in an Overview overlay. Omit
|
|
53
|
+
* `description` and the sidebar falls back to a clamped preview of these
|
|
54
|
+
* notes.
|
|
55
|
+
*/
|
|
56
|
+
notes?: string;
|
|
45
57
|
/** Extra controls in the sidebar header (source badge, refresh, …). */
|
|
46
58
|
headerActions?: ReactNode;
|
|
47
59
|
/**
|
|
@@ -199,6 +211,7 @@ export function C4ProjectionView({
|
|
|
199
211
|
memberships,
|
|
200
212
|
title,
|
|
201
213
|
description,
|
|
214
|
+
notes,
|
|
202
215
|
headerActions,
|
|
203
216
|
openContainerIds,
|
|
204
217
|
onOpenContainerIdsChange,
|
|
@@ -211,6 +224,18 @@ export function C4ProjectionView({
|
|
|
211
224
|
style,
|
|
212
225
|
}: C4ProjectionViewProps) {
|
|
213
226
|
const { theme } = useTheme();
|
|
227
|
+
const [notesOpen, setNotesOpen] = useState(false);
|
|
228
|
+
const rawDescription = description?.trim();
|
|
229
|
+
// The host caps the authored description; trim defensively for other hosts.
|
|
230
|
+
const shortDescription =
|
|
231
|
+
rawDescription && rawDescription.length > SUBSYSTEM_MODEL_DESCRIPTION_MAX
|
|
232
|
+
? `${rawDescription.slice(0, SUBSYSTEM_MODEL_DESCRIPTION_MAX - 1)}…`
|
|
233
|
+
: rawDescription;
|
|
234
|
+
const extendedNotes = notes?.trim();
|
|
235
|
+
// The short description owns the header; a legacy model with only notes
|
|
236
|
+
// falls back to a clamped preview of them.
|
|
237
|
+
const descriptionPreview = shortDescription || extendedNotes;
|
|
238
|
+
const hasNotes = Boolean(extendedNotes);
|
|
214
239
|
const [internalOpenIds, setInternalOpenIds] = useState<string[]>(() =>
|
|
215
240
|
[...(openContainerIds ?? model.openContainerIds ?? [])].sort(),
|
|
216
241
|
);
|
|
@@ -499,20 +524,15 @@ export function C4ProjectionView({
|
|
|
499
524
|
setOpenIds([]);
|
|
500
525
|
}, [setOpenIds]);
|
|
501
526
|
|
|
502
|
-
const sidebarHeader =
|
|
503
|
-
<
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
disableBasePadding
|
|
512
|
-
enableKeyboardScrolling={false}
|
|
513
|
-
autoFocusOnVisible={false}
|
|
514
|
-
/>
|
|
515
|
-
</div>
|
|
527
|
+
const sidebarHeader = descriptionPreview ? (
|
|
528
|
+
<DescriptionPreview
|
|
529
|
+
content={descriptionPreview}
|
|
530
|
+
clamp={!shortDescription}
|
|
531
|
+
open={hasNotes && notesOpen}
|
|
532
|
+
onOpen={hasNotes ? () => setNotesOpen(true) : undefined}
|
|
533
|
+
onClose={hasNotes ? () => setNotesOpen(false) : undefined}
|
|
534
|
+
slideIdPrefix="c4-projection-desc"
|
|
535
|
+
/>
|
|
516
536
|
) : null;
|
|
517
537
|
|
|
518
538
|
return (
|
|
@@ -636,6 +656,14 @@ export function C4ProjectionView({
|
|
|
636
656
|
)
|
|
637
657
|
}
|
|
638
658
|
>
|
|
659
|
+
{hasNotes && notesOpen && (
|
|
660
|
+
<DescriptionOverlay
|
|
661
|
+
description={extendedNotes ?? ''}
|
|
662
|
+
ariaLabel="Subsystem notes"
|
|
663
|
+
slideIdPrefix="c4-projection-notes-overlay"
|
|
664
|
+
onClose={() => setNotesOpen(false)}
|
|
665
|
+
/>
|
|
666
|
+
)}
|
|
639
667
|
<C4Graph
|
|
640
668
|
model={renderedModel}
|
|
641
669
|
onSelectEdge={(edge) => {
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Left: the model's files as a tree; clicking a file toggles its
|
|
6
6
|
* constructs. Right: signatures grouped by repo, and within a repo stacked
|
|
7
|
-
* per file under one combined file header carrying the path
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* per file under one combined file header carrying the path; a declaration
|
|
8
|
+
* with a known line labels just that construct's line in a file-like gutter,
|
|
9
|
+
* and `external` constructs get a header naming their kind with the body
|
|
10
|
+
* naming the construct. The short model description sits in the left chrome;
|
|
11
|
+
* when `notes` is set, its `Show more` link opens the extended Markdown as an
|
|
12
12
|
* overlay over the construct area. File opens still use the bottom FileDrawer
|
|
13
13
|
* when the host injects a viewer.
|
|
14
14
|
*/
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
17
17
|
import type { ReactNode } from 'react';
|
|
18
18
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
19
|
+
import { SUBSYSTEM_MODEL_DESCRIPTION_MAX } from '@principal-ai/subsystems-core';
|
|
19
20
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
20
21
|
import {
|
|
21
22
|
AlignLeft,
|
|
@@ -35,6 +36,7 @@ import { ComponentDeclaration } from './ComponentDeclaration';
|
|
|
35
36
|
import type { ComponentVerificationState } from './ComponentDeclaration';
|
|
36
37
|
import type { DeclarationSymbolRef, SymbolInspection } from './symbolRefs';
|
|
37
38
|
import { SubsystemDiagnosticToggle, type SubsystemDiagnostic } from './DiagnosticToggle';
|
|
39
|
+
import { DescriptionPreview } from './DescriptionPreview';
|
|
38
40
|
import { FileDrawer } from './FileDrawer';
|
|
39
41
|
import { componentColor } from '../pierre/constructColors';
|
|
40
42
|
import { resolvePierreSyntaxThemeName } from '../pierre/pierreSyntaxTheme';
|
|
@@ -45,14 +47,21 @@ export interface ConstructsCatalogProps {
|
|
|
45
47
|
title?: string;
|
|
46
48
|
hideSidebar?: boolean;
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
+
* Short model description shown in the left chrome. At most 200 characters;
|
|
51
|
+
* extended detail belongs in `notes`.
|
|
50
52
|
*/
|
|
51
53
|
description?: string;
|
|
52
54
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* Extended Markdown notes about the model. When set, the description's
|
|
56
|
+
* `Show more` link opens the full document in an Overview overlay over the
|
|
57
|
+
* construct area. Omit `description` and the chrome falls back to a clamped
|
|
58
|
+
* preview of these notes.
|
|
59
|
+
*/
|
|
60
|
+
notes?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Controlled open state for the notes overlay. When provided the host owns
|
|
63
|
+
* it (e.g. a button in its own header); otherwise the built-in link drives
|
|
64
|
+
* the state.
|
|
56
65
|
*/
|
|
57
66
|
descriptionOpen?: boolean;
|
|
58
67
|
onDescriptionOpenChange?: (open: boolean) => void;
|
|
@@ -196,6 +205,7 @@ export function ConstructsCatalog({
|
|
|
196
205
|
title,
|
|
197
206
|
hideSidebar,
|
|
198
207
|
description,
|
|
208
|
+
notes,
|
|
199
209
|
descriptionOpen: descriptionOpenProp,
|
|
200
210
|
onDescriptionOpenChange,
|
|
201
211
|
diagnostic,
|
|
@@ -237,7 +247,17 @@ export function ConstructsCatalog({
|
|
|
237
247
|
setDescriptionVisible(open);
|
|
238
248
|
onDescriptionOpenChange?.(open);
|
|
239
249
|
};
|
|
240
|
-
const
|
|
250
|
+
const rawDescription = description?.trim();
|
|
251
|
+
// The host caps the authored description; trim defensively for other hosts.
|
|
252
|
+
const shortDescription =
|
|
253
|
+
rawDescription && rawDescription.length > SUBSYSTEM_MODEL_DESCRIPTION_MAX
|
|
254
|
+
? `${rawDescription.slice(0, SUBSYSTEM_MODEL_DESCRIPTION_MAX - 1)}…`
|
|
255
|
+
: rawDescription;
|
|
256
|
+
const extendedNotes = notes?.trim();
|
|
257
|
+
// The short description owns the chrome; a legacy model with only notes
|
|
258
|
+
// falls back to a clamped preview of them.
|
|
259
|
+
const descriptionPreview = shortDescription || extendedNotes;
|
|
260
|
+
const hasNotes = Boolean(extendedNotes);
|
|
241
261
|
const [hoveredRow, setHoveredRow] = useState<string | null>(null);
|
|
242
262
|
const [collapsedFolders, setCollapsedFolders] = useState<Set<string>>(
|
|
243
263
|
new Set(),
|
|
@@ -571,7 +591,7 @@ export function ConstructsCatalog({
|
|
|
571
591
|
!hideSidebar &&
|
|
572
592
|
!!(
|
|
573
593
|
title ||
|
|
574
|
-
|
|
594
|
+
descriptionPreview ||
|
|
575
595
|
diagnostic ||
|
|
576
596
|
sidebarExtra ||
|
|
577
597
|
sidebarAfterDescription
|
|
@@ -612,7 +632,7 @@ export function ConstructsCatalog({
|
|
|
612
632
|
}}
|
|
613
633
|
>
|
|
614
634
|
{sidebarExtra}
|
|
615
|
-
{(title ||
|
|
635
|
+
{(title || diagnostic) && (
|
|
616
636
|
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 8 }}>
|
|
617
637
|
{title && (
|
|
618
638
|
<h2
|
|
@@ -629,50 +649,31 @@ export function ConstructsCatalog({
|
|
|
629
649
|
{title}
|
|
630
650
|
</h2>
|
|
631
651
|
)}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
aria-expanded={descriptionOpen}
|
|
646
|
-
aria-label={
|
|
647
|
-
descriptionOpen ? 'Hide description' : 'Show description'
|
|
648
|
-
}
|
|
649
|
-
title={
|
|
650
|
-
descriptionOpen ? 'Hide description' : 'Show description'
|
|
651
|
-
}
|
|
652
|
-
onMouseEnter={() => setDescToggleHover(true)}
|
|
653
|
-
onMouseLeave={() => setDescToggleHover(false)}
|
|
654
|
-
onClick={() => setDescriptionOpen(!descriptionOpen)}
|
|
655
|
-
style={{
|
|
656
|
-
display: 'inline-flex',
|
|
657
|
-
alignItems: 'center',
|
|
658
|
-
justifyContent: 'center',
|
|
659
|
-
flexShrink: 0,
|
|
660
|
-
width: 22,
|
|
661
|
-
height: 22,
|
|
662
|
-
padding: 0,
|
|
663
|
-
border: 'none',
|
|
664
|
-
borderRadius: 4,
|
|
665
|
-
background: descriptionOpen || descToggleHover ? theme.colors.border : 'transparent',
|
|
666
|
-
color: descriptionOpen || descToggleHover ? theme.colors.text : muted,
|
|
667
|
-
cursor: 'pointer',
|
|
668
|
-
}}
|
|
669
|
-
>
|
|
670
|
-
<FileText size={14} />
|
|
671
|
-
</button>
|
|
672
|
-
)}
|
|
673
|
-
</div>
|
|
652
|
+
{diagnostic && (
|
|
653
|
+
<div
|
|
654
|
+
style={{
|
|
655
|
+
display: 'flex',
|
|
656
|
+
alignItems: 'center',
|
|
657
|
+
gap: 4,
|
|
658
|
+
flexShrink: 0,
|
|
659
|
+
marginLeft: title ? undefined : 'auto',
|
|
660
|
+
}}
|
|
661
|
+
>
|
|
662
|
+
<SubsystemDiagnosticToggle {...diagnostic} />
|
|
663
|
+
</div>
|
|
664
|
+
)}
|
|
674
665
|
</div>
|
|
675
666
|
)}
|
|
667
|
+
{descriptionPreview && (
|
|
668
|
+
<DescriptionPreview
|
|
669
|
+
content={descriptionPreview}
|
|
670
|
+
clamp={!shortDescription}
|
|
671
|
+
open={hasNotes && descriptionOpen}
|
|
672
|
+
onOpen={hasNotes ? () => setDescriptionOpen(true) : undefined}
|
|
673
|
+
onClose={hasNotes ? () => setDescriptionOpen(false) : undefined}
|
|
674
|
+
slideIdPrefix="constructs-desc"
|
|
675
|
+
/>
|
|
676
|
+
)}
|
|
676
677
|
{sidebarAfterDescription}
|
|
677
678
|
</div>
|
|
678
679
|
)}
|
|
@@ -715,7 +716,7 @@ export function ConstructsCatalog({
|
|
|
715
716
|
flexDirection: 'column',
|
|
716
717
|
}}
|
|
717
718
|
>
|
|
718
|
-
{
|
|
719
|
+
{hasNotes && descriptionOpen && (
|
|
719
720
|
<div
|
|
720
721
|
style={{
|
|
721
722
|
position: 'absolute',
|
|
@@ -753,7 +754,7 @@ export function ConstructsCatalog({
|
|
|
753
754
|
</h3>
|
|
754
755
|
<button
|
|
755
756
|
type="button"
|
|
756
|
-
aria-label="Close
|
|
757
|
+
aria-label="Close notes"
|
|
757
758
|
title="Close"
|
|
758
759
|
onClick={() => setDescriptionOpen(false)}
|
|
759
760
|
style={{
|
|
@@ -792,7 +793,7 @@ export function ConstructsCatalog({
|
|
|
792
793
|
}}
|
|
793
794
|
>
|
|
794
795
|
<IndustryMarkdownSlide
|
|
795
|
-
content={
|
|
796
|
+
content={extendedNotes ?? ''}
|
|
796
797
|
slideIdPrefix="constructs-desc-overlay"
|
|
797
798
|
slideIndex={0}
|
|
798
799
|
isVisible
|
|
@@ -24,7 +24,7 @@ globals.matchMedia = dom.matchMedia.bind(dom);
|
|
|
24
24
|
|
|
25
25
|
afterEach(cleanup);
|
|
26
26
|
|
|
27
|
-
function renderGraph(description: string | undefined) {
|
|
27
|
+
function renderGraph(description: string | undefined, notes?: string) {
|
|
28
28
|
return render(createElement(
|
|
29
29
|
ThemeProvider,
|
|
30
30
|
{ theme: defaultEditorTheme },
|
|
@@ -39,21 +39,23 @@ function renderGraph(description: string | undefined) {
|
|
|
39
39
|
steps: [{ from: 'entry', to: 'store', mechanism: 'calls' }],
|
|
40
40
|
}],
|
|
41
41
|
description,
|
|
42
|
+
notes,
|
|
42
43
|
}),
|
|
43
44
|
));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
describe('subsystem description overlay', () => {
|
|
47
48
|
for (const closeWithEscape of [false, true]) {
|
|
48
|
-
test(`More opens the full
|
|
49
|
-
const
|
|
50
|
-
const view = renderGraph(description);
|
|
49
|
+
test(`More opens the full notes over the graph and closes with ${closeWithEscape ? 'Escape' : 'the close button'}`, () => {
|
|
50
|
+
const notes = `${'A long note. '.repeat(50)}\n\n**Final detail**`;
|
|
51
|
+
const view = renderGraph('Short description.', notes);
|
|
51
52
|
const more = view.getByRole('button', { name: 'Read full description' });
|
|
52
53
|
more.focus();
|
|
53
54
|
fireEvent.click(more);
|
|
54
|
-
const overlay = view.getByRole('dialog', { name: 'Subsystem
|
|
55
|
-
expect(overlay.textContent).toContain('A long
|
|
55
|
+
const overlay = view.getByRole('dialog', { name: 'Subsystem notes' });
|
|
56
|
+
expect(overlay.textContent).toContain('A long note. '.repeat(50).trim());
|
|
56
57
|
expect(overlay.querySelector('strong')?.textContent).toBe('Final detail');
|
|
58
|
+
expect(overlay.textContent).not.toContain('Short description.');
|
|
57
59
|
expect(overlay.style.position).toBe('absolute');
|
|
58
60
|
expect(overlay.parentElement?.contains(view.getByLabelText('Resize sidebar'))).toBe(false);
|
|
59
61
|
expect(more.getAttribute('aria-expanded')).toBe('true');
|
|
@@ -70,9 +72,15 @@ describe('subsystem description overlay', () => {
|
|
|
70
72
|
});
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
test('does not offer More when there
|
|
74
|
-
const view = renderGraph(
|
|
75
|
+
test('does not offer More when there are no notes', () => {
|
|
76
|
+
const view = renderGraph('Short description only.');
|
|
75
77
|
expect(view.queryByRole('button', { name: 'Read full description' })).toBeNull();
|
|
76
78
|
expect(view.queryByRole('dialog')).toBeNull();
|
|
77
79
|
});
|
|
80
|
+
|
|
81
|
+
test('falls back to a clamped notes preview when there is no description', () => {
|
|
82
|
+
const view = renderGraph(undefined, `${'A long note. '.repeat(50)}\n\n**Final detail**`);
|
|
83
|
+
expect(view.getByRole('button', { name: 'Read full description' })).toBeTruthy();
|
|
84
|
+
expect(view.queryByRole('dialog')).toBeNull();
|
|
85
|
+
});
|
|
78
86
|
});
|
|
@@ -61,19 +61,39 @@ describe('subsystem graph sidebar', () => {
|
|
|
61
61
|
expect(content?.textContent).not.toContain('Request subsystem');
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
test('
|
|
64
|
+
test('shows the short description unclamped and without a notes link', () => {
|
|
65
65
|
const body = renderGraph();
|
|
66
|
-
const description = body.querySelector('[style*="-webkit-line-clamp:6"]') as HTMLElement;
|
|
67
|
-
expect(description).
|
|
68
|
-
expect(
|
|
69
|
-
expect(
|
|
70
|
-
expect(
|
|
66
|
+
const description = body.querySelector('[style*="-webkit-line-clamp:6"]') as HTMLElement | null;
|
|
67
|
+
expect(description).toBeNull();
|
|
68
|
+
expect(body.textContent).toContain('Always visible description.');
|
|
69
|
+
expect(body.querySelector('button[aria-label="Read full description"]')).toBeNull();
|
|
70
|
+
expect(body.querySelector('[role="dialog"]')).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('offers the extended notes from the short description', () => {
|
|
74
|
+
const body = renderGraph({
|
|
75
|
+
notes: '## Extended\n\nLonger **context**.',
|
|
76
|
+
});
|
|
77
|
+
expect(body.textContent).toContain('Always visible description.');
|
|
78
|
+
expect(body.textContent).not.toContain('Longer context.');
|
|
71
79
|
const more = body.querySelector('button[aria-label="Read full description"]');
|
|
72
80
|
expect(more?.textContent).toBe('Show more');
|
|
73
81
|
expect(more?.getAttribute('aria-haspopup')).toBe('dialog');
|
|
74
82
|
expect(more?.getAttribute('aria-expanded')).toBe('false');
|
|
75
83
|
expect(body.querySelector('[role="dialog"]')).toBeNull();
|
|
76
|
-
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('falls back to a clamped notes preview when there is no description', () => {
|
|
87
|
+
const body = renderGraph({
|
|
88
|
+
description: undefined,
|
|
89
|
+
notes: '## Extended\n\nLonger **context**.',
|
|
90
|
+
});
|
|
91
|
+
const preview = body.querySelector('[style*="-webkit-line-clamp:6"]') as HTMLElement;
|
|
92
|
+
expect(preview).not.toBeNull();
|
|
93
|
+
expect(preview.textContent).toContain('Extended');
|
|
94
|
+
expect(preview.style.overflow).toBe('hidden');
|
|
95
|
+
expect(preview.style.maxHeight).toBe('9em');
|
|
96
|
+
expect(body.querySelector('button[aria-label="Read full description"]')?.textContent).toBe('Show more');
|
|
77
97
|
});
|
|
78
98
|
|
|
79
99
|
test('keeps the Files button in the header when no name is provided', () => {
|