@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
|
@@ -1,760 +1,853 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { render, renderHook, screen, cleanup, waitFor } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
5
|
-
import { AuthContext } from '../../auth/state/auth.context';
|
|
6
|
-
import { authValue } from '../../library/__tests__/auth-harness';
|
|
7
|
-
import { LibraryToastProvider } from '../../library/state/toast';
|
|
8
|
-
import { WelcomePage } from '../components/WelcomePage';
|
|
9
|
-
import { AppRegistryContext, EMPTY_REGISTRY } from '../../../core/registry';
|
|
10
|
-
import { ConnectAgentPill } from '../components/ConnectAgentPill';
|
|
11
|
-
import { RootLanding } from '../components/RootLanding';
|
|
12
|
-
import { POST_LOGIN_REDIRECT_KEY } from '../../auth/services/sso';
|
|
13
|
-
import { WELCOME_PATH } from '../paths';
|
|
14
|
-
import { resetOnboardingForTests } from '../state/onboarding';
|
|
15
|
-
import { configureMcpUrl } from '../../../shared/mcp';
|
|
16
|
-
import { setSidebarCollapsed, useSidebar } from '../../layout/state/sidebar';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The onboarding contract, end to end on the client:
|
|
20
|
-
*
|
|
21
|
-
* - `/` redirects to the welcome page ONCE, on an account the server says is
|
|
22
|
-
* not onboarded — and never hijacks anything after that first greeting.
|
|
23
|
-
* - the pill outlives the redirect: it stays until × or Done, exactly two.
|
|
24
|
-
* - Done concludes (server write + navigation); the skip link and the copy
|
|
25
|
-
* button conclude NOTHING — leaving and copying are not promises.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
// No parameters: the mock never reads its arguments, and `vi.fn` records every
|
|
29
|
-
// call regardless of the implementation's signature — so the call assertions
|
|
30
|
-
// below keep working while lint stays clean.
|
|
31
|
-
const { authFetchMock } = vi.hoisted(() => ({
|
|
32
|
-
authFetchMock: vi.fn(async () => ({ ok: true, status: 200 }) as Response),
|
|
33
|
-
}));
|
|
34
|
-
vi.mock('../../../lib/api', () => ({ authFetch: authFetchMock }));
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The `RequestInit` of a recorded `authFetch` call.
|
|
38
|
-
*
|
|
39
|
-
* The mock declares no parameters — deliberately, so lint stays clean — which
|
|
40
|
-
* leaves `mock.calls` typed as an empty tuple even though the calls really do
|
|
41
|
-
* carry two arguments. Naming that gap ONCE, here, is better than a cast at
|
|
42
|
-
* every assertion that wants to read a request body.
|
|
43
|
-
*/
|
|
44
|
-
function fetchInit(call = 0): RequestInit | undefined {
|
|
45
|
-
return (authFetchMock.mock.calls[call] as unknown as [string, RequestInit] | undefined)?.[1];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** A user the server considers NOT onboarded (the explicit false matters). */
|
|
49
|
-
const newUser = () => authValue({ user: { id: 'u1', email: 'juan@bevel.software', name: 'Juan Viera', onboardingDone: false } });
|
|
50
|
-
/** The same account after the server has recorded the onboarding as done. */
|
|
51
|
-
const doneUser = () => authValue({ user: { id: 'u1', email: 'juan@bevel.software', name: 'Juan Viera', onboardingDone: true } });
|
|
52
|
-
|
|
53
|
-
/** Reads the sidebar store the way a component would. */
|
|
54
|
-
function sidebarState() {
|
|
55
|
-
return renderHook(() => useSidebar()).result.current;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Where we are, whether we got here by being greeted, and any carried link. */
|
|
59
|
-
function LocationProbe() {
|
|
60
|
-
const { pathname, state } = useLocation();
|
|
61
|
-
const s = state as { greeting?: boolean; returnTo?: string | null } | null;
|
|
62
|
-
return (
|
|
63
|
-
<>
|
|
64
|
-
<div data-testid="pathname">{pathname}</div>
|
|
65
|
-
<div data-testid="greeting">{String(s?.greeting === true)}</div>
|
|
66
|
-
<div data-testid="returnTo">{s?.returnTo ?? ''}</div>
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** The welcome page as the first-sign-in redirect leaves it: greeted. */
|
|
72
|
-
const greeted = { pathname: WELCOME_PATH, state: { greeting: true } };
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Render `ui` inside the three contexts the onboarding actually reads — a
|
|
76
|
-
* router at `route`, an auth context holding `auth`, and the toast provider —
|
|
77
|
-
* plus the location probe every redirect assertion below looks at. `route`
|
|
78
|
-
* takes a location object when a test needs to arrive as the greeting does.
|
|
79
|
-
*/
|
|
80
|
-
function mount(
|
|
81
|
-
ui: React.ReactNode,
|
|
82
|
-
auth = newUser(),
|
|
83
|
-
route: string | { pathname: string; state?: unknown } = '/',
|
|
84
|
-
) {
|
|
85
|
-
return render(
|
|
86
|
-
<MemoryRouter initialEntries={[route]}>
|
|
87
|
-
<AuthContext.Provider value={auth}>
|
|
88
|
-
<LibraryToastProvider>
|
|
89
|
-
{ui}
|
|
90
|
-
<LocationProbe />
|
|
91
|
-
</LibraryToastProvider>
|
|
92
|
-
</AuthContext.Provider>
|
|
93
|
-
</MemoryRouter>,
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const landingRoutes = (
|
|
98
|
-
<Routes>
|
|
99
|
-
<Route path="/" element={<RootLanding />} />
|
|
100
|
-
<Route path={WELCOME_PATH} element={<div>welcome page</div>} />
|
|
101
|
-
<Route path="/workspace" element={<div>knowledge</div>} />
|
|
102
|
-
</Routes>
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
beforeEach(() => {
|
|
106
|
-
resetOnboardingForTests();
|
|
107
|
-
authFetchMock.mockClear();
|
|
108
|
-
sessionStorage.clear();
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* jsdom ships no `navigator.clipboard`, so a copy test has to install one —
|
|
113
|
-
* but only THAT property, never a replacement `navigator`: the rest of the
|
|
114
|
-
* object (`userAgent`, `language`, whatever a library reaches for next) has no
|
|
115
|
-
* business changing because one test wanted a spy.
|
|
116
|
-
*/
|
|
117
|
-
let restoreClipboard: (() => void) | null = null;
|
|
118
|
-
|
|
119
|
-
function stubClipboard() {
|
|
120
|
-
const writeText = vi.fn().mockResolvedValue(undefined);
|
|
121
|
-
const original = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
|
|
122
|
-
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
|
|
123
|
-
restoreClipboard = () => {
|
|
124
|
-
if (original) Object.defineProperty(navigator, 'clipboard', original);
|
|
125
|
-
else Reflect.deleteProperty(navigator, 'clipboard');
|
|
126
|
-
};
|
|
127
|
-
return writeText;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// In a hook, not at the end of a test body: a failing assertion would otherwise
|
|
131
|
-
// leave the stub installed for every test after it.
|
|
132
|
-
afterEach(() => {
|
|
133
|
-
restoreClipboard?.();
|
|
134
|
-
restoreClipboard = null;
|
|
135
|
-
vi.unstubAllGlobals();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
describe('RootLanding: the one-time greeting', () => {
|
|
139
|
-
it('sends a brand-new account to the welcome page', () => {
|
|
140
|
-
mount(landingRoutes);
|
|
141
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(WELCOME_PATH);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// The flag the page reads to know this arrival is a ceremony rather than a
|
|
145
|
-
// visit — the sidebar collapse hangs off it, and only this navigation sets it.
|
|
146
|
-
it('marks the automatic redirect as a greeting', () => {
|
|
147
|
-
mount(landingRoutes);
|
|
148
|
-
expect(screen.getByTestId('greeting')).toHaveTextContent('true');
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('sends everyone the server marked done straight to Knowledge', () => {
|
|
152
|
-
mount(landingRoutes, doneUser());
|
|
153
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
// Optional-field semantics: an ABSENT flag (old fixture, cached session)
|
|
157
|
-
// must never resurrect the welcome flow. Only an explicit false onboards.
|
|
158
|
-
it('treats a missing flag as done, not as new', () => {
|
|
159
|
-
mount(landingRoutes, authValue());
|
|
160
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* The SSO round-trip returns to a fixed callback URL, so a deep link
|
|
165
|
-
* someone clicked dies in transit unless `startSsoLogin` stashed it. These
|
|
166
|
-
* prove the far side: the stash is honoured, exactly once, and can never
|
|
167
|
-
* point off-site.
|
|
168
|
-
*/
|
|
169
|
-
it('sends an existing account straight to the stashed deep link, once', () => {
|
|
170
|
-
const DEEP = '/workspace/main/knowledge-base/KnowledgeBase/Start here.md';
|
|
171
|
-
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, DEEP);
|
|
172
|
-
mount(landingRoutes, doneUser());
|
|
173
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(DEEP);
|
|
174
|
-
// Taken, not peeked: the next front-door visit is an ordinary one.
|
|
175
|
-
expect(sessionStorage.getItem(POST_LOGIN_REDIRECT_KEY)).toBeNull();
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('greets a brand-new account first, handing the link to the welcome page', () => {
|
|
179
|
-
const DEEP = '/workspace/main/knowledge-base/KnowledgeBase/Start here.md';
|
|
180
|
-
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, DEEP);
|
|
181
|
-
mount(landingRoutes);
|
|
182
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent(WELCOME_PATH);
|
|
183
|
-
expect(screen.getByTestId('greeting')).toHaveTextContent('true');
|
|
184
|
-
expect(screen.getByTestId('returnTo')).toHaveTextContent(DEEP);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('discards a stash that is not an in-app path — never an off-site redirect', () => {
|
|
188
|
-
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, '//evil.example/phish');
|
|
189
|
-
mount(landingRoutes, doneUser());
|
|
190
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('greets ONCE: after the welcome page has been seen, / goes to Knowledge', async () => {
|
|
194
|
-
mount(
|
|
195
|
-
<Routes>
|
|
196
|
-
<Route path="/" element={<RootLanding />} />
|
|
197
|
-
<Route path={WELCOME_PATH} element={<WelcomePage />} />
|
|
198
|
-
<Route path="/workspace" element={<div>knowledge</div>} />
|
|
199
|
-
</Routes>,
|
|
200
|
-
);
|
|
201
|
-
// Landed on the real page, which marks `welcomed` on mount.
|
|
202
|
-
await screen.findByRole('heading', { name: /Welcome, Juan/ });
|
|
203
|
-
cleanup();
|
|
204
|
-
// A fresh visit to `/` — same account, same browser.
|
|
205
|
-
mount(landingRoutes);
|
|
206
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
describe('WelcomePage', () => {
|
|
211
|
-
// Default: the ordinary visit, from the sidebar pill. The greeting — the
|
|
212
|
-
// one-time redirect — is the special case, and says so at each call site.
|
|
213
|
-
const mountPage = (auth = newUser(), route: string | typeof greeted = WELCOME_PATH) =>
|
|
214
|
-
mount(
|
|
215
|
-
<Routes>
|
|
216
|
-
<Route path={WELCOME_PATH} element={<WelcomePage />} />
|
|
217
|
-
<Route path="/skills-and-tools" element={<div>library</div>} />
|
|
218
|
-
<Route path="/skills-and-tools/yours" element={<div>your plugin</div>} />
|
|
219
|
-
</Routes>,
|
|
220
|
-
auth,
|
|
221
|
-
route,
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
it('addresses the person by first name', () => {
|
|
225
|
-
mountPage();
|
|
226
|
-
expect(screen.getByRole('heading', { name: 'Welcome, Juan' })).toBeInTheDocument();
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* The entrance must BEGIN on a painted frame. A CSS animation runs on the
|
|
231
|
-
* document timeline whether or not the browser is producing frames, so an
|
|
232
|
-
* animation attached at mount can elapse entirely during a cold boot and
|
|
233
|
-
* never be seen — the bug that made this page "just appear" at every
|
|
234
|
-
* duration we tried. Held invisible first, animating second.
|
|
235
|
-
*/
|
|
236
|
-
it('starts its entrance on a painted frame, not at mount', async () => {
|
|
237
|
-
mountPage(newUser(), greeted);
|
|
238
|
-
const title = screen.getByRole('heading', { name: 'Welcome, Juan' });
|
|
239
|
-
const body = screen.getByText(/company’s shared library/).parentElement!;
|
|
240
|
-
// An inline style, deliberately — a utility class would depend on Tailwind
|
|
241
|
-
// having compiled it, and that is exactly what failed silently before.
|
|
242
|
-
expect(title.style.opacity).toBe('0');
|
|
243
|
-
expect(body.style.opacity).toBe('0');
|
|
244
|
-
await waitFor(() => {
|
|
245
|
-
expect(title.className).toContain('animate-onboarding-greeting');
|
|
246
|
-
expect(body.className).toContain('animate-onboarding-body');
|
|
247
|
-
});
|
|
248
|
-
// …and never both at once: held invisible and animating would fight.
|
|
249
|
-
expect(title.style.opacity).toBe('');
|
|
250
|
-
expect(body.style.opacity).toBe('');
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Being welcomed happens once. Opening the same page from the pill later is
|
|
255
|
-
* a visit, and a 2.6s arrival every time you come back to copy your MCP
|
|
256
|
-
* snippet is a page you learn to dread — so there is no hold and no fade,
|
|
257
|
-
* only the page.
|
|
258
|
-
*/
|
|
259
|
-
it('does not replay the entrance when you open it from the pill', () => {
|
|
260
|
-
mountPage();
|
|
261
|
-
const title = screen.getByRole('heading', { name: 'Welcome, Juan' });
|
|
262
|
-
expect(title.style.opacity).toBe('');
|
|
263
|
-
expect(title.className).not.toContain('animate-onboarding-greeting');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// However the sign-in record spells it. The page addressed to one person is
|
|
267
|
-
// the last place that should get their name wrong.
|
|
268
|
-
it('capitalizes the name whatever the account holds', () => {
|
|
269
|
-
mountPage(authValue({ user: { id: 'u1', email: 'j@bevel.software', name: 'juan viera', onboardingDone: false } }));
|
|
270
|
-
expect(screen.getByRole('heading', { name: 'Welcome, Juan' })).toBeInTheDocument();
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it('greets someone with no name at all', () => {
|
|
274
|
-
mountPage(authValue({ user: { id: 'u1', email: 'j@bevel.software', name: '', onboardingDone: false } }));
|
|
275
|
-
expect(screen.getByRole('heading', { name: 'Welcome, there' })).toBeInTheDocument();
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* The nav gets out of the way for the greeting and STAYS out — there is no
|
|
280
|
-
* restore. Putting it back meant leaving a screen with no nav and arriving
|
|
281
|
-
* at one where the nav had opened itself, which is the app rearranging a
|
|
282
|
-
* page you asked for. Whether the sidebar shows is the toolbar toggle's to
|
|
283
|
-
* say, and after the greeting it says whatever it said last.
|
|
284
|
-
*/
|
|
285
|
-
it('collapses the sidebar for the greeting, without animating it', () => {
|
|
286
|
-
setSidebarCollapsed(false);
|
|
287
|
-
mountPage(newUser(), greeted);
|
|
288
|
-
expect(sidebarState()).toMatchObject({ collapsed: true, instant: true });
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('leaves it collapsed when you go to your own plugin', async () => {
|
|
292
|
-
setSidebarCollapsed(false);
|
|
293
|
-
mountPage(newUser(), greeted);
|
|
294
|
-
await userEvent.click(screen.getByRole('button', { name: /Go to your skills/ }));
|
|
295
|
-
expect(screen.getByTestId('pathname')).toHaveTextContent('/skills-and-tools/yours');
|
|
296
|
-
expect(sidebarState().collapsed).toBe(true);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it('leaves it collapsed after Done too', async () => {
|
|
300
|
-
setSidebarCollapsed(false);
|
|
301
|
-
mountPage(newUser(), greeted);
|
|
302
|
-
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
303
|
-
expect(sidebarState().collapsed).toBe(true);
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* The one case where the nav is showing on the way out: you opened it
|
|
308
|
-
* yourself while you were here. The page collapses once, on arrival, and
|
|
309
|
-
* never touches the store again — so your gesture is the last word.
|
|
310
|
-
*/
|
|
311
|
-
it('respects a sidebar you opened yourself while reading the page', async () => {
|
|
312
|
-
setSidebarCollapsed(false);
|
|
313
|
-
mountPage(newUser(), greeted);
|
|
314
|
-
expect(sidebarState().collapsed).toBe(true);
|
|
315
|
-
setSidebarCollapsed(false); // …the toolbar toggle, from the user's hand
|
|
316
|
-
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
317
|
-
expect(sidebarState().collapsed).toBe(false);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
it('leaves it collapsed for someone who arrived that way', () => {
|
|
321
|
-
setSidebarCollapsed(true);
|
|
322
|
-
const { unmount } = mountPage(newUser(), greeted);
|
|
323
|
-
expect(sidebarState().collapsed).toBe(true);
|
|
324
|
-
unmount();
|
|
325
|
-
expect(sidebarState().collapsed).toBe(true);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
// Reached from the pill it is a page, not a ceremony: the nav it was just
|
|
329
|
-
// clicked in stays exactly where it is.
|
|
330
|
-
it('leaves the sidebar alone when you open it from the pill', () => {
|
|
331
|
-
setSidebarCollapsed(false);
|
|
332
|
-
const { unmount } = mountPage();
|
|
333
|
-
expect(sidebarState().collapsed).toBe(false);
|
|
334
|
-
unmount();
|
|
335
|
-
expect(sidebarState().collapsed).toBe(false);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it('shows one snippet at a time, following the picker', async () => {
|
|
339
|
-
mountPage();
|
|
340
|
-
//
|
|
341
|
-
expect(screen.getByText(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
expect(screen.
|
|
345
|
-
await userEvent.click(screen.getByRole('radio', { name: 'Other' }));
|
|
346
|
-
expect(screen.getByText(/skills-tools-knowledge/)).toBeInTheDocument();
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
expect(
|
|
360
|
-
'
|
|
361
|
-
'
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
);
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
'
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
'
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
'
|
|
545
|
-
|
|
546
|
-
'
|
|
547
|
-
'
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
)
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
await userEvent.click(screen.getByRole('button', { name: '
|
|
699
|
-
expect(
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
});
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { render, renderHook, screen, cleanup, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
5
|
+
import { AuthContext } from '../../auth/state/auth.context';
|
|
6
|
+
import { authValue } from '../../library/__tests__/auth-harness';
|
|
7
|
+
import { LibraryToastProvider } from '../../library/state/toast';
|
|
8
|
+
import { WelcomePage } from '../components/WelcomePage';
|
|
9
|
+
import { AppRegistryContext, EMPTY_REGISTRY } from '../../../core/registry';
|
|
10
|
+
import { ConnectAgentPill } from '../components/ConnectAgentPill';
|
|
11
|
+
import { RootLanding } from '../components/RootLanding';
|
|
12
|
+
import { POST_LOGIN_REDIRECT_KEY } from '../../auth/services/sso';
|
|
13
|
+
import { WELCOME_PATH } from '../paths';
|
|
14
|
+
import { resetOnboardingForTests } from '../state/onboarding';
|
|
15
|
+
import { configureMcpUrl } from '../../../shared/mcp';
|
|
16
|
+
import { setSidebarCollapsed, useSidebar } from '../../layout/state/sidebar';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The onboarding contract, end to end on the client:
|
|
20
|
+
*
|
|
21
|
+
* - `/` redirects to the welcome page ONCE, on an account the server says is
|
|
22
|
+
* not onboarded — and never hijacks anything after that first greeting.
|
|
23
|
+
* - the pill outlives the redirect: it stays until × or Done, exactly two.
|
|
24
|
+
* - Done concludes (server write + navigation); the skip link and the copy
|
|
25
|
+
* button conclude NOTHING — leaving and copying are not promises.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// No parameters: the mock never reads its arguments, and `vi.fn` records every
|
|
29
|
+
// call regardless of the implementation's signature — so the call assertions
|
|
30
|
+
// below keep working while lint stays clean.
|
|
31
|
+
const { authFetchMock } = vi.hoisted(() => ({
|
|
32
|
+
authFetchMock: vi.fn(async () => ({ ok: true, status: 200 }) as Response),
|
|
33
|
+
}));
|
|
34
|
+
vi.mock('../../../lib/api', () => ({ authFetch: authFetchMock }));
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The `RequestInit` of a recorded `authFetch` call.
|
|
38
|
+
*
|
|
39
|
+
* The mock declares no parameters — deliberately, so lint stays clean — which
|
|
40
|
+
* leaves `mock.calls` typed as an empty tuple even though the calls really do
|
|
41
|
+
* carry two arguments. Naming that gap ONCE, here, is better than a cast at
|
|
42
|
+
* every assertion that wants to read a request body.
|
|
43
|
+
*/
|
|
44
|
+
function fetchInit(call = 0): RequestInit | undefined {
|
|
45
|
+
return (authFetchMock.mock.calls[call] as unknown as [string, RequestInit] | undefined)?.[1];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A user the server considers NOT onboarded (the explicit false matters). */
|
|
49
|
+
const newUser = () => authValue({ user: { id: 'u1', email: 'juan@bevel.software', name: 'Juan Viera', onboardingDone: false } });
|
|
50
|
+
/** The same account after the server has recorded the onboarding as done. */
|
|
51
|
+
const doneUser = () => authValue({ user: { id: 'u1', email: 'juan@bevel.software', name: 'Juan Viera', onboardingDone: true } });
|
|
52
|
+
|
|
53
|
+
/** Reads the sidebar store the way a component would. */
|
|
54
|
+
function sidebarState() {
|
|
55
|
+
return renderHook(() => useSidebar()).result.current;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Where we are, whether we got here by being greeted, and any carried link. */
|
|
59
|
+
function LocationProbe() {
|
|
60
|
+
const { pathname, state } = useLocation();
|
|
61
|
+
const s = state as { greeting?: boolean; returnTo?: string | null } | null;
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
<div data-testid="pathname">{pathname}</div>
|
|
65
|
+
<div data-testid="greeting">{String(s?.greeting === true)}</div>
|
|
66
|
+
<div data-testid="returnTo">{s?.returnTo ?? ''}</div>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The welcome page as the first-sign-in redirect leaves it: greeted. */
|
|
72
|
+
const greeted = { pathname: WELCOME_PATH, state: { greeting: true } };
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Render `ui` inside the three contexts the onboarding actually reads — a
|
|
76
|
+
* router at `route`, an auth context holding `auth`, and the toast provider —
|
|
77
|
+
* plus the location probe every redirect assertion below looks at. `route`
|
|
78
|
+
* takes a location object when a test needs to arrive as the greeting does.
|
|
79
|
+
*/
|
|
80
|
+
function mount(
|
|
81
|
+
ui: React.ReactNode,
|
|
82
|
+
auth = newUser(),
|
|
83
|
+
route: string | { pathname: string; state?: unknown } = '/',
|
|
84
|
+
) {
|
|
85
|
+
return render(
|
|
86
|
+
<MemoryRouter initialEntries={[route]}>
|
|
87
|
+
<AuthContext.Provider value={auth}>
|
|
88
|
+
<LibraryToastProvider>
|
|
89
|
+
{ui}
|
|
90
|
+
<LocationProbe />
|
|
91
|
+
</LibraryToastProvider>
|
|
92
|
+
</AuthContext.Provider>
|
|
93
|
+
</MemoryRouter>,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const landingRoutes = (
|
|
98
|
+
<Routes>
|
|
99
|
+
<Route path="/" element={<RootLanding />} />
|
|
100
|
+
<Route path={WELCOME_PATH} element={<div>welcome page</div>} />
|
|
101
|
+
<Route path="/workspace" element={<div>knowledge</div>} />
|
|
102
|
+
</Routes>
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
beforeEach(() => {
|
|
106
|
+
resetOnboardingForTests();
|
|
107
|
+
authFetchMock.mockClear();
|
|
108
|
+
sessionStorage.clear();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* jsdom ships no `navigator.clipboard`, so a copy test has to install one —
|
|
113
|
+
* but only THAT property, never a replacement `navigator`: the rest of the
|
|
114
|
+
* object (`userAgent`, `language`, whatever a library reaches for next) has no
|
|
115
|
+
* business changing because one test wanted a spy.
|
|
116
|
+
*/
|
|
117
|
+
let restoreClipboard: (() => void) | null = null;
|
|
118
|
+
|
|
119
|
+
function stubClipboard() {
|
|
120
|
+
const writeText = vi.fn().mockResolvedValue(undefined);
|
|
121
|
+
const original = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
|
|
122
|
+
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
|
|
123
|
+
restoreClipboard = () => {
|
|
124
|
+
if (original) Object.defineProperty(navigator, 'clipboard', original);
|
|
125
|
+
else Reflect.deleteProperty(navigator, 'clipboard');
|
|
126
|
+
};
|
|
127
|
+
return writeText;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// In a hook, not at the end of a test body: a failing assertion would otherwise
|
|
131
|
+
// leave the stub installed for every test after it.
|
|
132
|
+
afterEach(() => {
|
|
133
|
+
restoreClipboard?.();
|
|
134
|
+
restoreClipboard = null;
|
|
135
|
+
vi.unstubAllGlobals();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('RootLanding: the one-time greeting', () => {
|
|
139
|
+
it('sends a brand-new account to the welcome page', () => {
|
|
140
|
+
mount(landingRoutes);
|
|
141
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(WELCOME_PATH);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// The flag the page reads to know this arrival is a ceremony rather than a
|
|
145
|
+
// visit — the sidebar collapse hangs off it, and only this navigation sets it.
|
|
146
|
+
it('marks the automatic redirect as a greeting', () => {
|
|
147
|
+
mount(landingRoutes);
|
|
148
|
+
expect(screen.getByTestId('greeting')).toHaveTextContent('true');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('sends everyone the server marked done straight to Knowledge', () => {
|
|
152
|
+
mount(landingRoutes, doneUser());
|
|
153
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Optional-field semantics: an ABSENT flag (old fixture, cached session)
|
|
157
|
+
// must never resurrect the welcome flow. Only an explicit false onboards.
|
|
158
|
+
it('treats a missing flag as done, not as new', () => {
|
|
159
|
+
mount(landingRoutes, authValue());
|
|
160
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The SSO round-trip returns to a fixed callback URL, so a deep link
|
|
165
|
+
* someone clicked dies in transit unless `startSsoLogin` stashed it. These
|
|
166
|
+
* prove the far side: the stash is honoured, exactly once, and can never
|
|
167
|
+
* point off-site.
|
|
168
|
+
*/
|
|
169
|
+
it('sends an existing account straight to the stashed deep link, once', () => {
|
|
170
|
+
const DEEP = '/workspace/main/knowledge-base/KnowledgeBase/Start here.md';
|
|
171
|
+
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, DEEP);
|
|
172
|
+
mount(landingRoutes, doneUser());
|
|
173
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(DEEP);
|
|
174
|
+
// Taken, not peeked: the next front-door visit is an ordinary one.
|
|
175
|
+
expect(sessionStorage.getItem(POST_LOGIN_REDIRECT_KEY)).toBeNull();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('greets a brand-new account first, handing the link to the welcome page', () => {
|
|
179
|
+
const DEEP = '/workspace/main/knowledge-base/KnowledgeBase/Start here.md';
|
|
180
|
+
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, DEEP);
|
|
181
|
+
mount(landingRoutes);
|
|
182
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(WELCOME_PATH);
|
|
183
|
+
expect(screen.getByTestId('greeting')).toHaveTextContent('true');
|
|
184
|
+
expect(screen.getByTestId('returnTo')).toHaveTextContent(DEEP);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('discards a stash that is not an in-app path — never an off-site redirect', () => {
|
|
188
|
+
sessionStorage.setItem(POST_LOGIN_REDIRECT_KEY, '//evil.example/phish');
|
|
189
|
+
mount(landingRoutes, doneUser());
|
|
190
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it('greets ONCE: after the welcome page has been seen, / goes to Knowledge', async () => {
|
|
194
|
+
mount(
|
|
195
|
+
<Routes>
|
|
196
|
+
<Route path="/" element={<RootLanding />} />
|
|
197
|
+
<Route path={WELCOME_PATH} element={<WelcomePage />} />
|
|
198
|
+
<Route path="/workspace" element={<div>knowledge</div>} />
|
|
199
|
+
</Routes>,
|
|
200
|
+
);
|
|
201
|
+
// Landed on the real page, which marks `welcomed` on mount.
|
|
202
|
+
await screen.findByRole('heading', { name: /Welcome, Juan/ });
|
|
203
|
+
cleanup();
|
|
204
|
+
// A fresh visit to `/` — same account, same browser.
|
|
205
|
+
mount(landingRoutes);
|
|
206
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('WelcomePage', () => {
|
|
211
|
+
// Default: the ordinary visit, from the sidebar pill. The greeting — the
|
|
212
|
+
// one-time redirect — is the special case, and says so at each call site.
|
|
213
|
+
const mountPage = (auth = newUser(), route: string | typeof greeted = WELCOME_PATH) =>
|
|
214
|
+
mount(
|
|
215
|
+
<Routes>
|
|
216
|
+
<Route path={WELCOME_PATH} element={<WelcomePage />} />
|
|
217
|
+
<Route path="/skills-and-tools" element={<div>library</div>} />
|
|
218
|
+
<Route path="/skills-and-tools/yours" element={<div>your plugin</div>} />
|
|
219
|
+
</Routes>,
|
|
220
|
+
auth,
|
|
221
|
+
route,
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
it('addresses the person by first name', () => {
|
|
225
|
+
mountPage();
|
|
226
|
+
expect(screen.getByRole('heading', { name: 'Welcome, Juan' })).toBeInTheDocument();
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The entrance must BEGIN on a painted frame. A CSS animation runs on the
|
|
231
|
+
* document timeline whether or not the browser is producing frames, so an
|
|
232
|
+
* animation attached at mount can elapse entirely during a cold boot and
|
|
233
|
+
* never be seen — the bug that made this page "just appear" at every
|
|
234
|
+
* duration we tried. Held invisible first, animating second.
|
|
235
|
+
*/
|
|
236
|
+
it('starts its entrance on a painted frame, not at mount', async () => {
|
|
237
|
+
mountPage(newUser(), greeted);
|
|
238
|
+
const title = screen.getByRole('heading', { name: 'Welcome, Juan' });
|
|
239
|
+
const body = screen.getByText(/company’s shared library/).parentElement!;
|
|
240
|
+
// An inline style, deliberately — a utility class would depend on Tailwind
|
|
241
|
+
// having compiled it, and that is exactly what failed silently before.
|
|
242
|
+
expect(title.style.opacity).toBe('0');
|
|
243
|
+
expect(body.style.opacity).toBe('0');
|
|
244
|
+
await waitFor(() => {
|
|
245
|
+
expect(title.className).toContain('animate-onboarding-greeting');
|
|
246
|
+
expect(body.className).toContain('animate-onboarding-body');
|
|
247
|
+
});
|
|
248
|
+
// …and never both at once: held invisible and animating would fight.
|
|
249
|
+
expect(title.style.opacity).toBe('');
|
|
250
|
+
expect(body.style.opacity).toBe('');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Being welcomed happens once. Opening the same page from the pill later is
|
|
255
|
+
* a visit, and a 2.6s arrival every time you come back to copy your MCP
|
|
256
|
+
* snippet is a page you learn to dread — so there is no hold and no fade,
|
|
257
|
+
* only the page.
|
|
258
|
+
*/
|
|
259
|
+
it('does not replay the entrance when you open it from the pill', () => {
|
|
260
|
+
mountPage();
|
|
261
|
+
const title = screen.getByRole('heading', { name: 'Welcome, Juan' });
|
|
262
|
+
expect(title.style.opacity).toBe('');
|
|
263
|
+
expect(title.className).not.toContain('animate-onboarding-greeting');
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// However the sign-in record spells it. The page addressed to one person is
|
|
267
|
+
// the last place that should get their name wrong.
|
|
268
|
+
it('capitalizes the name whatever the account holds', () => {
|
|
269
|
+
mountPage(authValue({ user: { id: 'u1', email: 'j@bevel.software', name: 'juan viera', onboardingDone: false } }));
|
|
270
|
+
expect(screen.getByRole('heading', { name: 'Welcome, Juan' })).toBeInTheDocument();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('greets someone with no name at all', () => {
|
|
274
|
+
mountPage(authValue({ user: { id: 'u1', email: 'j@bevel.software', name: '', onboardingDone: false } }));
|
|
275
|
+
expect(screen.getByRole('heading', { name: 'Welcome, there' })).toBeInTheDocument();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The nav gets out of the way for the greeting and STAYS out — there is no
|
|
280
|
+
* restore. Putting it back meant leaving a screen with no nav and arriving
|
|
281
|
+
* at one where the nav had opened itself, which is the app rearranging a
|
|
282
|
+
* page you asked for. Whether the sidebar shows is the toolbar toggle's to
|
|
283
|
+
* say, and after the greeting it says whatever it said last.
|
|
284
|
+
*/
|
|
285
|
+
it('collapses the sidebar for the greeting, without animating it', () => {
|
|
286
|
+
setSidebarCollapsed(false);
|
|
287
|
+
mountPage(newUser(), greeted);
|
|
288
|
+
expect(sidebarState()).toMatchObject({ collapsed: true, instant: true });
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('leaves it collapsed when you go to your own plugin', async () => {
|
|
292
|
+
setSidebarCollapsed(false);
|
|
293
|
+
mountPage(newUser(), greeted);
|
|
294
|
+
await userEvent.click(screen.getByRole('button', { name: /Go to your skills/ }));
|
|
295
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/skills-and-tools/yours');
|
|
296
|
+
expect(sidebarState().collapsed).toBe(true);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('leaves it collapsed after Done too', async () => {
|
|
300
|
+
setSidebarCollapsed(false);
|
|
301
|
+
mountPage(newUser(), greeted);
|
|
302
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
303
|
+
expect(sidebarState().collapsed).toBe(true);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The one case where the nav is showing on the way out: you opened it
|
|
308
|
+
* yourself while you were here. The page collapses once, on arrival, and
|
|
309
|
+
* never touches the store again — so your gesture is the last word.
|
|
310
|
+
*/
|
|
311
|
+
it('respects a sidebar you opened yourself while reading the page', async () => {
|
|
312
|
+
setSidebarCollapsed(false);
|
|
313
|
+
mountPage(newUser(), greeted);
|
|
314
|
+
expect(sidebarState().collapsed).toBe(true);
|
|
315
|
+
setSidebarCollapsed(false); // …the toolbar toggle, from the user's hand
|
|
316
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
317
|
+
expect(sidebarState().collapsed).toBe(false);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('leaves it collapsed for someone who arrived that way', () => {
|
|
321
|
+
setSidebarCollapsed(true);
|
|
322
|
+
const { unmount } = mountPage(newUser(), greeted);
|
|
323
|
+
expect(sidebarState().collapsed).toBe(true);
|
|
324
|
+
unmount();
|
|
325
|
+
expect(sidebarState().collapsed).toBe(true);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Reached from the pill it is a page, not a ceremony: the nav it was just
|
|
329
|
+
// clicked in stays exactly where it is.
|
|
330
|
+
it('leaves the sidebar alone when you open it from the pill', () => {
|
|
331
|
+
setSidebarCollapsed(false);
|
|
332
|
+
const { unmount } = mountPage();
|
|
333
|
+
expect(sidebarState().collapsed).toBe(false);
|
|
334
|
+
unmount();
|
|
335
|
+
expect(sidebarState().collapsed).toBe(false);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
it('shows one snippet at a time, following the picker', async () => {
|
|
339
|
+
mountPage();
|
|
340
|
+
// Claude default: the bare hosted URL, not a config.
|
|
341
|
+
expect(screen.getByText(/\/api\/mcp$/)).toBeInTheDocument();
|
|
342
|
+
expect(screen.queryByText(/mcpServers/)).toBeNull();
|
|
343
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
344
|
+
expect(screen.getByText(/@bevel-software\/hexis-mcp/)).toBeInTheDocument();
|
|
345
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Other tools' }));
|
|
346
|
+
expect(screen.getByText(/skills-tools-knowledge/)).toBeInTheDocument();
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* ChatGPT renamed Apps & Connectors to Plugins, and a one-line path with the
|
|
351
|
+
* old names stranded people. The steps are numbered, in the order the
|
|
352
|
+
* settings are actually walked, and each renamed thing is named both ways
|
|
353
|
+
* so either build of ChatGPT reads right.
|
|
354
|
+
*/
|
|
355
|
+
it('walks ChatGPT as numbered steps naming both the current and the previous page', async () => {
|
|
356
|
+
mountPage();
|
|
357
|
+
await userEvent.click(screen.getByRole('radio', { name: 'ChatGPT' }));
|
|
358
|
+
const steps = screen.getAllByRole('listitem').map((li) => li.textContent);
|
|
359
|
+
expect(steps).toEqual([
|
|
360
|
+
'Open Settings in ChatGPT.',
|
|
361
|
+
'Open Plugins (called Apps & Connectors in older versions).',
|
|
362
|
+
'Turn on Developer Mode (under Advanced in older versions).',
|
|
363
|
+
'Go back and choose Create (or Add).',
|
|
364
|
+
'Name it “Skills, Tools and Knowledge”.',
|
|
365
|
+
'Paste the address below, then save.',
|
|
366
|
+
]);
|
|
367
|
+
// An ordered list, so the numbers are real rather than typed into the text.
|
|
368
|
+
expect(screen.getByRole('list').tagName).toBe('OL');
|
|
369
|
+
// The other options keep their one-paragraph hint.
|
|
370
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
371
|
+
expect(screen.queryByRole('list')).toBeNull();
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* "A JSON config" told a business user nothing. The Other tools option
|
|
376
|
+
* says where it goes, and gives the bare address too — many tools take a
|
|
377
|
+
* URL and nothing else — each with its own copy button.
|
|
378
|
+
*/
|
|
379
|
+
it('tells Other tools where the configuration goes, and offers the bare address too', async () => {
|
|
380
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
381
|
+
const writeText = stubClipboard();
|
|
382
|
+
mountPage();
|
|
383
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Other tools' }));
|
|
384
|
+
expect(
|
|
385
|
+
screen.getByText(
|
|
386
|
+
'For any other AI tool that supports MCP servers. Open the tool’s settings, find MCP servers (also called connectors or integrations), choose add, and paste this configuration. If the tool asks for an address only, paste this instead:',
|
|
387
|
+
),
|
|
388
|
+
).toBeInTheDocument();
|
|
389
|
+
|
|
390
|
+
const address = screen.getByText('https://kb.acme.com/api/mcp');
|
|
391
|
+
const config = screen.getByText(/mcpServers/);
|
|
392
|
+
// The address first — the hint ends on "paste this instead:" — then the JSON.
|
|
393
|
+
expect(address.compareDocumentPosition(config) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
394
|
+
expect(config.textContent).toContain('https://kb.acme.com/api/mcp');
|
|
395
|
+
|
|
396
|
+
await userEvent.click(screen.getByRole('button', { name: 'Copy address' }));
|
|
397
|
+
expect(writeText).toHaveBeenLastCalledWith('https://kb.acme.com/api/mcp');
|
|
398
|
+
await userEvent.click(screen.getByRole('button', { name: 'Copy' }));
|
|
399
|
+
expect(writeText).toHaveBeenLastCalledWith(config.textContent);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it('shows the separate address block on Other tools alone', async () => {
|
|
403
|
+
mountPage();
|
|
404
|
+
expect(screen.queryByRole('button', { name: 'Copy address' })).toBeNull();
|
|
405
|
+
await userEvent.click(screen.getByRole('radio', { name: 'ChatGPT' }));
|
|
406
|
+
expect(screen.queryByRole('button', { name: 'Copy address' })).toBeNull();
|
|
407
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
408
|
+
expect(screen.queryByRole('button', { name: 'Copy address' })).toBeNull();
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* The default: Claude, which is what most people arriving here already use
|
|
413
|
+
* and the one connection that is a single click. The button and the hosted
|
|
414
|
+
* address are both on screen before anything is clicked.
|
|
415
|
+
*/
|
|
416
|
+
it('defaults to Claude: its install button and the hosted address, without a click', () => {
|
|
417
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
418
|
+
mountPage();
|
|
419
|
+
expect(screen.getByRole('radio', { name: 'Claude' })).toHaveAttribute('aria-checked', 'true');
|
|
420
|
+
expect(screen.getByRole('link', { name: 'Add to Claude' })).toBeInTheDocument();
|
|
421
|
+
expect(screen.getByText('https://kb.acme.com/api/mcp')).toBeInTheDocument();
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Desktop agents is no longer the default, but its snippet is still the
|
|
426
|
+
* keyless local-server config: the local server opens the browser to sign
|
|
427
|
+
* in on first run, so the config carries no key at all.
|
|
428
|
+
*/
|
|
429
|
+
it('offers Desktop agents the keyless hexis-mcp config', async () => {
|
|
430
|
+
mountPage();
|
|
431
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
432
|
+
const snippet = screen.getByText(/mcpServers/).textContent!;
|
|
433
|
+
expect(snippet).toContain('@bevel-software/hexis-mcp');
|
|
434
|
+
// Keyless = interactive sign-in: no key env at all, not a placeholder —
|
|
435
|
+
// the server opens the browser on first run.
|
|
436
|
+
expect(snippet).not.toContain('HEXIS_CONNECTION_KEY');
|
|
437
|
+
// The hint says how identity arrives instead: browser sign-in on first run.
|
|
438
|
+
expect(screen.getByText(/your browser opens so you can sign in/)).toBeInTheDocument();
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The two ways this snippet fails on a machine where it is otherwise
|
|
443
|
+
* right: the wrong Node major, and a client launched from the Dock, which
|
|
444
|
+
* was started by the window server and so never read the shell profile
|
|
445
|
+
* that put `npx` on PATH (Cursor and Claude Desktop on macOS). The fix for
|
|
446
|
+
* the second is an absolute path, which is specific to one machine — so it
|
|
447
|
+
* belongs in the hint and NOT in the snippet, which has to stay right for
|
|
448
|
+
* every reader whose PATH was fine all along.
|
|
449
|
+
*/
|
|
450
|
+
it('warns Desktop agents about Node and PATH, leaving the snippet on bare npx', async () => {
|
|
451
|
+
mountPage();
|
|
452
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
453
|
+
expect(screen.getByText(/Needs Node 22\.13\+ or 24/)).toBeInTheDocument();
|
|
454
|
+
expect(screen.getByText(/cannot see your shell’s PATH/)).toBeInTheDocument();
|
|
455
|
+
expect(screen.getByText(/run `which npx` in a terminal/)).toBeInTheDocument();
|
|
456
|
+
const snippet = screen.getByText(/mcpServers/).textContent!;
|
|
457
|
+
expect(JSON.parse(snippet).mcpServers['skills-tools-knowledge'].command).toBe('npx');
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* One click instead of a menu path. It is Claude-only because Claude is the
|
|
462
|
+
* only client with a documented install link, and it appears only when
|
|
463
|
+
* Anthropic could actually reach this deployment — see `canDeepLink`. The
|
|
464
|
+
* copy block stays either way; it is the route that always works.
|
|
465
|
+
*
|
|
466
|
+
* Every case still selects the Claude option explicitly, although it is
|
|
467
|
+
* the default: the link belongs to that option, and the cases say so.
|
|
468
|
+
*/
|
|
469
|
+
describe('the Add to Claude link', () => {
|
|
470
|
+
it('offers one-click connect on a reachable deployment', async () => {
|
|
471
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
472
|
+
mountPage();
|
|
473
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
474
|
+
const link = screen.getByRole('link', { name: 'Add to Claude' });
|
|
475
|
+
const href = new URL(link.getAttribute('href')!);
|
|
476
|
+
expect(href.origin + href.pathname).toBe('https://claude.ai/customize/connectors');
|
|
477
|
+
expect(href.searchParams.get('connectorUrl')).toBe('https://kb.acme.com/api/mcp');
|
|
478
|
+
expect(href.searchParams.get('connectorName')).toBe('Skills, Tools and Knowledge — kb.acme.com');
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* The default install: `PUBLIC_BACKEND_URL` unset means localhost, which
|
|
483
|
+
* claude.ai cannot reach. A dead button on the first screen a self-hoster
|
|
484
|
+
* sees reads as a broken product.
|
|
485
|
+
*/
|
|
486
|
+
it('offers nothing to click on a localhost deployment', async () => {
|
|
487
|
+
configureMcpUrl('http://localhost:3001/api/mcp');
|
|
488
|
+
mountPage();
|
|
489
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
490
|
+
expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
|
|
491
|
+
// …and the route that always works is still there.
|
|
492
|
+
expect(screen.getByText('http://localhost:3001/api/mcp')).toBeInTheDocument();
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* No `PUBLIC_BACKEND_URL` hint on THIS surface. The reader is a new
|
|
497
|
+
* employee who cannot change deployment config; naming an env var at them
|
|
498
|
+
* is noise. The settings page, whose reader plausibly can, says it there.
|
|
499
|
+
*/
|
|
500
|
+
it('does not lecture a new employee about deployment config', async () => {
|
|
501
|
+
configureMcpUrl('http://localhost:3001/api/mcp');
|
|
502
|
+
mountPage();
|
|
503
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
504
|
+
expect(screen.queryByText(/PUBLIC_BACKEND_URL/)).toBeNull();
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('belongs to Claude alone', async () => {
|
|
508
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
509
|
+
mountPage();
|
|
510
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
511
|
+
expect(screen.getByRole('link', { name: 'Add to Claude' })).toBeInTheDocument();
|
|
512
|
+
await userEvent.click(screen.getByRole('radio', { name: 'ChatGPT' }));
|
|
513
|
+
expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
|
|
514
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
515
|
+
expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
|
|
516
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Other tools' }));
|
|
517
|
+
expect(screen.queryByRole('link', { name: 'Add to Claude' })).toBeNull();
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* ChatGPT gets its own button, on its own option only. It cannot prefill
|
|
522
|
+
* anything — ChatGPT has no such link — so it opens the settings pane and
|
|
523
|
+
* the hint beside it spells out the name to type, which is what stops a
|
|
524
|
+
* dozen employees each inventing their own.
|
|
525
|
+
*/
|
|
526
|
+
it('offers Add to ChatGPT on the ChatGPT option alone, with the name to type', async () => {
|
|
527
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
528
|
+
mountPage();
|
|
529
|
+
// The default — Claude — carries no ChatGPT button.
|
|
530
|
+
expect(screen.queryByRole('link', { name: 'Add to ChatGPT' })).toBeNull();
|
|
531
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
532
|
+
expect(screen.queryByRole('link', { name: 'Add to ChatGPT' })).toBeNull();
|
|
533
|
+
await userEvent.click(screen.getByRole('radio', { name: 'ChatGPT' }));
|
|
534
|
+
const link = screen.getByRole('link', { name: 'Add to ChatGPT' });
|
|
535
|
+
expect(link).toHaveAttribute('href', 'https://chatgpt.com/#settings');
|
|
536
|
+
expect(link).toHaveAttribute('target', '_blank');
|
|
537
|
+
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
|
|
538
|
+
expect(screen.getByText(/Skills, Tools and Knowledge/)).toBeInTheDocument();
|
|
539
|
+
// …and the URL to paste is still the copy block.
|
|
540
|
+
expect(screen.getByText('https://kb.acme.com/api/mcp')).toBeInTheDocument();
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
it('offers no ChatGPT button on a localhost deployment either', async () => {
|
|
544
|
+
configureMcpUrl('http://localhost:3001/api/mcp');
|
|
545
|
+
mountPage();
|
|
546
|
+
await userEvent.click(screen.getByRole('radio', { name: 'ChatGPT' }));
|
|
547
|
+
expect(screen.queryByRole('link', { name: 'Add to ChatGPT' })).toBeNull();
|
|
548
|
+
expect(screen.getByText('http://localhost:3001/api/mcp')).toBeInTheDocument();
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// Opening claude.ai must not hand it a handle on this window.
|
|
552
|
+
it('opens in a new tab safely', async () => {
|
|
553
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
554
|
+
mountPage();
|
|
555
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
556
|
+
const link = screen.getByRole('link', { name: 'Add to Claude' });
|
|
557
|
+
expect(link).toHaveAttribute('target', '_blank');
|
|
558
|
+
expect(link).toHaveAttribute('rel', 'noopener noreferrer');
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* The whole point of the canonical URL: what the button hands Claude and
|
|
563
|
+
* what the copy block shows a human must be the same string, or one of
|
|
564
|
+
* them is lying.
|
|
565
|
+
*/
|
|
566
|
+
it('hands Claude exactly the URL the copy block shows', async () => {
|
|
567
|
+
configureMcpUrl('https://kb.acme.com/api/mcp');
|
|
568
|
+
mountPage();
|
|
569
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Claude' }));
|
|
570
|
+
const href = new URL(
|
|
571
|
+
screen.getByRole('link', { name: 'Add to Claude' }).getAttribute('href')!,
|
|
572
|
+
);
|
|
573
|
+
expect(href.searchParams.get('connectorUrl')).toBe(
|
|
574
|
+
screen.getByText(/\/api\/mcp$/).textContent,
|
|
575
|
+
);
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
it('copies the visible snippet without concluding anything', async () => {
|
|
580
|
+
const writeText = stubClipboard();
|
|
581
|
+
mountPage();
|
|
582
|
+
await userEvent.click(screen.getByRole('button', { name: 'Copy' }));
|
|
583
|
+
// The default snippet is Claude's: the hosted URL itself.
|
|
584
|
+
expect(writeText).toHaveBeenCalledWith(expect.stringMatching(/\/api\/mcp$/));
|
|
585
|
+
// Copying is not Done: no server write, no navigation.
|
|
586
|
+
expect(authFetchMock).not.toHaveBeenCalled();
|
|
587
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(WELCOME_PATH);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// Exact, not a substring: `/skills-and-tools` is a PREFIX of the personal
|
|
591
|
+
// plugin's path, so a loose match would pass even if Done dropped someone in
|
|
592
|
+
// the whole company's catalog instead of their own shelf.
|
|
593
|
+
it('Done concludes: server write + landing in your own plugin', async () => {
|
|
594
|
+
mountPage();
|
|
595
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
596
|
+
expect(authFetchMock).toHaveBeenCalledWith(
|
|
597
|
+
'/api/auth/onboarding-done',
|
|
598
|
+
expect.objectContaining({ method: 'POST' }),
|
|
599
|
+
);
|
|
600
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(/^\/skills-and-tools\/yours$/);
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
// Both exits, one destination — stated as its own fact so a future change to
|
|
604
|
+
// either button has to face the question deliberately.
|
|
605
|
+
it('sends you to the same place whether you finish or skip', async () => {
|
|
606
|
+
mountPage();
|
|
607
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
608
|
+
const afterDone = screen.getByTestId('pathname').textContent;
|
|
609
|
+
cleanup();
|
|
610
|
+
mountPage();
|
|
611
|
+
await userEvent.click(screen.getByRole('button', { name: /Go to your skills/ }));
|
|
612
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(afterDone!);
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
// Exclusive-choice semantics: `radio` says one of these is always chosen
|
|
616
|
+
// and the others are not. Three `aria-pressed` toggles said any combination,
|
|
617
|
+
// including none, was possible.
|
|
618
|
+
it('presents the client picker as an exclusive choice', async () => {
|
|
619
|
+
mountPage();
|
|
620
|
+
const group = screen.getByRole('radiogroup', { name: 'Your agent' });
|
|
621
|
+
const options = screen.getAllByRole('radio');
|
|
622
|
+
expect(group).toContainElement(options[0]!);
|
|
623
|
+
// Claude and ChatGPT lead; Claude is the default.
|
|
624
|
+
expect(options.map((o) => o.textContent)).toEqual(['Claude', 'ChatGPT', 'Desktop agents', 'Other tools']);
|
|
625
|
+
expect(options.map((o) => o.getAttribute('aria-checked'))).toEqual([
|
|
626
|
+
'true',
|
|
627
|
+
'false',
|
|
628
|
+
'false',
|
|
629
|
+
'false',
|
|
630
|
+
]);
|
|
631
|
+
await userEvent.click(screen.getByRole('radio', { name: 'Desktop agents' }));
|
|
632
|
+
expect(screen.getAllByRole('radio').map((o) => o.getAttribute('aria-checked'))).toEqual([
|
|
633
|
+
'false',
|
|
634
|
+
'false',
|
|
635
|
+
'true',
|
|
636
|
+
'false',
|
|
637
|
+
]);
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* `role="radiogroup"` is a promise about the keyboard, not just a label for
|
|
642
|
+
* a screen reader: arrows select, and selection follows focus. The plugin
|
|
643
|
+
* wraps, because four options in a row have no edge worth stopping at.
|
|
644
|
+
*/
|
|
645
|
+
it('drives the picker with the arrow keys, wrapping at both ends', async () => {
|
|
646
|
+
mountPage();
|
|
647
|
+
const checked = () =>
|
|
648
|
+
screen.getAllByRole('radio').find((o) => o.getAttribute('aria-checked') === 'true');
|
|
649
|
+
|
|
650
|
+
screen.getByRole('radio', { name: 'Claude' }).focus();
|
|
651
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
652
|
+
expect(checked()).toHaveAccessibleName('ChatGPT');
|
|
653
|
+
expect(checked()).toHaveFocus();
|
|
654
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
655
|
+
expect(checked()).toHaveAccessibleName('Desktop agents');
|
|
656
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
657
|
+
expect(checked()).toHaveAccessibleName('Other tools');
|
|
658
|
+
|
|
659
|
+
// Off the end and round to the first.
|
|
660
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
661
|
+
expect(checked()).toHaveAccessibleName('Claude');
|
|
662
|
+
|
|
663
|
+
// And backwards past the start, to the last.
|
|
664
|
+
await userEvent.keyboard('{ArrowLeft}');
|
|
665
|
+
expect(checked()).toHaveAccessibleName('Other tools');
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
// Roving tabindex: the picker is ONE tab stop, not one per client.
|
|
669
|
+
it('offers a single tab stop for the whole picker', () => {
|
|
670
|
+
mountPage();
|
|
671
|
+
expect(screen.getAllByRole('radio').map((o) => o.getAttribute('tabindex'))).toEqual([
|
|
672
|
+
'0',
|
|
673
|
+
'-1',
|
|
674
|
+
'-1',
|
|
675
|
+
'-1',
|
|
676
|
+
]);
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
// Into the person's OWN plugin, not the whole catalog — the same place the
|
|
680
|
+
// sidebar's personal row goes.
|
|
681
|
+
it('the skip link leaves for your own plugin, without concluding', async () => {
|
|
682
|
+
mountPage();
|
|
683
|
+
await userEvent.click(screen.getByRole('button', { name: /Go to your skills/ }));
|
|
684
|
+
expect(authFetchMock).not.toHaveBeenCalled();
|
|
685
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/skills-and-tools/yours');
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* A deep link that survived the SSO round-trip retargets BOTH exits: the
|
|
690
|
+
* greeting concluded by discarding the page someone was sent would cost
|
|
691
|
+
* them the reason they came. The skip label says where it now goes.
|
|
692
|
+
*/
|
|
693
|
+
it('keeps a carried deep link: Done lands on it, and the skip link says so', async () => {
|
|
694
|
+
const DEEP = '/workspace/main/knowledge-base/KnowledgeBase/Start here.md';
|
|
695
|
+
const arrivedWithLink = { pathname: WELCOME_PATH, state: { greeting: true, returnTo: DEEP } };
|
|
696
|
+
mountPage(newUser(), arrivedWithLink);
|
|
697
|
+
expect(screen.getByRole('button', { name: /Continue to your link/ })).toBeInTheDocument();
|
|
698
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
699
|
+
expect(authFetchMock).toHaveBeenCalledWith(
|
|
700
|
+
'/api/auth/onboarding-done',
|
|
701
|
+
expect.objectContaining({ method: 'POST' }),
|
|
702
|
+
);
|
|
703
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(DEEP);
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* `AppRegistry.welcomeExit` moves where a new person starts. WHERE that is,
|
|
708
|
+
* is a property of the product: core sends them to their own skills shelf,
|
|
709
|
+
* because on a core deployment that is the product and a fresh knowledge
|
|
710
|
+
* base is empty. A distribution built around the knowledge graph wants the
|
|
711
|
+
* opposite and would otherwise greet someone and then leave them in a
|
|
712
|
+
* surface they did not come for.
|
|
713
|
+
*
|
|
714
|
+
* The tests above deliberately mount WITHOUT a registry, so they pin the
|
|
715
|
+
* default: the seam must be invisible to a deployment that does not use it.
|
|
716
|
+
*/
|
|
717
|
+
describe('welcomeExit', () => {
|
|
718
|
+
const mountWithExit = (
|
|
719
|
+
welcomeExit: { path: string; label: string } | undefined,
|
|
720
|
+
// Same shape `mount` accepts — `typeof greeted` would pin `state` to
|
|
721
|
+
// `{ greeting: boolean }` and reject the deep-link case below.
|
|
722
|
+
route: string | { pathname: string; state?: unknown } = greeted,
|
|
723
|
+
) =>
|
|
724
|
+
mount(
|
|
725
|
+
<AppRegistryContext.Provider value={{ ...EMPTY_REGISTRY, welcomeExit }}>
|
|
726
|
+
<Routes>
|
|
727
|
+
<Route path={WELCOME_PATH} element={<WelcomePage />} />
|
|
728
|
+
<Route path="/skills-and-tools/yours" element={<div>your plugin</div>} />
|
|
729
|
+
<Route path="/workspace" element={<div>knowledge</div>} />
|
|
730
|
+
</Routes>
|
|
731
|
+
</AppRegistryContext.Provider>,
|
|
732
|
+
newUser(),
|
|
733
|
+
route,
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
it('sends both exits to the configured destination', async () => {
|
|
737
|
+
mountWithExit({ path: '/workspace', label: 'Go to your knowledge base' });
|
|
738
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
739
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace');
|
|
740
|
+
});
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* The label travels WITH the path. "Go to your skills →" pointing at a
|
|
744
|
+
* knowledge base is a lie, and letting a caller set one without the other
|
|
745
|
+
* is the likeliest way to produce it.
|
|
746
|
+
*/
|
|
747
|
+
it('labels the skip link with the configured destination', () => {
|
|
748
|
+
mountWithExit({ path: '/workspace', label: 'Go to your knowledge base' });
|
|
749
|
+
expect(
|
|
750
|
+
screen.getByRole('button', { name: /Go to your knowledge base/ }),
|
|
751
|
+
).toBeInTheDocument();
|
|
752
|
+
expect(screen.queryByRole('button', { name: /Go to your skills/ })).not.toBeInTheDocument();
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
it('falls back to the skills shelf when a registry sets nothing', async () => {
|
|
756
|
+
mountWithExit(undefined);
|
|
757
|
+
expect(screen.getByRole('button', { name: /Go to your skills/ })).toBeInTheDocument();
|
|
758
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
759
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/skills-and-tools/yours');
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* A deep link still outranks it. Someone who followed a link is owed that
|
|
764
|
+
* link, and no amount of deployment configuration may eat an intention.
|
|
765
|
+
*/
|
|
766
|
+
it('does not override a carried deep link', async () => {
|
|
767
|
+
const DEEP = '/workspace/main/knowledge-base/KnowledgeBase/Start here.md';
|
|
768
|
+
mountWithExit(
|
|
769
|
+
{ path: '/skills-and-tools/yours', label: 'Go to your skills' },
|
|
770
|
+
{ pathname: WELCOME_PATH, state: { greeting: true, returnTo: DEEP } },
|
|
771
|
+
);
|
|
772
|
+
expect(screen.getByRole('button', { name: /Continue to your link/ })).toBeInTheDocument();
|
|
773
|
+
await userEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
774
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(DEEP);
|
|
775
|
+
});
|
|
776
|
+
});
|
|
777
|
+
});
|
|
778
|
+
|
|
779
|
+
describe('ConnectAgentPill', () => {
|
|
780
|
+
const mountPill = (auth = newUser(), route = '/skills-and-tools') =>
|
|
781
|
+
mount(
|
|
782
|
+
<Routes>
|
|
783
|
+
<Route path="*" element={<ConnectAgentPill />} />
|
|
784
|
+
</Routes>,
|
|
785
|
+
auth,
|
|
786
|
+
route,
|
|
787
|
+
);
|
|
788
|
+
|
|
789
|
+
it('shows for a not-onboarded account and leads to the welcome page', async () => {
|
|
790
|
+
mountPill();
|
|
791
|
+
await userEvent.click(screen.getByRole('button', { name: 'Connect your agent' }));
|
|
792
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent(WELCOME_PATH);
|
|
793
|
+
// …as a plain visit. The pill opens the page; it does not re-run the
|
|
794
|
+
// first-sign-in ceremony that folds the nav it lives in away.
|
|
795
|
+
expect(screen.getByTestId('greeting')).toHaveTextContent('false');
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
it('renders nothing once the server says done', () => {
|
|
799
|
+
mountPill(doneUser());
|
|
800
|
+
expect(screen.queryByRole('button', { name: 'Connect your agent' })).toBeNull();
|
|
801
|
+
});
|
|
802
|
+
|
|
803
|
+
// `page`, not `true` — the pill navigates, so the value that means "this is
|
|
804
|
+
// the page you are on" is the one a screen reader announces as such.
|
|
805
|
+
it('wears the selected state on the welcome page itself', () => {
|
|
806
|
+
mountPill(newUser(), WELCOME_PATH);
|
|
807
|
+
expect(screen.getByRole('button', { name: 'Connect your agent' })).toHaveAttribute(
|
|
808
|
+
'aria-current',
|
|
809
|
+
'page',
|
|
810
|
+
);
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
it('claims no current page anywhere else', () => {
|
|
814
|
+
mountPill();
|
|
815
|
+
expect(screen.getByRole('button', { name: 'Connect your agent' })).not.toHaveAttribute(
|
|
816
|
+
'aria-current',
|
|
817
|
+
);
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
it('the × concludes: same field as Done. And the pill goes', async () => {
|
|
821
|
+
mountPill();
|
|
822
|
+
await userEvent.click(screen.getByRole('button', { name: /^Dismiss/ }));
|
|
823
|
+
expect(authFetchMock).toHaveBeenCalledWith(
|
|
824
|
+
'/api/auth/onboarding-done',
|
|
825
|
+
expect.objectContaining({ method: 'POST' }),
|
|
826
|
+
);
|
|
827
|
+
expect(screen.queryByRole('button', { name: 'Connect your agent' })).toBeNull();
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// The stale-tab guard's client half: the request states which account it
|
|
831
|
+
// means, so the server can refuse to conclude somebody else's onboarding.
|
|
832
|
+
it('states which account it is concluding', async () => {
|
|
833
|
+
mountPill();
|
|
834
|
+
await userEvent.click(screen.getByRole('button', { name: /^Dismiss/ }));
|
|
835
|
+
expect(JSON.parse(String(fetchInit()?.body))).toEqual({ userId: 'u1' });
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* A write that never landed must not leave the UI claiming it did. The pill
|
|
840
|
+
* comes back immediately, rather than mysteriously reappearing at the next
|
|
841
|
+
* sign-in with no account of why it left.
|
|
842
|
+
*/
|
|
843
|
+
it('brings the pill back when the server refuses the write', async () => {
|
|
844
|
+
authFetchMock.mockResolvedValueOnce({ ok: false, status: 409 } as Response);
|
|
845
|
+
const errors = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
846
|
+
mountPill();
|
|
847
|
+
await userEvent.click(screen.getByRole('button', { name: /^Dismiss/ }));
|
|
848
|
+
expect(
|
|
849
|
+
await screen.findByRole('button', { name: 'Connect your agent' }),
|
|
850
|
+
).toBeInTheDocument();
|
|
851
|
+
errors.mockRestore();
|
|
852
|
+
});
|
|
853
|
+
});
|