@bevel-software/platform-core-frontend 0.14.0 → 0.19.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 +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- 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 +781 -76
- 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__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- 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__/ConnectionKeysPage.test.tsx +266 -0
- 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/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- 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/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- 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 +109 -4
- 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 +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- 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 +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- 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 +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- 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 +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- 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 +67 -0
- 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/__tests__/useJoinRequests.test.tsx +46 -0
- 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 +107 -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 +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -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 +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- 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 +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- 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 +116 -17
- 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/useJoinRequests.ts +48 -18
- 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 +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- 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 +268 -37
- 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 +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- 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 +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +66 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- 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 +615 -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 +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -3
- 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 +395 -124
- 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 +659 -36
- 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 +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- 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 +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -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 +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -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 +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- 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 +126 -52
- 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 +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -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 +118 -0
- 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 +34 -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 -265
- 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
|
@@ -7,24 +7,65 @@ import { AuthContext, type AuthContextValue } from '../../auth/state/auth.contex
|
|
|
7
7
|
import {
|
|
8
8
|
createAccount,
|
|
9
9
|
deleteAccount,
|
|
10
|
+
getAccountReferences,
|
|
10
11
|
listAccounts,
|
|
12
|
+
type AccountReferences,
|
|
11
13
|
} from '../../auth/services/account.api';
|
|
12
14
|
|
|
13
15
|
vi.mock('../../auth/services/account.api', () => ({
|
|
14
16
|
createAccount: vi.fn(),
|
|
15
17
|
deleteAccount: vi.fn(),
|
|
18
|
+
getAccountReferences: vi.fn(),
|
|
16
19
|
listAccounts: vi.fn(),
|
|
17
20
|
}));
|
|
18
21
|
|
|
22
|
+
const REFS = {
|
|
23
|
+
roles: 1,
|
|
24
|
+
groups: 2,
|
|
25
|
+
accessRules: 3,
|
|
26
|
+
fileGrants: 1,
|
|
27
|
+
total: 7,
|
|
28
|
+
files: ['Sales/Plan.md', 'Sales/access.md', 'groups.yaml', 'roles.yaml'],
|
|
29
|
+
removable: true,
|
|
30
|
+
blockedReason: null,
|
|
31
|
+
unwritable: [] as string[],
|
|
32
|
+
};
|
|
33
|
+
|
|
19
34
|
const ME = { id: 'admin-1', email: 'admin@example.com', name: 'Admin' };
|
|
20
35
|
const ALICE = {
|
|
21
36
|
id: 'u-alice',
|
|
22
37
|
email: 'alice@example.com',
|
|
23
38
|
name: 'Alice',
|
|
24
39
|
hasPassword: false,
|
|
40
|
+
isEnvAdmin: false,
|
|
41
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
42
|
+
};
|
|
43
|
+
const BOB = {
|
|
44
|
+
id: 'u-bob',
|
|
45
|
+
email: 'bob@example.com',
|
|
46
|
+
name: 'Bob',
|
|
47
|
+
hasPassword: true,
|
|
48
|
+
isEnvAdmin: false,
|
|
49
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
50
|
+
};
|
|
51
|
+
// The deployment admin (ADMIN_EMAIL) — a different account from the signed-in
|
|
52
|
+
// admin, so its row offers the actions. No hash stored yet.
|
|
53
|
+
const ROOT = {
|
|
54
|
+
id: 'u-root',
|
|
55
|
+
email: 'root@example.com',
|
|
56
|
+
name: 'Root',
|
|
57
|
+
hasPassword: false,
|
|
58
|
+
isEnvAdmin: true,
|
|
25
59
|
createdAt: '2026-01-01T00:00:00Z',
|
|
26
60
|
};
|
|
27
61
|
|
|
62
|
+
/** The "email · Joined … · sign-in method" line of the named account's row. */
|
|
63
|
+
function row(name: string): HTMLElement {
|
|
64
|
+
const li = screen.getByText(name).closest('li');
|
|
65
|
+
if (!li) throw new Error(`no row for ${name}`);
|
|
66
|
+
return within(li).getByText(/· Joined /);
|
|
67
|
+
}
|
|
68
|
+
|
|
28
69
|
function renderPage(opts: { isAdmin?: boolean } = {}) {
|
|
29
70
|
const auth: AuthContextValue = {
|
|
30
71
|
user: ME,
|
|
@@ -57,10 +98,11 @@ beforeEach(() => {
|
|
|
57
98
|
vi.mocked(listAccounts)
|
|
58
99
|
.mockReset()
|
|
59
100
|
.mockResolvedValue([
|
|
60
|
-
{ ...ME, hasPassword: true, createdAt: '2026-01-01T00:00:00Z' },
|
|
101
|
+
{ ...ME, hasPassword: true, isEnvAdmin: false, createdAt: '2026-01-01T00:00:00Z' },
|
|
61
102
|
ALICE,
|
|
62
103
|
]);
|
|
63
|
-
vi.mocked(deleteAccount).mockReset().mockResolvedValue(
|
|
104
|
+
vi.mocked(deleteAccount).mockReset().mockResolvedValue(null);
|
|
105
|
+
vi.mocked(getAccountReferences).mockReset().mockResolvedValue(REFS);
|
|
64
106
|
vi.mocked(createAccount).mockReset().mockResolvedValue(undefined);
|
|
65
107
|
});
|
|
66
108
|
|
|
@@ -74,7 +116,7 @@ describe('UserAccountsPage', () => {
|
|
|
74
116
|
it('lists accounts with sign-in method; own row offers no actions', async () => {
|
|
75
117
|
renderPage();
|
|
76
118
|
await waitFor(() => expect(screen.getByText('Alice')).toBeInTheDocument());
|
|
77
|
-
expect(
|
|
119
|
+
expect(row('Alice')).toHaveTextContent(/· No password — signs in with single sign-on$/);
|
|
78
120
|
expect(
|
|
79
121
|
screen.getByRole('button', { name: 'Set password for alice@example.com' }),
|
|
80
122
|
).toBeInTheDocument();
|
|
@@ -89,6 +131,182 @@ describe('UserAccountsPage', () => {
|
|
|
89
131
|
).not.toBeInTheDocument();
|
|
90
132
|
});
|
|
91
133
|
|
|
134
|
+
it('labels each account with the sign-in methods it actually has', async () => {
|
|
135
|
+
vi.mocked(listAccounts).mockResolvedValue([
|
|
136
|
+
ALICE,
|
|
137
|
+
BOB,
|
|
138
|
+
ROOT,
|
|
139
|
+
{ ...ROOT, id: 'u-root-hashed', name: 'Root Hashed', hasPassword: true },
|
|
140
|
+
]);
|
|
141
|
+
renderPage();
|
|
142
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
143
|
+
expect(row('Alice')).toHaveTextContent(/· No password — signs in with single sign-on$/);
|
|
144
|
+
expect(row('Bob')).toHaveTextContent(/· Password$/);
|
|
145
|
+
// The deployment admin reads the same with or without a stored hash.
|
|
146
|
+
expect(row('Root')).toHaveTextContent(/· Password \(deployment admin\)$/);
|
|
147
|
+
expect(row('Root Hashed')).toHaveTextContent(/· Password \(deployment admin\)$/);
|
|
148
|
+
expect(screen.queryByText(/Single sign-on only/)).not.toBeInTheDocument();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('the delete confirmation describes the password state in the same words', async () => {
|
|
152
|
+
vi.mocked(listAccounts).mockResolvedValue([ALICE, BOB, ROOT]);
|
|
153
|
+
renderPage();
|
|
154
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
155
|
+
const cases: Array<[string, RegExp]> = [
|
|
156
|
+
['alice@example.com', /No password — signs in with single sign-on: they can sign in again later with single sign-on/],
|
|
157
|
+
['bob@example.com', /Password: to sign in again they will need an admin/],
|
|
158
|
+
['root@example.com', /Password \(deployment admin\): they can still sign in with the deployment admin password/],
|
|
159
|
+
];
|
|
160
|
+
for (const [email, wording] of cases) {
|
|
161
|
+
await userEvent.click(screen.getByRole('button', { name: `Delete account ${email}` }));
|
|
162
|
+
const dialog = screen.getByRole('dialog');
|
|
163
|
+
expect(dialog).toHaveTextContent(wording);
|
|
164
|
+
expect(dialog).not.toHaveTextContent(/Single sign-on only/);
|
|
165
|
+
await userEvent.click(within(dialog).getByRole('button', { name: 'Cancel' }));
|
|
166
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
167
|
+
}
|
|
168
|
+
expect(deleteAccount).not.toHaveBeenCalled();
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// The one account no admin may give a stored password. Its password is the
|
|
172
|
+
// environment's: a stored one would not replace that credential, it would add
|
|
173
|
+
// a second that survives rotating ADMIN_PASSWORD. The service refuses it, so
|
|
174
|
+
// the page must not offer a button that can only fail — it says why instead.
|
|
175
|
+
it('offers no password action on the deployment admin row, and says why', async () => {
|
|
176
|
+
vi.mocked(listAccounts).mockResolvedValue([
|
|
177
|
+
ALICE,
|
|
178
|
+
ROOT,
|
|
179
|
+
{ ...ROOT, id: 'u-root-hashed', name: 'Root Hashed', email: 'root2@example.com', hasPassword: true },
|
|
180
|
+
]);
|
|
181
|
+
renderPage();
|
|
182
|
+
await waitFor(() => screen.getByText('Root'));
|
|
183
|
+
// Neither label, and `hasPassword` does not pick one for it either: the
|
|
184
|
+
// deployment admin reads the same with or without a stored hash.
|
|
185
|
+
for (const email of ['root@example.com', 'root2@example.com']) {
|
|
186
|
+
expect(
|
|
187
|
+
screen.queryByRole('button', { name: `Set password for ${email}` }),
|
|
188
|
+
).not.toBeInTheDocument();
|
|
189
|
+
expect(
|
|
190
|
+
screen.queryByRole('button', { name: `Reset password for ${email}` }),
|
|
191
|
+
).not.toBeInTheDocument();
|
|
192
|
+
}
|
|
193
|
+
const li = screen.getByText('Root').closest('li');
|
|
194
|
+
expect(li).toHaveTextContent('Password set in the deployment environment');
|
|
195
|
+
expect(screen.getByText('Root Hashed').closest('li')).toHaveTextContent(
|
|
196
|
+
'Password set in the deployment environment',
|
|
197
|
+
);
|
|
198
|
+
// Only that one action is withheld — erasure still belongs to another admin.
|
|
199
|
+
expect(
|
|
200
|
+
screen.getByRole('button', { name: 'Delete account root@example.com' }),
|
|
201
|
+
).toBeInTheDocument();
|
|
202
|
+
// And the ordinary account beside it is untouched by the rule.
|
|
203
|
+
expect(
|
|
204
|
+
screen.getByRole('button', { name: 'Set password for alice@example.com' }),
|
|
205
|
+
).toBeInTheDocument();
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('after Set password the label follows the refreshed facts, no manual reload', async () => {
|
|
209
|
+
// Initial load, then one reload per Set password: each reload reports the
|
|
210
|
+
// hash now stored for the account that was just set.
|
|
211
|
+
vi.mocked(listAccounts)
|
|
212
|
+
.mockResolvedValueOnce([ALICE, BOB])
|
|
213
|
+
.mockResolvedValueOnce([{ ...ALICE, hasPassword: true }, BOB]);
|
|
214
|
+
renderPage();
|
|
215
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
216
|
+
|
|
217
|
+
expect(row('Alice')).toHaveTextContent(/· No password — signs in with single sign-on$/);
|
|
218
|
+
await userEvent.click(screen.getByRole('button', { name: 'Set password for alice@example.com' }));
|
|
219
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
220
|
+
await userEvent.type(dialog.getByLabelText('New password'), 'fresh-password-1');
|
|
221
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Set password' }));
|
|
222
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
223
|
+
|
|
224
|
+
await waitFor(() => expect(row('Alice')).toHaveTextContent(/· Password$/));
|
|
225
|
+
expect(listAccounts).toHaveBeenCalledTimes(2);
|
|
226
|
+
// ...and the action offered on that row is now the OTHER one: the same
|
|
227
|
+
// reload that changed the sign-in method changes what the button does.
|
|
228
|
+
expect(
|
|
229
|
+
screen.getByRole('button', { name: 'Reset password for alice@example.com' }),
|
|
230
|
+
).toBeInTheDocument();
|
|
231
|
+
expect(
|
|
232
|
+
screen.queryByRole('button', { name: 'Set password for alice@example.com' }),
|
|
233
|
+
).not.toBeInTheDocument();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// The whole point of the ticket: first setup and replacing a working
|
|
237
|
+
// credential are different acts, so they are not offered in the same words.
|
|
238
|
+
it('offers Set password without one and Reset password with one', async () => {
|
|
239
|
+
vi.mocked(listAccounts).mockResolvedValue([ALICE, BOB]);
|
|
240
|
+
renderPage();
|
|
241
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
242
|
+
expect(
|
|
243
|
+
screen.getByRole('button', { name: 'Set password for alice@example.com' }),
|
|
244
|
+
).toBeInTheDocument();
|
|
245
|
+
expect(
|
|
246
|
+
screen.getByRole('button', { name: 'Reset password for bob@example.com' }),
|
|
247
|
+
).toBeInTheDocument();
|
|
248
|
+
// Neither label leaks onto the other row.
|
|
249
|
+
expect(
|
|
250
|
+
screen.queryByRole('button', { name: 'Reset password for alice@example.com' }),
|
|
251
|
+
).not.toBeInTheDocument();
|
|
252
|
+
expect(
|
|
253
|
+
screen.queryByRole('button', { name: 'Set password for bob@example.com' }),
|
|
254
|
+
).not.toBeInTheDocument();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('the Set password dialog says the person gains a way to sign in', async () => {
|
|
258
|
+
vi.mocked(listAccounts).mockResolvedValue([ALICE, BOB]);
|
|
259
|
+
renderPage();
|
|
260
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
261
|
+
await userEvent.click(screen.getByRole('button', { name: 'Set password for alice@example.com' }));
|
|
262
|
+
const dialog = screen.getByRole('dialog');
|
|
263
|
+
// Title, explanation and confirm button all say the same act.
|
|
264
|
+
expect(within(dialog).getByRole('heading', { name: 'Set password' })).toBeInTheDocument();
|
|
265
|
+
expect(dialog).toHaveTextContent(/from now on they will be able to sign in with this one/);
|
|
266
|
+
expect(within(dialog).getByRole('button', { name: 'Set password' })).toBeInTheDocument();
|
|
267
|
+
// Nothing is being taken away, so nothing warns that it is.
|
|
268
|
+
expect(dialog).not.toHaveTextContent(/stops working/);
|
|
269
|
+
expect(dialog).not.toHaveTextContent(/Reset it\?/);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('the Reset password dialog says the old password stops working, and asks', async () => {
|
|
273
|
+
vi.mocked(listAccounts).mockResolvedValue([ALICE, BOB]);
|
|
274
|
+
renderPage();
|
|
275
|
+
await waitFor(() => screen.getByText('Bob'));
|
|
276
|
+
await userEvent.click(screen.getByRole('button', { name: 'Reset password for bob@example.com' }));
|
|
277
|
+
const dialog = screen.getByRole('dialog');
|
|
278
|
+
expect(within(dialog).getByRole('heading', { name: 'Reset password' })).toBeInTheDocument();
|
|
279
|
+
expect(dialog).toHaveTextContent(/current password stops working immediately/);
|
|
280
|
+
expect(dialog).toHaveTextContent(/Reset it\?/);
|
|
281
|
+
expect(within(dialog).getByRole('button', { name: 'Reset password' })).toBeInTheDocument();
|
|
282
|
+
// It asks before it does anything: the question is on screen and nothing
|
|
283
|
+
// has been sent until the confirm button is pressed.
|
|
284
|
+
expect(createAccount).not.toHaveBeenCalled();
|
|
285
|
+
await userEvent.type(within(dialog).getByLabelText('New password'), 'fresh-password-2');
|
|
286
|
+
await userEvent.click(within(dialog).getByRole('button', { name: 'Reset password' }));
|
|
287
|
+
await waitFor(() =>
|
|
288
|
+
expect(createAccount).toHaveBeenCalledWith('bob@example.com', '', 'fresh-password-2'),
|
|
289
|
+
);
|
|
290
|
+
// ...and the banner reports the act that was actually performed.
|
|
291
|
+
expect(await screen.findByRole('status')).toHaveTextContent(
|
|
292
|
+
'Password reset for bob@example.com',
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('cancelling a reset leaves the password alone', async () => {
|
|
297
|
+
vi.mocked(listAccounts).mockResolvedValue([ALICE, BOB]);
|
|
298
|
+
renderPage();
|
|
299
|
+
await waitFor(() => screen.getByText('Bob'));
|
|
300
|
+
await userEvent.click(screen.getByRole('button', { name: 'Reset password for bob@example.com' }));
|
|
301
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
302
|
+
await userEvent.type(dialog.getByLabelText('New password'), 'fresh-password-2');
|
|
303
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Cancel' }));
|
|
304
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
305
|
+
expect(createAccount).not.toHaveBeenCalled();
|
|
306
|
+
expect(screen.queryByRole('status')).not.toBeInTheDocument();
|
|
307
|
+
expect(listAccounts).toHaveBeenCalledTimes(1);
|
|
308
|
+
});
|
|
309
|
+
|
|
92
310
|
it('sets a password for a user WITHOUT touching their name', async () => {
|
|
93
311
|
renderPage();
|
|
94
312
|
await waitFor(() => screen.getByText('Alice'));
|
|
@@ -112,11 +330,190 @@ describe('UserAccountsPage', () => {
|
|
|
112
330
|
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
113
331
|
const dialog = within(screen.getByRole('dialog'));
|
|
114
332
|
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
115
|
-
await waitFor(() =>
|
|
333
|
+
await waitFor(() =>
|
|
334
|
+
expect(deleteAccount).toHaveBeenCalledWith('u-alice', { removeFromAccess: true }),
|
|
335
|
+
);
|
|
116
336
|
// List reloaded after the delete.
|
|
117
337
|
expect(listAccounts).toHaveBeenCalledTimes(2);
|
|
118
338
|
});
|
|
119
339
|
|
|
340
|
+
it('the confirmation counts where the address is named and offers removal, checked by default', async () => {
|
|
341
|
+
renderPage();
|
|
342
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
343
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
344
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
345
|
+
await waitFor(() =>
|
|
346
|
+
expect(screen.getByRole('dialog')).toHaveTextContent(
|
|
347
|
+
'Their address is named in 7 places: 1 role, 2 groups, 3 access rules and 1 file grant.',
|
|
348
|
+
),
|
|
349
|
+
);
|
|
350
|
+
expect(getAccountReferences).toHaveBeenCalledWith('u-alice');
|
|
351
|
+
const option = dialog.getByRole('checkbox', {
|
|
352
|
+
name: 'Also remove them from roles, groups and access rules',
|
|
353
|
+
});
|
|
354
|
+
expect(option).toBeChecked();
|
|
355
|
+
expect(screen.getByRole('dialog')).not.toHaveTextContent(/will remain in those files/);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
it('with the option off the dialog says the address remains, and the delete does not ask for removal', async () => {
|
|
359
|
+
renderPage();
|
|
360
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
361
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
362
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
363
|
+
await userEvent.click(
|
|
364
|
+
dialog.getByRole('checkbox', { name: 'Also remove them from roles, groups and access rules' }),
|
|
365
|
+
);
|
|
366
|
+
expect(screen.getByRole('dialog')).toHaveTextContent('Their address will remain in those files.');
|
|
367
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
368
|
+
await waitFor(() =>
|
|
369
|
+
expect(deleteAccount).toHaveBeenCalledWith('u-alice', { removeFromAccess: false }),
|
|
370
|
+
);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('names the files this admin cannot write, and still runs the removal for the rest', async () => {
|
|
374
|
+
vi.mocked(getAccountReferences).mockResolvedValue({ ...REFS, unwritable: ['Sales/Plan.md'] });
|
|
375
|
+
vi.mocked(deleteAccount).mockResolvedValueOnce({
|
|
376
|
+
ok: true,
|
|
377
|
+
removedFrom: ['Sales/access.md', 'groups.yaml', 'roles.yaml'],
|
|
378
|
+
stillNamedIn: ['Sales/Plan.md'],
|
|
379
|
+
});
|
|
380
|
+
renderPage();
|
|
381
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
382
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
383
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
384
|
+
await waitFor(() =>
|
|
385
|
+
expect(screen.getByRole('dialog')).toHaveTextContent(
|
|
386
|
+
'1 file you cannot write will keep the address: Sales/Plan.md.',
|
|
387
|
+
),
|
|
388
|
+
);
|
|
389
|
+
expect(
|
|
390
|
+
dialog.getByRole('checkbox', { name: 'Also remove them from roles, groups and access rules' }),
|
|
391
|
+
).toBeChecked();
|
|
392
|
+
|
|
393
|
+
// The removal really runs with the option ON — it cleans everything else.
|
|
394
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
395
|
+
await waitFor(() =>
|
|
396
|
+
expect(deleteAccount).toHaveBeenCalledWith('u-alice', { removeFromAccess: true }),
|
|
397
|
+
);
|
|
398
|
+
// And the file it could not write is named again in the outcome.
|
|
399
|
+
await waitFor(() => screen.getByText(/Some files still name them/));
|
|
400
|
+
expect(screen.getByText('Sales/Plan.md')).toBeInTheDocument();
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('with the option off, the unwritable-files warning goes away', async () => {
|
|
404
|
+
vi.mocked(getAccountReferences).mockResolvedValue({ ...REFS, unwritable: ['Sales/Plan.md'] });
|
|
405
|
+
renderPage();
|
|
406
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
407
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
408
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
409
|
+
await waitFor(() => expect(screen.getByRole('dialog')).toHaveTextContent(/you cannot write/));
|
|
410
|
+
await userEvent.click(
|
|
411
|
+
dialog.getByRole('checkbox', { name: 'Also remove them from roles, groups and access rules' }),
|
|
412
|
+
);
|
|
413
|
+
expect(screen.getByRole('dialog')).not.toHaveTextContent(/you cannot write/);
|
|
414
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
415
|
+
await waitFor(() =>
|
|
416
|
+
expect(deleteAccount).toHaveBeenCalledWith('u-alice', { removeFromAccess: false }),
|
|
417
|
+
);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('says so when it could not tell which files this admin can write', async () => {
|
|
421
|
+
vi.mocked(getAccountReferences).mockResolvedValue({ ...REFS, unwritable: null });
|
|
422
|
+
renderPage();
|
|
423
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
424
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
425
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
426
|
+
await waitFor(() =>
|
|
427
|
+
expect(screen.getByRole('dialog')).toHaveTextContent(
|
|
428
|
+
/Which of these files you can write could not be checked/,
|
|
429
|
+
),
|
|
430
|
+
);
|
|
431
|
+
// Unknown is not "none", and not a reason to refuse the removal. The
|
|
432
|
+
// definite "N files ...: <list>" line belongs to a check that DID run.
|
|
433
|
+
expect(screen.getByRole('dialog')).not.toHaveTextContent(/\d+ files? you cannot write/);
|
|
434
|
+
expect(
|
|
435
|
+
dialog.getByRole('checkbox', { name: 'Also remove them from roles, groups and access rules' }),
|
|
436
|
+
).toBeChecked();
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
it('the deployment owner / last Admin cannot be removed this way: option disabled with the reason', async () => {
|
|
440
|
+
vi.mocked(getAccountReferences).mockResolvedValue({
|
|
441
|
+
...REFS,
|
|
442
|
+
removable: false,
|
|
443
|
+
blockedReason: 'This is the last Admin; the Admin role must keep at least one direct email member.',
|
|
444
|
+
});
|
|
445
|
+
renderPage();
|
|
446
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
447
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
448
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
449
|
+
await waitFor(() => expect(screen.getByRole('dialog')).toHaveTextContent(/last Admin/));
|
|
450
|
+
const option = dialog.getByRole('checkbox', {
|
|
451
|
+
name: 'Also remove them from roles, groups and access rules',
|
|
452
|
+
});
|
|
453
|
+
expect(option).toBeDisabled();
|
|
454
|
+
expect(option).not.toBeChecked();
|
|
455
|
+
expect(screen.getByRole('dialog')).toHaveTextContent('Their address will remain in those files.');
|
|
456
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
457
|
+
await waitFor(() =>
|
|
458
|
+
expect(deleteAccount).toHaveBeenCalledWith('u-alice', { removeFromAccess: false }),
|
|
459
|
+
);
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
it('a failed removal commit still reloads the (deleted) list and lists the files that still name the user', async () => {
|
|
463
|
+
vi.mocked(deleteAccount).mockResolvedValueOnce({
|
|
464
|
+
ok: false,
|
|
465
|
+
error: 'Roles are being edited by Sam. Try again in a moment.',
|
|
466
|
+
removedFrom: [],
|
|
467
|
+
stillNamedIn: ['Sales/access.md', 'roles.yaml'],
|
|
468
|
+
});
|
|
469
|
+
renderPage();
|
|
470
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
471
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
472
|
+
await userEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: 'Delete account' }));
|
|
473
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
474
|
+
const alert = screen.getByRole('alert');
|
|
475
|
+
expect(alert).toHaveTextContent(/The account was deleted, but removing them .* failed: Roles are being edited by Sam/);
|
|
476
|
+
expect(within(alert).getByText('Sales/access.md')).toBeInTheDocument();
|
|
477
|
+
expect(within(alert).getByText('roles.yaml')).toBeInTheDocument();
|
|
478
|
+
expect(listAccounts).toHaveBeenCalledTimes(2);
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
it('a slower references answer for an account opened earlier does not land in a later dialog', async () => {
|
|
482
|
+
vi.mocked(listAccounts).mockResolvedValue([ALICE, BOB]);
|
|
483
|
+
let answerAlice: (refs: AccountReferences) => void = () => {};
|
|
484
|
+
vi.mocked(getAccountReferences).mockImplementation((id: string) =>
|
|
485
|
+
id === 'u-alice'
|
|
486
|
+
? new Promise((resolve) => {
|
|
487
|
+
answerAlice = resolve;
|
|
488
|
+
})
|
|
489
|
+
: Promise.resolve({ ...REFS, total: 1, roles: 1, groups: 0, accessRules: 0, fileGrants: 0 }),
|
|
490
|
+
);
|
|
491
|
+
renderPage();
|
|
492
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
493
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
494
|
+
await userEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: 'Cancel' }));
|
|
495
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account bob@example.com' }));
|
|
496
|
+
await waitFor(() => expect(screen.getByRole('dialog')).toHaveTextContent('named in 1 place: 1 role'));
|
|
497
|
+
answerAlice({ ...REFS, removable: false, blockedReason: 'This is the last Admin.' });
|
|
498
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
499
|
+
const dialog = screen.getByRole('dialog');
|
|
500
|
+
expect(dialog).toHaveTextContent('named in 1 place: 1 role');
|
|
501
|
+
expect(dialog).not.toHaveTextContent(/last Admin/);
|
|
502
|
+
expect(
|
|
503
|
+
within(dialog).getByRole('checkbox', { name: 'Also remove them from roles, groups and access rules' }),
|
|
504
|
+
).toBeChecked();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('a removal whose re-scan failed says the remaining files could not be checked', async () => {
|
|
508
|
+
vi.mocked(deleteAccount).mockResolvedValueOnce({ ok: true, removedFrom: ['roles.yaml'], stillNamedIn: null });
|
|
509
|
+
renderPage();
|
|
510
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
511
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
512
|
+
await userEvent.click(within(screen.getByRole('dialog')).getByRole('button', { name: 'Delete account' }));
|
|
513
|
+
await waitFor(() => expect(screen.getByRole('alert')).toHaveTextContent(/could not be checked/));
|
|
514
|
+
expect(screen.getByRole('alert')).toHaveTextContent(/roles, groups, access rules and file grants/);
|
|
515
|
+
});
|
|
516
|
+
|
|
120
517
|
it('a failed delete closes the dialog, surfaces the error, and does not reload', async () => {
|
|
121
518
|
vi.mocked(deleteAccount).mockRejectedValueOnce(new Error('Failed to erase user'));
|
|
122
519
|
renderPage();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { isNamedGroup, pathForGroupMembers } from '../components/group-members-path';
|
|
3
|
+
|
|
4
|
+
/** A `?group=` link names a group the way the backend does: case and inner whitespace aside. */
|
|
5
|
+
describe('isNamedGroup', () => {
|
|
6
|
+
const entry = { canonical: 'platform team', displayName: 'Platform Team' };
|
|
7
|
+
|
|
8
|
+
it('matches the display name and the canonical name without regard to case', () => {
|
|
9
|
+
expect(isNamedGroup(entry, 'platform team')).toBe(true);
|
|
10
|
+
expect(isNamedGroup(entry, 'PLATFORM TEAM')).toBe(true);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('matches a name whose inner whitespace differs, as the backend folds it', () => {
|
|
14
|
+
expect(isNamedGroup(entry, 'Platform Team')).toBe(true);
|
|
15
|
+
expect(isNamedGroup(entry, ' Platform\tTeam ')).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('is false for another group, or no name', () => {
|
|
19
|
+
expect(isNamedGroup(entry, 'Platform')).toBe(false);
|
|
20
|
+
expect(isNamedGroup(entry, null)).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('round-trips through the link it builds', () => {
|
|
24
|
+
const url = new URL(pathForGroupMembers('Platform Team'), 'http://x');
|
|
25
|
+
expect(isNamedGroup(entry, url.searchParams.get('group'))).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
});
|