@bevel-software/platform-core-frontend 0.4.0 → 0.5.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/package.json +5 -3
- package/src/core/CoreAppShell.tsx +195 -56
- package/src/core/__tests__/AppChrome.test.tsx +125 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +130 -95
- package/src/core/__tests__/bootstrap.test.ts +63 -0
- package/src/core/bootstrap.ts +73 -0
- package/src/core/events.ts +12 -0
- package/src/core/registry.ts +58 -9
- package/src/index.css +100 -11
- package/src/index.ts +24 -23
- package/src/lib/utils.ts +114 -138
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +281 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +166 -1
- package/src/modules/access/api.ts +49 -0
- package/src/modules/access/components/ManageAccessDialog.tsx +786 -481
- package/src/modules/access/hooks/useFileAccess.ts +1 -1
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +86 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +172 -156
- package/src/modules/admin/__tests__/admin.unread.test.tsx +61 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +44 -38
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +11 -10
- package/src/modules/admin/components/UserAccountsPage.tsx +361 -353
- package/src/modules/admin/state/admin.context.tsx +15 -6
- package/src/modules/auth/components/AccountPage.tsx +11 -11
- package/src/modules/auth/components/LoginScreen.tsx +12 -12
- package/src/modules/auth/services/sso.ts +47 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +277 -0
- package/src/modules/change-requests/__tests__/author.test.ts +48 -0
- package/src/modules/change-requests/__tests__/conflict.test.ts +73 -0
- package/src/modules/change-requests/__tests__/diff.test.ts +134 -0
- package/src/modules/change-requests/__tests__/propose.test.ts +93 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +72 -0
- package/src/modules/change-requests/change-requests.css +22 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +277 -0
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +713 -0
- package/src/modules/change-requests/components/ConflictHelp.tsx +47 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +398 -0
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +168 -0
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +236 -0
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +79 -0
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +80 -0
- package/src/modules/change-requests/services/change-requests.api.ts +45 -0
- package/src/modules/change-requests/services/propose.api.ts +162 -0
- package/src/modules/change-requests/utils/author.ts +47 -0
- package/src/modules/change-requests/utils/conflict.ts +38 -0
- package/src/modules/change-requests/utils/diff.ts +80 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +27 -18
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +36 -83
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +5 -5
- package/src/modules/git/__tests__/PullRequestsForMe.test.tsx +147 -0
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +2 -8
- package/src/modules/git/components/BranchSwitcher.tsx +68 -31
- package/src/modules/git/components/DiffView.tsx +4 -4
- package/src/modules/git/components/FileComparisonPanel.tsx +20 -20
- package/src/modules/git/components/FileHistoryPanel.tsx +71 -107
- package/src/modules/git/components/PullNeededBanner.tsx +6 -13
- package/src/modules/git/components/PullRequestsForMe.tsx +71 -36
- package/src/modules/git/components/UnifiedDiffView.tsx +4 -4
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +2 -2
- package/src/modules/git/hooks/useGitState.ts +15 -14
- package/src/modules/git/services/__tests__/error-messages.test.ts +4 -4
- package/src/modules/git/services/error-messages.ts +7 -7
- package/src/modules/git/services/git.api.ts +17 -11
- package/src/modules/git/services/pr-prompts.ts +2 -2
- package/src/modules/git/state/git.context.ts +10 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +224 -0
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +242 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +56 -0
- package/src/modules/layout/breakpoints.ts +6 -0
- package/src/modules/layout/components/AppLayout.tsx +17 -5
- package/src/modules/layout/components/DemoBanner.tsx +10 -1
- package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
- package/src/modules/layout/components/MobileChatLayout.tsx +31 -26
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +59 -24
- package/src/modules/layout/components/SidebarFrame.tsx +317 -0
- package/src/modules/layout/components/SidebarToggle.tsx +86 -0
- package/src/modules/layout/components/SlideOverlay.tsx +1 -1
- package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +40 -2
- package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +19 -3
- package/src/modules/layout/state/sidebar.ts +200 -0
- package/src/modules/library/__tests__/AddToGroupDialog.test.tsx +313 -0
- package/src/modules/library/__tests__/ChangeRequestDock.test.tsx +84 -0
- package/src/modules/library/__tests__/GroupJoinRequests.test.tsx +178 -0
- package/src/modules/library/__tests__/GroupPage.test.tsx +479 -0
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +283 -0
- package/src/modules/library/__tests__/GroupsSidebar.contextmenu.test.tsx +175 -0
- package/src/modules/library/__tests__/GroupsSidebar.locked.test.tsx +96 -0
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +142 -0
- package/src/modules/library/__tests__/GroupsSidebarMenu.test.tsx +142 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +149 -0
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +378 -0
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +347 -0
- package/src/modules/library/__tests__/LockedGroupView.test.tsx +203 -0
- package/src/modules/library/__tests__/NewGroupDialog.test.tsx +114 -0
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +177 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +1063 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +259 -0
- package/src/modules/library/__tests__/ToolLogo.test.tsx +63 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +315 -0
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +36 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +260 -0
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +197 -0
- package/src/modules/library/__tests__/auth-harness.tsx +37 -0
- package/src/modules/library/__tests__/oauth-fragment.test.ts +48 -0
- package/src/modules/library/__tests__/status.test.ts +210 -117
- package/src/modules/library/__tests__/useSkillDetail.test.tsx +102 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +146 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +101 -0
- package/src/modules/library/components/AddToGroupDialog.tsx +115 -0
- package/src/modules/library/components/ChangeRequestDock.tsx +71 -47
- package/src/modules/library/components/DeleteGroupDialog.tsx +87 -0
- package/src/modules/library/components/GroupIndexRow.tsx +63 -0
- package/src/modules/library/components/GroupJoinRequests.tsx +56 -0
- package/src/modules/library/components/GroupPage.tsx +373 -0
- package/src/modules/library/components/GroupsIndexPage.tsx +222 -0
- package/src/modules/library/components/GroupsSidebar.tsx +338 -0
- package/src/modules/library/components/GroupsSidebarMenu.tsx +160 -0
- package/src/modules/library/components/LibraryCard.tsx +153 -132
- package/src/modules/library/components/LibraryLayout.tsx +344 -0
- package/src/modules/library/components/LibraryPage.tsx +138 -254
- package/src/modules/library/components/LockGlyph.tsx +31 -0
- package/src/modules/library/components/LockedGroupView.tsx +159 -0
- package/src/modules/library/components/ManagedGroupRequests.tsx +70 -0
- package/src/modules/library/components/NewGroupDialog.tsx +112 -0
- package/src/modules/library/components/NewSkillPanel.tsx +151 -0
- package/src/modules/library/components/PageActions.tsx +156 -0
- package/src/modules/library/components/PendingSkillReview.tsx +63 -0
- package/src/modules/library/components/PersonalAddDialog.tsx +88 -0
- package/src/modules/library/components/PersonalGroupPage.tsx +125 -0
- package/src/modules/library/components/StatusDot.tsx +25 -0
- package/src/modules/library/components/ToolLogo.tsx +171 -0
- package/src/modules/library/components/group-page-parts.tsx +419 -0
- package/src/modules/library/components/skill-page/SkillFileEditor.tsx +134 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +117 -0
- package/src/modules/library/components/skill-page/SkillFileTabs.tsx +112 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +673 -0
- package/src/modules/library/components/skill-page/tab-ids.ts +33 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +175 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +228 -0
- package/src/modules/library/components/tool-page/ToolSharePanel.tsx +45 -0
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +289 -0
- package/src/modules/library/hooks/useJoinRequests.ts +114 -0
- package/src/modules/library/hooks/useLibraryData.ts +134 -119
- package/src/modules/library/hooks/useSkillDetail.ts +119 -74
- package/src/modules/library/hooks/useToolPage.ts +145 -0
- package/src/modules/library/library.css +108 -320
- package/src/modules/library/routes/LibraryRoutes.tsx +134 -0
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +74 -0
- package/src/modules/library/routes/library-paths.ts +191 -0
- package/src/modules/library/services/groups.api.ts +189 -0
- package/src/modules/library/services/library.api.ts +291 -164
- package/src/modules/library/services/tools.api.ts +60 -0
- package/src/modules/library/state/library-context.ts +22 -0
- package/src/modules/library/state/library-data.tsx +223 -0
- package/src/modules/library/state/toast.context.ts +32 -0
- package/src/modules/library/state/toast.tsx +84 -42
- package/src/modules/library/utils/clipboard.ts +33 -0
- package/src/modules/library/utils/group-summary.ts +68 -0
- package/src/modules/library/utils/names.ts +30 -0
- package/src/modules/library/utils/navigate-external.ts +15 -0
- package/src/modules/library/utils/oauth-fragment.ts +32 -0
- package/src/modules/library/utils/personal-group.ts +36 -0
- package/src/modules/library/utils/status.ts +199 -116
- package/src/modules/library/utils/toast-duration.ts +16 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +533 -0
- package/src/modules/onboarding/agent-clients.ts +48 -0
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +133 -0
- package/src/modules/onboarding/components/RootLanding.tsx +54 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +364 -0
- package/src/modules/onboarding/paths.ts +9 -0
- package/src/modules/onboarding/state/onboarding.ts +191 -0
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +10 -10
- package/src/modules/pr/services/pr-approvals.api.ts +19 -0
- package/src/modules/pr/services/pr-cancel.api.ts +11 -0
- package/src/modules/review/components/BinaryChangePlaceholder.tsx +3 -3
- package/src/modules/review/components/DiffViewer.tsx +4 -4
- package/src/modules/review/components/MarkdownDiffViewer.tsx +84 -26
- package/src/modules/review/components/ReviewFileRow.tsx +10 -10
- package/src/modules/review/components/ReviewPanel.tsx +49 -17
- package/src/modules/review/components/ReviewPanelSurface.tsx +1 -1
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +122 -0
- package/src/modules/review/hooks/__tests__/useReviewState.test.ts +1 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +273 -171
- package/src/modules/secrets-vault/components/SecretsPage.tsx +313 -276
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +82 -51
- package/src/modules/secrets-vault/services/connect.api.ts +24 -3
- package/src/modules/settings/components/DeploymentPage.tsx +90 -0
- package/src/modules/settings/components/SettingsLayout.tsx +135 -0
- package/src/modules/settings/components/SettingsNav.tsx +114 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +110 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +249 -0
- package/src/modules/settings/settings-nav-items.tsx +166 -0
- package/src/modules/setup/__tests__/setup.test.tsx +540 -0
- package/src/modules/setup/components/SetupGate.tsx +67 -0
- package/src/modules/setup/components/SetupScreen.tsx +573 -0
- package/src/modules/setup/services/setup.api.ts +106 -0
- package/src/modules/setup/utils/git-host.ts +34 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +131 -108
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
- package/src/modules/toolbar/components/ProfileMenu.tsx +294 -0
- package/src/modules/toolbar/components/Toolbar.tsx +56 -54
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +176 -122
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +252 -77
- package/src/modules/tools/ToolsExplorerPage.tsx +45 -40
- package/src/modules/workspace/__tests__/design-system-parity.test.ts +133 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +2 -0
- package/src/modules/workspace/components/EditorTabs.tsx +82 -50
- package/src/modules/workspace/components/FileExplorer.tsx +1292 -1068
- package/src/modules/workspace/components/FilePaneCard.tsx +53 -0
- package/src/modules/workspace/components/FileRoute.tsx +89 -84
- package/src/modules/workspace/components/FileViewer.tsx +1312 -906
- package/src/modules/workspace/components/KbDocumentShell.tsx +138 -0
- package/src/modules/workspace/components/KbFileRail.tsx +128 -0
- package/src/modules/workspace/components/KbPageHeader.tsx +390 -0
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +87 -3
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +293 -39
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +1 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +462 -44
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +84 -0
- package/src/modules/workspace/components/__tests__/KbFileRail.test.tsx +83 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +192 -0
- package/src/modules/workspace/components/renderers/CopyAnchorButton.tsx +64 -0
- package/src/modules/workspace/components/renderers/CsvRenderer.tsx +8 -8
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +18 -9
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +14 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +2 -2
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +31 -165
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +18 -5
- package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +27 -10
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +2 -2
- package/src/modules/workspace/components/renderers/TextRenderer.tsx +11 -5
- package/src/modules/workspace/components/renderers/ToolForm.tsx +24 -24
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +27 -27
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -11
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +66 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +17 -1
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +1 -1
- package/src/modules/workspace/components/renderers/__tests__/MermaidDiagram.test.tsx +58 -0
- package/src/modules/workspace/components/renderers/__tests__/lazyRenderer.test.tsx +68 -0
- package/src/modules/workspace/components/renderers/__tests__/rendererLayout.test.ts +64 -0
- package/src/modules/workspace/components/renderers/__tests__/sanitizeDocxHtml.test.ts +0 -0
- package/src/modules/workspace/components/renderers/chunk-boundary.tsx +71 -0
- package/src/modules/workspace/components/renderers/index.ts +78 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +241 -0
- package/src/modules/workspace/components/renderers/lazyRenderer.tsx +59 -0
- package/src/modules/workspace/components/renderers/sanitizeDocxHtml.ts +91 -0
- package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +59 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +237 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +185 -0
- package/src/modules/workspace/hooks/useAutoGrowTextarea.ts +30 -0
- package/src/modules/workspace/hooks/useLastCommit.ts +66 -0
- package/src/modules/workspace/hooks/useLinksOut.ts +56 -0
- package/src/modules/workspace/hooks/useOpenChangeRequests.ts +20 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +123 -14
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +1 -1
- package/src/modules/workspace/services/workspace.api.ts +9 -2
- package/src/modules/workspace/state/open-change-requests.context.ts +35 -0
- package/src/modules/workspace/state/open-change-requests.tsx +185 -0
- package/src/modules/workspace/state/workspace.context.ts +9 -0
- package/src/modules/workspace/utils/__tests__/diff.test.ts +87 -0
- package/src/modules/workspace/utils/diff.ts +130 -53
- package/src/modules/workspace/utils/fileTree.ts +182 -179
- package/src/modules/workspace/workspace.css +28 -0
- package/src/shared/components/Badge.tsx +62 -0
- package/src/shared/components/Banner.tsx +58 -0
- package/src/shared/components/Button.tsx +90 -0
- package/src/shared/components/Dialog.tsx +6 -6
- package/src/shared/components/Field.tsx +45 -0
- package/src/shared/components/IconButton.tsx +74 -0
- package/src/shared/components/ListRow.tsx +96 -0
- package/src/shared/components/Menu.tsx +88 -0
- package/src/shared/components/PageShell.tsx +54 -51
- package/src/shared/components/Surface.tsx +86 -0
- package/src/shared/components/__tests__/primitives.test.tsx +333 -0
- package/src/shared/components/index.ts +48 -0
- package/src/shared/components/useDismissableMenu.ts +71 -0
- package/src/shared/theme/__tests__/accent-contrast.test.ts +84 -0
- package/src/shared/theme/index.css +12 -0
- package/src/shared/theme/measure.ts +64 -0
- package/src/shared/theme/shadows.css +34 -0
- package/src/shared/theme/tokens.css +193 -0
- package/src/test-setup.ts +9 -0
- package/src/modules/access/components/AccessRestrictedBanner.tsx +0 -31
- package/src/modules/access/components/NodeOwnersBanner.tsx +0 -30
- package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +0 -82
- package/src/modules/git/components/ProtectedBranchBanner.tsx +0 -42
- package/src/modules/library/__tests__/DetailDialog.test.tsx +0 -200
- package/src/modules/library/__tests__/diff.test.ts +0 -62
- package/src/modules/library/__tests__/loadout.test.tsx +0 -72
- package/src/modules/library/components/CompareView.tsx +0 -357
- package/src/modules/library/components/DetailDialog.tsx +0 -566
- package/src/modules/library/components/GearIcon.tsx +0 -12
- package/src/modules/library/components/LoadoutSidebar.tsx +0 -156
- package/src/modules/library/components/StatusGem.tsx +0 -21
- package/src/modules/library/components/SuggestChange.tsx +0 -171
- package/src/modules/library/components/particles.ts +0 -50
- package/src/modules/library/state/loadout.tsx +0 -129
- package/src/modules/library/utils/diff.ts +0 -102
- package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +0 -93
- package/src/modules/pr/__tests__/PrCancelButton.test.tsx +0 -158
- package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +0 -44
- package/src/modules/pr/__tests__/PrMergeButton.test.tsx +0 -360
- package/src/modules/pr/__tests__/bucketize-comments.test.ts +0 -85
- package/src/modules/pr/__tests__/parsePatch.test.ts +0 -104
- package/src/modules/pr/__tests__/usePrViewerState.test.ts +0 -72
- package/src/modules/pr/components/PrApprovalBadge.tsx +0 -80
- package/src/modules/pr/components/PrCancelButton.tsx +0 -99
- package/src/modules/pr/components/PrCancelConfirmDialog.tsx +0 -119
- package/src/modules/pr/components/PrCommentComposer.tsx +0 -92
- package/src/modules/pr/components/PrCommentThread.tsx +0 -168
- package/src/modules/pr/components/PrCommentsPanel.tsx +0 -143
- package/src/modules/pr/components/PrDiffPane.tsx +0 -425
- package/src/modules/pr/components/PrFileRow.tsx +0 -164
- package/src/modules/pr/components/PrFilesList.tsx +0 -53
- package/src/modules/pr/components/PrHeader.tsx +0 -45
- package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +0 -58
- package/src/modules/pr/components/PrMergeButton.tsx +0 -268
- package/src/modules/pr/components/PrMergeConfirmDialog.tsx +0 -112
- package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +0 -110
- package/src/modules/pr/components/PrViewer.tsx +0 -364
- package/src/modules/pr/hooks/usePrViewerState.ts +0 -150
- package/src/modules/pr/state/pr-viewer.context.ts +0 -34
- package/src/modules/pr/utils/bucketize-comments.ts +0 -55
- package/src/modules/pr/utils/parsePatch.ts +0 -57
- package/src/modules/toolbar/components/AdminMenu.tsx +0 -271
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
WorkspaceContext,
|
|
7
|
+
type WorkspaceContextValue,
|
|
8
|
+
} from '../../workspace/state/workspace.context';
|
|
9
|
+
import type { ToolSecrets, ToolSetup } from '../../secrets-vault/services/tool-secrets.api';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The section frame: the Secrets deep link, the setup banner's three audiences,
|
|
13
|
+
* and that the rows keep server order (the `.tool` file's declaration order is
|
|
14
|
+
* the only order that means anything to the person who wrote it).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
vi.mock('../../secrets-vault/services/tool-secrets.api', () => ({
|
|
18
|
+
setAdminVar: vi.fn(),
|
|
19
|
+
setUserVar: vi.fn(),
|
|
20
|
+
deleteAdminVar: vi.fn(),
|
|
21
|
+
setOAuthClientSecret: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
vi.mock('../../secrets-vault/services/connect.api', () => ({ startToolOAuth: vi.fn() }));
|
|
24
|
+
vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
|
|
25
|
+
|
|
26
|
+
import { ToolConnectionSection } from '../components/tool-page/ToolConnectionSection';
|
|
27
|
+
|
|
28
|
+
function workspace(kbDirName: string | null): WorkspaceContextValue {
|
|
29
|
+
return { workspaceId: 'target-company-state', kbDirName } as unknown as WorkspaceContextValue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Exposes the router's pathname so the Edit link's destination is assertable. */
|
|
33
|
+
function LocationProbe() {
|
|
34
|
+
const location = useLocation();
|
|
35
|
+
return <div aria-label="pathname">{location.pathname}</div>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function wrap(children: ReactNode, kbDirName: string | null = 'knowledge-base') {
|
|
39
|
+
return (
|
|
40
|
+
<MemoryRouter>
|
|
41
|
+
<WorkspaceContext.Provider value={workspace(kbDirName)}>
|
|
42
|
+
{children}
|
|
43
|
+
<LocationProbe />
|
|
44
|
+
</WorkspaceContext.Provider>
|
|
45
|
+
</MemoryRouter>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function tool(over: Partial<ToolSecrets> = {}): ToolSecrets {
|
|
50
|
+
return {
|
|
51
|
+
slug: 'github',
|
|
52
|
+
name: 'github',
|
|
53
|
+
path: 'Groups/Engineering/github.tool',
|
|
54
|
+
type: 'mcp',
|
|
55
|
+
setup: null,
|
|
56
|
+
canWrite: false,
|
|
57
|
+
variables: [],
|
|
58
|
+
...over,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const OAUTH_MANUAL: ToolSetup = {
|
|
63
|
+
kind: 'oauth-manual',
|
|
64
|
+
reason: 'The server does not support dynamic client registration.',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function renderSection(t: ToolSecrets, kbDirName: string | null = 'knowledge-base') {
|
|
68
|
+
return render(
|
|
69
|
+
wrap(
|
|
70
|
+
<ToolConnectionSection tool={t} onChanged={vi.fn()} onError={vi.fn()} />,
|
|
71
|
+
kbDirName,
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe('ToolConnectionSection', () => {
|
|
77
|
+
it('heads the section and links to the Secrets page', () => {
|
|
78
|
+
renderSection(tool());
|
|
79
|
+
expect(screen.getByRole('heading', { name: 'Your connection' })).toBeInTheDocument();
|
|
80
|
+
expect(screen.getByRole('link', { name: 'Open Secrets' })).toHaveAttribute('href', '/secrets');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('says there is nothing to set up when the tool declares no variables', () => {
|
|
84
|
+
renderSection(tool());
|
|
85
|
+
expect(screen.getByText('Nothing to set up')).toBeInTheDocument();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('renders one row per variable, in server order', () => {
|
|
89
|
+
renderSection(
|
|
90
|
+
tool({
|
|
91
|
+
variables: [
|
|
92
|
+
{ name: 'B_KEY', scope: 'admin', label: 'Second', key: 'k1', adminConfigured: true, userConfigured: false },
|
|
93
|
+
{ name: 'A_KEY', scope: 'admin', label: 'First', key: 'k2', adminConfigured: true, userConfigured: false },
|
|
94
|
+
],
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
const labels = screen.getAllByText(/^(First|Second)$/).map((n) => n.textContent);
|
|
98
|
+
expect(labels).toEqual(['Second', 'First']);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('tells a writer how to finish an oauth-manual setup, with a link into the tool file', async () => {
|
|
102
|
+
renderSection(tool({ setup: OAUTH_MANUAL, canWrite: true }));
|
|
103
|
+
|
|
104
|
+
expect(screen.getByRole('status')).toHaveTextContent(
|
|
105
|
+
/Sign-in setup needed: this server needs users to sign in/,
|
|
106
|
+
);
|
|
107
|
+
expect(screen.getByText(OAUTH_MANUAL.reason!)).toBeInTheDocument();
|
|
108
|
+
|
|
109
|
+
fireEvent.click(screen.getByRole('button', { name: 'Edit the tool file' }));
|
|
110
|
+
await waitFor(() =>
|
|
111
|
+
expect(screen.getByLabelText('pathname').textContent).toContain(
|
|
112
|
+
'knowledge-base/Groups/Engineering/github.tool',
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('tells everyone else to ask the owner, with no edit link', () => {
|
|
118
|
+
renderSection(tool({ setup: OAUTH_MANUAL }));
|
|
119
|
+
expect(screen.getByRole('status')).toHaveTextContent(
|
|
120
|
+
"Sign-in setup needed: ask the tool's owner to finish setting this up.",
|
|
121
|
+
);
|
|
122
|
+
expect(screen.queryByRole('button', { name: 'Edit the tool file' })).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('omits the edit link while the workspace has no kb directory yet', () => {
|
|
126
|
+
renderSection(tool({ setup: OAUTH_MANUAL, canWrite: true }), null);
|
|
127
|
+
expect(screen.getByRole('status')).toBeInTheDocument();
|
|
128
|
+
expect(screen.queryByRole('button', { name: 'Edit the tool file' })).toBeNull();
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('drops every banner once the owner-side provider is configured', () => {
|
|
132
|
+
renderSection(
|
|
133
|
+
tool({
|
|
134
|
+
setup: OAUTH_MANUAL,
|
|
135
|
+
canWrite: true,
|
|
136
|
+
variables: [
|
|
137
|
+
{
|
|
138
|
+
name: 'SIGNIN',
|
|
139
|
+
scope: 'user',
|
|
140
|
+
label: null,
|
|
141
|
+
key: 'github_SIGNIN',
|
|
142
|
+
adminConfigured: true,
|
|
143
|
+
userConfigured: false,
|
|
144
|
+
oauth: true,
|
|
145
|
+
authorized: false,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
// The SETUP banner is gone because the provider is configured — and the
|
|
151
|
+
// connection banner does NOT take its place: configuration is done, and a
|
|
152
|
+
// pending sign-in is the row's business. The row below carries the state
|
|
153
|
+
// and the button, so a banner would be the same sentence twice.
|
|
154
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
155
|
+
expect(screen.queryByText(/Sign-in setup needed/)).toBeNull();
|
|
156
|
+
expect(screen.getByRole('button', { name: 'Sign in' })).toBeInTheDocument();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('keeps the banner about configuration: a missing key is named, a pending sign-in is not', () => {
|
|
160
|
+
renderSection(
|
|
161
|
+
tool({
|
|
162
|
+
variables: [
|
|
163
|
+
{
|
|
164
|
+
name: 'API_KEY',
|
|
165
|
+
scope: 'user',
|
|
166
|
+
label: 'HeyReach API key',
|
|
167
|
+
key: 'heyreach_API_KEY',
|
|
168
|
+
adminConfigured: false,
|
|
169
|
+
userConfigured: false,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'SIGNIN',
|
|
173
|
+
scope: 'user',
|
|
174
|
+
label: null,
|
|
175
|
+
key: 'heyreach_SIGNIN',
|
|
176
|
+
adminConfigured: true,
|
|
177
|
+
userConfigured: false,
|
|
178
|
+
oauth: true,
|
|
179
|
+
authorized: false,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
}),
|
|
183
|
+
);
|
|
184
|
+
const banner = screen.getByRole('status');
|
|
185
|
+
// One configuration gap → the singular headline, not "needs 2 things".
|
|
186
|
+
expect(banner).toHaveTextContent('This tool is not connected yet.');
|
|
187
|
+
expect(banner).toHaveTextContent('HeyReach API key: Needs a key from you');
|
|
188
|
+
expect(banner).not.toHaveTextContent('Needs your sign-in');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('says what a tool is missing, in amber, above the rows', () => {
|
|
192
|
+
renderSection(
|
|
193
|
+
tool({
|
|
194
|
+
variables: [
|
|
195
|
+
{
|
|
196
|
+
name: 'API_KEY',
|
|
197
|
+
scope: 'user',
|
|
198
|
+
label: 'HeyReach API key',
|
|
199
|
+
key: 'heyreach_API_KEY',
|
|
200
|
+
adminConfigured: false,
|
|
201
|
+
userConfigured: false,
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
// Named by its label, not its env var — and it says whose move it is.
|
|
207
|
+
expect(screen.getByRole('status')).toHaveTextContent(
|
|
208
|
+
'HeyReach API key: Needs a key from you',
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("the banner's Add key opens the missing variable's editor, from a distance", () => {
|
|
213
|
+
renderSection(
|
|
214
|
+
tool({
|
|
215
|
+
variables: [
|
|
216
|
+
{
|
|
217
|
+
name: 'API_KEY',
|
|
218
|
+
scope: 'user',
|
|
219
|
+
label: 'HeyReach API key',
|
|
220
|
+
key: 'heyreach_API_KEY',
|
|
221
|
+
adminConfigured: false,
|
|
222
|
+
userConfigured: false,
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
}),
|
|
226
|
+
);
|
|
227
|
+
expect(screen.queryByRole('textbox')).toBeNull();
|
|
228
|
+
fireEvent.click(screen.getByRole('button', { name: 'Add key: HeyReach API key' }));
|
|
229
|
+
// The same editor the row's own button opens — one path, two doors.
|
|
230
|
+
expect(screen.getByLabelText('Value for API_KEY')).toBeInTheDocument();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('says nothing when every variable is set', () => {
|
|
234
|
+
renderSection(
|
|
235
|
+
tool({
|
|
236
|
+
variables: [
|
|
237
|
+
{
|
|
238
|
+
name: 'API_KEY',
|
|
239
|
+
scope: 'user',
|
|
240
|
+
label: null,
|
|
241
|
+
key: 'heyreach_API_KEY',
|
|
242
|
+
adminConfigured: true,
|
|
243
|
+
userConfigured: true,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
}),
|
|
247
|
+
);
|
|
248
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it.each<ToolSetup | null>([{ kind: 'open' }, { kind: 'oauth-auto' }, null])(
|
|
252
|
+
'shows no setup banner for %s',
|
|
253
|
+
(setup) => {
|
|
254
|
+
// No variables at all, so neither banner has anything to report.
|
|
255
|
+
renderSection(tool({ setup, canWrite: true }));
|
|
256
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
257
|
+
},
|
|
258
|
+
);
|
|
259
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { render, cleanup } from '@testing-library/react';
|
|
3
|
+
import { ToolLogo } from '../components/ToolLogo';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A tool's mark. Two things are worth pinning, and neither is how it looks:
|
|
7
|
+
*
|
|
8
|
+
* - the fallback FIRES, because most tools will never have a drawn logo — the
|
|
9
|
+
* KB accepts any `.tool` anybody writes;
|
|
10
|
+
* - the fallback is STABLE, because a monogram whose colour moved when the
|
|
11
|
+
* catalog gained an entry would be worse than no colour at all.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
function mark(slug: string, name?: string) {
|
|
15
|
+
const { container } = render(<ToolLogo slug={slug} name={name} />);
|
|
16
|
+
return container.firstElementChild as HTMLElement;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('ToolLogo', () => {
|
|
20
|
+
it('draws the real logo for a service we ship a mark for', () => {
|
|
21
|
+
expect(mark('slack').querySelector('svg')).not.toBeNull();
|
|
22
|
+
cleanup();
|
|
23
|
+
expect(mark('github').querySelector('svg')).not.toBeNull();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('maps our slug, not the brand name', () => {
|
|
27
|
+
// The `.tool` files declare `google_gmail`; nothing in the catalog says
|
|
28
|
+
// "gmail", so keying on the brand would have silently missed every one.
|
|
29
|
+
expect(mark('google_gmail').querySelector('svg')).not.toBeNull();
|
|
30
|
+
cleanup();
|
|
31
|
+
expect(mark('google_calendar').querySelector('svg')).not.toBeNull();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('falls back to a monogram for a tool nobody has drawn', () => {
|
|
35
|
+
const el = mark('heyreach', 'HeyReach');
|
|
36
|
+
expect(el.querySelector('svg')).toBeNull();
|
|
37
|
+
expect(el.textContent).toBe('H');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('takes the monogram letter from the slug when there is no name', () => {
|
|
41
|
+
expect(mark('quickbooks').textContent).toBe('Q');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('gives one slug the same colour every time, and not by position', () => {
|
|
45
|
+
const first = mark('heyreach').getAttribute('style');
|
|
46
|
+
cleanup();
|
|
47
|
+
const again = mark('heyreach').getAttribute('style');
|
|
48
|
+
expect(again).toBe(first);
|
|
49
|
+
expect(first).toMatch(/background-color/);
|
|
50
|
+
|
|
51
|
+
// A different slug is free to collide on colour — what must NOT happen is
|
|
52
|
+
// a slug's colour depending on what else exists.
|
|
53
|
+
cleanup();
|
|
54
|
+
const other = mark('granola').getAttribute('style');
|
|
55
|
+
expect(other).toMatch(/background-color/);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('stays out of the accessible name. The row already says the tool', () => {
|
|
59
|
+
expect(mark('slack')).toHaveAttribute('aria-hidden', 'true');
|
|
60
|
+
cleanup();
|
|
61
|
+
expect(mark('heyreach')).toHaveAttribute('aria-hidden', 'true');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
WorkspaceContext,
|
|
7
|
+
type WorkspaceContextValue,
|
|
8
|
+
} from '../../workspace/state/workspace.context';
|
|
9
|
+
import { AdminContext } from '../../admin/state/admin.context';
|
|
10
|
+
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
11
|
+
import type { ToolManualDetail } from '../services/tools.api';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The page as a whole: what each URL state renders, the three signals that gate
|
|
15
|
+
* it (read access, `canWrite`, `isAdmin`), and the OAuth fragment round-trip.
|
|
16
|
+
*
|
|
17
|
+
* Everything is selected by role / accessible name / text — the a11y contract
|
|
18
|
+
* is what Ali's skill page and the deep links from `/secrets` and `/connect`
|
|
19
|
+
* are built against, so it is the thing worth pinning.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const secretsMock = vi.hoisted(() => ({
|
|
23
|
+
listToolSecrets: vi.fn(),
|
|
24
|
+
setAdminVar: vi.fn(),
|
|
25
|
+
setUserVar: vi.fn(),
|
|
26
|
+
deleteAdminVar: vi.fn(),
|
|
27
|
+
setOAuthClientSecret: vi.fn(),
|
|
28
|
+
}));
|
|
29
|
+
vi.mock('../../secrets-vault/services/tool-secrets.api', () => secretsMock);
|
|
30
|
+
|
|
31
|
+
const toolsMock = vi.hoisted(() => ({ getToolDetail: vi.fn() }));
|
|
32
|
+
vi.mock('../services/tools.api', () => ({ getToolDetail: toolsMock.getToolDetail }));
|
|
33
|
+
|
|
34
|
+
const libraryMock = vi.hoisted(() => ({ listSkills: vi.fn(), getSkill: vi.fn() }));
|
|
35
|
+
vi.mock('../services/library.api', () => ({
|
|
36
|
+
listSkills: libraryMock.listSkills,
|
|
37
|
+
getSkill: libraryMock.getSkill,
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
vi.mock('../../secrets-vault/services/connect.api', () => ({ startToolOAuth: vi.fn() }));
|
|
41
|
+
vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
|
|
42
|
+
|
|
43
|
+
import { ToolPage } from '../components/tool-page/ToolPage';
|
|
44
|
+
|
|
45
|
+
const GITHUB: ToolSecrets = {
|
|
46
|
+
slug: 'heyreach',
|
|
47
|
+
name: 'heyreach',
|
|
48
|
+
path: 'Groups/GTM/heyreach.tool',
|
|
49
|
+
type: 'inline',
|
|
50
|
+
setup: null,
|
|
51
|
+
canWrite: false,
|
|
52
|
+
variables: [],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const DETAIL: ToolManualDetail = {
|
|
56
|
+
slug: 'heyreach',
|
|
57
|
+
name: 'heyreach',
|
|
58
|
+
path: 'Groups/GTM/heyreach.tool',
|
|
59
|
+
type: 'inline',
|
|
60
|
+
description: 'Runs LinkedIn outreach campaigns.',
|
|
61
|
+
capabilities: [
|
|
62
|
+
{ name: 'add_leads', description: 'Add leads to a campaign.' },
|
|
63
|
+
{ name: 'get_campaign', description: null },
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const workspace = {
|
|
68
|
+
workspaceId: 'target-company-state',
|
|
69
|
+
kbDirName: 'knowledge-base',
|
|
70
|
+
} as unknown as WorkspaceContextValue;
|
|
71
|
+
|
|
72
|
+
function admin(isAdmin: boolean) {
|
|
73
|
+
return {
|
|
74
|
+
isAdmin,
|
|
75
|
+
unreadCount: 0,
|
|
76
|
+
lastSeen: null,
|
|
77
|
+
markSeen: vi.fn(),
|
|
78
|
+
refresh: vi.fn(),
|
|
79
|
+
rolesConfigCorrupted: false,
|
|
80
|
+
rolesConfigErrors: [],
|
|
81
|
+
runRolesRecovery: vi.fn(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Exposes the router's pathname so navigation away from the page is assertable. */
|
|
86
|
+
function LocationProbe() {
|
|
87
|
+
const location = useLocation();
|
|
88
|
+
return <div aria-label="pathname">{location.pathname}</div>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function wrap(children: ReactNode, isAdmin: boolean) {
|
|
92
|
+
return (
|
|
93
|
+
<AdminContext.Provider value={admin(isAdmin)}>
|
|
94
|
+
<WorkspaceContext.Provider value={workspace}>{children}</WorkspaceContext.Provider>
|
|
95
|
+
</AdminContext.Provider>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function renderPage({ slug = 'heyreach', isAdmin = false } = {}) {
|
|
100
|
+
return render(
|
|
101
|
+
<MemoryRouter initialEntries={[`/skills-and-tools/tools/${slug}`]}>
|
|
102
|
+
{wrap(
|
|
103
|
+
<Routes>
|
|
104
|
+
<Route path="/skills-and-tools/tools/:slug" element={<ToolPage />} />
|
|
105
|
+
<Route path="/skills-and-tools" element={<div>Gallery</div>} />
|
|
106
|
+
</Routes>,
|
|
107
|
+
isAdmin,
|
|
108
|
+
)}
|
|
109
|
+
<LocationProbe />
|
|
110
|
+
</MemoryRouter>,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
beforeEach(() => {
|
|
115
|
+
window.history.replaceState(null, '', '/skills-and-tools/tools/heyreach');
|
|
116
|
+
secretsMock.listToolSecrets.mockReset().mockResolvedValue([GITHUB]);
|
|
117
|
+
toolsMock.getToolDetail.mockReset().mockResolvedValue(DETAIL);
|
|
118
|
+
libraryMock.listSkills.mockReset().mockResolvedValue([]);
|
|
119
|
+
libraryMock.getSkill.mockReset().mockResolvedValue({ allowedTools: [] });
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('ToolPage: frame', () => {
|
|
123
|
+
it('loads, then shows the title, the lede and the ownerline, with no kicker', async () => {
|
|
124
|
+
renderPage();
|
|
125
|
+
expect(screen.getByText('Loading…')).toBeInTheDocument();
|
|
126
|
+
|
|
127
|
+
expect(await screen.findByRole('heading', { name: 'heyreach', level: 1 })).toBeInTheDocument();
|
|
128
|
+
expect(screen.queryByText(/Tool · /)).toBeNull();
|
|
129
|
+
expect(await screen.findByText('Runs LinkedIn outreach campaigns.')).toBeInTheDocument();
|
|
130
|
+
expect(screen.getByText('Managed by the Admins.')).toBeInTheDocument();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('shows no kicker for a legacy ungrouped path either', async () => {
|
|
134
|
+
secretsMock.listToolSecrets.mockResolvedValue([
|
|
135
|
+
{ ...GITHUB, slug: 'slack', name: 'slack', path: 'Tools/slack.tool' },
|
|
136
|
+
]);
|
|
137
|
+
toolsMock.getToolDetail.mockResolvedValue({ ...DETAIL, slug: 'slack', name: 'slack' });
|
|
138
|
+
renderPage({ slug: 'slack' });
|
|
139
|
+
|
|
140
|
+
await screen.findByRole('heading', { name: 'slack', level: 1 });
|
|
141
|
+
expect(screen.queryByText(/^Tool$/)).toBeNull();
|
|
142
|
+
expect(screen.queryByText(/Tool · /)).toBeNull();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("goes back to the tool's own group from the back link", async () => {
|
|
146
|
+
// Not the Library root: the reader opened this tool off its group page,
|
|
147
|
+
// and "back" should land where the tool lives. Derived from the path, so
|
|
148
|
+
// a deep link gets the same destination as a click.
|
|
149
|
+
renderPage();
|
|
150
|
+
await screen.findByRole('heading', { name: 'heyreach', level: 1 });
|
|
151
|
+
|
|
152
|
+
fireEvent.click(screen.getByRole('button', { name: '‹ GTM' }));
|
|
153
|
+
await waitFor(() =>
|
|
154
|
+
expect(screen.getByLabelText('pathname').textContent).toBe('/skills-and-tools/groups/GTM'),
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('shows the fail-closed not-found copy for a slug nobody can reach', async () => {
|
|
159
|
+
secretsMock.listToolSecrets.mockResolvedValue([]);
|
|
160
|
+
renderPage({ slug: 'ghost' });
|
|
161
|
+
|
|
162
|
+
expect(
|
|
163
|
+
await screen.findByText("This tool doesn't exist, or you don't have access to it."),
|
|
164
|
+
).toBeInTheDocument();
|
|
165
|
+
expect(screen.getByRole('button', { name: '‹ All skills & tools' })).toBeInTheDocument();
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('offers Try again when the secrets listing fails, and refetches on click', async () => {
|
|
169
|
+
secretsMock.listToolSecrets.mockRejectedValueOnce(new Error("Couldn't load tool secrets."));
|
|
170
|
+
renderPage();
|
|
171
|
+
|
|
172
|
+
const banner = await screen.findByRole('alert');
|
|
173
|
+
expect(banner).toHaveTextContent("Couldn't load tool secrets.");
|
|
174
|
+
|
|
175
|
+
fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
|
|
176
|
+
expect(await screen.findByRole('heading', { name: 'heyreach', level: 1 })).toBeInTheDocument();
|
|
177
|
+
expect(secretsMock.listToolSecrets).toHaveBeenCalledTimes(2);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('renders without the lede or capabilities when the detail read fails', async () => {
|
|
181
|
+
toolsMock.getToolDetail.mockRejectedValue(new Error('no such endpoint'));
|
|
182
|
+
renderPage();
|
|
183
|
+
|
|
184
|
+
await screen.findByRole('heading', { name: 'heyreach', level: 1 });
|
|
185
|
+
expect(screen.queryByText('Runs LinkedIn outreach campaigns.')).toBeNull();
|
|
186
|
+
expect(screen.queryByRole('heading', { name: 'What it lets the assistant do' })).toBeNull();
|
|
187
|
+
// The connection section still works — this is what makes the page
|
|
188
|
+
// shippable against a backend without the detail endpoint.
|
|
189
|
+
expect(screen.getByRole('heading', { name: 'Your connection' })).toBeInTheDocument();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
describe('ToolPage: capabilities', () => {
|
|
194
|
+
it('lists each capability, falling back to its name when it has no description', async () => {
|
|
195
|
+
renderPage();
|
|
196
|
+
expect(
|
|
197
|
+
await screen.findByRole('heading', { name: 'What it lets the assistant do' }),
|
|
198
|
+
).toBeInTheDocument();
|
|
199
|
+
expect(screen.getByText('· Add leads to a campaign.')).toBeInTheDocument();
|
|
200
|
+
expect(screen.getByText('· get_campaign')).toBeInTheDocument();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('hides the section on emptiness, not on type (mcp tools always report [])', async () => {
|
|
204
|
+
toolsMock.getToolDetail.mockResolvedValue({ ...DETAIL, type: 'mcp', capabilities: [] });
|
|
205
|
+
renderPage();
|
|
206
|
+
|
|
207
|
+
await screen.findByRole('heading', { name: 'heyreach', level: 1 });
|
|
208
|
+
expect(screen.queryByRole('heading', { name: 'What it lets the assistant do' })).toBeNull();
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('ToolPage: powers these skills', () => {
|
|
213
|
+
it('links each matching skill at the reserved skill route', async () => {
|
|
214
|
+
libraryMock.listSkills.mockResolvedValue([
|
|
215
|
+
{ name: 'outreach', description: '', path: 'Groups/GTM/outreach' },
|
|
216
|
+
{ name: 'roadmap', description: '', path: 'Groups/Product/roadmap' },
|
|
217
|
+
]);
|
|
218
|
+
libraryMock.getSkill.mockImplementation(async (name: string) =>
|
|
219
|
+
name === 'outreach' ? { allowedTools: ['heyreach_add_leads'] } : { allowedTools: ['Bash'] },
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
renderPage();
|
|
223
|
+
const chip = await screen.findByRole('link', { name: 'outreach' });
|
|
224
|
+
expect(chip).toHaveAttribute('href', '/skills-and-tools/skills/outreach');
|
|
225
|
+
expect(screen.queryByRole('link', { name: 'roadmap' })).toBeNull();
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('claims no skills use it only once the catalog has actually loaded', async () => {
|
|
229
|
+
let releaseSkills: (skills: unknown[]) => void = () => {};
|
|
230
|
+
libraryMock.listSkills.mockImplementation(
|
|
231
|
+
() =>
|
|
232
|
+
new Promise((resolve) => {
|
|
233
|
+
releaseSkills = resolve as (skills: unknown[]) => void;
|
|
234
|
+
}),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
renderPage();
|
|
238
|
+
await screen.findByRole('heading', { name: 'Powers these skills' });
|
|
239
|
+
// Not yet: an empty index we haven't loaded is not proof of absence.
|
|
240
|
+
expect(screen.queryByText('No skills use this yet.')).toBeNull();
|
|
241
|
+
|
|
242
|
+
releaseSkills([]);
|
|
243
|
+
expect(await screen.findByText('No skills use this yet.')).toBeInTheDocument();
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe('ToolPage: connection', () => {
|
|
248
|
+
it('says there is nothing to set up when the tool declares no variables', async () => {
|
|
249
|
+
renderPage();
|
|
250
|
+
expect(await screen.findByText('Nothing to set up')).toBeInTheDocument();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('surfaces a failed write as a page-level alert', async () => {
|
|
254
|
+
secretsMock.setAdminVar.mockRejectedValue(new Error('Forbidden'));
|
|
255
|
+
secretsMock.listToolSecrets.mockResolvedValue([
|
|
256
|
+
{
|
|
257
|
+
...GITHUB,
|
|
258
|
+
canWrite: true,
|
|
259
|
+
variables: [
|
|
260
|
+
{
|
|
261
|
+
name: 'API_KEY',
|
|
262
|
+
scope: 'admin',
|
|
263
|
+
label: null,
|
|
264
|
+
key: 'heyreach_API_KEY',
|
|
265
|
+
adminConfigured: false,
|
|
266
|
+
userConfigured: false,
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
]);
|
|
271
|
+
|
|
272
|
+
renderPage();
|
|
273
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Set key' }));
|
|
274
|
+
fireEvent.change(screen.getByLabelText('Value for API_KEY'), { target: { value: 'x' } });
|
|
275
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
276
|
+
|
|
277
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('Forbidden');
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
describe('ToolPage: manage access', () => {
|
|
282
|
+
it('offers none, to anyone, including an admin', async () => {
|
|
283
|
+
// Access is decided at the GROUP. A tool inherits its folder's rules, so an
|
|
284
|
+
// editor here would either duplicate the group's or quietly write a
|
|
285
|
+
// per-file override nobody looking at the group would ever see.
|
|
286
|
+
renderPage({ isAdmin: true });
|
|
287
|
+
await screen.findByRole('heading', { name: 'heyreach', level: 1 });
|
|
288
|
+
expect(screen.queryByRole('button', { name: 'Manage access' })).toBeNull();
|
|
289
|
+
expect(screen.queryByRole('button', { name: 'Share' })).toBeNull();
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe('ToolPage: OAuth round-trip', () => {
|
|
294
|
+
it('announces a successful sign-in and consumes the fragment', async () => {
|
|
295
|
+
window.history.replaceState(null, '', '/skills-and-tools/tools/heyreach#authorized=sec_1');
|
|
296
|
+
renderPage();
|
|
297
|
+
|
|
298
|
+
expect(await screen.findByRole('status')).toHaveTextContent('Signed in to heyreach.');
|
|
299
|
+
// Consumed, so a refresh doesn't re-announce it.
|
|
300
|
+
await waitFor(() => expect(window.location.hash).toBe(''));
|
|
301
|
+
expect(window.location.pathname).toBe('/skills-and-tools/tools/heyreach');
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('shows the callback error verbatim, decoded exactly once', async () => {
|
|
305
|
+
window.history.replaceState(
|
|
306
|
+
null,
|
|
307
|
+
'',
|
|
308
|
+
'/skills-and-tools/tools/heyreach#error=Access%20denied%20100%25',
|
|
309
|
+
);
|
|
310
|
+
renderPage();
|
|
311
|
+
|
|
312
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('Access denied 100%');
|
|
313
|
+
await waitFor(() => expect(window.location.hash).toBe(''));
|
|
314
|
+
});
|
|
315
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { ToolSharePanel } from '../components/tool-page/ToolSharePanel';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The SEAM Ali builds the F-lens into. These assertions are the contract, not
|
|
7
|
+
* an implementation detail: the dialog title, the props shape, and the body
|
|
8
|
+
* placeholder are what his work replaces without touching this file's callers.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const TOOL = { slug: 'github', name: 'github', path: 'Groups/Engineering/github.tool' };
|
|
12
|
+
|
|
13
|
+
describe('ToolSharePanel', () => {
|
|
14
|
+
it('renders nothing while closed', () => {
|
|
15
|
+
const { container } = render(
|
|
16
|
+
<ToolSharePanel open={false} tool={TOOL} onClose={vi.fn()} />,
|
|
17
|
+
);
|
|
18
|
+
expect(container.firstChild).toBeNull();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('opens a dialog titled "Share tool" naming the tool, with the seam placeholder', () => {
|
|
22
|
+
render(<ToolSharePanel open tool={TOOL} onClose={vi.fn()} />);
|
|
23
|
+
|
|
24
|
+
expect(screen.getByRole('dialog')).toHaveAccessibleName('Share tool');
|
|
25
|
+
expect(screen.getByText(/Access, ownership, and roles for/)).toBeInTheDocument();
|
|
26
|
+
expect(screen.getByText('github')).toBeInTheDocument();
|
|
27
|
+
expect(screen.getByTestId('tool-share-panel-body')).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('closes on Done', () => {
|
|
31
|
+
const onClose = vi.fn();
|
|
32
|
+
render(<ToolSharePanel open tool={TOOL} onClose={onClose} />);
|
|
33
|
+
fireEvent.click(screen.getByRole('button', { name: 'Done' }));
|
|
34
|
+
expect(onClose).toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
});
|