@bevel-software/platform-core-frontend 0.15.1 → 0.20.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.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +20 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +13 -3
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +532 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +141 -4
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +172 -46
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FileTreeEntry } from '@bevel-software/platform-shared';
|
|
2
|
+
|
|
3
|
+
/** The file tree's own root row — the whole KB, not a folder inside it. */
|
|
4
|
+
const TREE_ROOT_PATH = '.';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether an entry offers `Manage access` at all — the explorer's right-click
|
|
8
|
+
* rule, stated once so every other surface that opens the dialog on a folder
|
|
9
|
+
* (the skill page's Share) follows the same condition instead of restating it.
|
|
10
|
+
*
|
|
11
|
+
* This is the AFFORDANCE, not the permission: the dialog resolves the caller's
|
|
12
|
+
* verdict itself and renders read-only for anyone who cannot write the rules,
|
|
13
|
+
* and the grant route enforces it again server-side.
|
|
14
|
+
*/
|
|
15
|
+
export function offersManageAccess(entry: Pick<FileTreeEntry, 'relativePath'>): boolean {
|
|
16
|
+
return entry.relativePath !== TREE_ROOT_PATH;
|
|
17
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { AddMemberInput, SUGGEST_DEBOUNCE_MS } from '../components/AddMemberInput';
|
|
6
|
+
import { suggestPrincipals, type SuggestResponse } from '../../access/api';
|
|
7
|
+
|
|
8
|
+
vi.mock('../../access/api', async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal<typeof import('../../access/api')>();
|
|
10
|
+
return { ...actual, suggestPrincipals: vi.fn() };
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* How long "no request" has to hold: the component's own debounce plus slack,
|
|
15
|
+
* derived from the component so raising the debounce cannot leave this test
|
|
16
|
+
* asserting over a window the request has not been scheduled in yet.
|
|
17
|
+
*/
|
|
18
|
+
const PAST_DEBOUNCE_MS = SUGGEST_DEBOUNCE_MS + 150;
|
|
19
|
+
|
|
20
|
+
const ALICE = { name: 'Alice Green', email: 'alice@example.com' };
|
|
21
|
+
const PAT = { name: 'Pat Kim', email: 'pat@example.com' };
|
|
22
|
+
|
|
23
|
+
function people(...list: { name: string; email: string }[]): SuggestResponse {
|
|
24
|
+
return { roles: [], groups: [], people: list, peopleWithheld: false };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The component is controlled — the caller owns the value, as both pages do. */
|
|
28
|
+
function Harness({
|
|
29
|
+
onSubmit = () => {},
|
|
30
|
+
exclude = [],
|
|
31
|
+
busy = false,
|
|
32
|
+
}: {
|
|
33
|
+
onSubmit?: (value: string) => void;
|
|
34
|
+
exclude?: string[];
|
|
35
|
+
busy?: boolean;
|
|
36
|
+
}) {
|
|
37
|
+
const [value, setValue] = useState('');
|
|
38
|
+
return (
|
|
39
|
+
<AddMemberInput
|
|
40
|
+
value={value}
|
|
41
|
+
onValueChange={setValue}
|
|
42
|
+
onSubmit={onSubmit}
|
|
43
|
+
exclude={exclude}
|
|
44
|
+
inputLabel="Member email"
|
|
45
|
+
busy={busy}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
vi.mocked(suggestPrincipals).mockReset().mockResolvedValue(people(ALICE));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('AddMemberInput', () => {
|
|
55
|
+
it('makes no suggest request below two characters, and one at two', async () => {
|
|
56
|
+
render(<Harness />);
|
|
57
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
58
|
+
|
|
59
|
+
await userEvent.type(input, 'a');
|
|
60
|
+
await new Promise((resolve) => setTimeout(resolve, PAST_DEBOUNCE_MS));
|
|
61
|
+
// The server withholds people under two characters anyway — asking is pure
|
|
62
|
+
// waste, and the guard is what keeps a one-letter keystroke off the wire.
|
|
63
|
+
expect(suggestPrincipals).not.toHaveBeenCalled();
|
|
64
|
+
|
|
65
|
+
await userEvent.type(input, 'l');
|
|
66
|
+
await waitFor(() => expect(suggestPrincipals).toHaveBeenCalledTimes(1));
|
|
67
|
+
expect(suggestPrincipals).toHaveBeenCalledWith('target-company-state', 'al');
|
|
68
|
+
expect(await screen.findByText('Alice Green')).toBeInTheDocument();
|
|
69
|
+
expect(screen.getByText('alice@example.com')).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('never offers someone the caller already counts as a member', async () => {
|
|
73
|
+
vi.mocked(suggestPrincipals).mockResolvedValue(people(PAT, ALICE));
|
|
74
|
+
// Mixed case on purpose: membership is case-insensitive.
|
|
75
|
+
render(<Harness exclude={['PAT@example.com']} />);
|
|
76
|
+
|
|
77
|
+
await userEvent.type(screen.getByRole('combobox', { name: 'Member email' }), 'ex');
|
|
78
|
+
expect(await screen.findByText('Alice Green')).toBeInTheDocument();
|
|
79
|
+
expect(screen.queryByText('Pat Kim')).not.toBeInTheDocument();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('choosing a suggestion submits exactly the email typing it would have', async () => {
|
|
83
|
+
const onSubmit = vi.fn();
|
|
84
|
+
render(<Harness onSubmit={onSubmit} />);
|
|
85
|
+
|
|
86
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
87
|
+
await userEvent.type(input, 'ali');
|
|
88
|
+
await userEvent.click(await screen.findByText('Alice Green'));
|
|
89
|
+
expect(onSubmit).toHaveBeenCalledWith('alice@example.com');
|
|
90
|
+
|
|
91
|
+
// Same handler, same argument, from the plain typed path.
|
|
92
|
+
onSubmit.mockClear();
|
|
93
|
+
await userEvent.clear(input);
|
|
94
|
+
await userEvent.type(input, 'alice@example.com{Enter}');
|
|
95
|
+
expect(onSubmit).toHaveBeenCalledWith('alice@example.com');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('degrades to a plain email input when the suggest request fails', async () => {
|
|
99
|
+
vi.mocked(suggestPrincipals).mockRejectedValue(new Error('suggest is down'));
|
|
100
|
+
const onSubmit = vi.fn();
|
|
101
|
+
render(<Harness onSubmit={onSubmit} />);
|
|
102
|
+
|
|
103
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
104
|
+
await userEvent.type(input, 'newcomer@example.com');
|
|
105
|
+
await waitFor(() => expect(suggestPrincipals).toHaveBeenCalled());
|
|
106
|
+
|
|
107
|
+
// No list, no error takes over the form — and the value still submits.
|
|
108
|
+
expect(screen.queryByRole('list')).not.toBeInTheDocument();
|
|
109
|
+
expect(screen.queryByText(/suggest is down/)).not.toBeInTheDocument();
|
|
110
|
+
await userEvent.click(screen.getByRole('button', { name: 'Add' }));
|
|
111
|
+
expect(onSubmit).toHaveBeenCalledWith('newcomer@example.com');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('the arrow keys walk the suggestions while focus stays in the field, and Enter takes the active one', async () => {
|
|
115
|
+
vi.mocked(suggestPrincipals).mockResolvedValue(people(ALICE, PAT));
|
|
116
|
+
const onSubmit = vi.fn();
|
|
117
|
+
render(<Harness onSubmit={onSubmit} />);
|
|
118
|
+
|
|
119
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
120
|
+
await userEvent.type(input, 'al');
|
|
121
|
+
await screen.findByText('Alice Green');
|
|
122
|
+
expect(input).not.toHaveAttribute('aria-activedescendant');
|
|
123
|
+
const alice = screen.getByRole('option', { name: /Alice Green/ });
|
|
124
|
+
const pat = screen.getByRole('option', { name: /Pat Kim/ });
|
|
125
|
+
|
|
126
|
+
// With no row active, Up starts at the bottom…
|
|
127
|
+
await userEvent.keyboard('{ArrowUp}');
|
|
128
|
+
expect(input).toHaveAttribute('aria-activedescendant', pat.id);
|
|
129
|
+
// …and Down from there wraps to the top.
|
|
130
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
131
|
+
expect(input).toHaveFocus();
|
|
132
|
+
expect(input).toHaveAttribute('aria-activedescendant', alice.id);
|
|
133
|
+
expect(alice).toHaveAttribute('aria-selected', 'true');
|
|
134
|
+
expect(pat).toHaveAttribute('aria-selected', 'false');
|
|
135
|
+
|
|
136
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
137
|
+
expect(input).toHaveAttribute('aria-activedescendant', pat.id);
|
|
138
|
+
// Past the end wraps to the top; ArrowUp from the top wraps to the end.
|
|
139
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
140
|
+
expect(input).toHaveAttribute('aria-activedescendant', alice.id);
|
|
141
|
+
await userEvent.keyboard('{ArrowUp}');
|
|
142
|
+
expect(input).toHaveAttribute('aria-activedescendant', pat.id);
|
|
143
|
+
await userEvent.keyboard('{Home}');
|
|
144
|
+
expect(input).toHaveAttribute('aria-activedescendant', alice.id);
|
|
145
|
+
await userEvent.keyboard('{End}');
|
|
146
|
+
expect(input).toHaveAttribute('aria-activedescendant', pat.id);
|
|
147
|
+
await userEvent.keyboard('{Home}');
|
|
148
|
+
|
|
149
|
+
await userEvent.keyboard('{Enter}');
|
|
150
|
+
expect(onSubmit).toHaveBeenCalledWith('alice@example.com');
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('scrolls the active row into the list as the arrows move it — focus stays in the field, so nothing else would', async () => {
|
|
154
|
+
vi.mocked(suggestPrincipals).mockResolvedValue(people(ALICE, PAT));
|
|
155
|
+
const scrolled = vi.fn();
|
|
156
|
+
const proto = window.HTMLElement.prototype as HTMLElement & { scrollIntoView?: (o?: unknown) => void };
|
|
157
|
+
const before = proto.scrollIntoView;
|
|
158
|
+
proto.scrollIntoView = scrolled;
|
|
159
|
+
try {
|
|
160
|
+
render(<Harness />);
|
|
161
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
162
|
+
await userEvent.type(input, 'al');
|
|
163
|
+
await screen.findByText('Alice Green');
|
|
164
|
+
await userEvent.keyboard('{ArrowDown}{ArrowDown}');
|
|
165
|
+
const pat = screen.getByRole('option', { name: /Pat Kim/ });
|
|
166
|
+
expect(scrolled).toHaveBeenCalledWith({ block: 'nearest' });
|
|
167
|
+
expect(scrolled.mock.instances.at(-1)).toBe(pat);
|
|
168
|
+
} finally {
|
|
169
|
+
proto.scrollIntoView = before;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('the active row follows the person, not the position, when the list refreshes underneath', async () => {
|
|
174
|
+
vi.mocked(suggestPrincipals).mockResolvedValue(people(ALICE, PAT));
|
|
175
|
+
const onSubmit = vi.fn();
|
|
176
|
+
function Refreshing() {
|
|
177
|
+
const [value, setValue] = useState('');
|
|
178
|
+
const [exclude, setExclude] = useState<string[]>([]);
|
|
179
|
+
return (
|
|
180
|
+
<>
|
|
181
|
+
<AddMemberInput value={value} onValueChange={setValue} onSubmit={onSubmit} exclude={exclude} inputLabel="Member email" />
|
|
182
|
+
<button type="button" onClick={() => setExclude([ALICE.email])}>
|
|
183
|
+
drop alice
|
|
184
|
+
</button>
|
|
185
|
+
</>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
render(<Refreshing />);
|
|
189
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
190
|
+
await userEvent.type(input, 'al');
|
|
191
|
+
await screen.findByText('Alice Green');
|
|
192
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
193
|
+
expect(input).toHaveAttribute('aria-activedescendant', screen.getByRole('option', { name: /Alice Green/ }).id);
|
|
194
|
+
|
|
195
|
+
// Alice leaves the list (someone added her elsewhere); the first row is
|
|
196
|
+
// Pat now, and Pat must not inherit Alice's highlight.
|
|
197
|
+
await userEvent.click(screen.getByRole('button', { name: 'drop alice' }));
|
|
198
|
+
await userEvent.click(input);
|
|
199
|
+
// The refreshed list arrives after the debounce.
|
|
200
|
+
const patRow = await screen.findByRole('option', { name: /Pat Kim/ });
|
|
201
|
+
expect(screen.queryByText('Alice Green')).not.toBeInTheDocument();
|
|
202
|
+
expect(patRow).toHaveAttribute('aria-selected', 'false');
|
|
203
|
+
expect(input).not.toHaveAttribute('aria-activedescendant');
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('Tab leaves the widget and closes the list — the rows are not tab stops, the arrows are the way through them', async () => {
|
|
207
|
+
const onSubmit = vi.fn();
|
|
208
|
+
render(<Harness onSubmit={onSubmit} />);
|
|
209
|
+
|
|
210
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
211
|
+
await userEvent.type(input, 'ali');
|
|
212
|
+
await screen.findByText('Alice Green');
|
|
213
|
+
|
|
214
|
+
await userEvent.tab();
|
|
215
|
+
expect(screen.getByRole('button', { name: 'Add' })).toHaveFocus();
|
|
216
|
+
expect(screen.queryByRole('option', { name: /Alice Green/ })).not.toBeInTheDocument();
|
|
217
|
+
expect(onSubmit).not.toHaveBeenCalled();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('offers no suggestion rows while a mutation is in flight', async () => {
|
|
221
|
+
const onSubmit = vi.fn();
|
|
222
|
+
const { rerender } = render(<Harness onSubmit={onSubmit} />);
|
|
223
|
+
|
|
224
|
+
await userEvent.type(screen.getByRole('combobox', { name: 'Member email' }), 'ali');
|
|
225
|
+
expect(await screen.findByText('Alice Green')).toBeInTheDocument();
|
|
226
|
+
|
|
227
|
+
// The input and Add button already go inert while the add runs; a live row
|
|
228
|
+
// would be the one way left to queue a second mutation behind the first.
|
|
229
|
+
rerender(<Harness onSubmit={onSubmit} busy />);
|
|
230
|
+
await waitFor(() => expect(screen.queryByText('Alice Green')).not.toBeInTheDocument());
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('drops the previous query\'s people the moment the text changes', async () => {
|
|
234
|
+
let answerPat: ((r: SuggestResponse) => void) | undefined;
|
|
235
|
+
// Keyed by query rather than by call order: how many requests a burst of
|
|
236
|
+
// typing produces depends on where the debounce lands, and that is not what
|
|
237
|
+
// this test is about.
|
|
238
|
+
vi.mocked(suggestPrincipals).mockImplementation((_workspace, q) =>
|
|
239
|
+
q === 'al'
|
|
240
|
+
? Promise.resolve(people(ALICE))
|
|
241
|
+
: new Promise<SuggestResponse>((resolve) => {
|
|
242
|
+
answerPat = resolve;
|
|
243
|
+
}),
|
|
244
|
+
);
|
|
245
|
+
render(<Harness />);
|
|
246
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
247
|
+
|
|
248
|
+
await userEvent.type(input, 'al');
|
|
249
|
+
expect(await screen.findByText('Alice Green')).toBeInTheDocument();
|
|
250
|
+
|
|
251
|
+
// 'al' is REPLACED by 'pat' in one edit, rather than typed onto the end of
|
|
252
|
+
// it. Two things ride on that. The query has to genuinely become 'pat' —
|
|
253
|
+
// appending would ask for 'alpat' and the test would not mean what it says.
|
|
254
|
+
// And the text must never dip below two characters on the way: the
|
|
255
|
+
// below-threshold path clears the list on its own, so a clear-then-type
|
|
256
|
+
// would pass even with the new-query clear removed, proving nothing.
|
|
257
|
+
await userEvent.click(input);
|
|
258
|
+
(input as HTMLInputElement).select();
|
|
259
|
+
await userEvent.paste('pat');
|
|
260
|
+
expect(input).toHaveValue('pat');
|
|
261
|
+
|
|
262
|
+
// Alice answered the OLD text, so leaving her row up would let a click add
|
|
263
|
+
// someone the current text never named.
|
|
264
|
+
await waitFor(() => expect(screen.queryByText('Alice Green')).not.toBeInTheDocument());
|
|
265
|
+
await waitFor(() => expect(answerPat).toBeDefined());
|
|
266
|
+
|
|
267
|
+
answerPat!(people(PAT));
|
|
268
|
+
expect(await screen.findByText('Pat Kim')).toBeInTheDocument();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('a stale response never overwrites the current query, and a backspace clears the list', async () => {
|
|
272
|
+
const resolvers: ((r: SuggestResponse) => void)[] = [];
|
|
273
|
+
vi.mocked(suggestPrincipals).mockImplementation(
|
|
274
|
+
() => new Promise<SuggestResponse>((resolve) => resolvers.push(resolve)),
|
|
275
|
+
);
|
|
276
|
+
render(<Harness />);
|
|
277
|
+
const input = screen.getByRole('combobox', { name: 'Member email' });
|
|
278
|
+
|
|
279
|
+
await userEvent.type(input, 'pa');
|
|
280
|
+
await waitFor(() => expect(resolvers).toHaveLength(1));
|
|
281
|
+
await userEvent.type(input, 'li');
|
|
282
|
+
await waitFor(() => expect(resolvers).toHaveLength(2));
|
|
283
|
+
|
|
284
|
+
// The NEWER query answers first, then the older one lands late.
|
|
285
|
+
resolvers[1](people(ALICE));
|
|
286
|
+
expect(await screen.findByText('Alice Green')).toBeInTheDocument();
|
|
287
|
+
resolvers[0](people(PAT));
|
|
288
|
+
await waitFor(() => expect(screen.queryByText('Pat Kim')).not.toBeInTheDocument());
|
|
289
|
+
expect(screen.getByText('Alice Green')).toBeInTheDocument();
|
|
290
|
+
|
|
291
|
+
// Backspacing under the threshold drops the list rather than leaving a
|
|
292
|
+
// stale one hanging under a query too short to have produced it.
|
|
293
|
+
await userEvent.clear(input);
|
|
294
|
+
await userEvent.type(input, 'a');
|
|
295
|
+
await waitFor(() => expect(screen.queryByText('Alice Green')).not.toBeInTheDocument());
|
|
296
|
+
});
|
|
297
|
+
});
|
|
@@ -240,7 +240,7 @@ describe('AdminRolesPage: membership-only surface', () => {
|
|
|
240
240
|
expect(screen.queryByRole('button', { name: /delete role/i })).not.toBeInTheDocument();
|
|
241
241
|
// What remains is membership: member emails and (where assignable) groups.
|
|
242
242
|
const adminCard = within(await findCard('Admin'));
|
|
243
|
-
expect(adminCard.getByRole('
|
|
243
|
+
expect(adminCard.getByRole('combobox', { name: 'Member email' })).toBeInTheDocument();
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
it('the Admin ≥1-direct-email 422 renders the backend message inline on the card', async () => {
|
|
@@ -269,7 +269,7 @@ describe('AdminRolesPage: membership-only surface', () => {
|
|
|
269
269
|
renderPage();
|
|
270
270
|
const editorCard = within(await findCard('Editor'));
|
|
271
271
|
await userEvent.type(
|
|
272
|
-
editorCard.getByRole('
|
|
272
|
+
editorCard.getByRole('combobox', { name: 'Member email' }),
|
|
273
273
|
'group:engineering',
|
|
274
274
|
);
|
|
275
275
|
await userEvent.click(editorCard.getByRole('button', { name: 'Add' }));
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { AdminRolesPage } from '../components/AdminRolesPage';
|
|
5
|
+
import { AdminContext } from '../state/admin.context';
|
|
6
|
+
import {
|
|
7
|
+
addMember,
|
|
8
|
+
assignGroup,
|
|
9
|
+
convertRoleToGroup,
|
|
10
|
+
fetchRoles,
|
|
11
|
+
removeMember,
|
|
12
|
+
unassignGroup,
|
|
13
|
+
type RoleRosterEntry,
|
|
14
|
+
} from '../services/roles.api';
|
|
15
|
+
|
|
16
|
+
vi.mock('../services/roles.api', async (importOriginal) => {
|
|
17
|
+
const actual = await importOriginal<typeof import('../services/roles.api')>();
|
|
18
|
+
return {
|
|
19
|
+
...actual,
|
|
20
|
+
fetchRoles: vi.fn(),
|
|
21
|
+
addMember: vi.fn(),
|
|
22
|
+
removeMember: vi.fn(),
|
|
23
|
+
assignGroup: vi.fn(),
|
|
24
|
+
unassignGroup: vi.fn(),
|
|
25
|
+
convertRoleToGroup: vi.fn(),
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
vi.mock('../../access/api', async (importOriginal) => {
|
|
29
|
+
const actual = await importOriginal<typeof import('../../access/api')>();
|
|
30
|
+
return { ...actual, suggestPrincipals: vi.fn() };
|
|
31
|
+
});
|
|
32
|
+
import { suggestPrincipals } from '../../access/api';
|
|
33
|
+
|
|
34
|
+
const OWNER = 'owner@bevel.software';
|
|
35
|
+
const NOTE = 'Deployment admin, set in the server configuration; cannot be removed here';
|
|
36
|
+
|
|
37
|
+
/** Admin as the backend now reports it: a fixed member plus editable ones. */
|
|
38
|
+
function adminRole(over: Partial<RoleRosterEntry> = {}): RoleRosterEntry {
|
|
39
|
+
return {
|
|
40
|
+
canonical: 'admin',
|
|
41
|
+
displayName: 'Admin',
|
|
42
|
+
members: ['razvan@bevel.software'],
|
|
43
|
+
fixedMembers: [OWNER],
|
|
44
|
+
groups: [],
|
|
45
|
+
capability: { description: 'Full administrative access.', groupAssignable: true },
|
|
46
|
+
isAdmin: true,
|
|
47
|
+
referencedBy: [],
|
|
48
|
+
...over,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const SALES: RoleRosterEntry = {
|
|
53
|
+
canonical: 'sales',
|
|
54
|
+
displayName: 'Sales',
|
|
55
|
+
members: ['felix@example.com'],
|
|
56
|
+
fixedMembers: [],
|
|
57
|
+
groups: [],
|
|
58
|
+
capability: null,
|
|
59
|
+
isAdmin: false,
|
|
60
|
+
referencedBy: [],
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
function renderPage() {
|
|
64
|
+
return render(
|
|
65
|
+
<AdminContext.Provider
|
|
66
|
+
value={{
|
|
67
|
+
isAdmin: true,
|
|
68
|
+
unreadCount: 0,
|
|
69
|
+
lastSeen: null,
|
|
70
|
+
markSeen: () => {},
|
|
71
|
+
refresh: () => {},
|
|
72
|
+
rolesConfigCorrupted: false,
|
|
73
|
+
rolesConfigErrors: [],
|
|
74
|
+
runRolesRecovery: async () => {},
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<AdminRolesPage />
|
|
78
|
+
</AdminContext.Provider>,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async function findCard(name: string): Promise<HTMLElement> {
|
|
83
|
+
const heading = await screen.findByRole('heading', { name });
|
|
84
|
+
return heading.closest('div.rounded-lg') as HTMLElement;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
vi.mocked(suggestPrincipals)
|
|
89
|
+
.mockReset()
|
|
90
|
+
.mockResolvedValue({ roles: [], groups: [], people: [], peopleWithheld: false });
|
|
91
|
+
vi.mocked(fetchRoles).mockReset().mockResolvedValue([adminRole(), SALES]);
|
|
92
|
+
vi.mocked(addMember).mockReset().mockResolvedValue([adminRole(), SALES]);
|
|
93
|
+
vi.mocked(removeMember).mockReset().mockResolvedValue([adminRole(), SALES]);
|
|
94
|
+
vi.mocked(assignGroup).mockReset().mockResolvedValue([adminRole(), SALES]);
|
|
95
|
+
vi.mocked(unassignGroup).mockReset().mockResolvedValue([adminRole(), SALES]);
|
|
96
|
+
vi.mocked(convertRoleToGroup).mockReset().mockResolvedValue([adminRole(), SALES]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('AdminRolesPage: the deployment admin is a fixed Admin member', () => {
|
|
100
|
+
it('lists the deployment admin under Admin with the note and no remove control', async () => {
|
|
101
|
+
renderPage();
|
|
102
|
+
const card = within(await findCard('Admin'));
|
|
103
|
+
expect(card.getByText(OWNER)).toBeInTheDocument();
|
|
104
|
+
// The explanation is VISIBLE on the card, not just a tooltip.
|
|
105
|
+
expect(card.getByText(`${NOTE}.`)).toBeInTheDocument();
|
|
106
|
+
// No X for that address — the one editable member still has one.
|
|
107
|
+
expect(card.queryByRole('button', { name: `Remove ${OWNER}` })).not.toBeInTheDocument();
|
|
108
|
+
expect(card.getByRole('button', { name: 'Remove razvan@bevel.software' })).toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('renders an address named by BOTH roles.yaml and the server config exactly once, as fixed', async () => {
|
|
112
|
+
// The normal deployment: seeding wrote ADMIN_EMAIL into roles.yaml, so the
|
|
113
|
+
// backend reports it in `members` AND `fixedMembers`.
|
|
114
|
+
vi.mocked(fetchRoles).mockResolvedValue([
|
|
115
|
+
adminRole({ members: [OWNER, 'razvan@bevel.software'] }),
|
|
116
|
+
SALES,
|
|
117
|
+
]);
|
|
118
|
+
renderPage();
|
|
119
|
+
const card = await findCard('Admin');
|
|
120
|
+
expect(within(card).getAllByText(OWNER)).toHaveLength(1);
|
|
121
|
+
expect(within(card).queryByRole('button', { name: `Remove ${OWNER}` })).not.toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('still allows removing the last EDITABLE admin when the file names the fixed one too', async () => {
|
|
125
|
+
// Regression guard for the chip filtering: `roles.yaml` has two direct
|
|
126
|
+
// members, so the >=1-direct-email invariant does not bite — hiding the
|
|
127
|
+
// fixed chip must not make the UI think there is only one.
|
|
128
|
+
vi.mocked(fetchRoles).mockResolvedValue([
|
|
129
|
+
adminRole({ members: [OWNER, 'razvan@bevel.software'] }),
|
|
130
|
+
SALES,
|
|
131
|
+
]);
|
|
132
|
+
renderPage();
|
|
133
|
+
const card = within(await findCard('Admin'));
|
|
134
|
+
await userEvent.click(card.getByRole('button', { name: 'Remove razvan@bevel.software' }));
|
|
135
|
+
await waitFor(() =>
|
|
136
|
+
expect(removeMember).toHaveBeenCalledWith('admin', 'razvan@bevel.software'),
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('keeps the last-direct-member guard when the fixed address is the only one in the file', async () => {
|
|
141
|
+
vi.mocked(fetchRoles).mockResolvedValue([adminRole({ members: ['razvan@bevel.software'] }), SALES]);
|
|
142
|
+
renderPage();
|
|
143
|
+
const card = within(await findCard('Admin'));
|
|
144
|
+
expect(card.getByRole('button', { name: 'Remove razvan@bevel.software' })).toBeDisabled();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('refuses to add the deployment admin as a regular member, with the same explanation', async () => {
|
|
148
|
+
renderPage();
|
|
149
|
+
const card = within(await findCard('Admin'));
|
|
150
|
+
await userEvent.type(card.getByRole('combobox', { name: 'Member email' }), OWNER);
|
|
151
|
+
await userEvent.keyboard('{Enter}');
|
|
152
|
+
|
|
153
|
+
expect(await card.findByText(`${NOTE}. ${OWNER} is already an Admin.`)).toBeInTheDocument();
|
|
154
|
+
// Refused locally: no request, and no optimistic chip left behind.
|
|
155
|
+
expect(addMember).not.toHaveBeenCalled();
|
|
156
|
+
expect(card.getAllByText(OWNER)).toHaveLength(1);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('surfaces the backend refusal verbatim if one reaches the page anyway', async () => {
|
|
160
|
+
// A second admin could configure ADMIN_EMAIL between this page's load and
|
|
161
|
+
// the submit — then only the server knows, and its 422 is the explanation.
|
|
162
|
+
vi.mocked(fetchRoles).mockResolvedValue([adminRole({ fixedMembers: [] }), SALES]);
|
|
163
|
+
vi.mocked(addMember).mockRejectedValue(
|
|
164
|
+
new Error(`${NOTE}. ${OWNER} is always an Admin, so its Admin membership cannot be added or removed from this page.`),
|
|
165
|
+
);
|
|
166
|
+
renderPage();
|
|
167
|
+
const card = await findCard('Admin');
|
|
168
|
+
await userEvent.type(within(card).getByRole('combobox', { name: 'Member email' }), OWNER);
|
|
169
|
+
await userEvent.keyboard('{Enter}');
|
|
170
|
+
expect(await within(card).findByText(new RegExp(NOTE))).toBeInTheDocument();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('shows no fixed member (and no note) on a role that has none', async () => {
|
|
174
|
+
renderPage();
|
|
175
|
+
const card = within(await findCard('Sales'));
|
|
176
|
+
expect(card.queryByText(`${NOTE}.`)).not.toBeInTheDocument();
|
|
177
|
+
expect(card.getByRole('button', { name: 'Remove felix@example.com' })).toBeInTheDocument();
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('degrades to today’s behaviour when the backend omits fixedMembers', async () => {
|
|
181
|
+
const legacyShape = { ...adminRole() } as Partial<RoleRosterEntry>;
|
|
182
|
+
delete legacyShape.fixedMembers;
|
|
183
|
+
vi.mocked(fetchRoles).mockResolvedValue([legacyShape as RoleRosterEntry, SALES]);
|
|
184
|
+
renderPage();
|
|
185
|
+
const card = within(await findCard('Admin'));
|
|
186
|
+
expect(card.queryByText(`${NOTE}.`)).not.toBeInTheDocument();
|
|
187
|
+
expect(card.getByText('razvan@bevel.software')).toBeInTheDocument();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -66,7 +66,7 @@ describe('AdminRolesPage: add-member autocomplete', () => {
|
|
|
66
66
|
const user = userEvent.setup();
|
|
67
67
|
renderPage();
|
|
68
68
|
|
|
69
|
-
const input = await screen.findByRole('
|
|
69
|
+
const input = await screen.findByRole('combobox', { name: 'Member email' });
|
|
70
70
|
await user.type(input, 'al');
|
|
71
71
|
|
|
72
72
|
// The suggest fetch is debounced 200ms; wait for the list to materialise.
|