@bevel-software/platform-core-frontend 0.15.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +20 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +13 -3
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +532 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +141 -4
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +172 -46
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
1
|
+
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest';
|
|
2
2
|
import { act, render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
3
|
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
4
4
|
import type { ReactNode } from 'react';
|
|
5
|
+
import { buttonClasses, type ButtonSize } from '../../../shared/components';
|
|
5
6
|
import { AuthContext, type AuthContextValue } from '../../auth/state/auth.context';
|
|
6
7
|
import {
|
|
7
8
|
WorkspaceContext,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
} from '../../workspace/state/workspace.context';
|
|
10
11
|
import {
|
|
11
12
|
checkToolConnection,
|
|
13
|
+
deleteAdminVar,
|
|
12
14
|
setAdminVar,
|
|
13
15
|
type ProbeVerdict,
|
|
14
16
|
type ToolSecrets,
|
|
@@ -32,6 +34,7 @@ vi.mock('../../secrets-vault/services/connect.api', () => ({ startToolOAuth: vi.
|
|
|
32
34
|
vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
|
|
33
35
|
|
|
34
36
|
import { ToolConnectionSection } from '../components/tool-page/ToolConnectionSection';
|
|
37
|
+
import { TOOL_CREDENTIALS_STALE_EVENT } from '../../../core/events';
|
|
35
38
|
|
|
36
39
|
// `checkToolConnection` is one module-level mock shared by every test here.
|
|
37
40
|
// `resetAllMocks`, not `clearAllMocks`: clearing kept whatever implementation
|
|
@@ -214,78 +217,131 @@ describe('ToolConnectionSection', () => {
|
|
|
214
217
|
expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
|
|
215
218
|
});
|
|
216
219
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
expect(banner).toHaveTextContent('HeyReach API key: Needs a key from you');
|
|
246
|
-
expect(banner).not.toHaveTextContent('Needs your sign-in');
|
|
247
|
-
});
|
|
220
|
+
/**
|
|
221
|
+
* What used to be a banner listing every missing key above rows that already
|
|
222
|
+
* carried those keys. The rows kept the labels, the statuses and the buttons;
|
|
223
|
+
* what they gained is the colour, so "how many things does this need" is
|
|
224
|
+
* answered by counting amber rows instead of by a sentence that could drift
|
|
225
|
+
* out of step with them.
|
|
226
|
+
*/
|
|
227
|
+
describe('the unset rows', () => {
|
|
228
|
+
/** The row element for a variable, found by the label it renders. */
|
|
229
|
+
function row(label: string): HTMLElement {
|
|
230
|
+
const found = screen.getByText(label).closest('[data-testid="tool-var-row"]');
|
|
231
|
+
expect(found).not.toBeNull();
|
|
232
|
+
return found as HTMLElement;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Every row the section rendered, amber or not. */
|
|
236
|
+
const rows = () => screen.getAllByTestId('tool-var-row');
|
|
237
|
+
const amber = () => rows().filter((r) => r.className.split(' ').includes('bg-wait-soft'));
|
|
238
|
+
|
|
239
|
+
const userKey = (over: Partial<ToolSecrets['variables'][number]> = {}) => ({
|
|
240
|
+
name: 'API_KEY',
|
|
241
|
+
scope: 'user' as const,
|
|
242
|
+
label: 'HeyReach API key',
|
|
243
|
+
key: 'heyreach_API_KEY',
|
|
244
|
+
adminConfigured: false,
|
|
245
|
+
userConfigured: false,
|
|
246
|
+
...over,
|
|
247
|
+
});
|
|
248
248
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
tool({
|
|
252
|
-
variables: [
|
|
253
|
-
{
|
|
254
|
-
name: 'API_KEY',
|
|
255
|
-
scope: 'user',
|
|
256
|
-
label: 'HeyReach API key',
|
|
257
|
-
key: 'heyreach_API_KEY',
|
|
258
|
-
adminConfigured: false,
|
|
259
|
-
userConfigured: false,
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
}),
|
|
263
|
-
);
|
|
264
|
-
// Named by its label, not its env var — and it says whose move it is.
|
|
265
|
-
expect(screen.getByRole('status')).toHaveTextContent(
|
|
266
|
-
'HeyReach API key: Needs a key from you',
|
|
267
|
-
);
|
|
268
|
-
});
|
|
249
|
+
it('draws the one unset key amber, and says so without a banner', () => {
|
|
250
|
+
renderSection(tool({ variables: [userKey()] }));
|
|
269
251
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
252
|
+
expect(row('HeyReach API key')).toHaveClass('bg-wait-soft');
|
|
253
|
+
// The row still carries the action the banner used to duplicate.
|
|
254
|
+
expect(screen.getByRole('button', { name: 'Add key' })).toBeInTheDocument();
|
|
255
|
+
// And the sentence that named it is gone: nothing re-lists the row.
|
|
256
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
257
|
+
expect(screen.queryByText(/This tool is not connected yet/)).toBeNull();
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('draws several unset keys amber and leaves the set one alone', () => {
|
|
261
|
+
renderSection(
|
|
262
|
+
tool({
|
|
263
|
+
canWrite: true,
|
|
264
|
+
variables: [
|
|
265
|
+
userKey(),
|
|
266
|
+
userKey({ name: 'STORED', label: 'Stored key', userConfigured: true }),
|
|
267
|
+
{
|
|
268
|
+
name: 'TEAM_KEY',
|
|
269
|
+
scope: 'admin',
|
|
270
|
+
label: 'Team key',
|
|
271
|
+
key: 'heyreach_TEAM_KEY',
|
|
272
|
+
adminConfigured: false,
|
|
273
|
+
userConfigured: false,
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
}),
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
// The count the banner used to state in prose IS the number of amber
|
|
280
|
+
// rows — the two that need a key, and not the one that has one.
|
|
281
|
+
expect(amber()).toHaveLength(2);
|
|
282
|
+
expect(row('HeyReach API key')).toHaveClass('bg-wait-soft');
|
|
283
|
+
expect(row('Team key')).toHaveClass('bg-wait-soft');
|
|
284
|
+
expect(row('Stored key')).not.toHaveClass('bg-wait-soft');
|
|
285
|
+
expect(screen.getByRole('button', { name: 'Add key' })).toBeInTheDocument();
|
|
286
|
+
expect(screen.getByRole('button', { name: 'Set key' })).toBeInTheDocument();
|
|
287
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('leaves every row in the normal tone when nothing is unset', () => {
|
|
291
|
+
renderSection(
|
|
292
|
+
tool({
|
|
293
|
+
variables: [
|
|
294
|
+
userKey({ userConfigured: true }),
|
|
295
|
+
userKey({ name: 'STORED', label: 'Stored key', userConfigured: true }),
|
|
296
|
+
],
|
|
297
|
+
}),
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
expect(rows()).toHaveLength(2);
|
|
301
|
+
expect(amber()).toEqual([]);
|
|
302
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('tells a screen reader what the colour says, and only on the unset row', () => {
|
|
306
|
+
renderSection(
|
|
307
|
+
tool({
|
|
308
|
+
variables: [userKey(), userKey({ name: 'STORED', label: 'Stored key', userConfigured: true })],
|
|
309
|
+
}),
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
// The information the amber carries, in words: the row is required and
|
|
313
|
+
// has nothing in it. One row has it; the set row says nothing extra.
|
|
314
|
+
expect(screen.getAllByText('Required, not set')).toHaveLength(1);
|
|
315
|
+
expect(row('HeyReach API key')).toHaveTextContent('Required, not set');
|
|
316
|
+
expect(row('Stored key')).not.toHaveTextContent('Required, not set');
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('leaves a pending sign-in in the normal tone: it is a step, not a gap', () => {
|
|
320
|
+
// `adminConfigured` on an OAuth variable means the OWNER finished the
|
|
321
|
+
// provider setup, so nothing about this tool is unconfigured. Signing in
|
|
322
|
+
// is a step each person takes, and the row already offers the button —
|
|
323
|
+
// exactly the distinction the banner drew, kept now in the tone.
|
|
324
|
+
renderSection(
|
|
325
|
+
tool({
|
|
326
|
+
variables: [
|
|
327
|
+
{
|
|
328
|
+
name: 'SIGNIN',
|
|
329
|
+
scope: 'user',
|
|
330
|
+
label: 'Sign-in',
|
|
331
|
+
key: 'heyreach_SIGNIN',
|
|
332
|
+
adminConfigured: true,
|
|
333
|
+
userConfigured: false,
|
|
334
|
+
oauth: true,
|
|
335
|
+
authorized: false,
|
|
336
|
+
},
|
|
337
|
+
],
|
|
338
|
+
}),
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
expect(amber()).toEqual([]);
|
|
342
|
+
expect(screen.queryByText('Required, not set')).toBeNull();
|
|
343
|
+
expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
|
|
344
|
+
});
|
|
289
345
|
});
|
|
290
346
|
|
|
291
347
|
it('says nothing when every variable is set', () => {
|
|
@@ -495,4 +551,459 @@ describe('ToolConnectionSection', () => {
|
|
|
495
551
|
expect(screen.queryByTestId('tool-health')).toBeNull();
|
|
496
552
|
});
|
|
497
553
|
});
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* The same three answers, reached the way a person actually reaches them:
|
|
557
|
+
* by SAVING a key, not by pressing Test.
|
|
558
|
+
*
|
|
559
|
+
* The Test button is the deliberate act of someone who already suspects
|
|
560
|
+
* something. The save is the moment that matters — the key is still in the
|
|
561
|
+
* clipboard, the person is still here, and a wrong one costs a retype
|
|
562
|
+
* instead of a debugging session next Tuesday. This surface has probed on
|
|
563
|
+
* save for a while; these tests exist so it keeps doing it while the
|
|
564
|
+
* lifecycle moves into `useSavedKeyProbe`, shared now with the Connect page
|
|
565
|
+
* and the vault.
|
|
566
|
+
*/
|
|
567
|
+
describe('after a save', () => {
|
|
568
|
+
/** Already connected, so replacing the key leaves the health line up. */
|
|
569
|
+
const replaceable = () =>
|
|
570
|
+
tool({
|
|
571
|
+
canWrite: true,
|
|
572
|
+
variables: [
|
|
573
|
+
{
|
|
574
|
+
name: 'API_KEY',
|
|
575
|
+
scope: 'admin',
|
|
576
|
+
label: null,
|
|
577
|
+
key: 'github_API_KEY',
|
|
578
|
+
adminConfigured: true,
|
|
579
|
+
userConfigured: false,
|
|
580
|
+
},
|
|
581
|
+
],
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
/** Type a new value into the row's editor and save it. */
|
|
585
|
+
const saveKey = (secret = 'k') => {
|
|
586
|
+
fireEvent.click(screen.getByRole('button', { name: 'Replace' }));
|
|
587
|
+
fireEvent.change(screen.getByLabelText('Value for API_KEY'), { target: { value: secret } });
|
|
588
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
it('shows the quiet connected state when the provider accepts the key', async () => {
|
|
592
|
+
vi.mocked(setAdminVar).mockResolvedValue(undefined);
|
|
593
|
+
vi.mocked(checkToolConnection).mockResolvedValue({
|
|
594
|
+
status: 'ok',
|
|
595
|
+
detail: null,
|
|
596
|
+
checkedAt: new Date().toISOString(),
|
|
597
|
+
});
|
|
598
|
+
renderSection(replaceable());
|
|
599
|
+
|
|
600
|
+
saveKey();
|
|
601
|
+
|
|
602
|
+
await waitFor(() => expect(screen.getByTestId('tool-health')).toHaveTextContent('Connected'));
|
|
603
|
+
// Quiet means quiet: a working tool needs nobody, so nothing shouts.
|
|
604
|
+
expect(screen.queryByRole('alert')).toBeNull();
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
it("shows the provider's own status text when it rejects the key", async () => {
|
|
608
|
+
vi.mocked(setAdminVar).mockResolvedValue(undefined);
|
|
609
|
+
vi.mocked(checkToolConnection).mockResolvedValue({
|
|
610
|
+
status: 'failed',
|
|
611
|
+
detail: '401 Unauthorized: bad credentials',
|
|
612
|
+
checkedAt: new Date().toISOString(),
|
|
613
|
+
});
|
|
614
|
+
renderSection(replaceable());
|
|
615
|
+
|
|
616
|
+
saveKey();
|
|
617
|
+
|
|
618
|
+
await waitFor(() =>
|
|
619
|
+
expect(screen.getByTestId('tool-health-failed')).toHaveTextContent(
|
|
620
|
+
'401 Unauthorized: bad credentials',
|
|
621
|
+
),
|
|
622
|
+
);
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
it('says Unverified, and why, when the manual defines no health check', async () => {
|
|
626
|
+
vi.mocked(setAdminVar).mockResolvedValue(undefined);
|
|
627
|
+
vi.mocked(checkToolConnection).mockResolvedValue({
|
|
628
|
+
status: 'unverifiable',
|
|
629
|
+
detail: "This tool doesn't offer a way to test its connection.",
|
|
630
|
+
checkedAt: new Date().toISOString(),
|
|
631
|
+
});
|
|
632
|
+
renderSection(replaceable());
|
|
633
|
+
|
|
634
|
+
saveKey();
|
|
635
|
+
|
|
636
|
+
// Not "Key saved": a probe RAN. Saying only what was stored would report
|
|
637
|
+
// the wrong event — the question was put to the provider and came back
|
|
638
|
+
// unanswerable, which is a different thing to not having asked.
|
|
639
|
+
await waitFor(() =>
|
|
640
|
+
expect(screen.getByTestId('tool-health')).toHaveTextContent('Unverified'),
|
|
641
|
+
);
|
|
642
|
+
// And the reason is on the page, not only in a tooltip: a title attribute
|
|
643
|
+
// is unreachable on a touch screen and to a screen reader, so a word that
|
|
644
|
+
// hides its reason there has only moved the question.
|
|
645
|
+
expect(screen.getByTestId('tool-health-unverified')).toHaveTextContent(
|
|
646
|
+
"This tool doesn't offer a way to test its connection.",
|
|
647
|
+
);
|
|
648
|
+
// Nothing needs a person, so nothing is raised.
|
|
649
|
+
expect(screen.queryByRole('alert')).toBeNull();
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
it('stores the value first: a probe that never answers never blocks the save', async () => {
|
|
653
|
+
// The store is held OPEN, so the order is observable rather than merely
|
|
654
|
+
// plausible. Asserting only that both happened would pass just as well
|
|
655
|
+
// if the probe ran first — and a probe that runs before the store
|
|
656
|
+
// completes asks the provider about the key being replaced, which is the
|
|
657
|
+
// confident stale answer this whole feature exists to remove.
|
|
658
|
+
let releaseStore = () => {};
|
|
659
|
+
let stored = false;
|
|
660
|
+
vi.mocked(setAdminVar).mockImplementation(
|
|
661
|
+
() =>
|
|
662
|
+
new Promise<void>((resolve) => {
|
|
663
|
+
releaseStore = () => {
|
|
664
|
+
stored = true;
|
|
665
|
+
resolve();
|
|
666
|
+
};
|
|
667
|
+
}),
|
|
668
|
+
);
|
|
669
|
+
vi.mocked(checkToolConnection).mockReturnValue(new Promise<ProbeVerdict>(() => {}));
|
|
670
|
+
renderSection(replaceable());
|
|
671
|
+
|
|
672
|
+
saveKey();
|
|
673
|
+
|
|
674
|
+
// While the write is in flight: nothing has been asked of the provider,
|
|
675
|
+
// and the editor is still open because the save has not landed.
|
|
676
|
+
await waitFor(() => expect(setAdminVar).toHaveBeenCalledTimes(1));
|
|
677
|
+
expect(checkToolConnection).not.toHaveBeenCalled();
|
|
678
|
+
expect(screen.getByLabelText('Value for API_KEY')).toBeInTheDocument();
|
|
679
|
+
|
|
680
|
+
// Inside `act`, like the definition-edit race test above: resolving the
|
|
681
|
+
// held promise runs the save handler's continuation — `close`,
|
|
682
|
+
// `onChanged`, `onSaved` — and every one of those is a React state
|
|
683
|
+
// update. Outside an act window they warn and, worse for an ORDERING
|
|
684
|
+
// test, the assertions below could read a render that has not flushed.
|
|
685
|
+
await act(async () => {
|
|
686
|
+
releaseStore();
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
// Only now, and the editor closes with the value gone from the DOM while
|
|
690
|
+
// the probe is still hanging — the save is complete on its own terms.
|
|
691
|
+
await waitFor(() => expect(checkToolConnection).toHaveBeenCalledTimes(1));
|
|
692
|
+
await waitFor(() => expect(screen.queryByLabelText('Value for API_KEY')).toBeNull());
|
|
693
|
+
expect(stored).toBe(true);
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
it('never repeats the submitted secret, whatever the probe says', async () => {
|
|
697
|
+
const secret = 'sk-live-DO-NOT-ECHO-4242';
|
|
698
|
+
vi.mocked(setAdminVar).mockResolvedValue(undefined);
|
|
699
|
+
// The worst case for a leak: a rejection whose detail quotes the request
|
|
700
|
+
// back. The server composes `detail` from the provider's status line, and
|
|
701
|
+
// nothing on this side ever joins the value to it.
|
|
702
|
+
vi.mocked(checkToolConnection).mockResolvedValue({
|
|
703
|
+
status: 'failed',
|
|
704
|
+
detail: 'The API key you supplied was rejected.',
|
|
705
|
+
checkedAt: new Date().toISOString(),
|
|
706
|
+
});
|
|
707
|
+
const { container } = renderSection(replaceable());
|
|
708
|
+
|
|
709
|
+
saveKey(secret);
|
|
710
|
+
|
|
711
|
+
await waitFor(() => expect(screen.getByTestId('tool-health-failed')).toBeInTheDocument());
|
|
712
|
+
expect(container.textContent).not.toContain(secret);
|
|
713
|
+
// Nor left sitting in the write-only field for the next person at the desk.
|
|
714
|
+
expect(container.innerHTML).not.toContain(secret);
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* What this section owes the REST of the app.
|
|
720
|
+
*
|
|
721
|
+
* The stale-status bug never showed here: a save re-probes, so the page the
|
|
722
|
+
* key was typed on was always right. It showed one click later, on the
|
|
723
|
+
* plugin page and the cards, which read a catalog loaded before the write.
|
|
724
|
+
* So the thing worth pinning is the announcement, not the local repaint.
|
|
725
|
+
*/
|
|
726
|
+
describe('announcing a landed credential', () => {
|
|
727
|
+
const heard = vi.fn();
|
|
728
|
+
beforeEach(() => {
|
|
729
|
+
heard.mockReset();
|
|
730
|
+
window.addEventListener(TOOL_CREDENTIALS_STALE_EVENT, heard);
|
|
731
|
+
});
|
|
732
|
+
afterEach(() => window.removeEventListener(TOOL_CREDENTIALS_STALE_EVENT, heard));
|
|
733
|
+
|
|
734
|
+
/** One admin key a writer can set, replace and remove. */
|
|
735
|
+
const withKey = (adminConfigured: boolean) =>
|
|
736
|
+
tool({
|
|
737
|
+
canWrite: true,
|
|
738
|
+
variables: [
|
|
739
|
+
{
|
|
740
|
+
name: 'API_KEY',
|
|
741
|
+
scope: 'admin',
|
|
742
|
+
label: null,
|
|
743
|
+
key: 'github_API_KEY',
|
|
744
|
+
adminConfigured,
|
|
745
|
+
userConfigured: false,
|
|
746
|
+
},
|
|
747
|
+
],
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
it('announces a save without waiting for the probe to answer', async () => {
|
|
751
|
+
// The catalog's answer does not depend on whether the provider likes the
|
|
752
|
+
// key, so making the reload wait on a round-trip nobody is watching only
|
|
753
|
+
// keeps the plugin page stale for longer.
|
|
754
|
+
vi.mocked(setAdminVar).mockResolvedValue(undefined);
|
|
755
|
+
vi.mocked(checkToolConnection).mockReturnValue(new Promise<ProbeVerdict>(() => {}));
|
|
756
|
+
renderSection(withKey(false));
|
|
757
|
+
|
|
758
|
+
fireEvent.click(screen.getByRole('button', { name: 'Set key' }));
|
|
759
|
+
fireEvent.change(screen.getByLabelText('Value for API_KEY'), { target: { value: 'k' } });
|
|
760
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
761
|
+
|
|
762
|
+
// The probe is started and will never answer, so an announcement that
|
|
763
|
+
// arrives at all is one that did not wait for a verdict.
|
|
764
|
+
await waitFor(() => expect(heard).toHaveBeenCalledTimes(1));
|
|
765
|
+
expect(checkToolConnection).toHaveBeenCalledTimes(1);
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
it('announces a removal, which starts no probe of its own', async () => {
|
|
769
|
+
vi.mocked(deleteAdminVar).mockResolvedValue(undefined);
|
|
770
|
+
renderSection(withKey(true));
|
|
771
|
+
|
|
772
|
+
fireEvent.click(screen.getByRole('button', { name: 'Remove' }));
|
|
773
|
+
|
|
774
|
+
await waitFor(() => expect(heard).toHaveBeenCalledTimes(1));
|
|
775
|
+
expect(checkToolConnection).not.toHaveBeenCalled();
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
it('announces nothing when the save fails', async () => {
|
|
779
|
+
// A failed save changed nothing. Reloading on it would blink every card
|
|
780
|
+
// in the Library for no reason — and teach the reader that the blink
|
|
781
|
+
// means something landed.
|
|
782
|
+
vi.mocked(setAdminVar).mockRejectedValue(new Error('Nope.'));
|
|
783
|
+
const onError = vi.fn();
|
|
784
|
+
render(
|
|
785
|
+
wrap(
|
|
786
|
+
<ToolConnectionSection
|
|
787
|
+
tool={withKey(false)}
|
|
788
|
+
configRevision={0}
|
|
789
|
+
onChanged={vi.fn()}
|
|
790
|
+
onError={onError}
|
|
791
|
+
/>,
|
|
792
|
+
),
|
|
793
|
+
);
|
|
794
|
+
|
|
795
|
+
fireEvent.click(screen.getByRole('button', { name: 'Set key' }));
|
|
796
|
+
fireEvent.change(screen.getByLabelText('Value for API_KEY'), { target: { value: 'k' } });
|
|
797
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
798
|
+
|
|
799
|
+
await waitFor(() => expect(onError).toHaveBeenCalledWith('Nope.'));
|
|
800
|
+
expect(heard).not.toHaveBeenCalled();
|
|
801
|
+
});
|
|
802
|
+
});
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* One size for every action in the section.
|
|
806
|
+
*
|
|
807
|
+
* The heights used to disagree: Set key was `sm` while Test connection,
|
|
808
|
+
* Remove and Sign in beside it were `tiny`, so a single row read as three
|
|
809
|
+
* unrelated controls. Edit server and Save set the size and everything here
|
|
810
|
+
* follows them.
|
|
811
|
+
*
|
|
812
|
+
* Asserted through the size TOKENS `buttonClasses` emits rather than a
|
|
813
|
+
* literal class string, so moving the padding scale moves this test with it
|
|
814
|
+
* instead of leaving it asserting a size nothing renders any more. The
|
|
815
|
+
* `px-*` token differs between quiet and solid buttons; what every button of
|
|
816
|
+
* a size shares is its vertical padding and its type scale — which is
|
|
817
|
+
* precisely what a row's height is made of.
|
|
818
|
+
*/
|
|
819
|
+
describe('one size', () => {
|
|
820
|
+
function sizeTokens(size: ButtonSize): string[] {
|
|
821
|
+
const solid = buttonClasses({ variant: 'outline', size }).split(' ');
|
|
822
|
+
const quiet = new Set(buttonClasses({ variant: 'quiet', size }).split(' '));
|
|
823
|
+
// `md` carries everything that is NOT size-specific — the frame, the
|
|
824
|
+
// focus ring, the variant's colours — so subtracting it leaves the size.
|
|
825
|
+
const sizeless = new Set(buttonClasses({ variant: 'outline', size: 'md' }).split(' '));
|
|
826
|
+
return solid.filter((c) => quiet.has(c) && !sizeless.has(c));
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
const SMALL = sizeTokens('sm');
|
|
830
|
+
const TINY = sizeTokens('tiny');
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* What the section offers as an action: every <button>, plus the links
|
|
834
|
+
* that are DRESSED as buttons. A link only counts when it carries the
|
|
835
|
+
* frame every button shares — `buttonClasses` is what turns Open Secrets
|
|
836
|
+
* into a button to the eye — so a plain link written into the banner's
|
|
837
|
+
* prose one day stays prose, and this test keeps its opinion to the
|
|
838
|
+
* controls it is about.
|
|
839
|
+
*/
|
|
840
|
+
const FRAME = (() => {
|
|
841
|
+
const md = new Set(buttonClasses({ variant: 'outline', size: 'md' }).split(' '));
|
|
842
|
+
// Different variant AND different size, so what survives is neither.
|
|
843
|
+
return buttonClasses({ variant: 'quiet', size: 'tiny' })
|
|
844
|
+
.split(' ')
|
|
845
|
+
.filter((c) => md.has(c));
|
|
846
|
+
})();
|
|
847
|
+
|
|
848
|
+
/** Every action the section is currently offering. */
|
|
849
|
+
function actions(): HTMLElement[] {
|
|
850
|
+
return [
|
|
851
|
+
...screen.queryAllByRole('button'),
|
|
852
|
+
...screen
|
|
853
|
+
.queryAllByRole('link')
|
|
854
|
+
.filter((el) => FRAME.every((c) => el.className.split(' ').includes(c))),
|
|
855
|
+
];
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* What those actions call themselves. Size alone cannot hold a case
|
|
860
|
+
* honest: `notSmall()` reads nothing into a control that is absent, and
|
|
861
|
+
* every fixture below carries Open Secrets — a link that is always small —
|
|
862
|
+
* so a branch that stopped rendering its action entirely would leave
|
|
863
|
+
* `notSmall()` just as empty as one that sized it correctly. Each case
|
|
864
|
+
* names the actions it expects first, and the size assertion then speaks
|
|
865
|
+
* about a cast already known to be complete.
|
|
866
|
+
*/
|
|
867
|
+
function actionNames(): string[] {
|
|
868
|
+
return actions()
|
|
869
|
+
.map(
|
|
870
|
+
(el) =>
|
|
871
|
+
el.getAttribute('aria-label') ?? (el.textContent ?? '').replace(/\s+/g, ' ').trim(),
|
|
872
|
+
)
|
|
873
|
+
.sort();
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* Every action on screen that is NOT small, named by what it reads as —
|
|
878
|
+
* so a failure says which control drifted rather than only how many did.
|
|
879
|
+
*/
|
|
880
|
+
function notSmall(): string[] {
|
|
881
|
+
return actions()
|
|
882
|
+
.filter((el) => {
|
|
883
|
+
const classes = el.className.split(' ');
|
|
884
|
+
return !SMALL.every((c) => classes.includes(c)) || TINY.some((c) => classes.includes(c));
|
|
885
|
+
})
|
|
886
|
+
.map((el) => `${el.textContent} — ${el.className}`);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
it('distinguishes the two sizes it is asserting on', () => {
|
|
890
|
+
// Guards the derivation itself: were `sizeTokens` to come back empty, or
|
|
891
|
+
// the two sizes to share every token, `notSmall` would be vacuous and
|
|
892
|
+
// every case below would pass against tiny buttons.
|
|
893
|
+
expect(SMALL.length).toBeGreaterThan(0);
|
|
894
|
+
expect(SMALL.filter((c) => TINY.includes(c))).toEqual([]);
|
|
895
|
+
// And that the frame is a real filter: an empty one would wave every
|
|
896
|
+
// link through as an action, which is the opposite of what it is for.
|
|
897
|
+
expect(FRAME.length).toBeGreaterThan(0);
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
it('holds the one action that is a link to the same size', () => {
|
|
901
|
+
// Named on its own because it is the case the frame test above protects:
|
|
902
|
+
// Open Secrets is a <Link>, not a <Button>, and it is the control most
|
|
903
|
+
// easily left behind when the buttons beside it move.
|
|
904
|
+
renderSection(tool());
|
|
905
|
+
const link = screen.getByRole('link', { name: 'Open Secrets' });
|
|
906
|
+
expect(SMALL.every((c) => link.className.split(' ').includes(c))).toBe(true);
|
|
907
|
+
expect(actionNames()).toEqual(['Open Secrets', 'Test connection: github'].sort());
|
|
908
|
+
expect(notSmall()).toEqual([]);
|
|
909
|
+
});
|
|
910
|
+
|
|
911
|
+
type Var = ToolSecrets['variables'][number];
|
|
912
|
+
|
|
913
|
+
const signIn = (over: Partial<Var> = {}): Var => ({
|
|
914
|
+
name: 'SIGNIN',
|
|
915
|
+
scope: 'user',
|
|
916
|
+
label: null,
|
|
917
|
+
key: 'github_SIGNIN',
|
|
918
|
+
adminConfigured: true,
|
|
919
|
+
userConfigured: false,
|
|
920
|
+
oauth: true,
|
|
921
|
+
authorized: false,
|
|
922
|
+
...over,
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
const sharedKey = (over: Partial<Var> = {}): Var => ({
|
|
926
|
+
name: 'API_KEY',
|
|
927
|
+
scope: 'admin',
|
|
928
|
+
label: null,
|
|
929
|
+
key: 'github_API_KEY',
|
|
930
|
+
adminConfigured: true,
|
|
931
|
+
userConfigured: false,
|
|
932
|
+
...over,
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
// Between them these cover every button the section can render: the header
|
|
936
|
+
// pair and each branch of the row matrix.
|
|
937
|
+
it.each<[string, ToolSecrets, string[]]>([
|
|
938
|
+
[
|
|
939
|
+
'a settled tool an owner is looking at',
|
|
940
|
+
tool({
|
|
941
|
+
setup: { kind: 'oauth-manual' },
|
|
942
|
+
canWrite: true,
|
|
943
|
+
variables: [signIn({ authorized: true }), sharedKey()],
|
|
944
|
+
}),
|
|
945
|
+
[
|
|
946
|
+
'Test connection: github',
|
|
947
|
+
'Open Secrets',
|
|
948
|
+
'Reconnect',
|
|
949
|
+
'Replace client secret',
|
|
950
|
+
'Replace',
|
|
951
|
+
'Remove',
|
|
952
|
+
],
|
|
953
|
+
],
|
|
954
|
+
[
|
|
955
|
+
'a tool still waiting on its keys',
|
|
956
|
+
tool({
|
|
957
|
+
canWrite: true,
|
|
958
|
+
variables: [
|
|
959
|
+
sharedKey({ adminConfigured: false }),
|
|
960
|
+
{
|
|
961
|
+
name: 'MY_KEY',
|
|
962
|
+
scope: 'user',
|
|
963
|
+
label: null,
|
|
964
|
+
key: 'github_MY_KEY',
|
|
965
|
+
adminConfigured: false,
|
|
966
|
+
userConfigured: false,
|
|
967
|
+
},
|
|
968
|
+
],
|
|
969
|
+
}),
|
|
970
|
+
// One action per row and nothing above them: the banner that used to
|
|
971
|
+
// carry a duplicate Set key is gone, so the rows are the only offer.
|
|
972
|
+
['Open Secrets', 'Set key', 'Add key'],
|
|
973
|
+
],
|
|
974
|
+
['a sign-in nobody has done yet', tool({ variables: [signIn()] }), ['Open Secrets', 'Sign in']],
|
|
975
|
+
[
|
|
976
|
+
'a sign-in that has to be done again',
|
|
977
|
+
tool({ variables: [signIn({ authorized: true, needsReauth: true })] }),
|
|
978
|
+
['Open Secrets', 'Sign in again'],
|
|
979
|
+
],
|
|
980
|
+
[
|
|
981
|
+
'an oauth-manual setup the owner has not started',
|
|
982
|
+
tool({ setup: OAUTH_MANUAL, canWrite: true }),
|
|
983
|
+
['Open Secrets', 'Edit the tool file'],
|
|
984
|
+
],
|
|
985
|
+
[
|
|
986
|
+
'a declared sign-in still missing its client secret',
|
|
987
|
+
tool({ setup: OAUTH_MANUAL, canWrite: true, variables: [signIn({ adminConfigured: false })] }),
|
|
988
|
+
['Open Secrets', 'Set client secret'],
|
|
989
|
+
],
|
|
990
|
+
])('sizes every action small on %s', (_name, t, expected) => {
|
|
991
|
+
renderSection(t);
|
|
992
|
+
expect(actionNames()).toEqual([...expected].sort());
|
|
993
|
+
expect(notSmall()).toEqual([]);
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
it("sizes the row editor's Save and Cancel like the row that opened it", () => {
|
|
997
|
+
renderSection(tool({ canWrite: true, variables: [sharedKey()] }));
|
|
998
|
+
fireEvent.click(screen.getByRole('button', { name: 'Replace' }));
|
|
999
|
+
expect(screen.getByLabelText('Value for API_KEY')).toBeInTheDocument();
|
|
1000
|
+
// The row keeps its own actions while the editor is open, so Save and
|
|
1001
|
+
// Cancel are joining a row rather than replacing it — which is exactly
|
|
1002
|
+
// why they have to match the height of what they stand next to.
|
|
1003
|
+
expect(actionNames()).toEqual(
|
|
1004
|
+
['Test connection: github', 'Open Secrets', 'Replace', 'Remove', 'Save', 'Cancel'].sort(),
|
|
1005
|
+
);
|
|
1006
|
+
expect(notSmall()).toEqual([]);
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
498
1009
|
});
|