@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,143 +0,0 @@
1
- /**
2
- * The annotate path's overridable media registry, symmetric to the browse
3
- * path's.
4
- *
5
- * A host that brings its own PDF stack can replace the read-only renderer via
6
- * `BrowseView`'s `renderers` prop; without the same seam here it ends up
7
- * running two PDF engines depending on which mode the user is in.
8
- */
9
- import React from 'react';
10
- import { describe, it, expect, vi } from 'vitest';
11
- import { screen } from '@testing-library/react';
12
- import {
13
- renderInEnglish,
14
- englishTranslationManager,
15
- } from '../../../test-utils';
16
- import '@testing-library/jest-dom';
17
- import type { XynologSession } from '@xynolog/sdk';
18
- import type { AnnotationUIState } from '../../../types/annotation-props';
19
- import { AnnotateView } from '../AnnotateView';
20
- import type { AnnotateMediaRendererProps } from '../annotate-renderers';
21
- import { resourceId, EventBus } from '@xynolog/core';
22
-
23
- vi.mock('../../annotation/AnnotateToolbar', () => ({
24
- AnnotateToolbar: () => null,
25
- }));
26
- vi.mock('../../CodeMirrorRenderer', () => ({
27
- CodeMirrorRenderer: () => <div data-testid="default-text">default-cm</div>,
28
- }));
29
- vi.mock('../../image-annotation/SvgDrawingCanvas', () => ({
30
- SvgDrawingCanvas: () => <div data-testid="default-image">default-svg</div>,
31
- }));
32
-
33
- const emptyAnnotations = {
34
- highlights: [],
35
- references: [],
36
- assessments: [],
37
- comments: [],
38
- tags: [],
39
- };
40
- const uiState: AnnotationUIState = {
41
- selectedMotivation: 'linking',
42
- selectedClick: 'detail',
43
- selectedShape: 'rectangle',
44
- hoveredAnnotationId: null,
45
- scrollToAnnotationId: null,
46
- };
47
-
48
- function fakeSession(): XynologSession {
49
- return {
50
- client: {
51
- bus: new EventBus(),
52
- mark: { request: vi.fn() },
53
- },
54
- } as unknown as XynologSession;
55
- }
56
-
57
- type ViewProps = React.ComponentProps<typeof AnnotateView>;
58
-
59
- const base = (mimeType: string): ViewProps => ({
60
- translationManager: englishTranslationManager,
61
- resourceUri: resourceId('res-1'),
62
- content: 'the-body',
63
- mimeType,
64
- annotations: emptyAnnotations,
65
- uiState,
66
- annotateMode: true,
67
- session: fakeSession(),
68
- });
69
-
70
- describe('AnnotateView — media-renderer registry', () => {
71
- it('uses a custom text renderer from the `renderers` override', () => {
72
- const CustomText = ({ content }: AnnotateMediaRendererProps) => (
73
- <div data-testid="custom-text">custom: {content}</div>
74
- );
75
-
76
- renderInEnglish(
77
- <AnnotateView {...base('text/plain')} renderers={{ text: CustomText }} />,
78
- );
79
-
80
- expect(screen.getByTestId('custom-text')).toHaveTextContent(
81
- 'custom: the-body',
82
- );
83
- expect(screen.queryByTestId('default-text')).not.toBeInTheDocument();
84
- });
85
-
86
- it('uses a custom pdf renderer — the realistic override, a host bringing its own viewer', () => {
87
- const CustomPdf = ({ content }: AnnotateMediaRendererProps) => (
88
- <div data-testid="custom-pdf">{content}</div>
89
- );
90
-
91
- renderInEnglish(
92
- <AnnotateView
93
- {...base('application/pdf')}
94
- renderers={{ pdf: CustomPdf }}
95
- />,
96
- );
97
-
98
- expect(screen.getByTestId('custom-pdf')).toBeInTheDocument();
99
- });
100
-
101
- it('merges over the defaults rather than replacing them: overriding text leaves image alone', () => {
102
- const CustomText = () => <div data-testid="custom-text" />;
103
-
104
- renderInEnglish(
105
- <AnnotateView {...base('image/png')} renderers={{ text: CustomText }} />,
106
- );
107
-
108
- expect(screen.getByTestId('default-image')).toBeInTheDocument();
109
- expect(screen.queryByTestId('custom-text')).not.toBeInTheDocument();
110
- });
111
-
112
- it('a mode in neither the defaults nor the override falls back to unsupported, download intact', () => {
113
- // The browse side gives a type it cannot preview the same kind of answer.
114
- // Annotating a type nothing here can render is not harmless, so the
115
- // missing renderer must stay explicit.
116
- const { container } = renderInEnglish(
117
- <AnnotateView {...base('application/octet-stream')} />,
118
- );
119
-
120
- expect(
121
- container.querySelector('[data-mime-type="unsupported"]'),
122
- ).toBeInTheDocument();
123
- expect(screen.getByText(/Annotation not supported/)).toBeInTheDocument();
124
- expect(screen.getByText('Download File')).toBeInTheDocument();
125
- });
126
-
127
- it('renders one toolbar and one content shell, whatever the render mode', () => {
128
- // What the registry buys: the wrapper, the toolbar block and the content
129
- // div exist once, not once per render-mode branch.
130
- for (const mimeType of ['text/plain', 'application/pdf', 'image/png']) {
131
- const { container, unmount } = renderInEnglish(
132
- <AnnotateView {...base(mimeType)} />,
133
- );
134
- expect(container.querySelectorAll('.xynolog-annotate-view')).toHaveLength(
135
- 1,
136
- );
137
- expect(
138
- container.querySelectorAll('.xynolog-annotate-view__content'),
139
- ).toHaveLength(1);
140
- unmount();
141
- }
142
- });
143
- });
@@ -1,257 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import React from 'react';
3
- import { screen } from '@testing-library/react';
4
- import '@testing-library/jest-dom';
5
- import type { AttributedEvent } from '@xynolog/core';
6
- import type {
7
- LinkComponentProps,
8
- RouteBuilder,
9
- } from '../../../contexts/RoutingContext';
10
- import { AnnotationHistory } from '../AnnotationHistory';
11
- import type { HistoryEvent } from '../HistoryEvent';
12
- import { renderWithProviders } from '../../../test-utils';
13
-
14
- // Mock @xynolog/core - must use importOriginal to preserve EventBus etc.
15
- vi.mock('@xynolog/core', async (importOriginal) => {
16
- const actual = await importOriginal<typeof import('@xynolog/core')>();
17
- return {
18
- ...actual,
19
- getAnnotationIdFromEvent: vi.fn(() => null),
20
- };
21
- });
22
-
23
- // Mock TranslationContext
24
- vi.mock('../../../contexts/TranslationContext', () => ({
25
- useTranslations: vi.fn(() => (key: string) => {
26
- const translations: Record<string, string> = {
27
- history: 'History',
28
- loading: 'Loading...',
29
- failed: 'Could not load history.',
30
- retry: 'Try again',
31
- };
32
- return translations[key] || key;
33
- }),
34
- TranslationProvider: ({ children }: { children: React.ReactNode }) =>
35
- children,
36
- }));
37
-
38
- // Mock HistoryEvent to avoid deep rendering and mocking all its dependencies
39
- const MockHistoryEvent = vi.fn(
40
- ({ event }: React.ComponentProps<typeof HistoryEvent>) => (
41
- <div data-testid={`history-event-${event.id}`}>{event.type}</div>
42
- ),
43
- );
44
-
45
- vi.mock('../HistoryEvent', () => ({
46
- HistoryEvent: (props: React.ComponentProps<typeof HistoryEvent>) =>
47
- MockHistoryEvent(props),
48
- }));
49
-
50
- import { getAnnotationIdFromEvent, resourceId, userId } from '@xynolog/core';
51
- const mockGetAnnotationId = getAnnotationIdFromEvent as ReturnType<
52
- typeof vi.fn
53
- >;
54
-
55
- const USER = 'did:web:example.org:users:user-1';
56
-
57
- /** An event as a history reply carries it: the stored event and its actor's agent. */
58
- function makeStoredEvent(
59
- id: string,
60
- type: string,
61
- seq: number,
62
- ): AttributedEvent {
63
- return {
64
- id,
65
- type,
66
- timestamp: '2026-03-06T12:00:00Z',
67
- resourceId: resourceId('res-1'),
68
- userId: userId(USER),
69
- agent: { '@type': 'Person', '@id': USER },
70
- version: 1,
71
- payload: {},
72
- metadata: {
73
- sequenceNumber: seq,
74
- },
75
- };
76
- }
77
-
78
- const MockLink = ({ href, children, ...props }: LinkComponentProps) => (
79
- <a href={href} {...props}>
80
- {children}
81
- </a>
82
- );
83
- const mockRoutes: RouteBuilder = {
84
- resourceDetail: (id: string) => `/resources/${id}`,
85
- };
86
-
87
- describe('AnnotationHistory', () => {
88
- beforeEach(() => {
89
- vi.clearAllMocks();
90
- mockGetAnnotationId.mockReturnValue(null);
91
- });
92
-
93
- it('renders loading state', () => {
94
- renderWithProviders(
95
- <AnnotationHistory
96
- events={[]}
97
- eventsLoading
98
- Link={MockLink}
99
- routes={mockRoutes}
100
- />,
101
- );
102
-
103
- expect(screen.getByText('History')).toBeInTheDocument();
104
- expect(screen.getByText('Loading...')).toBeInTheDocument();
105
- });
106
-
107
- describe('terminal load failure', () => {
108
- // A panel that derives `loading` from `eventsData === undefined` and has
109
- // no error input leaves a failed load on "Loading..." for ever.
110
-
111
- it('reports the failure instead of staying on the loading text', () => {
112
- renderWithProviders(
113
- <AnnotationHistory
114
- events={[]}
115
- eventsLoading={false}
116
- eventsError={new Error('Resource not found')}
117
- Link={MockLink}
118
- routes={mockRoutes}
119
- />,
120
- );
121
-
122
- expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
123
- expect(screen.getByText('Could not load history.')).toBeInTheDocument();
124
- });
125
-
126
- it('offers a retry that calls back', async () => {
127
- const onRetryEvents = vi.fn();
128
- const { default: userEvent } =
129
- await import('@testing-library/user-event');
130
-
131
- renderWithProviders(
132
- <AnnotationHistory
133
- events={[]}
134
- eventsError={new Error('boom')}
135
- onRetryEvents={onRetryEvents}
136
- Link={MockLink}
137
- routes={mockRoutes}
138
- />,
139
- );
140
-
141
- await userEvent.click(screen.getByRole('button', { name: 'Try again' }));
142
- expect(onRetryEvents).toHaveBeenCalledTimes(1);
143
- });
144
-
145
- it('the failure beats the loading state — a dead request is not still loading', () => {
146
- renderWithProviders(
147
- <AnnotationHistory
148
- events={[]}
149
- eventsLoading
150
- eventsError={new Error('boom')}
151
- Link={MockLink}
152
- routes={mockRoutes}
153
- />,
154
- );
155
-
156
- expect(screen.getByText('Could not load history.')).toBeInTheDocument();
157
- });
158
- });
159
-
160
- it('renders null when no events', () => {
161
- const { container } = renderWithProviders(
162
- <AnnotationHistory events={[]} Link={MockLink} routes={mockRoutes} />,
163
- );
164
-
165
- expect(container.innerHTML).toBe('');
166
- });
167
-
168
- it('renders events sorted by sequence number', () => {
169
- const events = [
170
- makeStoredEvent('e3', 'mark:added', 3),
171
- makeStoredEvent('e1', 'mark:added', 1),
172
- makeStoredEvent('e2', 'mark:added', 2),
173
- ];
174
-
175
- renderWithProviders(
176
- <AnnotationHistory events={events} Link={MockLink} routes={mockRoutes} />,
177
- );
178
-
179
- const renderedEvents = screen.getAllByTestId(/^history-event-/);
180
- expect(renderedEvents).toHaveLength(3);
181
- expect(renderedEvents[0]).toHaveAttribute(
182
- 'data-testid',
183
- 'history-event-e1',
184
- );
185
- expect(renderedEvents[1]).toHaveAttribute(
186
- 'data-testid',
187
- 'history-event-e2',
188
- );
189
- expect(renderedEvents[2]).toHaveAttribute(
190
- 'data-testid',
191
- 'history-event-e3',
192
- );
193
- });
194
-
195
- it('filters out job events', () => {
196
- // e3 is `job:progress`, a retired event type. Stored logs can hold them,
197
- // so the filter must exclude it.
198
- const events = [
199
- makeStoredEvent('e1', 'mark:added', 1),
200
- makeStoredEvent('e2', 'job:started', 2),
201
- makeStoredEvent('e3', 'job:progress', 3),
202
- makeStoredEvent('e4', 'job:completed', 4),
203
- makeStoredEvent('e5', 'mark:body-updated', 5),
204
- ];
205
-
206
- renderWithProviders(
207
- <AnnotationHistory events={events} Link={MockLink} routes={mockRoutes} />,
208
- );
209
-
210
- const renderedEvents = screen.getAllByTestId(/^history-event-/);
211
- expect(renderedEvents).toHaveLength(2);
212
- expect(renderedEvents[0]).toHaveAttribute(
213
- 'data-testid',
214
- 'history-event-e1',
215
- );
216
- expect(renderedEvents[1]).toHaveAttribute(
217
- 'data-testid',
218
- 'history-event-e5',
219
- );
220
- });
221
-
222
- it('passes isRelated when hovered annotation matches event', () => {
223
- const events = [makeStoredEvent('e1', 'mark:added', 1)];
224
- mockGetAnnotationId.mockReturnValue('ann-1');
225
-
226
- renderWithProviders(
227
- <AnnotationHistory
228
- events={events}
229
- hoveredAnnotationId="ann-1"
230
- Link={MockLink}
231
- routes={mockRoutes}
232
- />,
233
- );
234
-
235
- expect(MockHistoryEvent).toHaveBeenCalledWith(
236
- expect.objectContaining({ isRelated: true }),
237
- );
238
- });
239
-
240
- it('renders history panel structure with title and list', () => {
241
- const events = [makeStoredEvent('e1', 'mark:added', 1)];
242
-
243
- const { container } = renderWithProviders(
244
- <AnnotationHistory events={events} Link={MockLink} routes={mockRoutes} />,
245
- );
246
-
247
- expect(
248
- container.querySelector('.xynolog-history-panel'),
249
- ).toBeInTheDocument();
250
- expect(
251
- container.querySelector('.xynolog-history-panel__title'),
252
- ).toBeInTheDocument();
253
- expect(
254
- container.querySelector('.xynolog-history-panel__list'),
255
- ).toBeInTheDocument();
256
- });
257
- });
@@ -1,123 +0,0 @@
1
- /**
2
- * Rendered markdown, from a stored selector to the words the overlay lights.
3
- *
4
- * A text offset counts Unicode code points from the start of the content. The
5
- * rendered text is DOM text, indexed in UTF-16 code units, where a character
6
- * outside the Basic Multilingual Plane is two; and it has none of the
7
- * source's markdown syntax. These tests put such characters and such syntax
8
- * before the annotated words.
9
- *
10
- * The real markdown renderer and the real overlay are used. Every offset was
11
- * counted by hand and again in Python, whose strings count code points.
12
- */
13
- import { describe, it, expect } from 'vitest';
14
- import '@testing-library/jest-dom';
15
- import { annotationId, resourceId, type Annotation } from '@xynolog/core';
16
- import {
17
- createTestXynologWrapper,
18
- renderInEnglish,
19
- englishTranslationManager,
20
- } from '../../../test-utils';
21
- import { BrowseView } from '../BrowseView';
22
-
23
- /** A heading, a blank line and a paragraph with bold words. 49 code points; its "words" are at 42 to 47, and at 44 to 49 in the string. */
24
- const MARKDOWN = '# 😀 Title\n\nSome **bold 𝑥** text, then the words.\n';
25
-
26
- /** The offset table's third text. 19 code points and 20 UTF-16 code units. */
27
- const PLAIN = '😀 first, then words';
28
-
29
- const RESOURCE = resourceId('res-1');
30
- const NO_ANNOTATIONS = {
31
- highlights: [],
32
- references: [],
33
- assessments: [],
34
- comments: [],
35
- tags: [],
36
- };
37
-
38
- function highlight(id: string, start: number, end: number): Annotation {
39
- return {
40
- '@context': 'http://www.w3.org/ns/anno.jsonld',
41
- type: 'Annotation',
42
- id: annotationId(id),
43
- motivation: 'highlighting',
44
- target: {
45
- source: RESOURCE,
46
- selector: { type: 'TextPositionSelector', start, end },
47
- },
48
- created: '2026-01-01T00:00:00Z',
49
- };
50
- }
51
-
52
- function mount(
53
- content: string,
54
- mimeType: string,
55
- highlights: Annotation[],
56
- ): HTMLElement {
57
- const { session } = createTestXynologWrapper();
58
- return renderInEnglish(
59
- <BrowseView
60
- translationManager={englishTranslationManager}
61
- content={content}
62
- mimeType={mimeType}
63
- resourceUri={RESOURCE}
64
- annotations={{ ...NO_ANNOTATIONS, highlights }}
65
- annotateMode={false}
66
- session={session}
67
- showToolbar={false}
68
- />,
69
- ).container;
70
- }
71
-
72
- /** The rendered text lit for an annotation: its spans' text, in order, as one. */
73
- function lit(container: HTMLElement, id: string): string {
74
- return Array.from(container.querySelectorAll(`[data-annotation-id="${id}"]`))
75
- .map((span) => span.textContent)
76
- .join('');
77
- }
78
-
79
- describe('a stored selector lights exactly its words over rendered markdown', () => {
80
- it('after a character outside the basic plane and markdown syntax', () => {
81
- const container = mount(MARKDOWN, 'text/markdown', [
82
- highlight('title', 4, 9),
83
- highlight('bold', 18, 24),
84
- highlight('words', 42, 47),
85
- ]);
86
-
87
- expect(lit(container, 'title')).toBe('Title');
88
- expect(lit(container, 'bold')).toBe('bold 𝑥');
89
- expect(lit(container, 'words')).toBe('words');
90
- });
91
-
92
- it('from such a character, across the syntax that closes the bold words', () => {
93
- const container = mount(MARKDOWN, 'text/markdown', [
94
- highlight('across', 23, 31),
95
- ]);
96
-
97
- // The source there is "𝑥** text"; the two asterisks are not rendered.
98
- expect(lit(container, 'across')).toBe('𝑥 text');
99
- });
100
-
101
- it('in a plain text, which the same renderer shows', () => {
102
- const container = mount(PLAIN, 'text/plain', [
103
- highlight('first', 2, 7),
104
- highlight('words', 14, 19),
105
- ]);
106
-
107
- expect(lit(container, 'first')).toBe('first');
108
- expect(lit(container, 'words')).toBe('words');
109
- });
110
-
111
- it('an offset the content does not have lights nothing, and the rest is still lit', () => {
112
- // 20 is a position in the string, which is 20 code units; the content is 19 code points.
113
- const container = mount(PLAIN, 'text/plain', [
114
- highlight('past-the-end', 15, 20),
115
- highlight('not-whole', 2.5, 7.5),
116
- highlight('first', 2, 7),
117
- ]);
118
-
119
- expect(lit(container, 'past-the-end')).toBe('');
120
- expect(lit(container, 'not-whole')).toBe('');
121
- expect(lit(container, 'first')).toBe('first');
122
- });
123
- });
@@ -1,76 +0,0 @@
1
- /**
2
- * The embeddable viewer — BrowseView renders provider-free.
3
- *
4
- * BrowseView takes its `session` + `sparkleAnnotationIds` as props (not
5
- * `useXynolog()` / `useResourceAnnotations()`), and subscribes to session-scoped
6
- * beckon events on `session.client`. `AnnotateToolbar` is mocked here — its
7
- * own provider-freedom is pinned in AnnotateView.embeddable.test.tsx — so this
8
- * spec isolates BrowseView's body.
9
- */
10
- import { describe, it, expect, vi } from 'vitest';
11
- import { render, screen } from '@testing-library/react';
12
- import '@testing-library/jest-dom';
13
- import type { XynologSession } from '@xynolog/sdk';
14
- import { englishTranslationManager } from '../../../test-utils';
15
- import { BrowseView } from '../BrowseView';
16
- import { resourceId, EventBus } from '@xynolog/core';
17
-
18
- // AnnotateToolbar is stubbed out so this spec exercises only BrowseView's own
19
- // provider-freedom.
20
- vi.mock('../../annotation/AnnotateToolbar', () => ({
21
- AnnotateToolbar: () => null,
22
- }));
23
- vi.mock('react-markdown', () => ({
24
- default: ({ children }: { children: string }) => <div>{children}</div>,
25
- }));
26
- vi.mock('remark-gfm', () => ({ default: () => ({}) }));
27
-
28
- const emptyAnnotations = {
29
- highlights: [],
30
- references: [],
31
- assessments: [],
32
- comments: [],
33
- tags: [],
34
- };
35
-
36
- function fakeSession(): XynologSession {
37
- return {
38
- client: {
39
- bus: new EventBus(),
40
- browse: { click: vi.fn() },
41
- beckon: { hover: vi.fn() },
42
- },
43
- } as unknown as XynologSession;
44
- }
45
-
46
- describe('BrowseView — embeddable (session prop, no providers)', () => {
47
- it('renders content fed only a session, with NO providers mounted', () => {
48
- render(
49
- <BrowseView
50
- translationManager={englishTranslationManager}
51
- content="Embeddable browse content."
52
- mimeType="text/plain"
53
- resourceUri={resourceId('res-1')}
54
- annotations={emptyAnnotations}
55
- annotateMode={false}
56
- session={fakeSession()}
57
- />,
58
- );
59
- expect(screen.getByText('Embeddable browse content.')).toBeInTheDocument();
60
- });
61
-
62
- it('does not compile without a language: react-ui assumes none', () => {
63
- const elements = [
64
- // @ts-expect-error no language
65
- <BrowseView
66
- content="x"
67
- mimeType="text/plain"
68
- resourceUri={resourceId('res-1')}
69
- annotations={emptyAnnotations}
70
- annotateMode={false}
71
- session={fakeSession()}
72
- />,
73
- ];
74
- expect(elements).toHaveLength(1);
75
- });
76
- });
@@ -1,84 +0,0 @@
1
- /**
2
- * Content-link delegation.
3
- *
4
- * A content link (`<a href>` rendered inside the resource content) must be
5
- * intercepted: the viewer `preventDefault`s (never navigates on its own — an
6
- * embedded/Electron security requirement) and delegates to `onLinkClick({href,
7
- * event})`. With no handler, the click is still cancelled (nothing happens).
8
- *
9
- * Real react-markdown (not the mock) so the `<a>` is a genuine rendered
10
- * content link.
11
- */
12
- import { describe, it, expect, vi } from 'vitest';
13
- import { render, screen, fireEvent } from '@testing-library/react';
14
- import '@testing-library/jest-dom';
15
- import type { XynologSession } from '@xynolog/sdk';
16
- import { BrowseView } from '../BrowseView';
17
- import { resourceId, EventBus } from '@xynolog/core';
18
- import { englishTranslationManager } from '../../../test-utils';
19
-
20
- vi.mock('../../annotation/AnnotateToolbar', () => ({
21
- AnnotateToolbar: () => null,
22
- }));
23
-
24
- const emptyAnnotations = {
25
- highlights: [],
26
- references: [],
27
- assessments: [],
28
- comments: [],
29
- tags: [],
30
- };
31
-
32
- function fakeSession(): XynologSession {
33
- return {
34
- client: {
35
- bus: new EventBus(),
36
- browse: { click: vi.fn() },
37
- beckon: { hover: vi.fn() },
38
- },
39
- } as unknown as XynologSession;
40
- }
41
-
42
- const MD = 'see [the link](https://example.test/x) here';
43
-
44
- describe('BrowseView — content link delegation', () => {
45
- it('intercepts a content <a> click: preventDefault + onLinkClick(href)', () => {
46
- const onLinkClick = vi.fn();
47
- render(
48
- <BrowseView
49
- translationManager={englishTranslationManager}
50
- content={MD}
51
- mimeType="text/markdown"
52
- resourceUri={resourceId('res-1')}
53
- annotations={emptyAnnotations}
54
- annotateMode={false}
55
- session={fakeSession()}
56
- onLinkClick={onLinkClick}
57
- />,
58
- );
59
- const anchor = screen.getByText('the link').closest('a')!;
60
- // fireEvent.click returns false when the event was cancelled (preventDefault).
61
- const notCancelled = fireEvent.click(anchor);
62
- expect(notCancelled).toBe(false); // navigation blocked
63
- expect(onLinkClick).toHaveBeenCalledTimes(1);
64
- expect(onLinkClick.mock.calls[0]![0]).toMatchObject({
65
- href: 'https://example.test/x',
66
- });
67
- });
68
-
69
- it('blocks navigation even with no handler (never navigates on its own)', () => {
70
- render(
71
- <BrowseView
72
- translationManager={englishTranslationManager}
73
- content={MD}
74
- mimeType="text/markdown"
75
- resourceUri={resourceId('res-1')}
76
- annotations={emptyAnnotations}
77
- annotateMode={false}
78
- session={fakeSession()}
79
- />,
80
- );
81
- const anchor = screen.getByText('the link').closest('a')!;
82
- expect(fireEvent.click(anchor)).toBe(false); // still cancelled — nothing happens, but no navigation
83
- });
84
- });