@xynolog/react-ui 0.0.0-stage → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (379) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +379 -2
  3. package/dist/PdfAnnotationCanvas.client-S64VRLUN.css +193 -0
  4. package/dist/PdfAnnotationCanvas.client-V7R4NXFO.js +799 -0
  5. package/dist/ar-AIV7P4FL.js +594 -0
  6. package/dist/bn-J2OR57PB.js +594 -0
  7. package/dist/chunk-4L3TYOIV.js +172 -0
  8. package/dist/chunk-BM76QBIO.js +594 -0
  9. package/dist/chunk-D2O46PZQ.js +240 -0
  10. package/dist/chunk-O23TLLXW.js +42 -0
  11. package/dist/chunk-WGTUIB6C.js +304 -0
  12. package/dist/cs-JNEAMHFB.js +594 -0
  13. package/dist/da-UY5ZRVTZ.js +594 -0
  14. package/dist/de-EETVXC42.js +594 -0
  15. package/dist/el-S5YKDMTL.js +594 -0
  16. package/dist/en-3YQWF45H.js +61 -0
  17. package/dist/es-GHA7S27R.js +594 -0
  18. package/dist/fa-JTR3GF6I.js +594 -0
  19. package/dist/fi-CQZ7BW57.js +594 -0
  20. package/dist/fr-OJH2WIY7.js +594 -0
  21. package/dist/he-2DBXWA2V.js +594 -0
  22. package/dist/hi-NZP7B55I.js +594 -0
  23. package/dist/id-4KXFKWOI.js +594 -0
  24. package/dist/index.css +4134 -0
  25. package/dist/index.d.ts +4040 -0
  26. package/dist/index.js +29638 -0
  27. package/dist/it-XBMYGKKY.js +594 -0
  28. package/dist/ja-OVHZS3EH.js +594 -0
  29. package/dist/ko-NW2MVM5L.js +594 -0
  30. package/dist/ms-RXLPBZLK.js +594 -0
  31. package/dist/nl-77CTBEDA.js +594 -0
  32. package/dist/no-RAPO56SE.js +594 -0
  33. package/dist/pl-XCFXZCTT.js +594 -0
  34. package/dist/pt-EMBE27IS.js +594 -0
  35. package/dist/ro-M7QLJBYN.js +594 -0
  36. package/dist/sv-ST6CITQY.js +594 -0
  37. package/dist/test-utils.css +112 -0
  38. package/dist/test-utils.d.ts +126 -0
  39. package/dist/test-utils.js +13119 -0
  40. package/dist/th-EEQGL3G7.js +594 -0
  41. package/dist/tr-5FYHZQKD.js +594 -0
  42. package/dist/uk-VTWDC467.js +594 -0
  43. package/dist/vi-ISBKJ66X.js +594 -0
  44. package/dist/zh-2AW2N66Z.js +594 -0
  45. package/package.json +129 -4
  46. package/src/components/Button/Button.tsx +188 -0
  47. package/src/components/Button/__tests__/Button.test.tsx +449 -0
  48. package/src/components/CodeMirrorRenderer.tsx +536 -0
  49. package/src/components/DelegateProgress.tsx +308 -0
  50. package/src/components/ErrorBoundary.tsx +174 -0
  51. package/src/components/ItemFoundLog.tsx +42 -0
  52. package/src/components/LiveRegion.tsx +261 -0
  53. package/src/components/ProtectedErrorBoundary.css +121 -0
  54. package/src/components/ProtectedErrorBoundary.tsx +114 -0
  55. package/src/components/ResizeHandle.tsx +167 -0
  56. package/src/components/ResourceTagsInline.tsx +120 -0
  57. package/src/components/SessionExpiryBanner.css +67 -0
  58. package/src/components/SessionExpiryBanner.tsx +74 -0
  59. package/src/components/SessionTimer.tsx +17 -0
  60. package/src/components/StatusDisplay.css +439 -0
  61. package/src/components/StatusDisplay.tsx +131 -0
  62. package/src/components/Toast.css +136 -0
  63. package/src/components/Toast.tsx +217 -0
  64. package/src/components/Toolbar.tsx +194 -0
  65. package/src/components/UserMenuSkeleton.tsx +13 -0
  66. package/src/components/__tests__/DelegateProgress.denominator.test.tsx +102 -0
  67. package/src/components/__tests__/DelegateProgress.test.tsx +649 -0
  68. package/src/components/__tests__/ErrorBoundary.test.tsx +565 -0
  69. package/src/components/__tests__/LiveRegion.a11y.test.tsx +258 -0
  70. package/src/components/__tests__/LiveRegion.hooks.test.tsx +140 -0
  71. package/src/components/__tests__/ProtectedErrorBoundary.test.tsx +225 -0
  72. package/src/components/__tests__/ResizeHandle.test.tsx +159 -0
  73. package/src/components/__tests__/ResourceTagsInline.test.tsx +325 -0
  74. package/src/components/__tests__/SessionExpiryBanner.test.tsx +124 -0
  75. package/src/components/__tests__/SessionTimer.test.tsx +199 -0
  76. package/src/components/__tests__/StatusDisplay.test.tsx +179 -0
  77. package/src/components/__tests__/Toast.test.tsx +96 -0
  78. package/src/components/__tests__/Toolbar.test.tsx +111 -0
  79. package/src/components/__tests__/UserMenuSkeleton.test.tsx +182 -0
  80. package/src/components/annotation/AnchoredTextNotice.tsx +36 -0
  81. package/src/components/annotation/AnnotateToolbar.tsx +531 -0
  82. package/src/components/annotation/__tests__/AnnotateToolbar.display.test.tsx +127 -0
  83. package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +304 -0
  84. package/src/components/annotation/annotation-entries.css +138 -0
  85. package/src/components/annotation/annotations.css +93 -0
  86. package/src/components/annotation/references.css +300 -0
  87. package/src/components/annotation-popups/JsonLdView.tsx +127 -0
  88. package/src/components/annotation-popups/SharedPopupElements.tsx +131 -0
  89. package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +432 -0
  90. package/src/components/annotation-popups/__tests__/SharedPopupElements.test.tsx +297 -0
  91. package/src/components/branding/Branding.css +129 -0
  92. package/src/components/branding/XynologBranding.tsx +41 -0
  93. package/src/components/branding/__tests__/XynologBranding.test.tsx +383 -0
  94. package/src/components/error-states/ResourceErrorState.tsx +30 -0
  95. package/src/components/error-states/__tests__/ResourceErrorState.test.tsx +102 -0
  96. package/src/components/error-states/errors.css +34 -0
  97. package/src/components/image-annotation/AnnotationOverlay.tsx +307 -0
  98. package/src/components/image-annotation/SvgDrawingCanvas.tsx +514 -0
  99. package/src/components/image-annotation/__tests__/AnnotationOverlay.click.test.tsx +169 -0
  100. package/src/components/image-annotation/__tests__/AnnotationOverlay.hover.test.tsx +83 -0
  101. package/src/components/image-annotation/__tests__/SvgDrawingCanvas.annotate-gate.test.tsx +228 -0
  102. package/src/components/image-annotation/__tests__/SvgDrawingCanvas.click.test.tsx +204 -0
  103. package/src/components/layout/Header.css +99 -0
  104. package/src/components/layout/LeftSidebar.css +115 -0
  105. package/src/components/layout/LeftSidebar.tsx +150 -0
  106. package/src/components/layout/PageLayout.tsx +49 -0
  107. package/src/components/layout/ResizeHandle.css +110 -0
  108. package/src/components/layout/SkipLinks.css +84 -0
  109. package/src/components/layout/SkipLinks.tsx +36 -0
  110. package/src/components/layout/UnifiedHeader.tsx +151 -0
  111. package/src/components/layout/__tests__/LeftSidebar.test.tsx +426 -0
  112. package/src/components/layout/__tests__/PageLayout.test.tsx +311 -0
  113. package/src/components/layout/__tests__/SkipLinks.a11y.test.tsx +218 -0
  114. package/src/components/layout/__tests__/UnifiedHeader.test.tsx +555 -0
  115. package/src/components/loading-states/ComposeLoadingState.tsx +19 -0
  116. package/src/components/loading-states/ResourceLoadingState.tsx +13 -0
  117. package/src/components/loading-states/__tests__/ComposeLoadingState.test.tsx +37 -0
  118. package/src/components/loading-states/__tests__/ResourceLoadingState.test.tsx +31 -0
  119. package/src/components/loading-states/loading.css +42 -0
  120. package/src/components/modals/ComposeStep.tsx +245 -0
  121. package/src/components/modals/ConfigureGatherStep.tsx +110 -0
  122. package/src/components/modals/ConfigureGenerationStep.tsx +458 -0
  123. package/src/components/modals/ConfigureSearchStep.tsx +124 -0
  124. package/src/components/modals/ContextSummary.tsx +317 -0
  125. package/src/components/modals/CorpusPane.tsx +96 -0
  126. package/src/components/modals/DiscardPrompt.tsx +44 -0
  127. package/src/components/modals/GatherContextStep.tsx +480 -0
  128. package/src/components/modals/KbIdentityConflictModal.tsx +122 -0
  129. package/src/components/modals/KeyboardShortcutsHelpModal.tsx +238 -0
  130. package/src/components/modals/PermissionDeniedModal.tsx +207 -0
  131. package/src/components/modals/ReferenceWizardModal.tsx +656 -0
  132. package/src/components/modals/ResourceGenerateModal.tsx +457 -0
  133. package/src/components/modals/SearchModal.css +1019 -0
  134. package/src/components/modals/SearchModal.tsx +334 -0
  135. package/src/components/modals/SearchResultsStep.tsx +117 -0
  136. package/src/components/modals/SessionEndedModal.tsx +148 -0
  137. package/src/components/modals/WizardFooter.tsx +72 -0
  138. package/src/components/modals/__tests__/ComposeStep.test.tsx +187 -0
  139. package/src/components/modals/__tests__/ConfigureGatherStep.test.tsx +92 -0
  140. package/src/components/modals/__tests__/ConfigureGenerationStep.test.tsx +574 -0
  141. package/src/components/modals/__tests__/ConfigureSearchStep.test.tsx +124 -0
  142. package/src/components/modals/__tests__/GatherContextStep.resource.test.tsx +702 -0
  143. package/src/components/modals/__tests__/KbIdentityConflictModal.test.tsx +102 -0
  144. package/src/components/modals/__tests__/KeyboardShortcutsHelpModal.test.tsx +115 -0
  145. package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +218 -0
  146. package/src/components/modals/__tests__/ReferenceWizardModal.test.tsx +936 -0
  147. package/src/components/modals/__tests__/ResourceGenerateModal.test.tsx +532 -0
  148. package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +95 -0
  149. package/src/components/modals/__tests__/SearchModal.basic.test.tsx +84 -0
  150. package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +162 -0
  151. package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +237 -0
  152. package/src/components/modals/__tests__/SearchModal.translations.test.tsx +91 -0
  153. package/src/components/modals/__tests__/SearchResultsStep.test.tsx +95 -0
  154. package/src/components/modals/__tests__/SessionEndedModal.test.tsx +171 -0
  155. package/src/components/modals/__tests__/WizardFooter.test.tsx +446 -0
  156. package/src/components/modals/__tests__/search-modal-harness.ts +82 -0
  157. package/src/components/modals/modals.css +655 -0
  158. package/src/components/navigation/CollapsibleResourceNavigation.css +10 -0
  159. package/src/components/navigation/CollapsibleResourceNavigation.tsx +364 -0
  160. package/src/components/navigation/NavigationMenu.css +59 -0
  161. package/src/components/navigation/NavigationMenu.tsx +66 -0
  162. package/src/components/navigation/NavigationTabs.css +466 -0
  163. package/src/components/navigation/ObservableLink.tsx +90 -0
  164. package/src/components/navigation/SimpleNavigation.css +9 -0
  165. package/src/components/navigation/SimpleNavigation.tsx +169 -0
  166. package/src/components/navigation/SortableResourceTab.tsx +122 -0
  167. package/src/components/navigation/__tests__/NavigationMenu.a11y.test.tsx +302 -0
  168. package/src/components/navigation/__tests__/NavigationMenu.test.tsx +399 -0
  169. package/src/components/navigation/__tests__/ObservableLink.test.tsx +85 -0
  170. package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +193 -0
  171. package/src/components/navigation/__tests__/SortableResourceTab.test.tsx +421 -0
  172. package/src/components/pdf-annotation/PdfAnnotationCanvas.client.tsx +10 -0
  173. package/src/components/pdf-annotation/PdfAnnotationCanvas.css +288 -0
  174. package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +632 -0
  175. package/src/components/pdf-annotation/PdfPageView.tsx +527 -0
  176. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.annotate-gate.test.tsx +295 -0
  177. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.pixels-before-anchoring.test.tsx +166 -0
  178. package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +1719 -0
  179. package/src/components/pdf-annotation/__tests__/estimate-slot-height.test.ts +61 -0
  180. package/src/components/pdf-annotation/__tests__/rects-for-page.test.ts +110 -0
  181. package/src/components/pdf-annotation/estimate-slot-height.ts +31 -0
  182. package/src/components/pdf-annotation/rects-for-page.ts +50 -0
  183. package/src/components/resource/AnnotateView.tsx +373 -0
  184. package/src/components/resource/AnnotationHistory.tsx +169 -0
  185. package/src/components/resource/BrowseView.tsx +440 -0
  186. package/src/components/resource/DownloadFileLink.tsx +53 -0
  187. package/src/components/resource/HistoryEvent.tsx +186 -0
  188. package/src/components/resource/ResourceViewer.tsx +617 -0
  189. package/src/components/resource/__tests__/AnnotateView.code-point-offsets.test.tsx +482 -0
  190. package/src/components/resource/__tests__/AnnotateView.embeddable.test.tsx +78 -0
  191. package/src/components/resource/__tests__/AnnotateView.focus.test.tsx +147 -0
  192. package/src/components/resource/__tests__/AnnotateView.registry.test.tsx +143 -0
  193. package/src/components/resource/__tests__/AnnotationHistory.test.tsx +257 -0
  194. package/src/components/resource/__tests__/BrowseView.code-point-offsets.test.tsx +123 -0
  195. package/src/components/resource/__tests__/BrowseView.embeddable.test.tsx +76 -0
  196. package/src/components/resource/__tests__/BrowseView.links.test.tsx +84 -0
  197. package/src/components/resource/__tests__/BrowseView.overlay-async.test.tsx +165 -0
  198. package/src/components/resource/__tests__/BrowseView.reference-hover.test.tsx +200 -0
  199. package/src/components/resource/__tests__/BrowseView.registry.test.tsx +57 -0
  200. package/src/components/resource/__tests__/BrowseView.test.tsx +915 -0
  201. package/src/components/resource/__tests__/HistoryEvent.test.tsx +571 -0
  202. package/src/components/resource/__tests__/ResourceViewer.delete-failure.test.tsx +103 -0
  203. package/src/components/resource/__tests__/ResourceViewer.embeddable.test.tsx +250 -0
  204. package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +262 -0
  205. package/src/components/resource/__tests__/ResourceViewer.multi-mount-invalidation.test.tsx +166 -0
  206. package/src/components/resource/__tests__/ResourceViewer.registry.test.tsx +112 -0
  207. package/src/components/resource/__tests__/ResourceViewer.toolbar-opt-out.test.tsx +207 -0
  208. package/src/components/resource/__tests__/ResourceViewer.toolbar-prefs.test.tsx +274 -0
  209. package/src/components/resource/__tests__/annotation-interactions.test.tsx +116 -0
  210. package/src/components/resource/__tests__/browse-renderers.dispatch.test.tsx +183 -0
  211. package/src/components/resource/__tests__/browse-renderers.test.tsx +47 -0
  212. package/src/components/resource/__tests__/download-link.test.tsx +171 -0
  213. package/src/components/resource/__tests__/event-formatting.test.ts +379 -0
  214. package/src/components/resource/__tests__/inline-embedding.test.tsx +133 -0
  215. package/src/components/resource/__tests__/media-completeness.test.tsx +144 -0
  216. package/src/components/resource/annotate-renderers.tsx +186 -0
  217. package/src/components/resource/browse-renderers.tsx +133 -0
  218. package/src/components/resource/event-formatting.ts +393 -0
  219. package/src/components/resource/panels/AssessmentEntry.tsx +127 -0
  220. package/src/components/resource/panels/AssessmentPanel.tsx +309 -0
  221. package/src/components/resource/panels/CollaborationPanel.css +184 -0
  222. package/src/components/resource/panels/CollaborationPanel.tsx +228 -0
  223. package/src/components/resource/panels/CommentEntry.tsx +242 -0
  224. package/src/components/resource/panels/CommentsPanel.tsx +320 -0
  225. package/src/components/resource/panels/DelegateSection.css +330 -0
  226. package/src/components/resource/panels/DelegateSection.tsx +282 -0
  227. package/src/components/resource/panels/DelegateShell.tsx +134 -0
  228. package/src/components/resource/panels/HighlightEntry.tsx +83 -0
  229. package/src/components/resource/panels/HighlightPanel.tsx +212 -0
  230. package/src/components/resource/panels/JsonLdPanel.css +37 -0
  231. package/src/components/resource/panels/JsonLdPanel.tsx +119 -0
  232. package/src/components/resource/panels/PanelHeader.tsx +22 -0
  233. package/src/components/resource/panels/ReferenceEntry.tsx +232 -0
  234. package/src/components/resource/panels/ReferencesPanel.css +108 -0
  235. package/src/components/resource/panels/ReferencesPanel.tsx +626 -0
  236. package/src/components/resource/panels/ResourceInfoPanel.css +183 -0
  237. package/src/components/resource/panels/ResourceInfoPanel.tsx +433 -0
  238. package/src/components/resource/panels/StatisticsPanel.css +127 -0
  239. package/src/components/resource/panels/StatisticsPanel.tsx +145 -0
  240. package/src/components/resource/panels/TagEntry.tsx +87 -0
  241. package/src/components/resource/panels/TaggingPanel.tsx +554 -0
  242. package/src/components/resource/panels/UnifiedAnnotationsPanel.css +129 -0
  243. package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +384 -0
  244. package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +292 -0
  245. package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +685 -0
  246. package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +685 -0
  247. package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +750 -0
  248. package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +877 -0
  249. package/src/components/resource/panels/__tests__/DelegateSection.test.tsx +623 -0
  250. package/src/components/resource/panels/__tests__/DelegateShell.test.tsx +212 -0
  251. package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +236 -0
  252. package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +506 -0
  253. package/src/components/resource/panels/__tests__/HighlightPanel.out-of-order.test.tsx +132 -0
  254. package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +230 -0
  255. package/src/components/resource/panels/__tests__/PanelHeader.test.tsx +54 -0
  256. package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +578 -0
  257. package/src/components/resource/panels/__tests__/ReferencesPanel.headless.test.tsx +193 -0
  258. package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +193 -0
  259. package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +1080 -0
  260. package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +812 -0
  261. package/src/components/resource/panels/__tests__/ResourceInfoPanel.text-layer.test.tsx +106 -0
  262. package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +329 -0
  263. package/src/components/resource/panels/__tests__/TagEntry.test.tsx +250 -0
  264. package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +772 -0
  265. package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.delegated-job.test.tsx +207 -0
  266. package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.failure.test.tsx +89 -0
  267. package/src/components/resource/panels/__tests__/agent-label.test.ts +136 -0
  268. package/src/components/resource/panels/agent-label.ts +35 -0
  269. package/src/components/settings/SettingsPanel.css +92 -0
  270. package/src/components/settings/SettingsPanel.tsx +251 -0
  271. package/src/components/settings/__tests__/SettingsPanel.test.tsx +260 -0
  272. package/src/components/toolbar/Toolbar.css +245 -0
  273. package/src/components/viewers/ImageViewer.tsx +18 -0
  274. package/src/components/viewers/__tests__/ImageViewer.test.tsx +57 -0
  275. package/src/components/viewers/index.ts +1 -0
  276. package/src/features/auth/__tests__/AuthErrorDisplay.test.tsx +181 -0
  277. package/src/features/auth/auth.css +120 -0
  278. package/src/features/auth/components/AuthErrorDisplay.tsx +89 -0
  279. package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +387 -0
  280. package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +161 -0
  281. package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +183 -0
  282. package/src/features/moderate-entity-tags/state/entity-tags-state-unit.ts +73 -0
  283. package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +422 -0
  284. package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +117 -0
  285. package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +481 -0
  286. package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +161 -0
  287. package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +600 -0
  288. package/src/features/resource-compose/__tests__/UploadProgressBar.test.tsx +256 -0
  289. package/src/features/resource-compose/components/ResourceComposePage.tsx +809 -0
  290. package/src/features/resource-compose/components/UploadProgressBar.tsx +125 -0
  291. package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +195 -0
  292. package/src/features/resource-compose/state/compose-page-state-unit.ts +187 -0
  293. package/src/features/resource-discovery/__tests__/ResourceCard.test.tsx +338 -0
  294. package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +449 -0
  295. package/src/features/resource-discovery/components/ResourceCard.tsx +80 -0
  296. package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +330 -0
  297. package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +477 -0
  298. package/src/features/resource-discovery/state/discover-state-unit.ts +162 -0
  299. package/src/features/resource-viewer/__tests__/ResourceViewerPage.content-loading.test.tsx +260 -0
  300. package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +570 -0
  301. package/src/features/resource-viewer/__tests__/generation-params.test.ts +49 -0
  302. package/src/features/resource-viewer/components/ResourceViewerPage.tsx +1058 -0
  303. package/src/features/resource-viewer/generation-params.ts +23 -0
  304. package/src/features/resource-viewer/hooks/__tests__/useResourceViewedReport.test.tsx +77 -0
  305. package/src/features/resource-viewer/hooks/useResourceViewedReport.ts +38 -0
  306. package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +178 -0
  307. package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +505 -0
  308. package/src/features/resource-viewer/state/resource-loader-state-unit.ts +93 -0
  309. package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +156 -0
  310. package/src/styles/base/reset.css +105 -0
  311. package/src/styles/base/utilities.css +35 -0
  312. package/src/styles/core/badges.css +17 -0
  313. package/src/styles/core/buttons.css +772 -0
  314. package/src/styles/core/checkboxes.css +85 -0
  315. package/src/styles/core/forms.css +237 -0
  316. package/src/styles/core/index.css +43 -0
  317. package/src/styles/core/indicators.css +24 -0
  318. package/src/styles/core/inputs.css +164 -0
  319. package/src/styles/core/progress.css +85 -0
  320. package/src/styles/core/selects.css +119 -0
  321. package/src/styles/core/sliders.css +180 -0
  322. package/src/styles/core/tags.css +86 -0
  323. package/src/styles/core/textareas.css +104 -0
  324. package/src/styles/core/toggles.css +82 -0
  325. package/src/styles/features/compose.css +341 -0
  326. package/src/styles/features/entity-tags.css +140 -0
  327. package/src/styles/features/recent-docs.css +97 -0
  328. package/src/styles/features/resource-discovery.css +349 -0
  329. package/src/styles/features/resource-viewer.css +609 -0
  330. package/src/styles/features/resource.css +483 -0
  331. package/src/styles/features/schemas.css +222 -0
  332. package/src/styles/index.css +84 -0
  333. package/src/styles/layout/layout.css +28 -0
  334. package/src/styles/motivations/motivation-assessment.css +179 -0
  335. package/src/styles/motivations/motivation-comment.css +164 -0
  336. package/src/styles/motivations/motivation-highlight.css +132 -0
  337. package/src/styles/motivations/motivation-reference.css +167 -0
  338. package/src/styles/motivations/motivation-tag.css +182 -0
  339. package/src/styles/panels/history-panel.css +212 -0
  340. package/src/styles/panels/user-panel.css +21 -0
  341. package/src/styles/patterns/cards.css +26 -0
  342. package/src/styles/patterns/panel-helpers.css +32 -0
  343. package/src/styles/patterns/panels-base.css +272 -0
  344. package/src/styles/utilities/contrast.css +280 -0
  345. package/src/styles/utilities/focus-extended.css +276 -0
  346. package/src/styles/utilities/focus.css +41 -0
  347. package/src/styles/utilities/motion-overrides.css +286 -0
  348. package/src/styles/utilities/motion.css +184 -0
  349. package/src/styles/utilities/semantic-indicators.css +254 -0
  350. package/src/styles/variables.css +410 -0
  351. package/translations/ar.json +534 -0
  352. package/translations/bn.json +534 -0
  353. package/translations/cs.json +534 -0
  354. package/translations/da.json +534 -0
  355. package/translations/de.json +534 -0
  356. package/translations/el.json +534 -0
  357. package/translations/en.json +534 -0
  358. package/translations/es.json +534 -0
  359. package/translations/fa.json +534 -0
  360. package/translations/fi.json +534 -0
  361. package/translations/fr.json +534 -0
  362. package/translations/he.json +534 -0
  363. package/translations/hi.json +534 -0
  364. package/translations/id.json +534 -0
  365. package/translations/it.json +534 -0
  366. package/translations/ja.json +534 -0
  367. package/translations/ko.json +534 -0
  368. package/translations/ms.json +534 -0
  369. package/translations/nl.json +534 -0
  370. package/translations/no.json +534 -0
  371. package/translations/pl.json +534 -0
  372. package/translations/pt.json +534 -0
  373. package/translations/ro.json +534 -0
  374. package/translations/sv.json +534 -0
  375. package/translations/th.json +534 -0
  376. package/translations/tr.json +534 -0
  377. package/translations/uk.json +534 -0
  378. package/translations/vi.json +534 -0
  379. package/translations/zh.json +534 -0
@@ -0,0 +1,1080 @@
1
+ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2
+ import React from 'react';
3
+ import { render, screen, within } from '@testing-library/react';
4
+ import userEvent from '@testing-library/user-event';
5
+ import '@testing-library/jest-dom';
6
+ import { ReferencesPanel } from '../ReferencesPanel';
7
+ import type {
8
+ Annotation,
9
+ AnnotationId,
10
+ EventBus,
11
+ EventMap,
12
+ } from '@xynolog/core';
13
+ import type {
14
+ LinkComponentProps,
15
+ RouteBuilder,
16
+ } from '../../../../contexts/RoutingContext';
17
+ import {
18
+ createMarkStateUnit,
19
+ type MarkStateUnit,
20
+ type XynologSession,
21
+ } from '@xynolog/sdk';
22
+ import { createTestXynologWrapper } from '../../../../test-utils';
23
+ import { FrameRefusal, jobId, resourceId } from '@xynolog/core';
24
+
25
+ // Composition-based event tracker
26
+ interface TrackedEvent {
27
+ event: string;
28
+ payload: EventMap['mark:submit'];
29
+ }
30
+
31
+ function createEventTracker() {
32
+ const events: TrackedEvent[] = [];
33
+ return {
34
+ events,
35
+ clear: () => {
36
+ events.length = 0;
37
+ },
38
+ _attach(eventBus: EventBus) {
39
+ const panelEvents = ['mark:submit'] as const;
40
+ panelEvents.forEach((eventName) => {
41
+ eventBus.on(eventName).subscribe((payload) => {
42
+ // Nothing bridges into this test's bus: a refusal on it is the test's own fault.
43
+ if (payload instanceof FrameRefusal)
44
+ throw new Error(
45
+ `refused: ${payload.channel} ${payload.reason} ${payload.member}`,
46
+ );
47
+ events.push({ event: eventName, payload });
48
+ });
49
+ });
50
+ },
51
+ };
52
+ }
53
+
54
+ // Per-test session/wrapper: created in beforeEach — test-utils disposes every
55
+ // created client in a module-scope afterEach, so a module-scope factory call
56
+ // would hand tests after the first a disposed client. The component is
57
+ // provider-free: the `session` passed as a prop (same factory call as the
58
+ // eventBus the tracker attaches to) is the only session it sees.
59
+ let session: XynologSession;
60
+ let mark: MarkStateUnit;
61
+ let eventBus: EventBus;
62
+ let XynologWrapper: React.ComponentType<{ children: React.ReactNode }>;
63
+
64
+ beforeEach(() => {
65
+ ({ session, eventBus, XynologWrapper } = createTestXynologWrapper());
66
+ mark = createMarkStateUnit(session.client, resourceId('res-1'));
67
+ });
68
+
69
+ const renderWithEventBus = (
70
+ component: React.ReactElement,
71
+ tracker?: ReturnType<typeof createEventTracker>,
72
+ ) => {
73
+ if (tracker) tracker._attach(eventBus);
74
+ const Wrapper = ({ children }: { children: React.ReactNode }) => (
75
+ <XynologWrapper>{children}</XynologWrapper>
76
+ );
77
+ return render(component, { wrapper: Wrapper });
78
+ };
79
+
80
+ // Mock TranslationContext
81
+ vi.mock('../../../../contexts/TranslationContext', () => ({
82
+ useTranslations: vi.fn(
83
+ () => (key: string, params?: Record<string, unknown>) => {
84
+ const translations: Record<string, string> = {
85
+ annotateReferences: 'Annotate References',
86
+ selectEntityTypes: 'Select entity types',
87
+ noEntityTypes: 'No entity types available',
88
+ select: 'Select',
89
+ deselect: 'Deselect',
90
+ typesSelected: '{count} type(s) selected',
91
+ annotate: 'Annotate',
92
+ found: 'Found {count}',
93
+ includeDescriptiveReferences: 'Include descriptive references',
94
+ descriptiveReferencesTooltip:
95
+ "Also find phrases like 'the CEO', 'the tech giant', 'the physicist' (in addition to names)",
96
+ cancel: 'Cancel',
97
+ createReference: 'Create Reference',
98
+ annotating: 'Annotating...',
99
+ // The widget's own strings come from the
100
+ // DelegateProgress namespace, not from this panel's.
101
+ inProgress: 'Annotating...',
102
+ complete: 'Annotation complete!',
103
+ failed: 'Annotation failed',
104
+ };
105
+ let result = translations[key] || key;
106
+ // Replace {count} with actual count value if provided
107
+ if (params?.count !== undefined) {
108
+ result = result.replace('{count}', String(params.count));
109
+ }
110
+ return result;
111
+ },
112
+ ),
113
+ TranslationProvider: ({ children }: { children: React.ReactNode }) =>
114
+ children,
115
+ }));
116
+
117
+ describe('ReferencesPanel Component', () => {
118
+ // Mock Link component
119
+ const MockLink = ({ href, children, ...props }: LinkComponentProps) => (
120
+ <a href={href} {...props}>
121
+ {children}
122
+ </a>
123
+ );
124
+
125
+ // Mock routes
126
+ const mockRoutes: RouteBuilder = {
127
+ resourceDetail: (id: string) => `/resources/${id}`,
128
+ };
129
+
130
+ const defaultProps = {
131
+ resourceId: resourceId('res-1'),
132
+ allEntityTypes: ['Person', 'Organization', 'Location', 'Date'],
133
+ isDelegating: false,
134
+ progress: null,
135
+ jobId: null,
136
+ cancelled: false,
137
+ annotateMode: true,
138
+ Link: MockLink,
139
+ routes: mockRoutes,
140
+ pendingAnnotation: null,
141
+ };
142
+
143
+ // Per-test props: merges the beforeEach-created session at render time.
144
+ // (Module/describe-scope defaultProps must stay session-free — disposal
145
+ // hazard, see note above renderWithEventBus.)
146
+ const panelProps = () => ({ ...defaultProps, session, mark });
147
+
148
+ beforeEach(() => {
149
+ vi.clearAllMocks();
150
+ });
151
+
152
+ afterEach(() => {
153
+ vi.restoreAllMocks();
154
+ mark.dispose();
155
+ });
156
+
157
+ // The panel threads the host's sparkle set down to
158
+ // the entries — exactly the ids in the set glow, nothing else.
159
+ describe('Resolution sparkle threading', () => {
160
+ const linkingReference = (id: string): Annotation => ({
161
+ '@context': 'http://www.w3.org/ns/anno.jsonld',
162
+ id: id as AnnotationId,
163
+ type: 'Annotation',
164
+ motivation: 'linking',
165
+ created: '2026-08-21T12:00:00Z',
166
+ modified: '2026-08-21T12:00:00Z',
167
+ target: {
168
+ source: resourceId('res-1'),
169
+ selector: { type: 'TextQuoteSelector', exact: `text of ${id}` },
170
+ },
171
+ body: {
172
+ type: 'SpecificResource',
173
+ source: resourceId('linked-doc'),
174
+ purpose: 'linking',
175
+ },
176
+ });
177
+
178
+ it('sparkles exactly the entries named by sparkleAnnotationIds', () => {
179
+ const { container } = renderWithEventBus(
180
+ <ReferencesPanel
181
+ {...panelProps()}
182
+ annotations={[
183
+ linkingReference('ann-dark'),
184
+ linkingReference('ann-lit'),
185
+ ]}
186
+ sparkleAnnotationIds={new Set(['ann-lit'])}
187
+ />,
188
+ );
189
+
190
+ const sparkling = container.querySelectorAll(
191
+ '.xynolog-reference-icon.annotation-sparkle',
192
+ );
193
+ expect(sparkling).toHaveLength(1);
194
+ expect(
195
+ sparkling[0]!.closest('.xynolog-annotation-entry'),
196
+ ).toHaveTextContent('text of ann-lit');
197
+ });
198
+ });
199
+
200
+ describe('Rendering', () => {
201
+ it('should render panel with title', () => {
202
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
203
+
204
+ expect(screen.getByText('Annotate References')).toBeInTheDocument();
205
+ });
206
+
207
+ it('should render all entity type buttons', () => {
208
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
209
+
210
+ expect(screen.getByText('Person')).toBeInTheDocument();
211
+ expect(screen.getByText('Organization')).toBeInTheDocument();
212
+ expect(screen.getByText('Location')).toBeInTheDocument();
213
+ expect(screen.getByText('Date')).toBeInTheDocument();
214
+ });
215
+
216
+ it('should show message when no entity types available', () => {
217
+ renderWithEventBus(
218
+ <ReferencesPanel {...panelProps()} allEntityTypes={[]} />,
219
+ );
220
+
221
+ expect(screen.getByText('No entity types available')).toBeInTheDocument();
222
+ });
223
+
224
+ it('should render start detection button', () => {
225
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
226
+
227
+ expect(screen.getByTitle('Annotate')).toBeInTheDocument();
228
+ });
229
+ });
230
+
231
+ // Entity types are optional on a reference, but `MarkSubmitEvent.body` is
232
+ // `minItems: 1` — so "no types selected" must OMIT body, not send `[]`.
233
+ // Sending `[]` 400s at /bus/emit, and `mark.submit` is fire-and-forget, so
234
+ // the failure is silent: the button looks inert.
235
+ describe('Create Reference payload', () => {
236
+ const pendingLinking = {
237
+ motivation: 'linking' as const,
238
+ selector: { type: 'TextQuoteSelector' as const, exact: 'thylakoid' },
239
+ };
240
+
241
+ const submitPayloads = (tracker: ReturnType<typeof createEventTracker>) =>
242
+ tracker.events
243
+ .filter((e) => e.event === 'mark:submit')
244
+ .map((e) => e.payload);
245
+
246
+ // The panel's own entity-type chips, not DelegateSection's identically
247
+ // labelled ones.
248
+ const renderPrompt = (tracker: ReturnType<typeof createEventTracker>) => {
249
+ const { container } = renderWithEventBus(
250
+ <ReferencesPanel
251
+ {...panelProps()}
252
+ pendingAnnotation={pendingLinking}
253
+ />,
254
+ tracker,
255
+ );
256
+ return within(
257
+ container.querySelector('.xynolog-annotation-prompt') as HTMLElement,
258
+ );
259
+ };
260
+
261
+ it('omits body entirely when no entity type is selected', async () => {
262
+ const tracker = createEventTracker();
263
+ const prompt = renderPrompt(tracker);
264
+
265
+ await userEvent.click(
266
+ prompt.getByRole('button', { name: /create reference/i }),
267
+ );
268
+
269
+ const [payload] = submitPayloads(tracker);
270
+ expect(payload).toBeDefined();
271
+ expect(payload).not.toHaveProperty('body');
272
+ });
273
+
274
+ it('sends a one-item body when an entity type is selected', async () => {
275
+ const tracker = createEventTracker();
276
+ const prompt = renderPrompt(tracker);
277
+
278
+ await userEvent.click(prompt.getByRole('button', { name: 'Person' }));
279
+ await userEvent.click(
280
+ prompt.getByRole('button', { name: /create reference/i }),
281
+ );
282
+
283
+ const [payload] = submitPayloads(tracker);
284
+ expect(payload.body).toEqual([
285
+ { type: 'TextualBody', value: 'Person', purpose: 'tagging' },
286
+ ]);
287
+ });
288
+ });
289
+
290
+ describe('Entity Type Selection', () => {
291
+ it('should toggle entity type selection on click', async () => {
292
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
293
+
294
+ const personButton = screen.getByText('Person');
295
+
296
+ // Initially not selected
297
+ expect(personButton).toHaveAttribute('aria-pressed', 'false');
298
+
299
+ // Click to select
300
+ await userEvent.click(personButton);
301
+
302
+ expect(personButton).toHaveAttribute('aria-pressed', 'true');
303
+
304
+ // Click again to deselect
305
+ await userEvent.click(personButton);
306
+
307
+ expect(personButton).toHaveAttribute('aria-pressed', 'false');
308
+ });
309
+
310
+ it('should allow multiple selections', async () => {
311
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
312
+
313
+ const personButton = screen.getByText('Person');
314
+ const orgButton = screen.getByText('Organization');
315
+ const locationButton = screen.getByText('Location');
316
+
317
+ await userEvent.click(personButton);
318
+ await userEvent.click(orgButton);
319
+ await userEvent.click(locationButton);
320
+
321
+ expect(personButton).toHaveAttribute('aria-pressed', 'true');
322
+ expect(orgButton).toHaveAttribute('aria-pressed', 'true');
323
+ expect(locationButton).toHaveAttribute('aria-pressed', 'true');
324
+ });
325
+
326
+ it('should deselect when clicking selected type', async () => {
327
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
328
+
329
+ const personButton = screen.getByText('Person');
330
+
331
+ await userEvent.click(personButton);
332
+ expect(personButton).toHaveAttribute('aria-pressed', 'true');
333
+
334
+ await userEvent.click(personButton);
335
+ expect(personButton).toHaveAttribute('aria-pressed', 'false');
336
+ });
337
+
338
+ it('should show selected count', async () => {
339
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
340
+
341
+ const personButton = screen.getByText('Person');
342
+ const orgButton = screen.getByText('Organization');
343
+
344
+ await userEvent.click(personButton);
345
+
346
+ // Should show count
347
+ expect(screen.getByText(/selected/i)).toBeInTheDocument();
348
+
349
+ await userEvent.click(orgButton);
350
+
351
+ // Should update count
352
+ expect(screen.getByText(/selected/i)).toBeInTheDocument();
353
+ });
354
+
355
+ it('should not show selected count when none selected', () => {
356
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
357
+
358
+ expect(screen.queryByText(/selected/i)).not.toBeInTheDocument();
359
+ });
360
+ });
361
+
362
+ describe('Button Styling', () => {
363
+ it('should style selected buttons differently', async () => {
364
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
365
+
366
+ const personButton = screen.getByText('Person');
367
+
368
+ // Before selection
369
+ expect(personButton).toHaveClass(
370
+ 'xynolog-chip',
371
+ 'xynolog-chip--selectable',
372
+ );
373
+ expect(personButton).toHaveAttribute('data-selected', 'false');
374
+
375
+ await userEvent.click(personButton);
376
+
377
+ // After selection
378
+ expect(personButton).toHaveAttribute('data-selected', 'true');
379
+ });
380
+
381
+ it('should have proper ARIA attributes', () => {
382
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
383
+
384
+ const personButton = screen.getByText('Person');
385
+
386
+ expect(personButton).toHaveAttribute('aria-pressed');
387
+ expect(personButton).toHaveAttribute('aria-label');
388
+ });
389
+
390
+ it('should have focus styles', () => {
391
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
392
+
393
+ const personButton = screen.getByText('Person');
394
+
395
+ expect(personButton).toHaveClass(
396
+ 'xynolog-chip',
397
+ 'xynolog-chip--selectable',
398
+ );
399
+ });
400
+ });
401
+
402
+ describe('Start Annotate Button', () => {
403
+ it('should be disabled when no types selected', () => {
404
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
405
+
406
+ const startButton = screen.getByTitle('Annotate');
407
+
408
+ expect(startButton).toBeDisabled();
409
+ });
410
+
411
+ it('should be enabled when types are selected', async () => {
412
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
413
+
414
+ const personButton = screen.getByText('Person');
415
+ await userEvent.click(personButton);
416
+
417
+ const startButton = screen.getByTitle('Annotate');
418
+
419
+ expect(startButton).not.toBeDisabled();
420
+ });
421
+
422
+ it('asks the mark unit to delegate a linking job of the chosen types, descriptive references left out', async () => {
423
+ const requestDelegate = vi
424
+ .spyOn(mark, 'requestDelegate')
425
+ .mockImplementation(() => {});
426
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
427
+
428
+ await userEvent.click(screen.getByText('Person'));
429
+ await userEvent.click(screen.getByText('Organization'));
430
+
431
+ const startButton = screen.getByTitle('Annotate');
432
+ await userEvent.click(startButton);
433
+
434
+ expect(requestDelegate).toHaveBeenCalledExactlyOnceWith(
435
+ expect.objectContaining({
436
+ motivation: 'linking',
437
+ entityTypes: ['Person', 'Organization'],
438
+ includeDescriptiveReferences: false,
439
+ }),
440
+ );
441
+ });
442
+
443
+ it('delegates with descriptive references included when the box is checked', async () => {
444
+ const requestDelegate = vi
445
+ .spyOn(mark, 'requestDelegate')
446
+ .mockImplementation(() => {});
447
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
448
+
449
+ await userEvent.click(screen.getByText('Person'));
450
+
451
+ // Check the "Include descriptive references" checkbox
452
+ const checkboxLabel = screen.getByText('Include descriptive references');
453
+ const checkbox = checkboxLabel.previousElementSibling as HTMLInputElement;
454
+ await userEvent.click(checkbox);
455
+
456
+ const startButton = screen.getByTitle('Annotate');
457
+ await userEvent.click(startButton);
458
+
459
+ expect(requestDelegate).toHaveBeenCalledExactlyOnceWith(
460
+ expect.objectContaining({
461
+ motivation: 'linking',
462
+ entityTypes: ['Person'],
463
+ includeDescriptiveReferences: true,
464
+ }),
465
+ );
466
+ });
467
+
468
+ it('the control of a running job asks for that job to be cancelled, by its id', async () => {
469
+ const cancelSpy = vi
470
+ .spyOn(session.client.job, 'cancel')
471
+ .mockResolvedValue(true);
472
+ renderWithEventBus(
473
+ <ReferencesPanel
474
+ {...panelProps()}
475
+ isDelegating={true}
476
+ jobId={jobId('job-1')}
477
+ progress={{ percentage: 0, completedItems: [] }}
478
+ />,
479
+ );
480
+
481
+ await userEvent.click(screen.getByTestId('xynolog-delegate-control'));
482
+ expect(cancelSpy).toHaveBeenCalledExactlyOnceWith('job-1');
483
+ });
484
+
485
+ it('a running job the queue has not named yet has no cancel control', () => {
486
+ renderWithEventBus(
487
+ <ReferencesPanel
488
+ {...panelProps()}
489
+ isDelegating={true}
490
+ jobId={null}
491
+ cancelled={false}
492
+ progress={{ percentage: 0, completedItems: [] }}
493
+ />,
494
+ );
495
+
496
+ expect(screen.queryByTestId('xynolog-delegate-control')).toBeNull();
497
+ });
498
+
499
+ it('shows how many of the priced entities a running job has found', () => {
500
+ // The wire prices the denominator; the panel's own copy words it. The
501
+ // count goes through the same translations the panel builds for its
502
+ // display, so it fails here if they drop it on the way.
503
+ renderWithEventBus(
504
+ <ReferencesPanel
505
+ {...panelProps()}
506
+ isDelegating={true}
507
+ progress={{ percentage: 40, entitiesFound: 3, entitiesExpected: 10 }}
508
+ />,
509
+ );
510
+
511
+ expect(screen.getByTestId('xynolog-delegate-tally')).toBeInTheDocument();
512
+ });
513
+
514
+ it('should clear selected types after detection starts', async () => {
515
+ const { rerender } = renderWithEventBus(
516
+ <ReferencesPanel {...panelProps()} />,
517
+ );
518
+
519
+ await userEvent.click(screen.getByText('Person'));
520
+
521
+ const startButton = screen.getByTitle('Annotate');
522
+ await userEvent.click(startButton);
523
+
524
+ // Simulate detection starting
525
+ rerender(
526
+ <ReferencesPanel
527
+ {...panelProps()}
528
+ isDelegating={true}
529
+ progress={{ percentage: 0, completedItems: [] }}
530
+ />,
531
+ );
532
+
533
+ // Simulate detection completing
534
+ rerender(
535
+ <ReferencesPanel
536
+ {...panelProps()}
537
+ isDelegating={false}
538
+ progress={{
539
+ percentage: 100,
540
+ completedItems: [{ value: 'Person', foundCount: 5 }],
541
+ }}
542
+ />,
543
+ );
544
+
545
+ // UI should reset but we can't directly test internal state
546
+ // We can test that buttons are back to unselected state after going through full cycle
547
+ });
548
+
549
+ it('should have proper styling when disabled', () => {
550
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
551
+
552
+ const startButton = screen.getByTitle('Annotate');
553
+
554
+ expect(startButton).toHaveClass('xynolog-button');
555
+ expect(startButton).toHaveAttribute('data-variant', 'delegate');
556
+ expect(startButton).toHaveAttribute('data-type', 'reference');
557
+ expect(startButton).toBeDisabled();
558
+ });
559
+
560
+ it('should have proper styling when enabled', async () => {
561
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
562
+
563
+ await userEvent.click(screen.getByText('Person'));
564
+
565
+ const startButton = screen.getByTitle('Annotate');
566
+
567
+ expect(startButton).toHaveClass('xynolog-button');
568
+ expect(startButton).toHaveAttribute('data-variant', 'delegate');
569
+ expect(startButton).toHaveAttribute('data-type', 'reference');
570
+ expect(startButton).not.toBeDisabled();
571
+ });
572
+ });
573
+
574
+ describe('Detection Progress', () => {
575
+ it('should show progress widget when detecting', () => {
576
+ renderWithEventBus(
577
+ <ReferencesPanel
578
+ {...panelProps()}
579
+ isDelegating={true}
580
+ progress={{ percentage: 0, completedItems: [] }}
581
+ />,
582
+ );
583
+
584
+ expect(screen.getByText('Annotating...')).toBeInTheDocument();
585
+ });
586
+
587
+ it('should pass progress data to widget', () => {
588
+ const progress = {
589
+ percentage: 100,
590
+ completedItems: [
591
+ { value: 'Person', foundCount: 5 },
592
+ { value: 'Organization', foundCount: 3 },
593
+ ],
594
+ };
595
+
596
+ renderWithEventBus(
597
+ <ReferencesPanel
598
+ {...panelProps()}
599
+ isDelegating={true}
600
+ progress={progress}
601
+ />,
602
+ );
603
+
604
+ // Real DelegateProgress renders the completed entity-type log.
605
+ expect(screen.getByText('Person:')).toBeInTheDocument();
606
+ expect(screen.getByText('Organization:')).toBeInTheDocument();
607
+ });
608
+
609
+ it('renders the entity log with the SAME markup the progress display uses', () => {
610
+ // This form-side log and DelegateProgress's completed-entity log are the
611
+ // same concept, so both use the xynolog-annotation-log* classes and
612
+ // neither has a xynolog-delegate-widget__log* family of its own — one
613
+ // concept, one markup.
614
+ const { container, rerender } = renderWithEventBus(
615
+ <ReferencesPanel
616
+ {...panelProps()}
617
+ isDelegating={false}
618
+ progress={{
619
+ percentage: 100,
620
+ completedItems: [{ value: 'Person', foundCount: 5 }],
621
+ }}
622
+ />,
623
+ );
624
+ rerender(
625
+ <ReferencesPanel
626
+ {...panelProps()}
627
+ isDelegating={false}
628
+ progress={null}
629
+ />,
630
+ );
631
+
632
+ expect(
633
+ container.querySelector('.xynolog-annotation-log'),
634
+ ).toBeInTheDocument();
635
+ expect(
636
+ container.querySelector('.xynolog-annotation-log-item'),
637
+ ).toBeInTheDocument();
638
+ expect(
639
+ container.querySelector('.xynolog-delegate-widget__log'),
640
+ ).not.toBeInTheDocument();
641
+ });
642
+
643
+ it('should hide entity type selection during detection', () => {
644
+ renderWithEventBus(
645
+ <ReferencesPanel
646
+ {...panelProps()}
647
+ isDelegating={true}
648
+ progress={{ percentage: 0, completedItems: [] }}
649
+ />,
650
+ );
651
+
652
+ expect(screen.queryByText('Select entity types')).not.toBeInTheDocument();
653
+ expect(screen.queryByText('Person')).not.toBeInTheDocument();
654
+ });
655
+
656
+ it('should render cancel button when detecting, once the job has its id', async () => {
657
+ renderWithEventBus(
658
+ <ReferencesPanel
659
+ {...panelProps()}
660
+ isDelegating={true}
661
+ jobId={jobId('job-1')}
662
+ progress={{ percentage: 0, completedItems: [] }}
663
+ />,
664
+ );
665
+
666
+ // The control's label comes from the DelegateProgress namespace's `cancel`.
667
+ const cancelButton = screen.getByTitle('Cancel');
668
+ expect(cancelButton).toBeInTheDocument();
669
+ });
670
+ });
671
+
672
+ describe('Detection Complete Log', () => {
673
+ it('should show completed log after detection finishes', () => {
674
+ const { rerender } = renderWithEventBus(
675
+ <ReferencesPanel
676
+ {...panelProps()}
677
+ isDelegating={false}
678
+ progress={{
679
+ percentage: 100,
680
+ completedItems: [
681
+ { value: 'Person', foundCount: 5 },
682
+ { value: 'Organization', foundCount: 3 },
683
+ ],
684
+ }}
685
+ />,
686
+ );
687
+
688
+ // Parent clears progress after completion
689
+ rerender(
690
+ <ReferencesPanel
691
+ {...panelProps()}
692
+ isDelegating={false}
693
+ progress={null}
694
+ />,
695
+ );
696
+
697
+ expect(screen.getByText('Person:')).toBeInTheDocument();
698
+ expect(screen.getByText('Organization:')).toBeInTheDocument();
699
+ });
700
+
701
+ it('should show found counts in log', () => {
702
+ const { rerender } = renderWithEventBus(
703
+ <ReferencesPanel
704
+ {...panelProps()}
705
+ isDelegating={false}
706
+ progress={{
707
+ percentage: 100,
708
+ completedItems: [{ value: 'Person', foundCount: 5 }],
709
+ }}
710
+ />,
711
+ );
712
+
713
+ rerender(
714
+ <ReferencesPanel
715
+ {...panelProps()}
716
+ isDelegating={false}
717
+ progress={null}
718
+ />,
719
+ );
720
+ expect(screen.getByText(/Found.*5/i)).toBeInTheDocument();
721
+ });
722
+
723
+ it('should show checkmarks for completed types', () => {
724
+ const { rerender } = renderWithEventBus(
725
+ <ReferencesPanel
726
+ {...panelProps()}
727
+ isDelegating={false}
728
+ progress={{
729
+ percentage: 100,
730
+ completedItems: [{ value: 'Person', foundCount: 5 }],
731
+ }}
732
+ />,
733
+ );
734
+
735
+ rerender(
736
+ <ReferencesPanel
737
+ {...panelProps()}
738
+ isDelegating={false}
739
+ progress={null}
740
+ />,
741
+ );
742
+ expect(screen.getByText('✓')).toBeInTheDocument();
743
+ });
744
+
745
+ it('should show detection log and selection UI together after completion', () => {
746
+ const { rerender } = renderWithEventBus(
747
+ <ReferencesPanel
748
+ {...panelProps()}
749
+ isDelegating={false}
750
+ progress={{
751
+ percentage: 100,
752
+ completedItems: [{ value: 'Person', foundCount: 5 }],
753
+ }}
754
+ />,
755
+ );
756
+
757
+ rerender(
758
+ <ReferencesPanel
759
+ {...panelProps()}
760
+ isDelegating={false}
761
+ progress={null}
762
+ />,
763
+ );
764
+
765
+ // Should show both the completed log AND the selection UI
766
+ expect(screen.getByText('Person:')).toBeInTheDocument(); // Log entry
767
+ expect(screen.getByText('Select entity types')).toBeInTheDocument(); // Selection UI
768
+ });
769
+
770
+ it('should show selection UI immediately after detection completes', async () => {
771
+ const { rerender } = renderWithEventBus(
772
+ <ReferencesPanel
773
+ {...panelProps()}
774
+ isDelegating={false}
775
+ progress={{
776
+ percentage: 100,
777
+ completedItems: [{ value: 'Person', foundCount: 5 }],
778
+ }}
779
+ />,
780
+ );
781
+
782
+ rerender(
783
+ <ReferencesPanel
784
+ {...panelProps()}
785
+ isDelegating={false}
786
+ progress={null}
787
+ />,
788
+ );
789
+
790
+ // Selection UI should be immediately available (no button click needed)
791
+ expect(screen.getByText('Select entity types')).toBeInTheDocument();
792
+ expect(screen.getByText('Person')).toBeInTheDocument(); // Entity type chip
793
+ });
794
+
795
+ it('should not show log when empty', () => {
796
+ renderWithEventBus(
797
+ <ReferencesPanel
798
+ {...panelProps()}
799
+ isDelegating={false}
800
+ progress={{
801
+ percentage: 100,
802
+ completedItems: [],
803
+ }}
804
+ />,
805
+ );
806
+
807
+ // Should not show any log items. Terminal progress (dismissable) is
808
+ // shown instead of the form — the DelegateShell normalization; the
809
+ // form returns once progress clears.
810
+ expect(screen.queryByText('✓')).not.toBeInTheDocument();
811
+ expect(screen.queryByText('Select entity types')).not.toBeInTheDocument();
812
+ });
813
+ });
814
+
815
+ describe('State Transitions', () => {
816
+ it('should transition from idle to detecting', () => {
817
+ const { rerender } = renderWithEventBus(
818
+ <ReferencesPanel {...panelProps()} />,
819
+ );
820
+
821
+ // Idle state
822
+ expect(screen.getByText('Select entity types')).toBeInTheDocument();
823
+
824
+ // Start detecting
825
+ rerender(
826
+ <ReferencesPanel
827
+ {...panelProps()}
828
+ isDelegating={true}
829
+ progress={{ percentage: 0, completedItems: [] }}
830
+ />,
831
+ );
832
+
833
+ // Detecting state
834
+ expect(screen.getByText('Annotating...')).toBeInTheDocument();
835
+ expect(screen.queryByText('Select entity types')).not.toBeInTheDocument();
836
+ });
837
+
838
+ it('should transition from detecting to complete', () => {
839
+ const { rerender } = renderWithEventBus(
840
+ <ReferencesPanel
841
+ {...panelProps()}
842
+ isDelegating={true}
843
+ progress={{ percentage: 0, completedItems: [] }}
844
+ />,
845
+ );
846
+
847
+ // Detecting
848
+ expect(screen.getByText('Annotating...')).toBeInTheDocument();
849
+
850
+ // Complete - first trigger useEffect to copy to lastDetectionLog
851
+ rerender(
852
+ <ReferencesPanel
853
+ {...panelProps()}
854
+ isDelegating={false}
855
+ progress={{
856
+ percentage: 100,
857
+ completedItems: [{ value: 'Person', foundCount: 5 }],
858
+ }}
859
+ />,
860
+ );
861
+
862
+ // Then clear progress to show the log
863
+ rerender(
864
+ <ReferencesPanel
865
+ {...panelProps()}
866
+ isDelegating={false}
867
+ progress={null}
868
+ />,
869
+ );
870
+
871
+ expect(
872
+ screen.queryByText('Annotation complete!'),
873
+ ).not.toBeInTheDocument();
874
+ // Both log and selection UI should be visible
875
+ expect(screen.getByText('Person:')).toBeInTheDocument();
876
+ expect(screen.getByText('Select entity types')).toBeInTheDocument();
877
+ });
878
+
879
+ it('should show selection UI after detection completes', async () => {
880
+ const { rerender } = renderWithEventBus(
881
+ <ReferencesPanel
882
+ {...panelProps()}
883
+ isDelegating={false}
884
+ progress={{
885
+ percentage: 100,
886
+ completedItems: [{ value: 'Person', foundCount: 5 }],
887
+ }}
888
+ />,
889
+ );
890
+
891
+ // Clear progress to show the log
892
+ rerender(
893
+ <ReferencesPanel
894
+ {...panelProps()}
895
+ isDelegating={false}
896
+ progress={null}
897
+ />,
898
+ );
899
+
900
+ // Selection UI should be immediately available
901
+ expect(screen.getByText('Select entity types')).toBeInTheDocument();
902
+
903
+ rerender(<ReferencesPanel {...panelProps()} />);
904
+
905
+ expect(screen.getByText('Select entity types')).toBeInTheDocument();
906
+ });
907
+ });
908
+
909
+ describe('Edge Cases', () => {
910
+ it('should handle empty entity types array', () => {
911
+ expect(() => {
912
+ renderWithEventBus(
913
+ <ReferencesPanel {...panelProps()} allEntityTypes={[]} />,
914
+ );
915
+ }).not.toThrow();
916
+ });
917
+
918
+ it('should handle many entity types', () => {
919
+ const manyTypes = Array.from({ length: 50 }, (_, i) => `Type${i}`);
920
+
921
+ expect(() => {
922
+ renderWithEventBus(
923
+ <ReferencesPanel {...panelProps()} allEntityTypes={manyTypes} />,
924
+ );
925
+ }).not.toThrow();
926
+
927
+ expect(screen.getByText('Type0')).toBeInTheDocument();
928
+ expect(screen.getByText('Type49')).toBeInTheDocument();
929
+ });
930
+
931
+ it('should handle entity types with special characters', () => {
932
+ const specialTypes = ['Type-A', 'Type_B', 'Type.C', 'Type/D'];
933
+
934
+ renderWithEventBus(
935
+ <ReferencesPanel {...panelProps()} allEntityTypes={specialTypes} />,
936
+ );
937
+
938
+ specialTypes.forEach((type) => {
939
+ expect(screen.getByText(type)).toBeInTheDocument();
940
+ });
941
+ });
942
+
943
+ it('should handle selecting and deselecting all types', async () => {
944
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
945
+
946
+ // Select all
947
+ for (const type of defaultProps.allEntityTypes) {
948
+ await userEvent.click(screen.getByText(type));
949
+ }
950
+
951
+ defaultProps.allEntityTypes.forEach((type) => {
952
+ expect(screen.getByText(type)).toHaveAttribute('aria-pressed', 'true');
953
+ });
954
+
955
+ // Deselect all
956
+ for (const type of defaultProps.allEntityTypes) {
957
+ await userEvent.click(screen.getByText(type));
958
+ }
959
+
960
+ defaultProps.allEntityTypes.forEach((type) => {
961
+ expect(screen.getByText(type)).toHaveAttribute('aria-pressed', 'false');
962
+ });
963
+ });
964
+
965
+ it('should handle rapid selection changes', async () => {
966
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
967
+
968
+ const personButton = screen.getByText('Person');
969
+
970
+ // Rapid clicks
971
+ for (let i = 0; i < 10; i++) {
972
+ await userEvent.click(personButton);
973
+ }
974
+
975
+ // Should be in a consistent state (even number of clicks = not selected)
976
+ expect(personButton).toHaveAttribute('aria-pressed', 'false');
977
+ });
978
+
979
+ it('should handle zero found count in results', () => {
980
+ renderWithEventBus(
981
+ <ReferencesPanel
982
+ {...panelProps()}
983
+ isDelegating={false}
984
+ progress={{
985
+ percentage: 100,
986
+ completedItems: [{ value: 'Person', foundCount: 0 }],
987
+ }}
988
+ />,
989
+ );
990
+
991
+ expect(screen.getByText(/Found.*0/i)).toBeInTheDocument();
992
+ });
993
+
994
+ it('should handle undefined progress', () => {
995
+ expect(() => {
996
+ renderWithEventBus(
997
+ <ReferencesPanel
998
+ {...panelProps()}
999
+ isDelegating={false}
1000
+ // @ts-expect-error — progress is JobProgress or null; this holds that undefined does not throw
1001
+ progress={undefined}
1002
+ />,
1003
+ );
1004
+ }).not.toThrow();
1005
+ });
1006
+ });
1007
+
1008
+ describe('Styling and Appearance', () => {
1009
+ it('should have proper panel structure', () => {
1010
+ const { container } = renderWithEventBus(
1011
+ <ReferencesPanel {...panelProps()} />,
1012
+ );
1013
+
1014
+ const panel = container.firstChild as HTMLElement;
1015
+ expect(panel).toHaveClass('xynolog-panel');
1016
+ });
1017
+
1018
+ it('should support dark mode', () => {
1019
+ const { container } = renderWithEventBus(
1020
+ <ReferencesPanel {...panelProps()} />,
1021
+ );
1022
+
1023
+ const panel = container.firstChild as HTMLElement;
1024
+ expect(panel).toHaveClass('xynolog-panel');
1025
+ });
1026
+
1027
+ it('should have title without emoji', () => {
1028
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
1029
+
1030
+ // The emoji is not in the title (it is only in the tab)
1031
+ const title = screen.getByRole('heading', { level: 2 });
1032
+ expect(title.textContent).not.toContain('🔵');
1033
+ expect(title.textContent).toContain('title');
1034
+ });
1035
+
1036
+ it('should have proper button layout', () => {
1037
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
1038
+
1039
+ const buttonContainer = screen.getByText('Person').parentElement;
1040
+ expect(buttonContainer).toHaveClass('xynolog-delegate-widget__chips');
1041
+ });
1042
+ });
1043
+
1044
+ describe('Accessibility', () => {
1045
+ it('should have proper ARIA labels for selection', async () => {
1046
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
1047
+
1048
+ const personButton = screen.getByText('Person');
1049
+
1050
+ expect(personButton).toHaveAttribute('aria-label');
1051
+
1052
+ await userEvent.click(personButton);
1053
+
1054
+ // Label should update to indicate deselection is possible
1055
+ const label = personButton.getAttribute('aria-label');
1056
+ expect(label).toBeTruthy();
1057
+ });
1058
+
1059
+ it('should have proper ARIA pressed states', async () => {
1060
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
1061
+
1062
+ const personButton = screen.getByText('Person');
1063
+
1064
+ expect(personButton).toHaveAttribute('aria-pressed', 'false');
1065
+
1066
+ await userEvent.click(personButton);
1067
+
1068
+ expect(personButton).toHaveAttribute('aria-pressed', 'true');
1069
+ });
1070
+
1071
+ it('should be keyboard navigable', () => {
1072
+ renderWithEventBus(<ReferencesPanel {...panelProps()} />);
1073
+
1074
+ const personButton = screen.getByText('Person');
1075
+ personButton.focus();
1076
+
1077
+ expect(personButton).toHaveFocus();
1078
+ });
1079
+ });
1080
+ });