@bevel-software/platform-core-frontend 0.4.1 → 0.5.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 (326) hide show
  1. package/package.json +5 -3
  2. package/src/core/CoreAppShell.tsx +195 -56
  3. package/src/core/__tests__/AppChrome.test.tsx +125 -0
  4. package/src/core/__tests__/ShellRoutes.test.tsx +37 -2
  5. package/src/core/__tests__/bootstrap.test.ts +63 -0
  6. package/src/core/bootstrap.ts +73 -0
  7. package/src/core/events.ts +12 -0
  8. package/src/core/registry.ts +58 -9
  9. package/src/index.css +100 -11
  10. package/src/index.ts +24 -23
  11. package/src/lib/utils.ts +93 -117
  12. package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +281 -0
  13. package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +166 -1
  14. package/src/modules/access/api.ts +49 -0
  15. package/src/modules/access/components/ManageAccessDialog.tsx +786 -481
  16. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  17. package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +86 -0
  18. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +17 -1
  19. package/src/modules/admin/__tests__/admin.unread.test.tsx +61 -0
  20. package/src/modules/admin/components/AdminRolesPage.tsx +44 -38
  21. package/src/modules/admin/components/RolesCorruptedBanner.tsx +11 -10
  22. package/src/modules/admin/components/UserAccountsPage.tsx +36 -28
  23. package/src/modules/admin/state/admin.context.tsx +15 -6
  24. package/src/modules/auth/components/AccountPage.tsx +11 -11
  25. package/src/modules/auth/components/LoginScreen.tsx +12 -12
  26. package/src/modules/auth/services/sso.ts +47 -1
  27. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +277 -0
  28. package/src/modules/change-requests/__tests__/author.test.ts +48 -0
  29. package/src/modules/change-requests/__tests__/conflict.test.ts +73 -0
  30. package/src/modules/change-requests/__tests__/diff.test.ts +134 -0
  31. package/src/modules/change-requests/__tests__/propose.test.ts +93 -0
  32. package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +72 -0
  33. package/src/modules/change-requests/change-requests.css +22 -0
  34. package/src/modules/change-requests/components/ChangeBox.tsx +277 -0
  35. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +713 -0
  36. package/src/modules/change-requests/components/ConflictHelp.tsx +47 -0
  37. package/src/modules/change-requests/components/CrFileTree.tsx +398 -0
  38. package/src/modules/change-requests/components/FileChangeBoxes.tsx +168 -0
  39. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +236 -0
  40. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +79 -0
  41. package/src/modules/change-requests/hooks/useFileOnBranch.ts +80 -0
  42. package/src/modules/change-requests/services/change-requests.api.ts +45 -0
  43. package/src/modules/change-requests/services/propose.api.ts +162 -0
  44. package/src/modules/change-requests/utils/author.ts +47 -0
  45. package/src/modules/change-requests/utils/conflict.ts +38 -0
  46. package/src/modules/change-requests/utils/diff.ts +80 -0
  47. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +27 -18
  48. package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +36 -83
  49. package/src/modules/git/__tests__/PullNeededBanner.test.tsx +5 -5
  50. package/src/modules/git/__tests__/PullRequestsForMe.test.tsx +147 -0
  51. package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +2 -8
  52. package/src/modules/git/components/BranchSwitcher.tsx +68 -31
  53. package/src/modules/git/components/DiffView.tsx +4 -4
  54. package/src/modules/git/components/FileComparisonPanel.tsx +20 -20
  55. package/src/modules/git/components/FileHistoryPanel.tsx +71 -107
  56. package/src/modules/git/components/PullNeededBanner.tsx +6 -13
  57. package/src/modules/git/components/PullRequestsForMe.tsx +71 -36
  58. package/src/modules/git/components/UnifiedDiffView.tsx +4 -4
  59. package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +2 -2
  60. package/src/modules/git/hooks/useGitState.ts +15 -14
  61. package/src/modules/git/services/__tests__/error-messages.test.ts +4 -4
  62. package/src/modules/git/services/error-messages.ts +7 -7
  63. package/src/modules/git/services/git.api.ts +17 -11
  64. package/src/modules/git/services/pr-prompts.ts +2 -2
  65. package/src/modules/git/state/git.context.ts +10 -1
  66. package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +224 -0
  67. package/src/modules/layout/__tests__/SidebarToggle.test.tsx +242 -0
  68. package/src/modules/layout/__tests__/breakpoints.test.ts +56 -0
  69. package/src/modules/layout/breakpoints.ts +6 -0
  70. package/src/modules/layout/components/AppLayout.tsx +17 -5
  71. package/src/modules/layout/components/DemoBanner.tsx +10 -1
  72. package/src/modules/layout/components/MaintenanceOverlay.tsx +3 -3
  73. package/src/modules/layout/components/MobileChatLayout.tsx +31 -26
  74. package/src/modules/layout/components/ResizableThreePaneLayout.tsx +59 -24
  75. package/src/modules/layout/components/SidebarFrame.tsx +317 -0
  76. package/src/modules/layout/components/SidebarToggle.tsx +86 -0
  77. package/src/modules/layout/components/SlideOverlay.tsx +1 -1
  78. package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +40 -2
  79. package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +19 -3
  80. package/src/modules/layout/state/sidebar.ts +200 -0
  81. package/src/modules/library/__tests__/AddToGroupDialog.test.tsx +313 -0
  82. package/src/modules/library/__tests__/ChangeRequestDock.test.tsx +84 -0
  83. package/src/modules/library/__tests__/GroupJoinRequests.test.tsx +178 -0
  84. package/src/modules/library/__tests__/GroupPage.test.tsx +479 -0
  85. package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +283 -0
  86. package/src/modules/library/__tests__/GroupsSidebar.contextmenu.test.tsx +175 -0
  87. package/src/modules/library/__tests__/GroupsSidebar.locked.test.tsx +96 -0
  88. package/src/modules/library/__tests__/GroupsSidebar.test.tsx +142 -0
  89. package/src/modules/library/__tests__/GroupsSidebarMenu.test.tsx +142 -0
  90. package/src/modules/library/__tests__/LibraryCard.test.tsx +149 -0
  91. package/src/modules/library/__tests__/LibraryRoutes.test.tsx +378 -0
  92. package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +347 -0
  93. package/src/modules/library/__tests__/LockedGroupView.test.tsx +203 -0
  94. package/src/modules/library/__tests__/NewGroupDialog.test.tsx +114 -0
  95. package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +177 -0
  96. package/src/modules/library/__tests__/SkillPage.test.tsx +1063 -0
  97. package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +259 -0
  98. package/src/modules/library/__tests__/ToolLogo.test.tsx +63 -0
  99. package/src/modules/library/__tests__/ToolPage.test.tsx +315 -0
  100. package/src/modules/library/__tests__/ToolSharePanel.test.tsx +36 -0
  101. package/src/modules/library/__tests__/ToolVarRow.test.tsx +260 -0
  102. package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +197 -0
  103. package/src/modules/library/__tests__/auth-harness.tsx +37 -0
  104. package/src/modules/library/__tests__/oauth-fragment.test.ts +48 -0
  105. package/src/modules/library/__tests__/status.test.ts +113 -20
  106. package/src/modules/library/__tests__/useSkillDetail.test.tsx +102 -0
  107. package/src/modules/library/__tests__/useToolPage.test.tsx +146 -0
  108. package/src/modules/library/components/AccessRequestsBanner.tsx +101 -0
  109. package/src/modules/library/components/AddToGroupDialog.tsx +115 -0
  110. package/src/modules/library/components/ChangeRequestDock.tsx +52 -28
  111. package/src/modules/library/components/DeleteGroupDialog.tsx +87 -0
  112. package/src/modules/library/components/GroupIndexRow.tsx +63 -0
  113. package/src/modules/library/components/GroupJoinRequests.tsx +56 -0
  114. package/src/modules/library/components/GroupPage.tsx +373 -0
  115. package/src/modules/library/components/GroupsIndexPage.tsx +222 -0
  116. package/src/modules/library/components/GroupsSidebar.tsx +338 -0
  117. package/src/modules/library/components/GroupsSidebarMenu.tsx +160 -0
  118. package/src/modules/library/components/LibraryCard.tsx +123 -102
  119. package/src/modules/library/components/LibraryLayout.tsx +344 -0
  120. package/src/modules/library/components/LibraryPage.tsx +111 -227
  121. package/src/modules/library/components/LockGlyph.tsx +31 -0
  122. package/src/modules/library/components/LockedGroupView.tsx +159 -0
  123. package/src/modules/library/components/ManagedGroupRequests.tsx +70 -0
  124. package/src/modules/library/components/NewGroupDialog.tsx +112 -0
  125. package/src/modules/library/components/NewSkillPanel.tsx +151 -0
  126. package/src/modules/library/components/PageActions.tsx +156 -0
  127. package/src/modules/library/components/PendingSkillReview.tsx +63 -0
  128. package/src/modules/library/components/PersonalAddDialog.tsx +88 -0
  129. package/src/modules/library/components/PersonalGroupPage.tsx +125 -0
  130. package/src/modules/library/components/StatusDot.tsx +25 -0
  131. package/src/modules/library/components/ToolLogo.tsx +171 -0
  132. package/src/modules/library/components/group-page-parts.tsx +419 -0
  133. package/src/modules/library/components/skill-page/SkillFileEditor.tsx +134 -0
  134. package/src/modules/library/components/skill-page/SkillFilePane.tsx +117 -0
  135. package/src/modules/library/components/skill-page/SkillFileTabs.tsx +112 -0
  136. package/src/modules/library/components/skill-page/SkillPage.tsx +673 -0
  137. package/src/modules/library/components/skill-page/tab-ids.ts +33 -0
  138. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +175 -0
  139. package/src/modules/library/components/tool-page/ToolPage.tsx +228 -0
  140. package/src/modules/library/components/tool-page/ToolSharePanel.tsx +45 -0
  141. package/src/modules/library/components/tool-page/ToolVarRow.tsx +289 -0
  142. package/src/modules/library/hooks/useJoinRequests.ts +114 -0
  143. package/src/modules/library/hooks/useLibraryData.ts +134 -119
  144. package/src/modules/library/hooks/useSkillDetail.ts +119 -74
  145. package/src/modules/library/hooks/useToolPage.ts +145 -0
  146. package/src/modules/library/library.css +33 -245
  147. package/src/modules/library/routes/LibraryRoutes.tsx +134 -0
  148. package/src/modules/library/routes/WorkspaceItemRoute.tsx +74 -0
  149. package/src/modules/library/routes/library-paths.ts +191 -0
  150. package/src/modules/library/services/groups.api.ts +189 -0
  151. package/src/modules/library/services/library.api.ts +291 -164
  152. package/src/modules/library/services/tools.api.ts +60 -0
  153. package/src/modules/library/state/library-context.ts +22 -0
  154. package/src/modules/library/state/library-data.tsx +223 -0
  155. package/src/modules/library/state/toast.context.ts +32 -0
  156. package/src/modules/library/state/toast.tsx +84 -42
  157. package/src/modules/library/utils/clipboard.ts +33 -0
  158. package/src/modules/library/utils/group-summary.ts +68 -0
  159. package/src/modules/library/utils/names.ts +30 -0
  160. package/src/modules/library/utils/navigate-external.ts +15 -0
  161. package/src/modules/library/utils/oauth-fragment.ts +32 -0
  162. package/src/modules/library/utils/personal-group.ts +36 -0
  163. package/src/modules/library/utils/status.ts +108 -25
  164. package/src/modules/library/utils/toast-duration.ts +16 -0
  165. package/src/modules/onboarding/__tests__/onboarding.test.tsx +533 -0
  166. package/src/modules/onboarding/agent-clients.ts +48 -0
  167. package/src/modules/onboarding/components/ConnectAgentPill.tsx +133 -0
  168. package/src/modules/onboarding/components/RootLanding.tsx +54 -0
  169. package/src/modules/onboarding/components/WelcomePage.tsx +364 -0
  170. package/src/modules/onboarding/paths.ts +9 -0
  171. package/src/modules/onboarding/state/onboarding.ts +191 -0
  172. package/src/modules/pr/components/OpenChangeRequestDialog.tsx +10 -10
  173. package/src/modules/pr/services/pr-approvals.api.ts +19 -0
  174. package/src/modules/pr/services/pr-cancel.api.ts +11 -0
  175. package/src/modules/review/components/BinaryChangePlaceholder.tsx +3 -3
  176. package/src/modules/review/components/DiffViewer.tsx +4 -4
  177. package/src/modules/review/components/MarkdownDiffViewer.tsx +84 -26
  178. package/src/modules/review/components/ReviewFileRow.tsx +10 -10
  179. package/src/modules/review/components/ReviewPanel.tsx +49 -17
  180. package/src/modules/review/components/ReviewPanelSurface.tsx +1 -1
  181. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +122 -0
  182. package/src/modules/review/hooks/__tests__/useReviewState.test.ts +1 -1
  183. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +273 -171
  184. package/src/modules/secrets-vault/components/SecretsPage.tsx +147 -110
  185. package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
  186. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +35 -4
  187. package/src/modules/secrets-vault/services/connect.api.ts +24 -3
  188. package/src/modules/settings/components/DeploymentPage.tsx +90 -0
  189. package/src/modules/settings/components/SettingsLayout.tsx +135 -0
  190. package/src/modules/settings/components/SettingsNav.tsx +114 -0
  191. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +110 -0
  192. package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +249 -0
  193. package/src/modules/settings/settings-nav-items.tsx +166 -0
  194. package/src/modules/setup/__tests__/setup.test.tsx +540 -0
  195. package/src/modules/setup/components/SetupGate.tsx +67 -0
  196. package/src/modules/setup/components/SetupScreen.tsx +573 -0
  197. package/src/modules/setup/services/setup.api.ts +106 -0
  198. package/src/modules/setup/utils/git-host.ts +34 -0
  199. package/src/modules/toolbar/components/AppSwitcher.tsx +38 -15
  200. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +50 -50
  201. package/src/modules/toolbar/components/ProfileMenu.tsx +294 -0
  202. package/src/modules/toolbar/components/Toolbar.tsx +56 -54
  203. package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +176 -122
  204. package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +252 -77
  205. package/src/modules/tools/ToolsExplorerPage.tsx +45 -40
  206. package/src/modules/workspace/__tests__/design-system-parity.test.ts +133 -0
  207. package/src/modules/workspace/__tests__/testFixtures.ts +2 -0
  208. package/src/modules/workspace/components/EditorTabs.tsx +82 -50
  209. package/src/modules/workspace/components/FileExplorer.tsx +413 -189
  210. package/src/modules/workspace/components/FilePaneCard.tsx +53 -0
  211. package/src/modules/workspace/components/FileRoute.tsx +89 -84
  212. package/src/modules/workspace/components/FileViewer.tsx +700 -294
  213. package/src/modules/workspace/components/KbDocumentShell.tsx +138 -0
  214. package/src/modules/workspace/components/KbFileRail.tsx +128 -0
  215. package/src/modules/workspace/components/KbPageHeader.tsx +390 -0
  216. package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +87 -3
  217. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +293 -39
  218. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +1 -16
  219. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +462 -44
  220. package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +84 -0
  221. package/src/modules/workspace/components/__tests__/KbFileRail.test.tsx +83 -0
  222. package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +192 -0
  223. package/src/modules/workspace/components/renderers/CopyAnchorButton.tsx +64 -0
  224. package/src/modules/workspace/components/renderers/CsvRenderer.tsx +8 -8
  225. package/src/modules/workspace/components/renderers/DocxRenderer.tsx +18 -9
  226. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +14 -14
  227. package/src/modules/workspace/components/renderers/ImageRenderer.tsx +2 -2
  228. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +31 -165
  229. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +18 -5
  230. package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +27 -10
  231. package/src/modules/workspace/components/renderers/PdfRenderer.tsx +2 -2
  232. package/src/modules/workspace/components/renderers/TextRenderer.tsx +11 -5
  233. package/src/modules/workspace/components/renderers/ToolForm.tsx +24 -24
  234. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +27 -27
  235. package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -11
  236. package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +66 -0
  237. package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +17 -1
  238. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +1 -1
  239. package/src/modules/workspace/components/renderers/__tests__/MermaidDiagram.test.tsx +58 -0
  240. package/src/modules/workspace/components/renderers/__tests__/lazyRenderer.test.tsx +68 -0
  241. package/src/modules/workspace/components/renderers/__tests__/rendererLayout.test.ts +64 -0
  242. package/src/modules/workspace/components/renderers/__tests__/sanitizeDocxHtml.test.ts +0 -0
  243. package/src/modules/workspace/components/renderers/chunk-boundary.tsx +71 -0
  244. package/src/modules/workspace/components/renderers/index.ts +78 -2
  245. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +241 -0
  246. package/src/modules/workspace/components/renderers/lazyRenderer.tsx +59 -0
  247. package/src/modules/workspace/components/renderers/sanitizeDocxHtml.ts +91 -0
  248. package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +59 -0
  249. package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +237 -0
  250. package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +185 -0
  251. package/src/modules/workspace/hooks/useAutoGrowTextarea.ts +30 -0
  252. package/src/modules/workspace/hooks/useLastCommit.ts +66 -0
  253. package/src/modules/workspace/hooks/useLinksOut.ts +56 -0
  254. package/src/modules/workspace/hooks/useOpenChangeRequests.ts +20 -0
  255. package/src/modules/workspace/hooks/useWorkspaceState.ts +123 -14
  256. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +1 -1
  257. package/src/modules/workspace/services/workspace.api.ts +9 -2
  258. package/src/modules/workspace/state/open-change-requests.context.ts +35 -0
  259. package/src/modules/workspace/state/open-change-requests.tsx +185 -0
  260. package/src/modules/workspace/state/workspace.context.ts +9 -0
  261. package/src/modules/workspace/utils/__tests__/diff.test.ts +87 -0
  262. package/src/modules/workspace/utils/diff.ts +130 -53
  263. package/src/modules/workspace/utils/fileTree.ts +7 -4
  264. package/src/modules/workspace/workspace.css +28 -0
  265. package/src/shared/components/Badge.tsx +62 -0
  266. package/src/shared/components/Banner.tsx +58 -0
  267. package/src/shared/components/Button.tsx +90 -0
  268. package/src/shared/components/Dialog.tsx +6 -6
  269. package/src/shared/components/Field.tsx +45 -0
  270. package/src/shared/components/IconButton.tsx +74 -0
  271. package/src/shared/components/ListRow.tsx +96 -0
  272. package/src/shared/components/Menu.tsx +88 -0
  273. package/src/shared/components/PageShell.tsx +8 -5
  274. package/src/shared/components/Surface.tsx +86 -0
  275. package/src/shared/components/__tests__/primitives.test.tsx +333 -0
  276. package/src/shared/components/index.ts +48 -0
  277. package/src/shared/components/useDismissableMenu.ts +71 -0
  278. package/src/shared/theme/__tests__/accent-contrast.test.ts +84 -0
  279. package/src/shared/theme/index.css +12 -0
  280. package/src/shared/theme/measure.ts +64 -0
  281. package/src/shared/theme/shadows.css +34 -0
  282. package/src/shared/theme/tokens.css +193 -0
  283. package/src/test-setup.ts +9 -0
  284. package/src/modules/access/components/AccessRestrictedBanner.tsx +0 -31
  285. package/src/modules/access/components/NodeOwnersBanner.tsx +0 -30
  286. package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +0 -82
  287. package/src/modules/git/components/ProtectedBranchBanner.tsx +0 -42
  288. package/src/modules/library/__tests__/DetailDialog.test.tsx +0 -200
  289. package/src/modules/library/__tests__/diff.test.ts +0 -62
  290. package/src/modules/library/__tests__/loadout.test.tsx +0 -72
  291. package/src/modules/library/components/CompareView.tsx +0 -357
  292. package/src/modules/library/components/DetailDialog.tsx +0 -566
  293. package/src/modules/library/components/GearIcon.tsx +0 -12
  294. package/src/modules/library/components/LoadoutSidebar.tsx +0 -156
  295. package/src/modules/library/components/StatusGem.tsx +0 -21
  296. package/src/modules/library/components/SuggestChange.tsx +0 -171
  297. package/src/modules/library/components/particles.ts +0 -50
  298. package/src/modules/library/state/loadout.tsx +0 -129
  299. package/src/modules/library/utils/diff.ts +0 -102
  300. package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +0 -93
  301. package/src/modules/pr/__tests__/PrCancelButton.test.tsx +0 -158
  302. package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +0 -44
  303. package/src/modules/pr/__tests__/PrMergeButton.test.tsx +0 -360
  304. package/src/modules/pr/__tests__/bucketize-comments.test.ts +0 -85
  305. package/src/modules/pr/__tests__/parsePatch.test.ts +0 -104
  306. package/src/modules/pr/__tests__/usePrViewerState.test.ts +0 -72
  307. package/src/modules/pr/components/PrApprovalBadge.tsx +0 -80
  308. package/src/modules/pr/components/PrCancelButton.tsx +0 -99
  309. package/src/modules/pr/components/PrCancelConfirmDialog.tsx +0 -119
  310. package/src/modules/pr/components/PrCommentComposer.tsx +0 -92
  311. package/src/modules/pr/components/PrCommentThread.tsx +0 -168
  312. package/src/modules/pr/components/PrCommentsPanel.tsx +0 -143
  313. package/src/modules/pr/components/PrDiffPane.tsx +0 -425
  314. package/src/modules/pr/components/PrFileRow.tsx +0 -164
  315. package/src/modules/pr/components/PrFilesList.tsx +0 -53
  316. package/src/modules/pr/components/PrHeader.tsx +0 -45
  317. package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +0 -58
  318. package/src/modules/pr/components/PrMergeButton.tsx +0 -268
  319. package/src/modules/pr/components/PrMergeConfirmDialog.tsx +0 -112
  320. package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +0 -110
  321. package/src/modules/pr/components/PrViewer.tsx +0 -364
  322. package/src/modules/pr/hooks/usePrViewerState.ts +0 -150
  323. package/src/modules/pr/state/pr-viewer.context.ts +0 -34
  324. package/src/modules/pr/utils/bucketize-comments.ts +0 -55
  325. package/src/modules/pr/utils/parsePatch.ts +0 -57
  326. package/src/modules/toolbar/components/AdminMenu.tsx +0 -271
@@ -0,0 +1,283 @@
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
4
+ import type { LibraryData } from '../hooks/useLibraryData';
5
+ import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
6
+ import type { GroupSummary } from '../services/groups.api';
7
+
8
+ /**
9
+ * The all-groups index: which section a group lands in, what each row says, and
10
+ * where it goes. The locked section is the reason this page exists, so most of
11
+ * what is asserted here is about groups the caller cannot enter.
12
+ */
13
+
14
+ const dataMock = vi.hoisted(() => ({ useLibraryData: vi.fn() }));
15
+ vi.mock('../hooks/useLibraryData', () => ({ useLibraryData: dataMock.useLibraryData }));
16
+
17
+ const groupsMock = vi.hoisted(() => ({ listGroups: vi.fn(), listJoinRequests: vi.fn() }));
18
+ vi.mock('../services/groups.api', () => ({
19
+ listGroups: groupsMock.listGroups,
20
+ // The page carries the managers' join-request banners now — it is where the
21
+ // Library lands, so it is where an unanswered request is certain to be seen.
22
+ listJoinRequests: groupsMock.listJoinRequests,
23
+ reconcileJoinRequest: vi.fn(),
24
+ }));
25
+
26
+ import { LibraryProvider } from '../state/library-data';
27
+ import {
28
+ WorkspaceContext,
29
+ type WorkspaceContextValue,
30
+ } from '../../workspace/state/workspace.context';
31
+ import { GroupsIndexPage } from '../components/GroupsIndexPage';
32
+ import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
33
+
34
+ const tool = (over: Partial<ToolSecrets> = {}): ToolSecrets => ({
35
+ slug: 'heyreach',
36
+ name: 'heyreach',
37
+ path: 'Groups/GTM/heyreach.tool',
38
+ type: 'inline',
39
+ setup: null,
40
+ canWrite: false,
41
+ variables: [],
42
+ ...over,
43
+ });
44
+
45
+ const CATALOG: LibraryData = {
46
+ loading: false,
47
+ error: null,
48
+ skills: [
49
+ { name: 'outreach', description: '', path: 'Groups/GTM/outreach' },
50
+ { name: 'scratch', description: '', path: 'Skills/scratch' },
51
+ ],
52
+ pendingSkills: [],
53
+ tools: [
54
+ tool(),
55
+ // An ungrouped sign-in — `Tools/slack.tool` is two segments, so no group.
56
+ tool({
57
+ slug: 'slack',
58
+ name: 'slack',
59
+ path: 'Tools/slack.tool',
60
+ variables: [
61
+ {
62
+ name: 'API_KEY',
63
+ scope: 'user',
64
+ label: null,
65
+ key: 'slack_API_KEY',
66
+ adminConfigured: false,
67
+ userConfigured: false,
68
+ },
69
+ ],
70
+ }),
71
+ ],
72
+ ownedSkills: new Set(['outreach']),
73
+ allowedToolsBySkill: new Map(),
74
+ crs: [],
75
+ myCrNumbers: new Set<number>(),
76
+ reload: vi.fn(),
77
+ };
78
+
79
+ const summary = (over: Partial<GroupSummary> = {}): GroupSummary => ({
80
+ name: 'GTM',
81
+ folders: ['Groups/GTM'],
82
+ canRead: true,
83
+ canWrite: false,
84
+ isOwner: false,
85
+ skillCount: 4,
86
+ toolCount: 2,
87
+ owners: { roles: [], users: [{ name: 'Olga Ivanova', email: 'olga@bevel.software' }] },
88
+ writers: { roles: ['Admin'], users: [] },
89
+ readers: { restricted: true, roles: ['GTM Team'], users: [] },
90
+ hasRequested: false,
91
+ requestNumber: null,
92
+ ...over,
93
+ });
94
+
95
+ function LocationProbe() {
96
+ const location = useLocation();
97
+ return <div aria-label="href">{location.pathname + location.search}</div>;
98
+ }
99
+
100
+ /** `kbDirName` is what the request banners' Manage-access affordance needs. */
101
+ const WORKSPACE = {
102
+ workspaceId: 'target-company-state',
103
+ kbDirName: 'knowledge-base',
104
+ } as unknown as WorkspaceContextValue;
105
+
106
+ function renderIndex() {
107
+ return render(
108
+ <MemoryRouter initialEntries={['/skills-and-tools']}>
109
+ {withAuth(
110
+ <WorkspaceContext.Provider value={WORKSPACE}>
111
+ <LibraryProvider>
112
+ <Routes>
113
+ <Route path="/skills-and-tools" element={<GroupsIndexPage />} />
114
+ <Route path="*" element={<div />} />
115
+ </Routes>
116
+ <LocationProbe />
117
+ </LibraryProvider>
118
+ </WorkspaceContext.Provider>,
119
+ )}
120
+ </MemoryRouter>,
121
+ );
122
+ }
123
+
124
+ const href = () => screen.getByLabelText('href').textContent;
125
+ const row = (name: RegExp | string) => screen.getByRole('button', { name });
126
+
127
+ describe('GroupsIndexPage', () => {
128
+ beforeEach(() => {
129
+ dataMock.useLibraryData.mockReturnValue(CATALOG);
130
+ groupsMock.listGroups.mockResolvedValue([summary()]);
131
+ groupsMock.listJoinRequests.mockResolvedValue([]);
132
+ });
133
+
134
+ it('names itself and its two sections', async () => {
135
+ renderIndex();
136
+ expect(await screen.findByRole('heading', { name: 'All groups', level: 1 })).toBeInTheDocument();
137
+ expect(
138
+ screen.getByText('A group carries skills and tools for the people in it.'),
139
+ ).toBeInTheDocument();
140
+ expect(screen.getByRole('heading', { name: 'Yours' })).toBeInTheDocument();
141
+ expect(await screen.findByRole('heading', { name: "Groups you're in" })).toBeInTheDocument();
142
+ });
143
+
144
+ it("offers the caller's own group under Yours, and opens it", async () => {
145
+ renderIndex();
146
+ expect(
147
+ await screen.findByText('Your sign-ins and the skills no group carries'),
148
+ ).toBeInTheDocument();
149
+ // The lens is gone from this page — it lives in the sidebar.
150
+ expect(screen.queryByText('The skills you answer for')).not.toBeInTheDocument();
151
+ fireEvent.click(row(new RegExp(`^${TEST_PERSONAL_GROUP}`)));
152
+ await waitFor(() => expect(href()).toBe('/skills-and-tools/yours'));
153
+ });
154
+
155
+ it("keeps the caller's own group listed even when nothing sits outside a group", async () => {
156
+ dataMock.useLibraryData.mockReturnValue({
157
+ ...CATALOG,
158
+ skills: [{ name: 'outreach', description: '', path: 'Groups/GTM/outreach' }],
159
+ tools: [tool()],
160
+ });
161
+ renderIndex();
162
+ await screen.findByRole('heading', { name: 'All groups', level: 1 });
163
+ expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
164
+ // And never the lens: "Owned by me" is a view across groups, not a group.
165
+ expect(screen.queryByRole('button', { name: /^Owned by me/ })).not.toBeInTheDocument();
166
+ });
167
+
168
+ it("puts a readable group under Groups you're in, with its run-by line and totals", async () => {
169
+ renderIndex();
170
+ const gtm = await screen.findByRole('button', { name: /^GTM/ });
171
+ expect(gtm).toHaveAccessibleName('GTM Run by Olga Ivanova 4 skills · 2 tools');
172
+ fireEvent.click(gtm);
173
+ await waitFor(() => expect(href()).toBe('/skills-and-tools/groups/GTM'));
174
+ });
175
+
176
+ it('marks a group the caller can change with an Owner badge', async () => {
177
+ groupsMock.listGroups.mockResolvedValue([summary({ canWrite: true })]);
178
+ renderIndex();
179
+ expect(await screen.findByRole('button', { name: /^GTM Owner/ })).toBeInTheDocument();
180
+ });
181
+
182
+ it('shows the amber count when a group has integrations to set up', async () => {
183
+ groupsMock.listGroups.mockResolvedValue([
184
+ summary({
185
+ name: 'Yours',
186
+ folders: ['Groups/Yours'],
187
+ }),
188
+ summary(),
189
+ ]);
190
+ dataMock.useLibraryData.mockReturnValue({
191
+ ...CATALOG,
192
+ tools: [
193
+ tool({
194
+ variables: [
195
+ {
196
+ name: 'API_KEY',
197
+ scope: 'user',
198
+ label: null,
199
+ key: 'heyreach_API_KEY',
200
+ adminConfigured: false,
201
+ userConfigured: false,
202
+ },
203
+ ],
204
+ }),
205
+ ],
206
+ });
207
+ renderIndex();
208
+ expect(await screen.findByRole('button', { name: /^GTM .* 1$/ })).toBeInTheDocument();
209
+ });
210
+
211
+ it('lists a DISCOVERABLE locked group under Ask to join, Locked or Requested', async () => {
212
+ groupsMock.listGroups.mockResolvedValue([
213
+ summary(),
214
+ summary({ name: 'Finance', folders: ['Groups/Finance'], canRead: false, canWrite: false }),
215
+ ]);
216
+ renderIndex();
217
+ expect(await screen.findByRole('heading', { name: 'Ask to join' })).toBeInTheDocument();
218
+ expect(screen.getByRole('button', { name: /^Finance/ })).toBeInTheDocument();
219
+ expect(screen.getByTitle('Locked')).toBeInTheDocument();
220
+
221
+ // Once the caller's join request is open, the chip says THAT instead —
222
+ // the one thing the row can tell you that you did not already know.
223
+ groupsMock.listGroups.mockResolvedValue([
224
+ summary({
225
+ name: 'Finance',
226
+ folders: ['Groups/Finance'],
227
+ canRead: false,
228
+ canWrite: false,
229
+ hasRequested: true,
230
+ requestNumber: 9,
231
+ }),
232
+ ]);
233
+ renderIndex();
234
+ expect(await screen.findByTitle('Requested')).toBeInTheDocument();
235
+ });
236
+
237
+ it('never lists a group the endpoint omitted (fail-closed: absent = invisible)', async () => {
238
+ // The backend only returns accessible groups, and this page adds nothing
239
+ // on top: a group the caller cannot access has no row, no name, no counts.
240
+ groupsMock.listGroups.mockResolvedValue([summary()]);
241
+ renderIndex();
242
+ await screen.findByRole('button', { name: /^GTM/ });
243
+ expect(screen.queryByRole('button', { name: /^Finance/ })).not.toBeInTheDocument();
244
+ expect(screen.queryByRole('heading', { name: 'Ask to join' })).not.toBeInTheDocument();
245
+ });
246
+
247
+ it('lists a group an item grant reaches inside, even without a summary', async () => {
248
+ dataMock.useLibraryData.mockReturnValue({
249
+ ...CATALOG,
250
+ skills: [{ name: 'budget', description: '', path: 'Groups/Finance/budget' }],
251
+ });
252
+ renderIndex();
253
+ expect(await screen.findByRole('button', { name: /^Finance/ })).toBeInTheDocument();
254
+ });
255
+
256
+ it('lists a catalog-derived group with counts alone when no summary vouches for it', async () => {
257
+ groupsMock.listGroups.mockResolvedValue([]);
258
+ renderIndex();
259
+ // One skill and one tool in Groups/GTM, and nothing claiming to know who
260
+ // runs it — so the row states what it can count, not what it cannot.
261
+ expect(await screen.findByRole('button', { name: 'GTM 1 skills · 1 tools' })).toBeInTheDocument();
262
+ });
263
+
264
+ it('offers a retry when the groups endpoint fails, and keeps Yours', async () => {
265
+ groupsMock.listGroups.mockRejectedValue(new Error("Couldn't load groups."));
266
+ renderIndex();
267
+ const banner = await screen.findByRole('alert');
268
+ expect(banner).toHaveTextContent("Couldn't load groups.");
269
+ expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
270
+ expect(screen.queryByRole('heading', { name: "Groups you're in" })).not.toBeInTheDocument();
271
+
272
+ groupsMock.listGroups.mockResolvedValue([summary()]);
273
+ fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
274
+ expect(await screen.findByRole('button', { name: /^GTM/ })).toBeInTheDocument();
275
+ });
276
+
277
+ it('says it is loading before the first group index arrives', () => {
278
+ groupsMock.listGroups.mockReturnValue(new Promise(() => {}));
279
+ renderIndex();
280
+ expect(screen.getByText('Loading groups…')).toBeInTheDocument();
281
+ expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
282
+ });
283
+ });
@@ -0,0 +1,175 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { render, screen, fireEvent, createEvent } from '@testing-library/react';
3
+ import { GroupsSidebar, type GroupsSidebarProps } from '../components/GroupsSidebar';
4
+
5
+ /**
6
+ * Right-click in the Library nav, which has to answer the gesture the way
7
+ * Knowledge's file tree does — the same one the platform has had since the tree
8
+ * shipped (`FileExplorer.tsx:532`).
9
+ *
10
+ * The sidebar itself only REPORTS the click: it suppresses the browser menu,
11
+ * reads the pointer and the row synchronously, and hands both up. Everything
12
+ * about which verbs are true for a given row lives in `LibraryLayout`, because
13
+ * that is where the group summaries are — so that is where those assertions
14
+ * live too.
15
+ */
16
+
17
+ function renderSidebar(over: Partial<GroupsSidebarProps> = {}) {
18
+ const onContextMenu = vi.fn();
19
+ const onSelect = vi.fn();
20
+ const props: GroupsSidebarProps = {
21
+ filter: { kind: 'all' },
22
+ onSelect,
23
+ groups: [
24
+ { group: 'Engineering', count: 4, attention: 0 },
25
+ { group: 'GTM', count: 3, attention: 2 },
26
+ ],
27
+ lockedGroups: ['Finance'],
28
+ ownedCount: 2,
29
+ ownedAttention: 0,
30
+ personalGroupLabel: "Juan's Group",
31
+ ungroupedCount: 1,
32
+ attentionCount: 2,
33
+ onFinishSetup: vi.fn(),
34
+ onCreateGroup: vi.fn(),
35
+ groupsIndexActive: false,
36
+ onOpenGroupsIndex: vi.fn(),
37
+ onContextMenu,
38
+ ...over,
39
+ };
40
+ render(<GroupsSidebar {...props} />);
41
+ return { onContextMenu, onSelect };
42
+ }
43
+
44
+ const nav = () => screen.getByRole('navigation', { name: 'Library groups' });
45
+ const rightClick = (el: Element, at = { clientX: 120, clientY: 240 }) =>
46
+ fireEvent.contextMenu(el, at);
47
+
48
+ describe('GroupsSidebar: right-click', () => {
49
+ it('reports a group row with its filter, its name and the pointer', () => {
50
+ const { onContextMenu } = renderSidebar();
51
+ const gtm = screen.getByRole('button', { name: /^GTM/ });
52
+ rightClick(gtm, { clientX: 88, clientY: 310 });
53
+
54
+ expect(onContextMenu).toHaveBeenCalledTimes(1);
55
+ expect(onContextMenu).toHaveBeenCalledWith({
56
+ filter: { kind: 'group', group: 'GTM' },
57
+ label: 'GTM',
58
+ x: 88,
59
+ y: 310,
60
+ // The row itself, so Escape can hand focus back to it.
61
+ row: gtm,
62
+ });
63
+ });
64
+
65
+ it('reports a lens row by the filter it navigates to, not by its label', () => {
66
+ const { onContextMenu } = renderSidebar();
67
+ rightClick(screen.getByRole('button', { name: /^Owned by me/ }));
68
+ expect(onContextMenu.mock.calls[0][0]).toMatchObject({
69
+ filter: { kind: 'owned' },
70
+ label: 'Owned by me',
71
+ });
72
+
73
+ rightClick(screen.getByRole('button', { name: /^Juan's Group/ }));
74
+ expect(onContextMenu.mock.calls[1][0]).toMatchObject({
75
+ filter: { kind: 'ungrouped' },
76
+ label: "Juan's Group",
77
+ });
78
+ });
79
+
80
+ /**
81
+ * A locked row emits the same `{ kind: 'group' }` target a readable one does,
82
+ * for the same reason its CLICK does: a group you are not in is still a place.
83
+ * The label drops the "(locked)" suffix — that is the accessible name, not the
84
+ * group's name, and the menu titles itself with the latter.
85
+ */
86
+ it('reports a locked row exactly like a readable group', () => {
87
+ const { onContextMenu } = renderSidebar();
88
+ rightClick(screen.getByRole('button', { name: 'Finance (locked)' }));
89
+ expect(onContextMenu.mock.calls[0][0]).toMatchObject({
90
+ filter: { kind: 'group', group: 'Finance' },
91
+ label: 'Finance',
92
+ });
93
+ });
94
+
95
+ /**
96
+ * The home row has no `LibraryFilter` behind it — the index lists places, not
97
+ * a slice of the catalog — so it reports `null` and gets the nav's own menu:
98
+ * create a group, and none of the verbs that need a folder to point at.
99
+ */
100
+ it('reports the All groups row with no filter, but with its own row and name', () => {
101
+ const { onContextMenu } = renderSidebar();
102
+ const home = screen.getByRole('button', { name: 'All groups' });
103
+ rightClick(home);
104
+ expect(onContextMenu).toHaveBeenCalledTimes(1);
105
+ expect(onContextMenu.mock.calls[0][0]).toMatchObject({
106
+ filter: null,
107
+ label: 'All groups',
108
+ row: home,
109
+ });
110
+ });
111
+
112
+ it('reports the empty nav space as a target with no filter and no row', () => {
113
+ const { onContextMenu } = renderSidebar();
114
+ rightClick(nav());
115
+ expect(onContextMenu).toHaveBeenCalledWith({
116
+ filter: null,
117
+ label: 'Library',
118
+ x: 120,
119
+ y: 240,
120
+ row: null,
121
+ });
122
+ });
123
+
124
+ /**
125
+ * The nav wraps every row, so without `stopPropagation` a right-click on a
126
+ * group would report the group AND then the empty space — and the layout
127
+ * would render the empty-space menu, since the last call wins.
128
+ */
129
+ it('does not also report the nav when the click landed on a row', () => {
130
+ const { onContextMenu } = renderSidebar();
131
+ rightClick(screen.getByRole('button', { name: /^Engineering/ }));
132
+ expect(onContextMenu).toHaveBeenCalledTimes(1);
133
+ expect(onContextMenu.mock.calls[0][0].filter).toEqual({ kind: 'group', group: 'Engineering' });
134
+ });
135
+
136
+ it('suppresses the browser menu when the click is being handled', () => {
137
+ renderSidebar();
138
+ const gtm = screen.getByRole('button', { name: /^GTM/ });
139
+ const event = createEvent.contextMenu(gtm);
140
+ fireEvent(gtm, event);
141
+ expect(event.defaultPrevented).toBe(true);
142
+ });
143
+
144
+ /**
145
+ * With nobody listening there is nothing to open, and swallowing the gesture
146
+ * would leave the user with no menu at all — worse than the browser's.
147
+ */
148
+ it("leaves the browser's own menu alone when no handler is wired", () => {
149
+ renderSidebar({ onContextMenu: undefined });
150
+ const gtm = screen.getByRole('button', { name: /^GTM/ });
151
+ const event = createEvent.contextMenu(gtm);
152
+ fireEvent(gtm, event);
153
+ expect(event.defaultPrevented).toBe(false);
154
+ });
155
+
156
+ it('still navigates on a left click. The menu changes nothing about selection', () => {
157
+ const { onSelect, onContextMenu } = renderSidebar();
158
+ fireEvent.click(screen.getByRole('button', { name: /^GTM/ }));
159
+ expect(onSelect).toHaveBeenCalledWith({ kind: 'group', group: 'GTM' });
160
+ expect(onContextMenu).not.toHaveBeenCalled();
161
+ });
162
+
163
+ it('marks the current row from the target it navigates to', () => {
164
+ renderSidebar({ filter: { kind: 'group', group: 'GTM' } });
165
+ expect(screen.getByRole('button', { name: /^GTM/ })).toHaveAttribute('aria-current', 'true');
166
+ expect(screen.getByRole('button', { name: /^Engineering/ })).toHaveAttribute(
167
+ 'aria-current',
168
+ 'false',
169
+ );
170
+ expect(screen.getByRole('button', { name: /^Owned by me/ })).toHaveAttribute(
171
+ 'aria-current',
172
+ 'false',
173
+ );
174
+ });
175
+ });
@@ -0,0 +1,96 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { render, screen, fireEvent, within } from '@testing-library/react';
3
+ import { GroupsSidebar, type GroupsSidebarProps } from '../components/GroupsSidebar';
4
+
5
+ /**
6
+ * The locked half of the nav: groups the caller cannot read still appear, below
7
+ * a break, with a lock where a count would be.
8
+ *
9
+ * Locked selection is a URL like any other — a locked row emits the SAME
10
+ * `{ kind: 'group' }` intent as a readable one, and the group page decides which
11
+ * view the caller gets. That is deliberate: one route per group means a locked
12
+ * group can be linked to and bookmarked, and unlocking one changes nothing about
13
+ * where it lives.
14
+ */
15
+
16
+ function renderSidebar(over: Partial<GroupsSidebarProps> = {}) {
17
+ const onSelect = vi.fn();
18
+ const props: GroupsSidebarProps = {
19
+ filter: { kind: 'all' },
20
+ onSelect,
21
+ groups: [
22
+ { group: 'Engineering', count: 4, attention: 0 },
23
+ { group: 'GTM', count: 3, attention: 2 },
24
+ ],
25
+ lockedGroups: ['Finance', 'Legal'],
26
+ ownedCount: 2,
27
+ ownedAttention: 0,
28
+ personalGroupLabel: "Juan's Group",
29
+ ungroupedCount: 1,
30
+ attentionCount: 2,
31
+ onFinishSetup: vi.fn(),
32
+ onCreateGroup: vi.fn(),
33
+ groupsIndexActive: false,
34
+ onOpenGroupsIndex: vi.fn(),
35
+
36
+ ...over,
37
+ };
38
+ render(<GroupsSidebar {...props} />);
39
+ return { onSelect };
40
+ }
41
+
42
+ const nav = () => screen.getByRole('navigation', { name: 'Library groups' });
43
+
44
+ describe('GroupsSidebar: locked groups', () => {
45
+ it('names a locked row by its state, with no count in it', () => {
46
+ renderSidebar();
47
+ const finance = screen.getByRole('button', { name: 'Finance (locked)' });
48
+ expect(finance).toBeInTheDocument();
49
+ // A non-member cannot see inside to count anything, and never gets the
50
+ // amber attention badge — there is nothing they could fix.
51
+ expect(finance.textContent).toBe('Finance');
52
+ });
53
+
54
+ it('puts the locked rows last, after every group the caller is in', () => {
55
+ renderSidebar();
56
+ const labels = within(nav())
57
+ .getAllByRole('button')
58
+ .map((b) => b.getAttribute('aria-label') ?? b.textContent);
59
+ expect(labels).toEqual([
60
+ 'All groups',
61
+ 'Everything',
62
+ 'Owned by me2',
63
+ 'New group',
64
+ // Your own space leads the groups; the ones you cannot enter trail them.
65
+ "Juan's Group1",
66
+ 'Engineering4',
67
+ 'GTM2',
68
+ 'Finance (locked)',
69
+ 'Legal (locked)',
70
+ ]);
71
+ });
72
+
73
+ it('navigates to the group route on click, exactly like a readable group', () => {
74
+ const { onSelect } = renderSidebar();
75
+ fireEvent.click(screen.getByRole('button', { name: 'Finance (locked)' }));
76
+ expect(onSelect).toHaveBeenCalledWith({ kind: 'group', group: 'Finance' });
77
+ });
78
+
79
+ it('marks the locked row current when its group is the route', () => {
80
+ renderSidebar({ filter: { kind: 'group', group: 'Finance' } });
81
+ expect(screen.getByRole('button', { name: 'Finance (locked)' })).toHaveAttribute(
82
+ 'aria-current',
83
+ 'true',
84
+ );
85
+ expect(screen.getByRole('button', { name: 'Legal (locked)' })).toHaveAttribute(
86
+ 'aria-current',
87
+ 'false',
88
+ );
89
+ });
90
+
91
+ it('renders no locked section at all when nothing is locked', () => {
92
+ renderSidebar({ lockedGroups: [] });
93
+ expect(screen.queryByRole('button', { name: /\(locked\)$/ })).not.toBeInTheDocument();
94
+ expect(screen.getByRole('button', { name: /^GTM/ })).toBeInTheDocument();
95
+ });
96
+ });