@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
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import type { ConnectPending, ConnectTool, ConnectToolOAuth } from '../../services/connect.api';
|
|
5
|
+
import type { ToolSecrets, ToolVarStatus } from '../../services/tool-secrets.api';
|
|
6
|
+
import { outstandingCount, standaloneOutstanding } from '../../utils/connect-status';
|
|
7
|
+
import { ConnectToolsPage } from '../ConnectToolsPage';
|
|
8
|
+
import { attentionOf, type LibraryItem } from '../../../library/state/library-data';
|
|
9
|
+
import { toolStatus } from '../../../library/utils/status';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The plugin banner and this page, counting the same thing.
|
|
13
|
+
*
|
|
14
|
+
* A plugin page said four integrations needed setup and the Connect page it
|
|
15
|
+
* linked to showed two: the banner counts every integration that is not ok —
|
|
16
|
+
* workspace keys only an owner can set, tools the reader took out — and the page
|
|
17
|
+
* listed only what the reader could act on, then dropped the skipped ones from
|
|
18
|
+
* its total as well.
|
|
19
|
+
*
|
|
20
|
+
* So the scenario is built ONCE, as the tool catalog both surfaces are really
|
|
21
|
+
* derived from, and projected two ways: into the Library items the banner counts
|
|
22
|
+
* and into the `/connect/pending` payload the page renders. A test that built
|
|
23
|
+
* two hand-written fixtures could be made to agree while the product did not.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const connectMock = vi.hoisted(() => ({
|
|
27
|
+
getConnectPending: vi.fn(),
|
|
28
|
+
startToolOAuth: vi.fn(),
|
|
29
|
+
getMcpOAuthRequest: vi.fn(),
|
|
30
|
+
completeMcpOAuth: vi.fn(),
|
|
31
|
+
}));
|
|
32
|
+
vi.mock('../../services/connect.api', () => connectMock);
|
|
33
|
+
|
|
34
|
+
const varsMock = vi.hoisted(() => ({
|
|
35
|
+
setUserVar: vi.fn(),
|
|
36
|
+
setAdminVar: vi.fn(),
|
|
37
|
+
deleteUserVar: vi.fn(),
|
|
38
|
+
setOAuthClientSecret: vi.fn(),
|
|
39
|
+
}));
|
|
40
|
+
vi.mock('../../services/tool-secrets.api', () => varsMock);
|
|
41
|
+
vi.mock('../../services/secrets.api', () => ({ startOAuth: vi.fn() }));
|
|
42
|
+
|
|
43
|
+
/* ── the scenario, as one catalog ───────────────────────────────────────── */
|
|
44
|
+
|
|
45
|
+
function v(over: Partial<ToolVarStatus> & { name: string }): ToolVarStatus {
|
|
46
|
+
return {
|
|
47
|
+
scope: 'user',
|
|
48
|
+
label: null,
|
|
49
|
+
key: `k_${over.name}`,
|
|
50
|
+
adminConfigured: false,
|
|
51
|
+
userConfigured: false,
|
|
52
|
+
...over,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function tool(over: Partial<ToolSecrets> & { slug: string }): ToolSecrets {
|
|
57
|
+
return {
|
|
58
|
+
name: over.slug,
|
|
59
|
+
path: `Plugins/GTM/${over.slug}.tool`,
|
|
60
|
+
type: 'inline',
|
|
61
|
+
setup: null,
|
|
62
|
+
canWrite: false,
|
|
63
|
+
variables: [],
|
|
64
|
+
...over,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The spec's scenario: two of the reader's own keys unset, one workspace key
|
|
70
|
+
* only an owner can set, one tool they skipped (skipping WIPED its key, which is
|
|
71
|
+
* what makes it unconfigured), and one that is fully set up and must not be
|
|
72
|
+
* counted by either surface.
|
|
73
|
+
*/
|
|
74
|
+
const CATALOG: ToolSecrets[] = [
|
|
75
|
+
tool({ slug: 'heyreach', variables: [v({ name: 'API_KEY', key: 'heyreach_API_KEY' })] }),
|
|
76
|
+
tool({ slug: 'apollo', variables: [v({ name: 'API_KEY', key: 'apollo_API_KEY' })] }),
|
|
77
|
+
tool({
|
|
78
|
+
slug: 'salesforce',
|
|
79
|
+
variables: [v({ name: 'ORG_TOKEN', key: 'salesforce_ORG_TOKEN', scope: 'admin' })],
|
|
80
|
+
}),
|
|
81
|
+
tool({ slug: 'clay', variables: [v({ name: 'API_KEY', key: 'clay_API_KEY' })] }),
|
|
82
|
+
tool({
|
|
83
|
+
slug: 'notion',
|
|
84
|
+
variables: [v({ name: 'API_KEY', key: 'notion_API_KEY', userConfigured: true })],
|
|
85
|
+
}),
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A tool in the catalog that only `owner@x.com` may READ. It is here, not
|
|
90
|
+
* omitted, because "the page never names it" is only worth asserting if there
|
|
91
|
+
* was something to name: `pendingFor` prunes it the way the server does, from a
|
|
92
|
+
* catalog that really contains it.
|
|
93
|
+
*/
|
|
94
|
+
const SECRET_TOOL = 'blackbox';
|
|
95
|
+
const FULL_CATALOG: ToolSecrets[] = [
|
|
96
|
+
...CATALOG,
|
|
97
|
+
tool({
|
|
98
|
+
slug: SECRET_TOOL,
|
|
99
|
+
variables: [v({ name: 'ORG_TOKEN', key: 'blackbox_ORG_TOKEN', scope: 'admin' })],
|
|
100
|
+
}),
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
/** Who may read what, as the workspace's access rules would answer it. */
|
|
104
|
+
const READABLE_BY = (email: string) => (t: ToolSecrets) =>
|
|
105
|
+
t.slug !== SECRET_TOOL || email === 'owner@x.com';
|
|
106
|
+
|
|
107
|
+
/** What the Library holds, and what the plugin banner counts off it. */
|
|
108
|
+
function libraryItems(catalog: ToolSecrets[]): LibraryItem[] {
|
|
109
|
+
return catalog.map((t) => ({
|
|
110
|
+
kind: 'integration' as const,
|
|
111
|
+
id: t.slug,
|
|
112
|
+
name: t.name,
|
|
113
|
+
description: '',
|
|
114
|
+
owned: false,
|
|
115
|
+
canWrite: t.canWrite,
|
|
116
|
+
status: toolStatus(t),
|
|
117
|
+
plugin: 'GTM',
|
|
118
|
+
path: t.path,
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* What `GET /api/connect/pending` returns for the same catalog — the server's
|
|
124
|
+
* rules, restated: the listing is built from what the caller may READ (the route
|
|
125
|
+
* lists `listAccessible`, never the whole catalog), workspace values that are
|
|
126
|
+
* already set are dropped (nobody's outstanding work), one the caller cannot
|
|
127
|
+
* write is `ownerOnly`, and oauth vars move to the sign-in list.
|
|
128
|
+
*
|
|
129
|
+
* `canRead` is a parameter rather than a pre-filtered fixture so the readability
|
|
130
|
+
* rule is something this function DOES to a catalog that contains the withheld
|
|
131
|
+
* tool. Handed a catalog it may all read, it lists all of it.
|
|
132
|
+
*/
|
|
133
|
+
function pendingFor(
|
|
134
|
+
catalog: ToolSecrets[],
|
|
135
|
+
canRead: (t: ToolSecrets) => boolean = () => true,
|
|
136
|
+
): ConnectPending {
|
|
137
|
+
const readable = catalog.filter(canRead);
|
|
138
|
+
const tools: ConnectTool[] = readable
|
|
139
|
+
.map((t) => ({
|
|
140
|
+
slug: t.slug,
|
|
141
|
+
name: t.name,
|
|
142
|
+
path: t.path,
|
|
143
|
+
type: t.type,
|
|
144
|
+
canWrite: t.canWrite,
|
|
145
|
+
variables: t.variables
|
|
146
|
+
.filter((x) => !x.oauth)
|
|
147
|
+
.map((x) => ({
|
|
148
|
+
name: x.name,
|
|
149
|
+
label: x.label,
|
|
150
|
+
key: x.key,
|
|
151
|
+
scope: x.scope,
|
|
152
|
+
configured: x.scope === 'admin' ? x.adminConfigured : x.userConfigured,
|
|
153
|
+
ownerOnly: x.scope === 'admin' && !t.canWrite,
|
|
154
|
+
}))
|
|
155
|
+
.filter((x) => x.scope !== 'admin' || !x.configured),
|
|
156
|
+
}))
|
|
157
|
+
.filter((t) => t.variables.length > 0);
|
|
158
|
+
const toolOAuth: ConnectToolOAuth[] = readable.flatMap((t) =>
|
|
159
|
+
t.variables
|
|
160
|
+
.filter((x) => x.oauth)
|
|
161
|
+
.map((x) => ({
|
|
162
|
+
slug: t.slug,
|
|
163
|
+
varName: x.name,
|
|
164
|
+
toolName: t.name,
|
|
165
|
+
key: x.key,
|
|
166
|
+
label: x.label,
|
|
167
|
+
authorized: x.authorized ?? false,
|
|
168
|
+
needsReauth: x.needsReauth ?? false,
|
|
169
|
+
ownerConfigured: x.adminConfigured,
|
|
170
|
+
ownerOnly: !x.adminConfigured && !t.canWrite,
|
|
171
|
+
})),
|
|
172
|
+
);
|
|
173
|
+
return { tools, oauth: [], toolOAuth };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function renderPage() {
|
|
177
|
+
return render(
|
|
178
|
+
<MemoryRouter>
|
|
179
|
+
<ConnectToolsPage />
|
|
180
|
+
</MemoryRouter>,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The card for one tool: the Surface holding the row head its name links from.
|
|
186
|
+
* Awaited, because every one of these tests starts with the page's first load.
|
|
187
|
+
*/
|
|
188
|
+
async function rowFor(name: string): Promise<HTMLElement> {
|
|
189
|
+
const link = await screen.findByRole('link', { name: `Open ${name}` });
|
|
190
|
+
return link.closest('div')!.parentElement as HTMLElement;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
beforeEach(() => {
|
|
194
|
+
window.history.replaceState(null, '', '/connect');
|
|
195
|
+
sessionStorage.clear();
|
|
196
|
+
// The page is always handed what the server would build FOR THIS READER:
|
|
197
|
+
// the full catalog, pruned by their read grant. It comes out equal to
|
|
198
|
+
// `pendingFor(CATALOG)` — that is the point, and it is now a result rather
|
|
199
|
+
// than a fixture.
|
|
200
|
+
connectMock.getConnectPending
|
|
201
|
+
.mockReset()
|
|
202
|
+
.mockResolvedValue(pendingFor(FULL_CATALOG, READABLE_BY('a@x.com')));
|
|
203
|
+
connectMock.getMcpOAuthRequest.mockReset();
|
|
204
|
+
varsMock.setUserVar.mockReset().mockResolvedValue(undefined);
|
|
205
|
+
varsMock.setAdminVar.mockReset().mockResolvedValue(undefined);
|
|
206
|
+
varsMock.deleteUserVar.mockReset().mockResolvedValue(undefined);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
describe('the Connect page counts what the plugin banner counted', () => {
|
|
210
|
+
it('agrees with the banner on the spec’s 2 + 1 + 1 scenario', () => {
|
|
211
|
+
const { total, brokenLinks, warnings } = attentionOf(libraryItems(CATALOG), 'GTM');
|
|
212
|
+
const banner = total - brokenLinks - warnings;
|
|
213
|
+
|
|
214
|
+
// Four integrations need setup; `notion` is done and counted by neither.
|
|
215
|
+
expect(banner).toBe(4);
|
|
216
|
+
expect(outstandingCount(pendingFor(CATALOG))).toBe(banner);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('still agrees once a tool is skipped — skipping is not setting up', async () => {
|
|
220
|
+
// Skipping wipes the reader's keys, so the catalog the banner reads is
|
|
221
|
+
// unchanged by it: `clay` was already unconfigured. The page must not quietly
|
|
222
|
+
// drop it from its own total the way it used to.
|
|
223
|
+
renderPage();
|
|
224
|
+
|
|
225
|
+
const clay = await rowFor('clay');
|
|
226
|
+
const listedBefore = screen.getAllByRole('link', { name: /^Open / }).map((l) => l.textContent);
|
|
227
|
+
|
|
228
|
+
fireEvent.click(
|
|
229
|
+
within(clay).getByRole('checkbox', {
|
|
230
|
+
name: 'Skip this tool (removes your saved keys and sign-ins for it)',
|
|
231
|
+
}),
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
expect(await screen.findByText('Skipped by you')).toBeInTheDocument();
|
|
235
|
+
// Skipping is a client-side decision, so the assertion has to be about what
|
|
236
|
+
// the PAGE did with it: nothing left the list. `clay` is still one of the
|
|
237
|
+
// four the banner counted — dropping a skipped row is exactly how a page
|
|
238
|
+
// reached from "4 need setup" came to show two.
|
|
239
|
+
expect(screen.getAllByRole('link', { name: /^Open / }).map((l) => l.textContent)).toEqual(
|
|
240
|
+
listedBefore,
|
|
241
|
+
);
|
|
242
|
+
expect(screen.getByRole('link', { name: 'Open clay' })).toBeInTheDocument();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it('counts a tool once even when it owes both a sign-in and a key', () => {
|
|
246
|
+
// One integration, two rows — the banner counts the integration.
|
|
247
|
+
const both = tool({
|
|
248
|
+
slug: 'linear',
|
|
249
|
+
variables: [
|
|
250
|
+
v({ name: 'API_KEY', key: 'linear_API_KEY' }),
|
|
251
|
+
v({ name: 'TOKEN', key: 'linear_TOKEN', oauth: true, adminConfigured: true }),
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
const catalog = [both];
|
|
255
|
+
const { total, brokenLinks, warnings } = attentionOf(libraryItems(catalog), 'GTM');
|
|
256
|
+
|
|
257
|
+
expect(total - brokenLinks - warnings).toBe(1);
|
|
258
|
+
expect(outstandingCount(pendingFor(catalog))).toBe(1);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('does not count a standalone sign-in — no banner ever did', () => {
|
|
262
|
+
// Secrets registered on the Secrets page are not declared by any `.tool`,
|
|
263
|
+
// so no plugin counts them. Adding them here would break the agreement from
|
|
264
|
+
// the other side: five on a page reached from a banner saying four.
|
|
265
|
+
const withPersonal: ConnectPending = {
|
|
266
|
+
...pendingFor(CATALOG),
|
|
267
|
+
oauth: [{ id: 's1', key: 'MY_TOKEN', label: 'Mine', authorized: false }],
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
expect(outstandingCount(withPersonal)).toBe(4);
|
|
271
|
+
// Still work, still listed — just counted apart from the integrations.
|
|
272
|
+
expect(standaloneOutstanding(withPersonal)).toBe(1);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe('the Connect page says why, when the reader cannot act', () => {
|
|
277
|
+
it('lists a configured tool as set, with no demand on the reader', async () => {
|
|
278
|
+
renderPage();
|
|
279
|
+
const notion = await rowFor('notion');
|
|
280
|
+
|
|
281
|
+
expect(within(notion).getByText('Key saved')).toBeInTheDocument();
|
|
282
|
+
// The field is still there — this page is also where a key is replaced.
|
|
283
|
+
expect(within(notion).getByPlaceholderText('Replace…')).toBeInTheDocument();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('lists an unconfigured tool as the reader’s to fix, fields open', async () => {
|
|
287
|
+
renderPage();
|
|
288
|
+
const apollo = await rowFor('apollo');
|
|
289
|
+
|
|
290
|
+
expect(within(apollo).getByText('Needs a key from you')).toBeInTheDocument();
|
|
291
|
+
expect(within(apollo).getByLabelText('API_KEY value')).toBeInTheDocument();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('greys a workspace key the reader cannot set, and names the variable', async () => {
|
|
295
|
+
renderPage();
|
|
296
|
+
const sf = await rowFor('salesforce');
|
|
297
|
+
|
|
298
|
+
expect(within(sf).getAllByText('Needs an owner to set ORG_TOKEN').length).toBeGreaterThan(0);
|
|
299
|
+
// Nothing to save and nothing to opt out of: it was never the reader's.
|
|
300
|
+
expect(within(sf).queryByRole('button', { name: 'Save' })).not.toBeInTheDocument();
|
|
301
|
+
expect(within(sf).queryByRole('checkbox')).not.toBeInTheDocument();
|
|
302
|
+
// Nothing on the card is theirs, so the whole card is grey.
|
|
303
|
+
expect(sf.className).toContain('opacity-60');
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('leaves the reader’s own field bright on a card that also owes an owner’s key', async () => {
|
|
307
|
+
// Both at once: a personal key they can replace and a workspace value they
|
|
308
|
+
// cannot set. Greying the card for the second fades out the first, and a
|
|
309
|
+
// faded input reads as "not yours" about the one thing here that is.
|
|
310
|
+
const mixed = [
|
|
311
|
+
tool({
|
|
312
|
+
slug: 'zendesk',
|
|
313
|
+
variables: [
|
|
314
|
+
v({ name: 'API_KEY', key: 'zendesk_API_KEY', userConfigured: true }),
|
|
315
|
+
v({ name: 'ORG_TOKEN', key: 'zendesk_ORG_TOKEN', scope: 'admin' }),
|
|
316
|
+
],
|
|
317
|
+
}),
|
|
318
|
+
];
|
|
319
|
+
connectMock.getConnectPending.mockResolvedValue(pendingFor(mixed));
|
|
320
|
+
renderPage();
|
|
321
|
+
const zendesk = await rowFor('zendesk');
|
|
322
|
+
|
|
323
|
+
// The owner's line is still greyed and still names the variable…
|
|
324
|
+
expect(within(zendesk).getAllByText('Needs an owner to set ORG_TOKEN').length).toBeGreaterThan(0);
|
|
325
|
+
// …on its own row, without taking the reader's field down with it.
|
|
326
|
+
expect(zendesk.className).not.toContain('opacity-60');
|
|
327
|
+
expect(within(zendesk).getByPlaceholderText('Replace…')).toBeInTheDocument();
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('gives the OWNER the ordinary row, with the key field', async () => {
|
|
331
|
+
const owned = CATALOG.map((t) => (t.slug === 'salesforce' ? { ...t, canWrite: true } : t));
|
|
332
|
+
connectMock.getConnectPending.mockResolvedValue(pendingFor(owned));
|
|
333
|
+
renderPage();
|
|
334
|
+
const sf = await rowFor('salesforce');
|
|
335
|
+
|
|
336
|
+
expect(within(sf).queryByText('Needs an owner to set ORG_TOKEN')).not.toBeInTheDocument();
|
|
337
|
+
expect(within(sf).getByText('Needs a key from you')).toBeInTheDocument();
|
|
338
|
+
|
|
339
|
+
fireEvent.change(within(sf).getByLabelText('ORG_TOKEN value'), { target: { value: 's3cret' } });
|
|
340
|
+
fireEvent.click(within(sf).getByRole('button', { name: 'Save' }));
|
|
341
|
+
|
|
342
|
+
// The WORKSPACE value, not a personal one — the owner is setting it for
|
|
343
|
+
// everybody, which is the whole reason the other reader could not.
|
|
344
|
+
await waitFor(() =>
|
|
345
|
+
expect(varsMock.setAdminVar).toHaveBeenCalledWith('salesforce', 'ORG_TOKEN', 's3cret'),
|
|
346
|
+
);
|
|
347
|
+
expect(varsMock.setUserVar).not.toHaveBeenCalled();
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('keeps a skipped tool on the page, greyed, with a way back in', async () => {
|
|
351
|
+
renderPage();
|
|
352
|
+
const clay = await rowFor('clay');
|
|
353
|
+
|
|
354
|
+
fireEvent.click(
|
|
355
|
+
within(clay).getByRole('checkbox', {
|
|
356
|
+
name: 'Skip this tool (removes your saved keys and sign-ins for it)',
|
|
357
|
+
}),
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const skipped = await rowFor('clay');
|
|
361
|
+
expect(within(skipped).getByText('Skipped by you')).toBeInTheDocument();
|
|
362
|
+
expect(skipped.className).toContain('opacity-60');
|
|
363
|
+
fireEvent.click(within(skipped).getByRole('button', { name: 'Include' }));
|
|
364
|
+
|
|
365
|
+
expect(within(await rowFor('clay')).getByText('Needs a key from you')).toBeInTheDocument();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
it('says an unregistered sign-in is the owner’s, and offers no Authorize', async () => {
|
|
369
|
+
// Nobody can sign in until the provider registration exists, so offering the
|
|
370
|
+
// button would send the reader at a consent screen that cannot open.
|
|
371
|
+
const catalog = [
|
|
372
|
+
tool({
|
|
373
|
+
slug: 'google',
|
|
374
|
+
variables: [v({ name: 'GOOGLE_TOKEN', key: 'google_GOOGLE_TOKEN', oauth: true })],
|
|
375
|
+
}),
|
|
376
|
+
];
|
|
377
|
+
connectMock.getConnectPending.mockResolvedValue(pendingFor(catalog));
|
|
378
|
+
renderPage();
|
|
379
|
+
const google = await rowFor('google');
|
|
380
|
+
|
|
381
|
+
expect(within(google).getByText('Needs an owner to set GOOGLE_TOKEN')).toBeInTheDocument();
|
|
382
|
+
expect(within(google).queryByRole('button', { name: 'Authorize' })).not.toBeInTheDocument();
|
|
383
|
+
// Counted all the same — the banner counts the integration.
|
|
384
|
+
expect(outstandingCount(pendingFor(catalog))).toBe(1);
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('never names a tool the reader cannot read', async () => {
|
|
388
|
+
// `blackbox` IS in the catalog, needs a workspace key, and would be listed
|
|
389
|
+
// owner-only for anyone who could read it — so its absence below is the
|
|
390
|
+
// read grant doing work, not a fixture that forgot to mention it. Both
|
|
391
|
+
// projections come from the same catalog and differ only in who is asking.
|
|
392
|
+
const forReader = pendingFor(FULL_CATALOG, READABLE_BY('a@x.com'));
|
|
393
|
+
const forOwner = pendingFor(FULL_CATALOG, READABLE_BY('owner@x.com'));
|
|
394
|
+
expect(forOwner.tools.map((t) => t.slug)).toContain(SECRET_TOOL);
|
|
395
|
+
expect(forReader.tools.map((t) => t.slug)).not.toContain(SECRET_TOOL);
|
|
396
|
+
// It is a countable integration for the person who can see it — which is
|
|
397
|
+
// what makes "absent" mean withheld, rather than simply nothing to show.
|
|
398
|
+
expect(outstandingCount(forOwner)).toBe(outstandingCount(forReader) + 1);
|
|
399
|
+
|
|
400
|
+
connectMock.getConnectPending.mockResolvedValue(forReader);
|
|
401
|
+
renderPage();
|
|
402
|
+
await rowFor('apollo');
|
|
403
|
+
|
|
404
|
+
expect(screen.queryByText(SECRET_TOOL)).not.toBeInTheDocument();
|
|
405
|
+
expect(screen.queryByRole('link', { name: `Open ${SECRET_TOOL}` })).not.toBeInTheDocument();
|
|
406
|
+
});
|
|
407
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Banner } from '../../../shared/components';
|
|
2
|
+
import { cn } from '../../../lib/utils';
|
|
3
|
+
import { PROBE_UNREACHABLE_LEAD, probeWords } from './probe-verdict';
|
|
4
|
+
import type { SavedKeyProbe } from './useSavedKeyProbe';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the probe found, next to the key that was just saved.
|
|
8
|
+
*
|
|
9
|
+
* Renders for the two surfaces whose unit is a ROW — "Connect your tools" and
|
|
10
|
+
* the vault. The tool page draws the same answer at tool scale (a health line
|
|
11
|
+
* beside its Test button, a banner above its rows), so it keeps its own
|
|
12
|
+
* layout; what both share is `probeWords`, which is why the sentence a person
|
|
13
|
+
* meets is identical wherever they saved the key.
|
|
14
|
+
*
|
|
15
|
+
* The loudness follows who has to act:
|
|
16
|
+
* - REJECTED is the one state that needs a person — the provider looked at
|
|
17
|
+
* this key and refused it, no other banner covers that, and the key is
|
|
18
|
+
* still to hand. It gets a danger banner and `role="alert"`, exactly as the
|
|
19
|
+
* tool page does. This case is the reason the feature exists.
|
|
20
|
+
* - UNREACHABLE needs nobody yet: our own network failed, the key may well be
|
|
21
|
+
* fine. It says the check could not run — never that the key is wrong.
|
|
22
|
+
* - CONNECTED and UNVERIFIED stay quiet lines. Both describe a tool that
|
|
23
|
+
* needs nothing from anybody, and a warning on every untestable integration
|
|
24
|
+
* teaches people to ignore warnings.
|
|
25
|
+
*
|
|
26
|
+
* Nothing here is handed the submitted secret. The component sees a verdict
|
|
27
|
+
* and a transport message, neither of which the client composes from the value
|
|
28
|
+
* it sent — so there is no path by which a key reaches this text.
|
|
29
|
+
*/
|
|
30
|
+
export function SavedKeyProbeResult({
|
|
31
|
+
probe,
|
|
32
|
+
className,
|
|
33
|
+
}: {
|
|
34
|
+
probe: SavedKeyProbe;
|
|
35
|
+
className?: string;
|
|
36
|
+
}) {
|
|
37
|
+
const { result, checking } = probe;
|
|
38
|
+
|
|
39
|
+
// Only while there is nothing better to show. A re-test over an existing
|
|
40
|
+
// answer keeps the answer up and lets the row say it is checking again,
|
|
41
|
+
// rather than blanking to "Testing…" and looking like it forgot.
|
|
42
|
+
if (!result) {
|
|
43
|
+
return checking ? (
|
|
44
|
+
<p
|
|
45
|
+
className={cn('text-detail text-ink-faint', className)}
|
|
46
|
+
data-testid="saved-key-probe"
|
|
47
|
+
data-probe-state="checking"
|
|
48
|
+
>
|
|
49
|
+
Testing this key…
|
|
50
|
+
</p>
|
|
51
|
+
) : null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (result.kind === 'unreachable') {
|
|
55
|
+
return (
|
|
56
|
+
<Banner
|
|
57
|
+
tone="wait"
|
|
58
|
+
role="status"
|
|
59
|
+
className={className}
|
|
60
|
+
data-testid="saved-key-probe"
|
|
61
|
+
data-probe-state="unreachable"
|
|
62
|
+
>
|
|
63
|
+
<span className="font-semibold">{PROBE_UNREACHABLE_LEAD}</span>{' '}
|
|
64
|
+
<span>{result.message}</span>
|
|
65
|
+
</Banner>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const { tone, text, hint } = probeWords(result.verdict);
|
|
70
|
+
|
|
71
|
+
if (tone === 'err') {
|
|
72
|
+
return (
|
|
73
|
+
<Banner
|
|
74
|
+
tone="danger"
|
|
75
|
+
role="alert"
|
|
76
|
+
className={className}
|
|
77
|
+
data-testid="saved-key-probe"
|
|
78
|
+
data-probe-state="rejected"
|
|
79
|
+
>
|
|
80
|
+
<span className="font-semibold">{text}.</span> <span>{hint}</span>
|
|
81
|
+
</Banner>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<p
|
|
87
|
+
className={cn('text-detail text-ink-muted', className)}
|
|
88
|
+
data-testid="saved-key-probe"
|
|
89
|
+
data-probe-state={result.verdict.status === 'ok' ? 'connected' : 'unverified'}
|
|
90
|
+
>
|
|
91
|
+
{/* The word and the line behind it, both VISIBLE — not a tooltip. A row
|
|
92
|
+
that says "Unverified" and hides why has only moved the question. */}
|
|
93
|
+
<span className="font-semibold text-ink">{text}</span>
|
|
94
|
+
{' — '}
|
|
95
|
+
{hint}
|
|
96
|
+
</p>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { probeWords } from '../probe-verdict';
|
|
3
|
+
import { toolStatus } from '../../../library/utils/status';
|
|
4
|
+
import type { ProbeVerdict, ToolSecrets } from '../../services/tool-secrets.api';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One verdict, one sentence — wherever the key was typed.
|
|
8
|
+
*
|
|
9
|
+
* Three surfaces save tool credentials and all three now probe afterwards. The
|
|
10
|
+
* thing worth pinning is not that each renders SOMETHING, which their own
|
|
11
|
+
* tests cover, but that they render the SAME thing: a person who saves a wrong
|
|
12
|
+
* key on the Connect page and opens the tool page to fix it must meet one
|
|
13
|
+
* complaint about one rejection, not two sentences they have to reconcile.
|
|
14
|
+
*
|
|
15
|
+
* So the words live in one function and every surface reads it. These tests
|
|
16
|
+
* are what stops a well-meaning edit from giving one surface its own dialect.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const at = new Date().toISOString();
|
|
20
|
+
const verdict = (over: Partial<ProbeVerdict> = {}): ProbeVerdict => ({
|
|
21
|
+
status: 'ok',
|
|
22
|
+
detail: null,
|
|
23
|
+
checkedAt: at,
|
|
24
|
+
...over,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('probeWords', () => {
|
|
28
|
+
it('earns Connected from a passing probe, and says when it was checked', () => {
|
|
29
|
+
const w = probeWords(verdict({ status: 'ok' }));
|
|
30
|
+
expect(w.tone).toBe('ok');
|
|
31
|
+
expect(w.text).toBe('Connected');
|
|
32
|
+
// The evidence, not just the claim: "Connected" backed by nothing is the
|
|
33
|
+
// assumption this whole feature exists to remove.
|
|
34
|
+
expect(w.hint).toMatch(/^Checked /);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("quotes the provider's own words on a rejection, and goes loud", () => {
|
|
38
|
+
const w = probeWords(verdict({ status: 'failed', detail: '401 Unauthorized: bad token' }));
|
|
39
|
+
expect(w.tone).toBe('err');
|
|
40
|
+
expect(w.text).toBe('Not working');
|
|
41
|
+
expect(w.hint).toBe('401 Unauthorized: bad token');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('still names a reason when a rejection arrives without one', () => {
|
|
45
|
+
const w = probeWords(verdict({ status: 'failed', detail: null }));
|
|
46
|
+
expect(w.tone).toBe('err');
|
|
47
|
+
expect(w.hint).toBe('The provider rejected this credential.');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('says Unverified — quietly — when the probe reached no verdict', () => {
|
|
51
|
+
const w = probeWords(
|
|
52
|
+
verdict({
|
|
53
|
+
status: 'unverifiable',
|
|
54
|
+
detail: "This tool doesn't offer a way to test its connection.",
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
// Quiet on purpose. The key is saved and nobody has to act; painting every
|
|
58
|
+
// untestable integration amber teaches people that amber means nothing.
|
|
59
|
+
expect(w.tone).toBe('ok');
|
|
60
|
+
expect(w.text).toBe('Unverified');
|
|
61
|
+
expect(w.hint).toBe("This tool doesn't offer a way to test its connection.");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('still explains itself when an unverifiable verdict arrives without a reason', () => {
|
|
65
|
+
const w = probeWords(verdict({ status: 'unverifiable', detail: null }));
|
|
66
|
+
expect(w.text).toBe('Unverified');
|
|
67
|
+
expect(w.hint).not.toBe('');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A blank detail is an absent one. The backend can produce it without meaning
|
|
72
|
+
* to: redaction on a rejection body that was nothing but the credential
|
|
73
|
+
* leaves an empty string behind, and `??` would carry it through to a word
|
|
74
|
+
* with nothing under it — `Not working.` followed by silence, which is the
|
|
75
|
+
* evidence-free claim this file exists to prevent.
|
|
76
|
+
*/
|
|
77
|
+
it.each([
|
|
78
|
+
['failed' as const, 'The provider rejected this credential.'],
|
|
79
|
+
['unverifiable' as const, "This tool doesn't offer a way to test its connection."],
|
|
80
|
+
])('falls back to the reason when a %s detail is blank', (status, fallback) => {
|
|
81
|
+
for (const detail of ['', ' ']) {
|
|
82
|
+
expect(probeWords(verdict({ status, detail })).hint).toBe(fallback);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The tool page reaches these words through `toolStatus`, because its health
|
|
89
|
+
* line also has to weigh the tool's unset variables. Everything else reaches
|
|
90
|
+
* them through `probeWords` directly. Same verdict in, same words out.
|
|
91
|
+
*/
|
|
92
|
+
describe('the tool page and the rows agree, verdict for verdict', () => {
|
|
93
|
+
const settled: ToolSecrets = {
|
|
94
|
+
slug: 'github',
|
|
95
|
+
name: 'github',
|
|
96
|
+
path: 'Plugins/Engineering/github.tool',
|
|
97
|
+
type: 'mcp',
|
|
98
|
+
setup: null,
|
|
99
|
+
canWrite: false,
|
|
100
|
+
variables: [
|
|
101
|
+
{
|
|
102
|
+
name: 'API_KEY',
|
|
103
|
+
scope: 'user',
|
|
104
|
+
label: null,
|
|
105
|
+
key: 'github_API_KEY',
|
|
106
|
+
adminConfigured: true,
|
|
107
|
+
userConfigured: true,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const cases: ProbeVerdict[] = [
|
|
113
|
+
verdict({ status: 'ok' }),
|
|
114
|
+
verdict({ status: 'failed', detail: 'Invalid API key.' }),
|
|
115
|
+
verdict({ status: 'unverifiable', detail: 'Provider timed out.' }),
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
for (const v of cases) {
|
|
119
|
+
it(`says the same thing about a ${v.status} verdict`, () => {
|
|
120
|
+
const page = toolStatus(settled, v);
|
|
121
|
+
const row = probeWords(v);
|
|
122
|
+
expect(page.text).toBe(row.text);
|
|
123
|
+
expect(page.hint).toBe(row.hint);
|
|
124
|
+
expect(page.state).toBe(row.tone);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The one place they MUST differ: with nothing probed at all, the tool page
|
|
130
|
+
* can still say what is stored. `Unverified` would be wrong there — nobody
|
|
131
|
+
* asked, so there is nothing to be unverified about.
|
|
132
|
+
*/
|
|
133
|
+
it('parts company only where no probe has run', () => {
|
|
134
|
+
const page = toolStatus(settled);
|
|
135
|
+
expect(page.text).toBe('Key saved');
|
|
136
|
+
expect(page.state).toBe('ok');
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The secret is not an input to any of this.
|
|
142
|
+
*
|
|
143
|
+
* The strongest guarantee available is structural rather than a string search:
|
|
144
|
+
* `probeWords` takes the VERDICT alone, so no rendering built on it has the
|
|
145
|
+
* submitted value to leak. The surfaces' own tests then check the rendered
|
|
146
|
+
* document for the typed secret; this checks that the function cannot see one
|
|
147
|
+
* even when the provider's own words are doing their best to look like it.
|
|
148
|
+
*/
|
|
149
|
+
describe('the submitted secret has no route into the words', () => {
|
|
150
|
+
it('passes the provider detail through verbatim and invents nothing', () => {
|
|
151
|
+
const detail = 'The API key ending in 4242 was rejected.';
|
|
152
|
+
expect(probeWords(verdict({ status: 'failed', detail })).hint).toBe(detail);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('takes a verdict and nothing else', () => {
|
|
156
|
+
// One argument: there is no parameter through which a caller could hand it
|
|
157
|
+
// the value that was saved, by accident or otherwise.
|
|
158
|
+
expect(probeWords.length).toBe(1);
|
|
159
|
+
});
|
|
160
|
+
});
|