@xynolog/react-ui 0.8.0 → 0.8.1

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.
Files changed (235) hide show
  1. package/README.md +26 -46
  2. package/package.json +12 -9
  3. package/src/components/Button/Button.tsx +0 -188
  4. package/src/components/Button/__tests__/Button.test.tsx +0 -449
  5. package/src/components/CodeMirrorRenderer.tsx +0 -536
  6. package/src/components/DelegateProgress.tsx +0 -308
  7. package/src/components/ErrorBoundary.tsx +0 -174
  8. package/src/components/ItemFoundLog.tsx +0 -42
  9. package/src/components/LiveRegion.tsx +0 -261
  10. package/src/components/ProtectedErrorBoundary.tsx +0 -114
  11. package/src/components/ResizeHandle.tsx +0 -167
  12. package/src/components/ResourceTagsInline.tsx +0 -120
  13. package/src/components/SessionExpiryBanner.tsx +0 -74
  14. package/src/components/SessionTimer.tsx +0 -17
  15. package/src/components/StatusDisplay.tsx +0 -131
  16. package/src/components/Toast.tsx +0 -217
  17. package/src/components/Toolbar.tsx +0 -194
  18. package/src/components/UserMenuSkeleton.tsx +0 -13
  19. package/src/components/__tests__/DelegateProgress.denominator.test.tsx +0 -102
  20. package/src/components/__tests__/DelegateProgress.test.tsx +0 -649
  21. package/src/components/__tests__/ErrorBoundary.test.tsx +0 -565
  22. package/src/components/__tests__/LiveRegion.a11y.test.tsx +0 -258
  23. package/src/components/__tests__/LiveRegion.hooks.test.tsx +0 -140
  24. package/src/components/__tests__/ProtectedErrorBoundary.test.tsx +0 -225
  25. package/src/components/__tests__/ResizeHandle.test.tsx +0 -159
  26. package/src/components/__tests__/ResourceTagsInline.test.tsx +0 -325
  27. package/src/components/__tests__/SessionExpiryBanner.test.tsx +0 -124
  28. package/src/components/__tests__/SessionTimer.test.tsx +0 -199
  29. package/src/components/__tests__/StatusDisplay.test.tsx +0 -179
  30. package/src/components/__tests__/Toast.test.tsx +0 -96
  31. package/src/components/__tests__/Toolbar.test.tsx +0 -111
  32. package/src/components/__tests__/UserMenuSkeleton.test.tsx +0 -182
  33. package/src/components/annotation/AnchoredTextNotice.tsx +0 -36
  34. package/src/components/annotation/AnnotateToolbar.tsx +0 -531
  35. package/src/components/annotation/__tests__/AnnotateToolbar.display.test.tsx +0 -127
  36. package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +0 -304
  37. package/src/components/annotation-popups/JsonLdView.tsx +0 -127
  38. package/src/components/annotation-popups/SharedPopupElements.tsx +0 -131
  39. package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +0 -432
  40. package/src/components/annotation-popups/__tests__/SharedPopupElements.test.tsx +0 -297
  41. package/src/components/branding/XynologBranding.tsx +0 -41
  42. package/src/components/branding/__tests__/XynologBranding.test.tsx +0 -383
  43. package/src/components/error-states/ResourceErrorState.tsx +0 -30
  44. package/src/components/error-states/__tests__/ResourceErrorState.test.tsx +0 -102
  45. package/src/components/image-annotation/AnnotationOverlay.tsx +0 -307
  46. package/src/components/image-annotation/SvgDrawingCanvas.tsx +0 -514
  47. package/src/components/image-annotation/__tests__/AnnotationOverlay.click.test.tsx +0 -169
  48. package/src/components/image-annotation/__tests__/AnnotationOverlay.hover.test.tsx +0 -83
  49. package/src/components/image-annotation/__tests__/SvgDrawingCanvas.annotate-gate.test.tsx +0 -228
  50. package/src/components/image-annotation/__tests__/SvgDrawingCanvas.click.test.tsx +0 -204
  51. package/src/components/layout/LeftSidebar.tsx +0 -150
  52. package/src/components/layout/PageLayout.tsx +0 -49
  53. package/src/components/layout/SkipLinks.tsx +0 -36
  54. package/src/components/layout/UnifiedHeader.tsx +0 -151
  55. package/src/components/layout/__tests__/LeftSidebar.test.tsx +0 -426
  56. package/src/components/layout/__tests__/PageLayout.test.tsx +0 -311
  57. package/src/components/layout/__tests__/SkipLinks.a11y.test.tsx +0 -218
  58. package/src/components/layout/__tests__/UnifiedHeader.test.tsx +0 -555
  59. package/src/components/loading-states/ComposeLoadingState.tsx +0 -19
  60. package/src/components/loading-states/ResourceLoadingState.tsx +0 -13
  61. package/src/components/loading-states/__tests__/ComposeLoadingState.test.tsx +0 -37
  62. package/src/components/loading-states/__tests__/ResourceLoadingState.test.tsx +0 -31
  63. package/src/components/modals/ComposeStep.tsx +0 -245
  64. package/src/components/modals/ConfigureGatherStep.tsx +0 -110
  65. package/src/components/modals/ConfigureGenerationStep.tsx +0 -458
  66. package/src/components/modals/ConfigureSearchStep.tsx +0 -124
  67. package/src/components/modals/ContextSummary.tsx +0 -317
  68. package/src/components/modals/CorpusPane.tsx +0 -96
  69. package/src/components/modals/DiscardPrompt.tsx +0 -44
  70. package/src/components/modals/GatherContextStep.tsx +0 -480
  71. package/src/components/modals/KbIdentityConflictModal.tsx +0 -122
  72. package/src/components/modals/KeyboardShortcutsHelpModal.tsx +0 -238
  73. package/src/components/modals/PermissionDeniedModal.tsx +0 -207
  74. package/src/components/modals/ReferenceWizardModal.tsx +0 -656
  75. package/src/components/modals/ResourceGenerateModal.tsx +0 -457
  76. package/src/components/modals/SearchModal.tsx +0 -334
  77. package/src/components/modals/SearchResultsStep.tsx +0 -117
  78. package/src/components/modals/SessionEndedModal.tsx +0 -148
  79. package/src/components/modals/WizardFooter.tsx +0 -72
  80. package/src/components/modals/__tests__/ComposeStep.test.tsx +0 -187
  81. package/src/components/modals/__tests__/ConfigureGatherStep.test.tsx +0 -92
  82. package/src/components/modals/__tests__/ConfigureGenerationStep.test.tsx +0 -574
  83. package/src/components/modals/__tests__/ConfigureSearchStep.test.tsx +0 -124
  84. package/src/components/modals/__tests__/GatherContextStep.resource.test.tsx +0 -702
  85. package/src/components/modals/__tests__/KbIdentityConflictModal.test.tsx +0 -102
  86. package/src/components/modals/__tests__/KeyboardShortcutsHelpModal.test.tsx +0 -115
  87. package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +0 -218
  88. package/src/components/modals/__tests__/ReferenceWizardModal.test.tsx +0 -936
  89. package/src/components/modals/__tests__/ResourceGenerateModal.test.tsx +0 -532
  90. package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +0 -95
  91. package/src/components/modals/__tests__/SearchModal.basic.test.tsx +0 -84
  92. package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +0 -162
  93. package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +0 -237
  94. package/src/components/modals/__tests__/SearchModal.translations.test.tsx +0 -91
  95. package/src/components/modals/__tests__/SearchResultsStep.test.tsx +0 -95
  96. package/src/components/modals/__tests__/SessionEndedModal.test.tsx +0 -171
  97. package/src/components/modals/__tests__/WizardFooter.test.tsx +0 -446
  98. package/src/components/modals/__tests__/search-modal-harness.ts +0 -82
  99. package/src/components/navigation/CollapsibleResourceNavigation.tsx +0 -364
  100. package/src/components/navigation/NavigationMenu.tsx +0 -66
  101. package/src/components/navigation/ObservableLink.tsx +0 -90
  102. package/src/components/navigation/SimpleNavigation.tsx +0 -169
  103. package/src/components/navigation/SortableResourceTab.tsx +0 -122
  104. package/src/components/navigation/__tests__/NavigationMenu.a11y.test.tsx +0 -302
  105. package/src/components/navigation/__tests__/NavigationMenu.test.tsx +0 -399
  106. package/src/components/navigation/__tests__/ObservableLink.test.tsx +0 -85
  107. package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +0 -193
  108. package/src/components/navigation/__tests__/SortableResourceTab.test.tsx +0 -421
  109. package/src/components/pdf-annotation/PdfAnnotationCanvas.client.tsx +0 -10
  110. package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +0 -632
  111. package/src/components/pdf-annotation/PdfPageView.tsx +0 -527
  112. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.annotate-gate.test.tsx +0 -295
  113. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.pixels-before-anchoring.test.tsx +0 -166
  114. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +0 -1719
  115. package/src/components/pdf-annotation/__tests__/estimate-slot-height.test.ts +0 -61
  116. package/src/components/pdf-annotation/__tests__/rects-for-page.test.ts +0 -110
  117. package/src/components/pdf-annotation/estimate-slot-height.ts +0 -31
  118. package/src/components/pdf-annotation/rects-for-page.ts +0 -50
  119. package/src/components/resource/AnnotateView.tsx +0 -373
  120. package/src/components/resource/AnnotationHistory.tsx +0 -169
  121. package/src/components/resource/BrowseView.tsx +0 -440
  122. package/src/components/resource/DownloadFileLink.tsx +0 -53
  123. package/src/components/resource/HistoryEvent.tsx +0 -186
  124. package/src/components/resource/ResourceViewer.tsx +0 -617
  125. package/src/components/resource/__tests__/AnnotateView.code-point-offsets.test.tsx +0 -482
  126. package/src/components/resource/__tests__/AnnotateView.embeddable.test.tsx +0 -78
  127. package/src/components/resource/__tests__/AnnotateView.focus.test.tsx +0 -147
  128. package/src/components/resource/__tests__/AnnotateView.registry.test.tsx +0 -143
  129. package/src/components/resource/__tests__/AnnotationHistory.test.tsx +0 -257
  130. package/src/components/resource/__tests__/BrowseView.code-point-offsets.test.tsx +0 -123
  131. package/src/components/resource/__tests__/BrowseView.embeddable.test.tsx +0 -76
  132. package/src/components/resource/__tests__/BrowseView.links.test.tsx +0 -84
  133. package/src/components/resource/__tests__/BrowseView.overlay-async.test.tsx +0 -165
  134. package/src/components/resource/__tests__/BrowseView.reference-hover.test.tsx +0 -200
  135. package/src/components/resource/__tests__/BrowseView.registry.test.tsx +0 -57
  136. package/src/components/resource/__tests__/BrowseView.test.tsx +0 -915
  137. package/src/components/resource/__tests__/HistoryEvent.test.tsx +0 -571
  138. package/src/components/resource/__tests__/ResourceViewer.delete-failure.test.tsx +0 -103
  139. package/src/components/resource/__tests__/ResourceViewer.embeddable.test.tsx +0 -250
  140. package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +0 -262
  141. package/src/components/resource/__tests__/ResourceViewer.multi-mount-invalidation.test.tsx +0 -166
  142. package/src/components/resource/__tests__/ResourceViewer.registry.test.tsx +0 -112
  143. package/src/components/resource/__tests__/ResourceViewer.toolbar-opt-out.test.tsx +0 -207
  144. package/src/components/resource/__tests__/ResourceViewer.toolbar-prefs.test.tsx +0 -274
  145. package/src/components/resource/__tests__/annotation-interactions.test.tsx +0 -116
  146. package/src/components/resource/__tests__/browse-renderers.dispatch.test.tsx +0 -183
  147. package/src/components/resource/__tests__/browse-renderers.test.tsx +0 -47
  148. package/src/components/resource/__tests__/download-link.test.tsx +0 -171
  149. package/src/components/resource/__tests__/event-formatting.test.ts +0 -379
  150. package/src/components/resource/__tests__/inline-embedding.test.tsx +0 -133
  151. package/src/components/resource/__tests__/media-completeness.test.tsx +0 -144
  152. package/src/components/resource/annotate-renderers.tsx +0 -186
  153. package/src/components/resource/browse-renderers.tsx +0 -133
  154. package/src/components/resource/event-formatting.ts +0 -393
  155. package/src/components/resource/panels/AssessmentEntry.tsx +0 -127
  156. package/src/components/resource/panels/AssessmentPanel.tsx +0 -309
  157. package/src/components/resource/panels/CollaborationPanel.tsx +0 -228
  158. package/src/components/resource/panels/CommentEntry.tsx +0 -242
  159. package/src/components/resource/panels/CommentsPanel.tsx +0 -320
  160. package/src/components/resource/panels/DelegateSection.tsx +0 -282
  161. package/src/components/resource/panels/DelegateShell.tsx +0 -134
  162. package/src/components/resource/panels/HighlightEntry.tsx +0 -83
  163. package/src/components/resource/panels/HighlightPanel.tsx +0 -212
  164. package/src/components/resource/panels/JsonLdPanel.tsx +0 -119
  165. package/src/components/resource/panels/PanelHeader.tsx +0 -22
  166. package/src/components/resource/panels/ReferenceEntry.tsx +0 -232
  167. package/src/components/resource/panels/ReferencesPanel.tsx +0 -626
  168. package/src/components/resource/panels/ResourceInfoPanel.tsx +0 -433
  169. package/src/components/resource/panels/StatisticsPanel.tsx +0 -145
  170. package/src/components/resource/panels/TagEntry.tsx +0 -87
  171. package/src/components/resource/panels/TaggingPanel.tsx +0 -554
  172. package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +0 -384
  173. package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +0 -292
  174. package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +0 -685
  175. package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +0 -685
  176. package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +0 -750
  177. package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +0 -877
  178. package/src/components/resource/panels/__tests__/DelegateSection.test.tsx +0 -623
  179. package/src/components/resource/panels/__tests__/DelegateShell.test.tsx +0 -212
  180. package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +0 -236
  181. package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +0 -506
  182. package/src/components/resource/panels/__tests__/HighlightPanel.out-of-order.test.tsx +0 -132
  183. package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +0 -230
  184. package/src/components/resource/panels/__tests__/PanelHeader.test.tsx +0 -54
  185. package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +0 -578
  186. package/src/components/resource/panels/__tests__/ReferencesPanel.headless.test.tsx +0 -193
  187. package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +0 -193
  188. package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +0 -1080
  189. package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +0 -812
  190. package/src/components/resource/panels/__tests__/ResourceInfoPanel.text-layer.test.tsx +0 -106
  191. package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +0 -329
  192. package/src/components/resource/panels/__tests__/TagEntry.test.tsx +0 -250
  193. package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +0 -772
  194. package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.delegated-job.test.tsx +0 -207
  195. package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.failure.test.tsx +0 -89
  196. package/src/components/resource/panels/__tests__/agent-label.test.ts +0 -136
  197. package/src/components/resource/panels/agent-label.ts +0 -35
  198. package/src/components/settings/SettingsPanel.tsx +0 -251
  199. package/src/components/settings/__tests__/SettingsPanel.test.tsx +0 -260
  200. package/src/components/viewers/ImageViewer.tsx +0 -18
  201. package/src/components/viewers/__tests__/ImageViewer.test.tsx +0 -57
  202. package/src/components/viewers/index.ts +0 -1
  203. package/src/features/auth/__tests__/AuthErrorDisplay.test.tsx +0 -181
  204. package/src/features/auth/components/AuthErrorDisplay.tsx +0 -89
  205. package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +0 -387
  206. package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +0 -161
  207. package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +0 -183
  208. package/src/features/moderate-entity-tags/state/entity-tags-state-unit.ts +0 -73
  209. package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +0 -422
  210. package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +0 -117
  211. package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +0 -481
  212. package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +0 -161
  213. package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +0 -600
  214. package/src/features/resource-compose/__tests__/UploadProgressBar.test.tsx +0 -256
  215. package/src/features/resource-compose/components/ResourceComposePage.tsx +0 -809
  216. package/src/features/resource-compose/components/UploadProgressBar.tsx +0 -125
  217. package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +0 -195
  218. package/src/features/resource-compose/state/compose-page-state-unit.ts +0 -187
  219. package/src/features/resource-discovery/__tests__/ResourceCard.test.tsx +0 -338
  220. package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +0 -449
  221. package/src/features/resource-discovery/components/ResourceCard.tsx +0 -80
  222. package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +0 -330
  223. package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +0 -477
  224. package/src/features/resource-discovery/state/discover-state-unit.ts +0 -162
  225. package/src/features/resource-viewer/__tests__/ResourceViewerPage.content-loading.test.tsx +0 -260
  226. package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +0 -570
  227. package/src/features/resource-viewer/__tests__/generation-params.test.ts +0 -49
  228. package/src/features/resource-viewer/components/ResourceViewerPage.tsx +0 -1058
  229. package/src/features/resource-viewer/generation-params.ts +0 -23
  230. package/src/features/resource-viewer/hooks/__tests__/useResourceViewedReport.test.tsx +0 -77
  231. package/src/features/resource-viewer/hooks/useResourceViewedReport.ts +0 -38
  232. package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +0 -178
  233. package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +0 -505
  234. package/src/features/resource-viewer/state/resource-loader-state-unit.ts +0 -93
  235. package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +0 -156
@@ -1,532 +0,0 @@
1
- /**
2
- * The resource-generate flow modal.
3
- *
4
- * One composite stack, no step machine: the gather controls sit at the TOP,
5
- * the gathered evidence appears below them once gather fires, and the
6
- * generation params render beneath the evidence once context arrives —
7
- * [gather zone] → [evidence] → [act zone], the same grammar the resolve
8
- * wizard expresses. Gather state arrives as PROPS (the page reads
9
- * `gather.resourceContext$` and friends off the state unit) and the gather
10
- * itself is an `onGather` callback — the modal mocks no hook and reaches for
11
- * no provider. Entity-type options are owner-supplied, so a failed
12
- * load cannot surface as an empty vocabulary.
13
- */
14
- import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
15
- import { render, screen, fireEvent } from '@testing-library/react';
16
- import '@testing-library/jest-dom';
17
- import type { GatheredContext } from '@xynolog/core';
18
- import type { ResourceGatherOptions } from '@xynolog/sdk';
19
- import type { GenerationConfig } from '../ConfigureGenerationStep';
20
- import { ResourceGenerateModal } from '../ResourceGenerateModal';
21
-
22
- const RESOURCE_CONTEXT = {
23
- focus: {
24
- kind: 'resource',
25
- resource: { '@id': 'res-1', name: 'My Resource' },
26
- summary: 'A short summary',
27
- },
28
- graph: {
29
- nodes: [{ id: 'res-1', type: 'resource', label: 'My Resource' }],
30
- edges: [],
31
- },
32
- metadata: {},
33
- } as unknown as GatheredContext;
34
-
35
- const T = {
36
- title: 'Generate from this Resource',
37
- gatherIntro: 'Choose what to include.',
38
- includeContent: 'Include content',
39
- includeSummary: 'Include summary',
40
- gatherDepth: 'Depth',
41
- gatherMaxResources: 'Max resources',
42
- gatherButton: 'Gather',
43
- recallLabel: 'Included in recall — deselect to exclude',
44
- loadingContext: 'Gathering…',
45
- failedContext: 'Failed',
46
- sourceContextLabel: 'Resource',
47
- connectionsLabel: 'Connections',
48
- citedByLabel: 'Cited by',
49
- graphPaneTitle: 'In the graph',
50
- graphEmpty: 'No links yet.',
51
- resourceLinkLabel: 'Resource link',
52
- corpusPaneTitle: 'In the corpus',
53
- corpusEmpty: 'Nothing similar in the corpus.',
54
- excludedReceipt: '{{types}} excluded from this recall',
55
- machineRead: 'OCR',
56
- score: 'Score',
57
- resourceTitle: 'New resource title',
58
- resourceTitlePlaceholder: 'Title…',
59
- saveLocation: 'Save location',
60
- additionalInstructions: 'Additional Instructions',
61
- additionalInstructionsPlaceholder: 'Optional…',
62
- language: 'Language',
63
- languageHelp: 'Language help',
64
- creativity: 'Creativity',
65
- creativityFocused: 'Focused',
66
- creativityCreative: 'Creative',
67
- maxLength: 'Max Length',
68
- maxLengthHelp: 'Max help',
69
- maxLengthCeiling: 'Limited to {{maxOutputTokens}} tokens by {{model}}.',
70
- outputFormat: 'Format',
71
- formatExtensionMismatch:
72
- 'Save location must end in {{extension}} to match the selected format.',
73
- generate: 'Generate',
74
- discardDraftPrompt: 'Discard this draft?',
75
- discardDraft: 'Discard',
76
- keepEditing: 'Keep editing',
77
- editGather: 'Change gather settings',
78
- };
79
-
80
- let onClose: Mock<() => void>;
81
- let onGenerateSubmit: Mock<
82
- (resourceId: string, config: GenerationConfig) => void
83
- >;
84
- let onGather: Mock<(options: ResourceGatherOptions) => void>;
85
-
86
- function renderModal(
87
- props: Partial<React.ComponentProps<typeof ResourceGenerateModal>> = {},
88
- ) {
89
- return render(
90
- <ResourceGenerateModal
91
- isOpen
92
- onClose={onClose}
93
- resourceId="res-1"
94
- defaultTitle="Default Title"
95
- locale="en"
96
- entityTypeOptions={['Person', 'Topic']}
97
- onGenerateSubmit={onGenerateSubmit}
98
- gatherContext={null}
99
- gatherLoading={false}
100
- gatherError={null}
101
- onGather={onGather}
102
- translations={T}
103
- {...props}
104
- />,
105
- );
106
- }
107
-
108
- describe('ResourceGenerateModal', () => {
109
- beforeEach(() => {
110
- vi.clearAllMocks();
111
- onClose = vi.fn<() => void>();
112
- onGenerateSubmit =
113
- vi.fn<(resourceId: string, config: GenerationConfig) => void>();
114
- onGather = vi.fn<(options: ResourceGatherOptions) => void>();
115
- // jsdom doesn't implement scrollIntoView; GatherContextStep may call it.
116
- Element.prototype.scrollIntoView = vi.fn();
117
- });
118
-
119
- it('renders nothing when closed', () => {
120
- renderModal({ isOpen: false });
121
- expect(screen.queryByText(T.title)).not.toBeInTheDocument();
122
- });
123
-
124
- it('opens with the gather controls at the top and nothing below them yet', () => {
125
- // Stale slots must not leak a previous run's evidence into a fresh open:
126
- // even with a context PROP already present, nothing renders below the
127
- // controls until THIS run's gather fires.
128
- const { baseElement } = renderModal({ gatherContext: RESOURCE_CONTEXT });
129
- expect(screen.getByText(T.title)).toBeInTheDocument(); // the one modal title
130
- expect(screen.getByText(T.gatherIntro)).toBeInTheDocument();
131
- expect(screen.getByLabelText(T.includeContent)).toBeInTheDocument();
132
- expect(screen.getByRole('button', { name: 'Person' })).toBeInTheDocument();
133
- expect(screen.getByRole('button', { name: 'Topic' })).toBeInTheDocument();
134
- expect(
135
- baseElement.querySelector('.xynolog-wizard__step-scroll'),
136
- ).not.toBeNull();
137
- expect(screen.queryByText(T.graphPaneTitle)).not.toBeInTheDocument();
138
- expect(screen.queryByLabelText(T.resourceTitle)).not.toBeInTheDocument();
139
- });
140
-
141
- it('Gather emits onGather; the spent controls collapse to a receipt of what fired', () => {
142
- // The modal does not know how to gather — it says WHAT to gather and the
143
- // page wires the state unit. No resourceId in the payload: the
144
- // owner already holds it.
145
- const { baseElement } = renderModal({ gatherLoading: true });
146
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
147
- expect(onGather).toHaveBeenCalledWith({
148
- includeContent: true,
149
- includeSummary: true,
150
- depth: 2,
151
- maxResources: 10,
152
- });
153
- expect(
154
- baseElement.querySelector('.xynolog-gather__loading'),
155
- ).not.toBeNull();
156
- // The form's job is done: it folds into a one-line receipt of what THIS
157
- // gather asked for, and the evidence leads the pane. The form stays
158
- // mounted (hidden) so its values survive for the expand path.
159
- const receipt = screen.getByTitle(T.editGather);
160
- expect(receipt.textContent).toContain(`${T.gatherDepth} 2`);
161
- expect(receipt.textContent).toContain(`${T.gatherMaxResources} 10`);
162
- expect(receipt.textContent).toContain(T.includeContent);
163
- expect(screen.getByText(T.gatherIntro)).not.toBeVisible();
164
- });
165
-
166
- it('the receipt names the exclusions of THIS recall', () => {
167
- renderModal();
168
- fireEvent.click(screen.getByRole('button', { name: 'Person' }));
169
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
170
- expect(screen.getByTitle(T.editGather).textContent).toContain(
171
- 'Person excluded from this recall',
172
- );
173
- });
174
-
175
- it('the receipt expands back to the form — values preserved — and re-gather collapses again', () => {
176
- renderModal({ gatherContext: RESOURCE_CONTEXT });
177
- fireEvent.change(screen.getByLabelText(T.gatherDepth), {
178
- target: { value: '3' },
179
- });
180
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
181
- expect(screen.getByTitle(T.editGather).textContent).toContain(
182
- `${T.gatherDepth} 3`,
183
- );
184
-
185
- fireEvent.click(screen.getByTitle(T.editGather));
186
- const depthInput = screen.getByLabelText(T.gatherDepth);
187
- expect(depthInput).toBeVisible();
188
- expect(depthInput).toHaveValue(3); // not re-initialized — the form never unmounted
189
- expect(screen.queryByTitle(T.editGather)).not.toBeInTheDocument();
190
-
191
- fireEvent.change(depthInput, { target: { value: '1' } });
192
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
193
- expect(onGather).toHaveBeenCalledTimes(2);
194
- expect(onGather).toHaveBeenLastCalledWith(
195
- expect.objectContaining({ depth: 1 }),
196
- );
197
- expect(screen.getByTitle(T.editGather).textContent).toContain(
198
- `${T.gatherDepth} 1`,
199
- );
200
- });
201
-
202
- it('threads crossed-off entity types into the gather options as the exclude list', () => {
203
- renderModal();
204
- fireEvent.click(screen.getByRole('button', { name: 'Person' })); // cross off the recall
205
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
206
- expect(onGather).toHaveBeenCalledWith({
207
- includeContent: true,
208
- includeSummary: true,
209
- depth: 2,
210
- maxResources: 10,
211
- excludeEntityTypes: ['Person'],
212
- });
213
- });
214
-
215
- it('every entity type starts INCLUDED — deselecting is what excludes (recall chips)', () => {
216
- // The SDK's wire is an exclude list, but the natural posture is
217
- // "everything is in the recall until you say otherwise": chips render
218
- // included by default and a click crosses one off.
219
- renderModal();
220
- expect(screen.getByText(T.recallLabel)).toBeInTheDocument();
221
- const person = screen.getByRole('button', { name: 'Person' });
222
- const topic = screen.getByRole('button', { name: 'Topic' });
223
- expect(person).toHaveAttribute('aria-pressed', 'true');
224
- expect(person).toHaveAttribute('data-included', 'true');
225
- expect(person.className).toContain('xynolog-form__recall-chip');
226
-
227
- fireEvent.click(person);
228
- expect(person).toHaveAttribute('aria-pressed', 'false');
229
- expect(person).toHaveAttribute('data-included', 'false');
230
- expect(topic).toHaveAttribute('aria-pressed', 'true'); // the rest stay in
231
-
232
- fireEvent.click(person); // back in — the toggle round-trips
233
- expect(person).toHaveAttribute('aria-pressed', 'true');
234
- });
235
-
236
- it('params render beneath the evidence once context arrives; Generate emits and closes', () => {
237
- renderModal({ gatherContext: RESOURCE_CONTEXT }); // gather resolves immediately
238
-
239
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
240
-
241
- fireEvent.change(screen.getByLabelText(T.resourceTitle), {
242
- target: { value: 'Generated Doc' },
243
- });
244
- fireEvent.change(screen.getByLabelText(T.saveLocation), {
245
- target: { value: 'generated/out.md' },
246
- });
247
- fireEvent.click(screen.getByRole('button', { name: /Generate/ }));
248
-
249
- expect(onGenerateSubmit).toHaveBeenCalledTimes(1);
250
- expect(onGenerateSubmit).toHaveBeenCalledWith(
251
- 'res-1',
252
- expect.objectContaining({
253
- title: 'Generated Doc',
254
- // The submitted payload names this what it IS — a full storage
255
- // URI, built here by prefixing `file://`.
256
- storageUri: 'file://generated/out.md',
257
- // The default is sent, not inherited from the worker.
258
- outputMediaType: 'text/markdown',
259
- context: RESOURCE_CONTEXT,
260
- }),
261
- );
262
- expect(onClose).toHaveBeenCalled();
263
- });
264
-
265
- it('a chosen output format survives the host to onGenerateSubmit', () => {
266
- renderModal({ gatherContext: RESOURCE_CONTEXT });
267
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
268
-
269
- fireEvent.change(screen.getByLabelText(T.resourceTitle), {
270
- target: { value: 'Generated Doc' },
271
- });
272
- fireEvent.change(screen.getByLabelText(T.saveLocation), {
273
- target: { value: 'generated/out.pdf' },
274
- });
275
- fireEvent.change(screen.getByLabelText(T.outputFormat), {
276
- target: { value: 'application/pdf' },
277
- });
278
- fireEvent.click(screen.getByRole('button', { name: /Generate/ }));
279
-
280
- expect(onGenerateSubmit).toHaveBeenCalledWith(
281
- 'res-1',
282
- expect.objectContaining({
283
- outputMediaType: 'application/pdf',
284
- storageUri: 'file://generated/out.pdf',
285
- }),
286
- );
287
- });
288
-
289
- it('a failed gather shows its failure in place', () => {
290
- // The props are the state unit's slots verbatim; the modal renders them
291
- // without owning them.
292
- renderModal({ gatherLoading: true });
293
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
294
-
295
- render(
296
- <ResourceGenerateModal
297
- isOpen
298
- onClose={onClose}
299
- resourceId="res-1"
300
- defaultTitle="Default Title"
301
- locale="en"
302
- entityTypeOptions={['Person', 'Topic']}
303
- onGenerateSubmit={onGenerateSubmit}
304
- gatherContext={null}
305
- gatherLoading={false}
306
- gatherError={new Error('boom')}
307
- onGather={onGather}
308
- translations={T}
309
- />,
310
- );
311
- fireEvent.click(screen.getAllByRole('button', { name: /Gather/ }).at(-1)!);
312
- expect(screen.getByText(T.failedContext)).toBeInTheDocument();
313
- });
314
-
315
- it('re-Gather refreshes the evidence in place — the stack stays', () => {
316
- renderModal({ gatherContext: RESOURCE_CONTEXT });
317
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
318
- fireEvent.click(screen.getByTitle(T.editGather)); // expand the receipt
319
- fireEvent.click(screen.getByRole('button', { name: /Gather/ })); // tweak-and-regather
320
- expect(onGather).toHaveBeenCalledTimes(2);
321
- expect(screen.getByText(T.graphPaneTitle)).toBeInTheDocument();
322
- expect(screen.getByLabelText(T.resourceTitle)).toBeInTheDocument();
323
- });
324
-
325
- it('no Back anywhere — a single stack has nothing to go back to', () => {
326
- renderModal({ gatherContext: RESOURCE_CONTEXT });
327
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
328
- expect(screen.queryAllByRole('button', { name: /Back/ })).toHaveLength(0);
329
- });
330
-
331
- it('the header close button calls onClose', () => {
332
- renderModal();
333
- fireEvent.click(screen.getByLabelText('Close'));
334
- expect(onClose).toHaveBeenCalledTimes(1);
335
- });
336
-
337
- it('calls the onClose of the latest render', () => {
338
- // The modal reads the host's callbacks through refs. A host that passes a
339
- // new function on each render must be called with the one it passed last.
340
- const { rerender } = renderModal();
341
- const latest = vi.fn<() => void>();
342
- rerender(
343
- <ResourceGenerateModal
344
- isOpen
345
- onClose={latest}
346
- resourceId="res-1"
347
- defaultTitle="Default Title"
348
- locale="en"
349
- entityTypeOptions={['Person', 'Topic']}
350
- onGenerateSubmit={onGenerateSubmit}
351
- gatherContext={null}
352
- gatherLoading={false}
353
- gatherError={null}
354
- onGather={onGather}
355
- translations={T}
356
- />,
357
- );
358
- fireEvent.click(screen.getByLabelText('Close'));
359
- expect(latest).toHaveBeenCalledTimes(1);
360
- expect(onClose).not.toHaveBeenCalled();
361
- });
362
-
363
- it('opening seeds the proposed title from defaultTitle, even one that arrived after mount', () => {
364
- // The page passes the source resource's name, which loads asynchronously —
365
- // a draft seeded only in the useState initializer holds whatever was there
366
- // at FIRST render, which for the real page is ''. Opening is the moment
367
- // that matters: the draft re-seeds then.
368
- const { rerender } = render(
369
- <ResourceGenerateModal
370
- isOpen={false}
371
- onClose={onClose}
372
- resourceId="res-1"
373
- defaultTitle=""
374
- locale="en"
375
- entityTypeOptions={[]}
376
- onGenerateSubmit={onGenerateSubmit}
377
- gatherContext={RESOURCE_CONTEXT}
378
- gatherLoading={false}
379
- gatherError={null}
380
- onGather={onGather}
381
- translations={T}
382
- />,
383
- );
384
- rerender(
385
- <ResourceGenerateModal
386
- isOpen
387
- onClose={onClose}
388
- resourceId="res-1"
389
- defaultTitle="PB"
390
- locale="en"
391
- entityTypeOptions={[]}
392
- onGenerateSubmit={onGenerateSubmit}
393
- gatherContext={RESOURCE_CONTEXT}
394
- gatherLoading={false}
395
- gatherError={null}
396
- onGather={onGather}
397
- translations={T}
398
- />,
399
- );
400
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
401
- expect(screen.getByLabelText(T.resourceTitle)).toHaveValue('PB');
402
- });
403
-
404
- it('evidence stays in view above the params — ONE scroll pane, nothing scrolls alone', () => {
405
- const { baseElement } = renderModal({ gatherContext: RESOURCE_CONTEXT });
406
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
407
-
408
- const scroll = baseElement.querySelector('.xynolog-wizard__step-scroll');
409
- expect(scroll).not.toBeNull();
410
- expect(scroll!.querySelector('.xynolog-gather__outer')).not.toBeNull(); // the evidence
411
- expect(screen.getByText(T.graphPaneTitle)).toBeInTheDocument(); // graph pane up
412
- expect(screen.getByLabelText(T.resourceTitle)).toBeInTheDocument(); // the form, below
413
- for (const form of Array.from(
414
- scroll!.querySelectorAll('form.xynolog-form'),
415
- )) {
416
- expect(form.className).not.toContain('xynolog-form--scrollable');
417
- }
418
- });
419
-
420
- it('the panel carries the widened class', () => {
421
- const { baseElement } = renderModal();
422
- const panel = baseElement.querySelector(
423
- '.xynolog-search-modal__panel--gather',
424
- );
425
- expect(panel).not.toBeNull();
426
- expect(panel!.className).toContain('xynolog-search-modal__panel--wide');
427
- });
428
-
429
- it('every footer is the wizard footer — no dismissal, no flex', () => {
430
- // The modal renders via a HeadlessUI portal, so query the whole document.
431
- const { baseElement } = renderModal({ gatherContext: RESOURCE_CONTEXT });
432
- const footerPins = () => {
433
- expect(
434
- baseElement.querySelector('.xynolog-modal__actions--wizard'),
435
- ).not.toBeNull();
436
- expect(
437
- baseElement.querySelectorAll('.xynolog-button--flex'),
438
- ).toHaveLength(0);
439
- const footerButtons = Array.from(
440
- baseElement.querySelectorAll('.xynolog-modal__actions button'),
441
- ).map((b) => b.textContent ?? '');
442
- expect(footerButtons.filter((l) => /cancel|✕/i.test(l))).toEqual([]);
443
- };
444
-
445
- footerPins(); // controls alone
446
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
447
- footerPins(); // the full stack: Gather footer + Generate footer
448
- });
449
- });
450
-
451
- // Dismissal guards typed work, and typed text only (title beyond the seeded
452
- // default, save location, instructions); checkbox, depth, and exclusion state
453
- // is cheap to redo and never nags.
454
- describe('ResourceGenerateModal — dismissal guards typed work', () => {
455
- beforeEach(() => {
456
- onClose = vi.fn();
457
- onGenerateSubmit = vi.fn();
458
- onGather = vi.fn();
459
- });
460
-
461
- it('a typed save location guards dismissal; Keep editing stays, Discard closes', () => {
462
- renderModal({ gatherContext: RESOURCE_CONTEXT });
463
- fireEvent.click(screen.getByRole('button', { name: /Gather/ })); // reveal the stack
464
- fireEvent.change(screen.getByLabelText(T.saveLocation), {
465
- target: { value: 'generated/out.md' },
466
- });
467
-
468
- fireEvent.click(screen.getByLabelText('Close'));
469
- expect(onClose).not.toHaveBeenCalled();
470
- expect(screen.getByText(T.discardDraftPrompt)).toBeInTheDocument();
471
-
472
- fireEvent.click(screen.getByRole('button', { name: T.keepEditing }));
473
- expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
474
- expect(screen.getByLabelText(T.saveLocation)).toHaveValue(
475
- 'generated/out.md',
476
- );
477
- expect(onClose).not.toHaveBeenCalled();
478
-
479
- fireEvent.click(screen.getByLabelText('Close'));
480
- fireEvent.click(screen.getByRole('button', { name: T.discardDraft }));
481
- expect(onClose).toHaveBeenCalledTimes(1);
482
- });
483
-
484
- it('a clean draft dismisses without any prompt', () => {
485
- renderModal({ gatherContext: RESOURCE_CONTEXT });
486
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
487
-
488
- fireEvent.click(screen.getByLabelText('Close'));
489
- expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
490
- expect(onClose).toHaveBeenCalledTimes(1);
491
- });
492
-
493
- it('a defaultTitle arriving mid-flow does not fake a dirty draft', () => {
494
- // The source resource's name loads asynchronously: the baseline moves
495
- // while the modal is open, the user has typed nothing. Dirtiness compares
496
- // against what was SEEDED, not the live prop.
497
- const { rerender } = renderModal({
498
- defaultTitle: '',
499
- gatherContext: RESOURCE_CONTEXT,
500
- });
501
- fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
502
- rerender(
503
- <ResourceGenerateModal
504
- isOpen
505
- onClose={onClose}
506
- resourceId="res-1"
507
- defaultTitle="Loaded Name"
508
- locale="en"
509
- entityTypeOptions={['Person', 'Topic']}
510
- onGenerateSubmit={onGenerateSubmit}
511
- gatherContext={RESOURCE_CONTEXT}
512
- gatherLoading={false}
513
- gatherError={null}
514
- onGather={onGather}
515
- translations={T}
516
- />,
517
- );
518
-
519
- fireEvent.click(screen.getByLabelText('Close'));
520
- expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
521
- expect(onClose).toHaveBeenCalledTimes(1);
522
- });
523
-
524
- it('non-text state alone never nags — exclusions and depth are cheap to redo', () => {
525
- renderModal();
526
- fireEvent.click(screen.getByRole('button', { name: 'Person' })); // cross off the recall
527
-
528
- fireEvent.click(screen.getByLabelText('Close'));
529
- expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
530
- expect(onClose).toHaveBeenCalledTimes(1);
531
- });
532
- });
@@ -1,95 +0,0 @@
1
- /**
2
- * SearchModal for a person using assistive technology: a modal dialog with a
3
- * name, a named search box with focus in it when it opens, and nothing
4
- * axe-core finds wrong, empty or with results. The real HeadlessUI Dialog is
5
- * rendered: the dialog's role, its modality and its focus are its behaviour,
6
- * not the modal's own.
7
- */
8
- import { describe, it, expect, beforeEach, vi } from 'vitest';
9
- import '@testing-library/jest-dom';
10
- import { screen, fireEvent, waitFor } from '@testing-library/react';
11
- import { axe, toHaveNoViolations } from 'jest-axe';
12
- import { renderWithProviders } from '../../../test-utils';
13
- import { SearchModal } from '../SearchModal';
14
- import {
15
- buildResource,
16
- matchResourcesMock,
17
- resetSearch,
18
- searchTranslations,
19
- setBrowseResults,
20
- } from './search-modal-harness';
21
-
22
- vi.mock('../../../session/XynologProvider', async (importOriginal) => {
23
- const actual =
24
- await importOriginal<typeof import('../../../session/XynologProvider')>();
25
- const { searchBrowser } = await import('./search-modal-harness');
26
- return { ...actual, useXynolog: () => searchBrowser };
27
- });
28
-
29
- expect.extend(toHaveNoViolations);
30
-
31
- function open() {
32
- renderWithProviders(
33
- <SearchModal
34
- isOpen
35
- onClose={vi.fn()}
36
- onNavigate={vi.fn()}
37
- translations={searchTranslations}
38
- />,
39
- );
40
- return screen.getByRole('textbox', { name: searchTranslations.title });
41
- }
42
-
43
- /** Search, and answer with one result per name. */
44
- async function search(input: HTMLElement, ...names: string[]) {
45
- fireEvent.change(input, { target: { value: 'doc' } });
46
- await waitFor(() => expect(matchResourcesMock).toHaveBeenCalled(), {
47
- timeout: 1500,
48
- });
49
- setBrowseResults(
50
- names.map((name, index) => buildResource(`res-${index + 1}`, name)),
51
- );
52
- await waitFor(
53
- () => expect(screen.getByText(names.at(-1)!)).toBeInTheDocument(),
54
- { timeout: 1500 },
55
- );
56
- }
57
-
58
- describe('SearchModal — Accessibility', () => {
59
- beforeEach(() => {
60
- resetSearch();
61
- });
62
-
63
- it('is a modal dialog, named by its title', () => {
64
- open();
65
-
66
- const dialog = screen.getByRole('dialog', {
67
- name: searchTranslations.title,
68
- });
69
- expect(dialog).toHaveAttribute('aria-modal', 'true');
70
- });
71
-
72
- it('names its search box', () => {
73
- expect(open()).toBeInTheDocument();
74
- });
75
-
76
- it('puts focus in the search box when it opens', async () => {
77
- const input = open();
78
-
79
- await waitFor(() => expect(input).toHaveFocus());
80
- });
81
-
82
- it('has no axe violations when it opens', async () => {
83
- open();
84
-
85
- // The dialog is portalled to the body, outside the render's container.
86
- expect(await axe(document.body)).toHaveNoViolations();
87
- });
88
-
89
- it('has no axe violations with results shown', async () => {
90
- const input = open();
91
- await search(input, 'First', 'Second');
92
-
93
- expect(await axe(document.body)).toHaveNoViolations();
94
- });
95
- });