@bevel-software/platform-core-frontend 0.4.1 → 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 +37 -2
- 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 +93 -117
- 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 +17 -1
- 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 +36 -28
- 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 +3 -3
- 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 +113 -20
- 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 +52 -28
- 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 +123 -102
- package/src/modules/library/components/LibraryLayout.tsx +344 -0
- package/src/modules/library/components/LibraryPage.tsx +111 -227
- 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 +33 -245
- 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 +108 -25
- 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 +147 -110
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +35 -4
- 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 +38 -15
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +50 -50
- 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 +413 -189
- 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 +700 -294
- 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 +7 -4
- 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 +8 -5
- 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,378 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
3
|
+
import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
|
|
4
|
+
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
import {
|
|
7
|
+
WorkspaceContext,
|
|
8
|
+
type WorkspaceContextValue,
|
|
9
|
+
} from '../../workspace/state/workspace.context';
|
|
10
|
+
import { AdminContext } from '../../admin/state/admin.context';
|
|
11
|
+
import type { LibraryData } from '../hooks/useLibraryData';
|
|
12
|
+
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
13
|
+
import type { GroupSummary } from '../services/groups.api';
|
|
14
|
+
import type { ToolPageState } from '../hooks/useToolPage';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The routing skeleton: what each URL renders, what the sidebar marks as
|
|
18
|
+
* current, and where a click lands. The catalog is mocked at the hook (one
|
|
19
|
+
* seam) rather than at six endpoints — what's under test is the route table,
|
|
20
|
+
* not the fetching. The tool page's own data hook is mocked for the same
|
|
21
|
+
* reason; `ToolPage.test.tsx` is where its behaviour lives.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const dataMock = vi.hoisted(() => ({ useLibraryData: vi.fn() }));
|
|
25
|
+
vi.mock('../hooks/useLibraryData', () => ({ useLibraryData: dataMock.useLibraryData }));
|
|
26
|
+
|
|
27
|
+
const groupsMock = vi.hoisted(() => ({
|
|
28
|
+
listGroups: vi.fn(),
|
|
29
|
+
listJoinRequests: vi.fn(),
|
|
30
|
+
}));
|
|
31
|
+
vi.mock('../services/groups.api', () => ({
|
|
32
|
+
listGroups: groupsMock.listGroups,
|
|
33
|
+
listJoinRequests: groupsMock.listJoinRequests,
|
|
34
|
+
reconcileJoinRequest: vi.fn(),
|
|
35
|
+
requestGroupAccess: vi.fn(),
|
|
36
|
+
AlreadyReadableError: class AlreadyReadableError extends Error {},
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const toolPageMock = vi.hoisted(() => ({ useToolPage: vi.fn() }));
|
|
40
|
+
vi.mock('../hooks/useToolPage', () => ({ useToolPage: toolPageMock.useToolPage }));
|
|
41
|
+
|
|
42
|
+
// ManageAccessDialog (reachable from the group page's Share) fetches through
|
|
43
|
+
// this module. Nothing opens it in a routing test, but the stub keeps any
|
|
44
|
+
// accidental mount from waiting on a refused connection.
|
|
45
|
+
vi.mock('../../access/api', async (importOriginal) => {
|
|
46
|
+
const actual = await importOriginal<typeof import('../../access/api')>();
|
|
47
|
+
return {
|
|
48
|
+
...actual,
|
|
49
|
+
fetchFileAccess: vi.fn().mockResolvedValue({
|
|
50
|
+
canRead: true,
|
|
51
|
+
canWrite: false,
|
|
52
|
+
canDownload: false,
|
|
53
|
+
canOwner: false,
|
|
54
|
+
eligible: { roles: [], users: [] },
|
|
55
|
+
readers: { restricted: true, roles: [], users: [] },
|
|
56
|
+
owners: { roles: [], users: [] },
|
|
57
|
+
downloaders: { roles: [], users: [] },
|
|
58
|
+
sources: {},
|
|
59
|
+
}),
|
|
60
|
+
fetchAccessOverrides: vi.fn().mockResolvedValue({ overrides: [], truncated: false }),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
import { LibraryRoutes } from '../routes/LibraryRoutes';
|
|
65
|
+
import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
|
|
66
|
+
|
|
67
|
+
const tool = (over: Partial<ToolSecrets>): ToolSecrets => ({
|
|
68
|
+
slug: 'heyreach',
|
|
69
|
+
name: 'heyreach',
|
|
70
|
+
path: 'Groups/GTM/heyreach.tool',
|
|
71
|
+
type: 'inline',
|
|
72
|
+
setup: null,
|
|
73
|
+
canWrite: false,
|
|
74
|
+
variables: [],
|
|
75
|
+
...over,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const CATALOG: LibraryData = {
|
|
79
|
+
loading: false,
|
|
80
|
+
error: null,
|
|
81
|
+
skills: [
|
|
82
|
+
{ name: 'outreach', description: 'Runs the GTM outreach.', path: 'Groups/GTM/outreach' },
|
|
83
|
+
{ name: 'roadmap', description: 'Keeps the roadmap.', path: 'Groups/Product/roadmap' },
|
|
84
|
+
{ name: 'scratch', description: 'A skill in no group.', path: 'Skills/scratch' },
|
|
85
|
+
],
|
|
86
|
+
pendingSkills: [],
|
|
87
|
+
tools: [
|
|
88
|
+
tool({}),
|
|
89
|
+
// Ungrouped tool (`Tools/slack.tool` is two segments) — "Yours alone".
|
|
90
|
+
tool({ slug: 'slack', name: 'slack', path: 'Tools/slack.tool' }),
|
|
91
|
+
],
|
|
92
|
+
ownedSkills: new Set(['outreach']),
|
|
93
|
+
allowedToolsBySkill: new Map(),
|
|
94
|
+
crs: [],
|
|
95
|
+
myCrNumbers: new Set(),
|
|
96
|
+
reload: vi.fn(),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const GROUPS: GroupSummary[] = [
|
|
100
|
+
{
|
|
101
|
+
name: 'GTM',
|
|
102
|
+
folders: ['Groups/GTM'],
|
|
103
|
+
canRead: true,
|
|
104
|
+
canWrite: true,
|
|
105
|
+
isOwner: false,
|
|
106
|
+
skillCount: 1,
|
|
107
|
+
toolCount: 1,
|
|
108
|
+
owners: { roles: [], users: [{ name: 'Olga Ivanova', email: 'olga@bevel.software' }] },
|
|
109
|
+
writers: { roles: ['Admin'], users: [] },
|
|
110
|
+
readers: { restricted: true, roles: ['GTM Team'], users: [] },
|
|
111
|
+
hasRequested: false,
|
|
112
|
+
requestNumber: null,
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const TOOL_PAGE_STATE: ToolPageState = {
|
|
117
|
+
loading: false,
|
|
118
|
+
error: null,
|
|
119
|
+
notFound: false,
|
|
120
|
+
tool: tool({}),
|
|
121
|
+
detail: null,
|
|
122
|
+
skillsLoaded: true,
|
|
123
|
+
poweredSkills: [],
|
|
124
|
+
reload: vi.fn(),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** Exposes the router's current pathname without a testid. */
|
|
128
|
+
function LocationProbe() {
|
|
129
|
+
const location = useLocation();
|
|
130
|
+
// Hash included so the OAuth-fragment redirect below is assertable; it is
|
|
131
|
+
// the empty string everywhere else.
|
|
132
|
+
return <div aria-label="pathname">{location.pathname}{location.hash}</div>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The shell's providers, which the Library sits inside for real
|
|
137
|
+
* (`CoreAppShell` mounts both above every app surface). The tool page reads
|
|
138
|
+
* `isAdmin` and `kbDirName` from them; the locked-group and request surfaces
|
|
139
|
+
* read `kbDirName` to address `access.md`.
|
|
140
|
+
*/
|
|
141
|
+
function wrap(children: ReactNode) {
|
|
142
|
+
const adminValue = {
|
|
143
|
+
isAdmin: false,
|
|
144
|
+
unreadCount: 0,
|
|
145
|
+
lastSeen: null,
|
|
146
|
+
markSeen: vi.fn(),
|
|
147
|
+
refresh: vi.fn(),
|
|
148
|
+
rolesConfigCorrupted: false,
|
|
149
|
+
rolesConfigErrors: [],
|
|
150
|
+
runRolesRecovery: vi.fn(),
|
|
151
|
+
};
|
|
152
|
+
const workspaceValue = {
|
|
153
|
+
workspaceId: 'target-company-state',
|
|
154
|
+
kbDirName: 'knowledge-base',
|
|
155
|
+
} as unknown as WorkspaceContextValue;
|
|
156
|
+
|
|
157
|
+
return (
|
|
158
|
+
<AdminContext.Provider value={adminValue}>
|
|
159
|
+
<WorkspaceContext.Provider value={workspaceValue}>
|
|
160
|
+
{withAuth(children)}
|
|
161
|
+
</WorkspaceContext.Provider>
|
|
162
|
+
</AdminContext.Provider>
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function renderAt(path: string) {
|
|
167
|
+
return render(
|
|
168
|
+
<MemoryRouter initialEntries={[path]}>
|
|
169
|
+
{wrap(
|
|
170
|
+
<Routes>
|
|
171
|
+
<Route path="/skills-and-tools/*" element={<LibraryRoutes />} />
|
|
172
|
+
</Routes>,
|
|
173
|
+
)}
|
|
174
|
+
<LocationProbe />
|
|
175
|
+
</MemoryRouter>,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const pathname = () => screen.getByLabelText('pathname').textContent;
|
|
180
|
+
|
|
181
|
+
describe('LibraryRoutes', () => {
|
|
182
|
+
beforeEach(() => {
|
|
183
|
+
dataMock.useLibraryData.mockReturnValue(CATALOG);
|
|
184
|
+
groupsMock.listGroups.mockResolvedValue(GROUPS);
|
|
185
|
+
toolPageMock.useToolPage.mockReturnValue(TOOL_PAGE_STATE);
|
|
186
|
+
groupsMock.listJoinRequests.mockResolvedValue([]);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('opens on the all-groups index at /skills-and-tools', async () => {
|
|
190
|
+
renderAt('/skills-and-tools');
|
|
191
|
+
expect(
|
|
192
|
+
await screen.findByRole('heading', { name: 'All groups', level: 1 }),
|
|
193
|
+
).toBeInTheDocument();
|
|
194
|
+
expect(screen.getByRole('button', { name: /^All groups/ })).toHaveAttribute(
|
|
195
|
+
'aria-current',
|
|
196
|
+
'true',
|
|
197
|
+
);
|
|
198
|
+
// The lenses are lenses: landing home selects neither.
|
|
199
|
+
expect(screen.getByRole('button', { name: /^Everything/ })).toHaveAttribute(
|
|
200
|
+
'aria-current',
|
|
201
|
+
'false',
|
|
202
|
+
);
|
|
203
|
+
expect(screen.getByRole('button', { name: /^Owned by me/ })).toHaveAttribute(
|
|
204
|
+
'aria-current',
|
|
205
|
+
'false',
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('/skills-and-tools/everything is the whole catalog as cards', async () => {
|
|
210
|
+
renderAt('/skills-and-tools/everything');
|
|
211
|
+
expect(await screen.findByRole('heading', { name: 'Everything', level: 1 })).toBeInTheDocument();
|
|
212
|
+
expect(screen.getByRole('button', { name: /^Everything/ })).toHaveAttribute(
|
|
213
|
+
'aria-current',
|
|
214
|
+
'true',
|
|
215
|
+
);
|
|
216
|
+
expect(screen.getByTestId('library-card-skill-outreach')).toBeInTheDocument();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('/skills-and-tools/owned selects Owned by me', async () => {
|
|
220
|
+
renderAt('/skills-and-tools/owned');
|
|
221
|
+
expect(await screen.findByRole('heading', { name: 'Owned by me' })).toBeInTheDocument();
|
|
222
|
+
expect(screen.getByRole('button', { name: /^Owned by me/ })).toHaveAttribute('aria-current', 'true');
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("/skills-and-tools/yours is the caller's own group, as a group page", async () => {
|
|
226
|
+
renderAt('/skills-and-tools/yours');
|
|
227
|
+
expect(
|
|
228
|
+
await screen.findByRole('heading', { name: TEST_PERSONAL_GROUP, level: 1 }),
|
|
229
|
+
).toBeInTheDocument();
|
|
230
|
+
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toHaveAttribute(
|
|
231
|
+
'aria-current',
|
|
232
|
+
'true',
|
|
233
|
+
);
|
|
234
|
+
// The group-page furniture, not a filtered gallery: sections and a trail.
|
|
235
|
+
expect(screen.getByRole('heading', { name: 'Skills', level: 2 })).toBeInTheDocument();
|
|
236
|
+
expect(screen.getByRole('heading', { name: 'Tools', level: 2 })).toBeInTheDocument();
|
|
237
|
+
expect(screen.getByRole('navigation', { name: 'Breadcrumb' })).toBeInTheDocument();
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('a group you are in appears in the nav even when it is EMPTY', async () => {
|
|
241
|
+
// Membership is what puts a group in your MCP; content is not. Deriving
|
|
242
|
+
// the member rows from catalog items alone made a freshly created group
|
|
243
|
+
// vanish from the very list headed "Included in your MCP".
|
|
244
|
+
groupsMock.listGroups.mockResolvedValue([
|
|
245
|
+
...GROUPS,
|
|
246
|
+
{
|
|
247
|
+
name: 'Fresh',
|
|
248
|
+
folders: ['Groups/Fresh'],
|
|
249
|
+
canRead: true,
|
|
250
|
+
canWrite: true,
|
|
251
|
+
skillCount: 0,
|
|
252
|
+
toolCount: 0,
|
|
253
|
+
owners: { roles: [], users: [] },
|
|
254
|
+
writers: { roles: [], users: [] },
|
|
255
|
+
readers: { restricted: true, roles: [], users: [] },
|
|
256
|
+
hasRequested: false,
|
|
257
|
+
requestNumber: null,
|
|
258
|
+
},
|
|
259
|
+
]);
|
|
260
|
+
renderAt('/skills-and-tools');
|
|
261
|
+
const nav = await screen.findByRole('navigation', { name: 'Library groups' });
|
|
262
|
+
// In the member half, with a zero count — never below the gap as locked.
|
|
263
|
+
expect(await within(nav).findByRole('button', { name: /^Fresh/ })).toBeInTheDocument();
|
|
264
|
+
expect(within(nav).queryByRole('button', { name: 'Fresh (locked)' })).toBeNull();
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('a sidebar group click navigates to /skills-and-tools/groups/<name>', async () => {
|
|
268
|
+
renderAt('/skills-and-tools');
|
|
269
|
+
fireEvent.click(await screen.findByRole('button', { name: /^GTM/ }));
|
|
270
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools/groups/GTM'));
|
|
271
|
+
// The group page itself lands in a later work package; the ROUTE resolves
|
|
272
|
+
// now, which is why the sidebar can already point at it.
|
|
273
|
+
expect(screen.getByRole('button', { name: /^GTM/ })).toHaveAttribute('aria-current', 'true');
|
|
274
|
+
expect(screen.queryByRole('heading', { name: 'All groups', level: 1 })).not.toBeInTheDocument();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('sends the old /groups index path home, where the index lives now', async () => {
|
|
278
|
+
renderAt('/skills-and-tools/groups');
|
|
279
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
280
|
+
expect(
|
|
281
|
+
await screen.findByRole('heading', { name: 'All groups', level: 1 }),
|
|
282
|
+
).toBeInTheDocument();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
it("a group deep link renders that group's cards and no others", async () => {
|
|
286
|
+
renderAt('/skills-and-tools/groups/GTM');
|
|
287
|
+
expect(await screen.findByRole('heading', { name: 'GTM', level: 1 })).toBeInTheDocument();
|
|
288
|
+
expect(screen.getByTestId('library-card-skill-outreach')).toBeInTheDocument();
|
|
289
|
+
expect(screen.getByTestId('library-card-integration-heyreach')).toBeInTheDocument();
|
|
290
|
+
expect(screen.queryByTestId('library-card-skill-roadmap')).not.toBeInTheDocument();
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// `/propose` was retired with the role fork it served. An unknown path under
|
|
294
|
+
// the Library falls back to the root, which is what this now asserts.
|
|
295
|
+
it('sends the retired propose path back home', async () => {
|
|
296
|
+
renderAt('/skills-and-tools/propose?group=GTM');
|
|
297
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("reaches the index from a group page breadcrumb, at the root it lives at", async () => {
|
|
301
|
+
renderAt('/skills-and-tools/groups/GTM');
|
|
302
|
+
fireEvent.click(await screen.findByRole('link', { name: 'All groups' }));
|
|
303
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
304
|
+
expect(
|
|
305
|
+
await screen.findByRole('heading', { name: 'All groups', level: 1 }),
|
|
306
|
+
).toBeInTheDocument();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('leads the sidebar with All groups, from anywhere in the Library', async () => {
|
|
310
|
+
renderAt('/skills-and-tools/groups/GTM');
|
|
311
|
+
const allGroups = await screen.findByRole('button', { name: /^All groups/ });
|
|
312
|
+
expect(allGroups).toHaveAttribute('aria-current', 'false');
|
|
313
|
+
fireEvent.click(allGroups);
|
|
314
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
315
|
+
expect(screen.getByRole('button', { name: /^All groups/ })).toHaveAttribute(
|
|
316
|
+
'aria-current',
|
|
317
|
+
'true',
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('a group deep link with a URL-hostile name round-trips', async () => {
|
|
322
|
+
dataMock.useLibraryData.mockReturnValue({
|
|
323
|
+
...CATALOG,
|
|
324
|
+
skills: [{ name: 'pricing', description: '', path: 'Groups/Sales & Ops/pricing' }],
|
|
325
|
+
tools: [],
|
|
326
|
+
});
|
|
327
|
+
renderAt(`/skills-and-tools/groups/${encodeURIComponent('Sales & Ops')}`);
|
|
328
|
+
await waitFor(() =>
|
|
329
|
+
expect(screen.getByRole('button', { name: /^Sales & Ops/ })).toHaveAttribute('aria-current', 'true'),
|
|
330
|
+
);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('/skills-and-tools/tools/:slug redirects to the canonical workspace URL, hash intact', async () => {
|
|
334
|
+
// The legacy address is the OAuth callback's landing target, so the
|
|
335
|
+
// redirect must carry the `#…` outcome fragment to the canonical page.
|
|
336
|
+
renderAt('/skills-and-tools/tools/heyreach#authorized');
|
|
337
|
+
await waitFor(() =>
|
|
338
|
+
expect(pathname()).toBe(
|
|
339
|
+
`/workspace/${DEFAULT_BRANCH}/knowledge-base/Groups/GTM/heyreach.tool#authorized`,
|
|
340
|
+
),
|
|
341
|
+
);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it("/skills-and-tools/skills/:name redirects to the skill's canonical workspace URL", async () => {
|
|
345
|
+
renderAt('/skills-and-tools/skills/outreach');
|
|
346
|
+
await waitFor(() =>
|
|
347
|
+
expect(pathname()).toBe(
|
|
348
|
+
`/workspace/${DEFAULT_BRANCH}/knowledge-base/Groups/GTM/outreach/SKILL.md`,
|
|
349
|
+
),
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('an integration card navigates to the canonical workspace URL, not a dialog', async () => {
|
|
354
|
+
renderAt('/skills-and-tools/everything');
|
|
355
|
+
fireEvent.click(await screen.findByRole('button', { name: /^heyreach/ }));
|
|
356
|
+
|
|
357
|
+
await waitFor(() =>
|
|
358
|
+
expect(pathname()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Groups/GTM/heyreach.tool`),
|
|
359
|
+
);
|
|
360
|
+
expect(screen.queryByRole('dialog')).toBeNull();
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('an unknown subpath redirects home', async () => {
|
|
364
|
+
renderAt('/skills-and-tools/nope');
|
|
365
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
366
|
+
expect(
|
|
367
|
+
await screen.findByRole('heading', { name: 'All groups', level: 1 }),
|
|
368
|
+
).toBeInTheDocument();
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it('renders the gallery even when the groups endpoint fails', async () => {
|
|
372
|
+
groupsMock.listGroups.mockRejectedValue(new Error("Couldn't load groups."));
|
|
373
|
+
renderAt('/skills-and-tools/everything');
|
|
374
|
+
expect(await screen.findByRole('heading', { name: 'Everything', level: 1 })).toBeInTheDocument();
|
|
375
|
+
// Sidebar groups are catalog-derived, so they survive the endpoint being down.
|
|
376
|
+
expect(screen.getByRole('button', { name: /^GTM/ })).toBeInTheDocument();
|
|
377
|
+
});
|
|
378
|
+
});
|