@bevel-software/platform-core-frontend 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +5366 -0
- package/package.json +7 -4
- 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
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import type { FileApprovalState } from '@bevel-software/platform-shared';
|
|
4
|
-
import { PrApprovalBadge } from '../components/PrApprovalBadge';
|
|
5
|
-
|
|
6
|
-
const ALICE = { name: 'Alice', email: 'alice@bevel.software' };
|
|
7
|
-
|
|
8
|
-
function state(overrides: Partial<FileApprovalState>): FileApprovalState {
|
|
9
|
-
// Spread after defaults so an explicit empty `eligibleApprovers` (the
|
|
10
|
-
// "outside the gate" case) passes through.
|
|
11
|
-
return {
|
|
12
|
-
path: 'Foo.md',
|
|
13
|
-
eligibleApprovers: { roles: [], users: [ALICE] },
|
|
14
|
-
approvedBy: [],
|
|
15
|
-
isApproved: false,
|
|
16
|
-
viewerCanApprove: false,
|
|
17
|
-
...overrides,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('PrApprovalBadge', () => {
|
|
22
|
-
it('renders nothing when state is missing', () => {
|
|
23
|
-
const { container } = render(<PrApprovalBadge state={undefined} />);
|
|
24
|
-
expect(container.firstChild).toBeNull();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('shows the "confirmed" tooltip including the eligible approver', () => {
|
|
28
|
-
const { container } = render(
|
|
29
|
-
<PrApprovalBadge
|
|
30
|
-
state={state({
|
|
31
|
-
isApproved: true,
|
|
32
|
-
approvedBy: [
|
|
33
|
-
{ email: 'alice@bevel.software', name: 'Alice', approvedAt: 'x', isStale: false, isSelfApproval: false },
|
|
34
|
-
],
|
|
35
|
-
})}
|
|
36
|
-
/>,
|
|
37
|
-
);
|
|
38
|
-
const tooltipNode = container.querySelector('[title]');
|
|
39
|
-
expect(tooltipNode?.getAttribute('title')).toMatch(/confirmed by/i);
|
|
40
|
-
expect(tooltipNode?.getAttribute('title')).toMatch(/Alice/);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('renders nothing for md files with no eligible approvers (outside the gate)', () => {
|
|
44
|
-
const { container } = render(
|
|
45
|
-
<PrApprovalBadge state={state({ eligibleApprovers: { roles: [], users: [] } })} />,
|
|
46
|
-
);
|
|
47
|
-
expect(container.firstChild).toBeNull();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('renders nothing for non-md files regardless of eligibility', () => {
|
|
51
|
-
const { container } = render(
|
|
52
|
-
<PrApprovalBadge state={state({ path: 'src/foo.ts' })} />,
|
|
53
|
-
);
|
|
54
|
-
expect(container.firstChild).toBeNull();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('shows the outdated indicator when only stale approvals exist', () => {
|
|
58
|
-
const { container } = render(
|
|
59
|
-
<PrApprovalBadge
|
|
60
|
-
state={state({
|
|
61
|
-
isApproved: false,
|
|
62
|
-
approvedBy: [
|
|
63
|
-
{ email: 'alice@bevel.software', name: 'Alice', approvedAt: 'x', isStale: true, isSelfApproval: false },
|
|
64
|
-
],
|
|
65
|
-
})}
|
|
66
|
-
/>,
|
|
67
|
-
);
|
|
68
|
-
const tooltipNode = container.querySelector('[title]');
|
|
69
|
-
expect(tooltipNode?.getAttribute('title')).toMatch(/confirmation outdated/i);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('shows the waiting indicator when there are eligible approvers but none have approved', () => {
|
|
73
|
-
const { container } = render(
|
|
74
|
-
<PrApprovalBadge state={state({ isApproved: false, approvedBy: [] })} />,
|
|
75
|
-
);
|
|
76
|
-
const tooltipNode = container.querySelector('[title]');
|
|
77
|
-
expect(tooltipNode?.getAttribute('title')).toMatch(/waiting on/i);
|
|
78
|
-
expect(tooltipNode?.getAttribute('title')).toMatch(/Alice/);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('renders for files where eligibility comes from a role grant', () => {
|
|
82
|
-
const { container } = render(
|
|
83
|
-
<PrApprovalBadge
|
|
84
|
-
state={state({
|
|
85
|
-
eligibleApprovers: { roles: ['Admin'], users: [] },
|
|
86
|
-
isApproved: false,
|
|
87
|
-
})}
|
|
88
|
-
/>,
|
|
89
|
-
);
|
|
90
|
-
const tooltipNode = container.querySelector('[title]');
|
|
91
|
-
expect(tooltipNode?.getAttribute('title')).toMatch(/Admin/);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
|
-
import type { PullRequestDetail } from '@bevel-software/platform-shared';
|
|
4
|
-
|
|
5
|
-
// API mock — replaces the network call. Each test resets and configures.
|
|
6
|
-
vi.mock('../services/pr-cancel.api', () => ({
|
|
7
|
-
cancelPullRequest: vi.fn(),
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
import { PrCancelButton } from '../components/PrCancelButton';
|
|
11
|
-
import { cancelPullRequest } from '../services/pr-cancel.api';
|
|
12
|
-
|
|
13
|
-
const cancelMock = cancelPullRequest as unknown as ReturnType<typeof vi.fn>;
|
|
14
|
-
|
|
15
|
-
function detail(overrides: Partial<PullRequestDetail>): PullRequestDetail {
|
|
16
|
-
return {
|
|
17
|
-
number: 42,
|
|
18
|
-
title: 'Test PR',
|
|
19
|
-
author: { login: 'alice' },
|
|
20
|
-
branch: 'feature/x',
|
|
21
|
-
base: 'current-company-state',
|
|
22
|
-
state: 'open',
|
|
23
|
-
createdAt: '2026-05-01T00:00:00Z',
|
|
24
|
-
touchedNodePaths: [],
|
|
25
|
-
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
26
|
-
url: 'https://github.com/acme/repo/pull/42',
|
|
27
|
-
body: '',
|
|
28
|
-
headSha: 'head',
|
|
29
|
-
baseSha: 'base',
|
|
30
|
-
files: [],
|
|
31
|
-
comments: [],
|
|
32
|
-
approvals: [],
|
|
33
|
-
mergeableInBevel: true,
|
|
34
|
-
mergeBlockedReasons: [],
|
|
35
|
-
mergeWarnings: [],
|
|
36
|
-
viewerCanBypassMerge: false,
|
|
37
|
-
viewerCanCancel: true,
|
|
38
|
-
...overrides,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
describe('PrCancelButton', () => {
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
cancelMock.mockReset();
|
|
45
|
-
});
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
cancelMock.mockReset();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('renders nothing for a merged PR', () => {
|
|
51
|
-
const { container } = render(
|
|
52
|
-
<PrCancelButton detail={detail({ state: 'merged' })} onCancelled={() => {}} />,
|
|
53
|
-
);
|
|
54
|
-
expect(container.firstChild).toBeNull();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('renders nothing for a closed PR', () => {
|
|
58
|
-
const { container } = render(
|
|
59
|
-
<PrCancelButton detail={detail({ state: 'closed' })} onCancelled={() => {}} />,
|
|
60
|
-
);
|
|
61
|
-
expect(container.firstChild).toBeNull();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('marks the button aria-disabled with the only-author-or-admin tooltip when viewerCanCancel is false', () => {
|
|
65
|
-
render(
|
|
66
|
-
<PrCancelButton
|
|
67
|
-
detail={detail({ viewerCanCancel: false })}
|
|
68
|
-
onCancelled={() => {}}
|
|
69
|
-
/>,
|
|
70
|
-
);
|
|
71
|
-
const btn = screen.getByRole('button', { name: /cancel change request/i });
|
|
72
|
-
// aria-disabled (not the disabled attribute) so the button stays focusable
|
|
73
|
-
// for keyboard users and screen readers announce the unauthorized state.
|
|
74
|
-
expect(btn).toHaveAttribute('aria-disabled', 'true');
|
|
75
|
-
expect(btn).not.toBeDisabled();
|
|
76
|
-
expect(btn.getAttribute('title')).toMatch(/only the author or an admin/i);
|
|
77
|
-
// Click should still be a no-op (component-level guard).
|
|
78
|
-
fireEvent.click(btn);
|
|
79
|
-
expect(cancelMock).not.toHaveBeenCalled();
|
|
80
|
-
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('clicking the enabled button opens the confirm dialog without firing the API', () => {
|
|
84
|
-
render(
|
|
85
|
-
<PrCancelButton detail={detail({})} onCancelled={() => {}} />,
|
|
86
|
-
);
|
|
87
|
-
const btn = screen.getByRole('button', { name: /cancel change request/i });
|
|
88
|
-
fireEvent.click(btn);
|
|
89
|
-
// Dialog opens — both heading and a "Keep open" affordance are visible.
|
|
90
|
-
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
91
|
-
expect(screen.getByRole('heading', { name: /cancel this change request/i })).toBeInTheDocument();
|
|
92
|
-
expect(screen.getByRole('button', { name: /keep open/i })).toBeInTheDocument();
|
|
93
|
-
expect(cancelMock).not.toHaveBeenCalled();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('confirms in the dialog: calls the API, dispatches bevel:pr-stale, and calls onCancelled', async () => {
|
|
97
|
-
cancelMock.mockResolvedValue({ prNumber: 42, cancelledAt: '2026-05-11T15:00:00.000Z' });
|
|
98
|
-
const onCancelled = vi.fn();
|
|
99
|
-
const eventSpy = vi.fn();
|
|
100
|
-
window.addEventListener('bevel:pr-stale', eventSpy);
|
|
101
|
-
try {
|
|
102
|
-
render(<PrCancelButton detail={detail({})} onCancelled={onCancelled} />);
|
|
103
|
-
fireEvent.click(screen.getByRole('button', { name: /^cancel change request$/i }));
|
|
104
|
-
// Click the *confirm* button inside the dialog — there are two buttons
|
|
105
|
-
// with this label (the trigger and the confirm); the dialog's confirm
|
|
106
|
-
// is the second match.
|
|
107
|
-
const confirmButtons = screen.getAllByRole('button', { name: /^cancel change request$/i });
|
|
108
|
-
fireEvent.click(confirmButtons[confirmButtons.length - 1]);
|
|
109
|
-
await waitFor(() => expect(cancelMock).toHaveBeenCalledTimes(1));
|
|
110
|
-
expect(cancelMock).toHaveBeenCalledWith(42);
|
|
111
|
-
expect(onCancelled).toHaveBeenCalledTimes(1);
|
|
112
|
-
expect(eventSpy).toHaveBeenCalled();
|
|
113
|
-
} finally {
|
|
114
|
-
window.removeEventListener('bevel:pr-stale', eventSpy);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('on API error: surfaces friendly error inline and does NOT fire onCancelled or bevel:pr-stale', async () => {
|
|
119
|
-
cancelMock.mockRejectedValue(new Error('This change request was already applied.'));
|
|
120
|
-
const onCancelled = vi.fn();
|
|
121
|
-
const eventSpy = vi.fn();
|
|
122
|
-
window.addEventListener('bevel:pr-stale', eventSpy);
|
|
123
|
-
try {
|
|
124
|
-
render(<PrCancelButton detail={detail({})} onCancelled={onCancelled} />);
|
|
125
|
-
fireEvent.click(screen.getByRole('button', { name: /^cancel change request$/i }));
|
|
126
|
-
const confirmButtons = screen.getAllByRole('button', { name: /^cancel change request$/i });
|
|
127
|
-
fireEvent.click(confirmButtons[confirmButtons.length - 1]);
|
|
128
|
-
await waitFor(() => expect(cancelMock).toHaveBeenCalledTimes(1));
|
|
129
|
-
// Friendly mapping should kick in (see error-messages.ts).
|
|
130
|
-
const errorEl = await screen.findByRole('alert');
|
|
131
|
-
expect(errorEl.textContent).toMatch(/already applied/i);
|
|
132
|
-
expect(onCancelled).not.toHaveBeenCalled();
|
|
133
|
-
expect(eventSpy).not.toHaveBeenCalled();
|
|
134
|
-
} finally {
|
|
135
|
-
window.removeEventListener('bevel:pr-stale', eventSpy);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('guards against double-confirm: a second click while busy does not fire the API twice', async () => {
|
|
140
|
-
// Deferred resolve so the first call stays in-flight while we fire a second.
|
|
141
|
-
let resolveFirst!: (v: { prNumber: number; cancelledAt: string }) => void;
|
|
142
|
-
cancelMock.mockImplementation(
|
|
143
|
-
() =>
|
|
144
|
-
new Promise((res) => {
|
|
145
|
-
resolveFirst = res;
|
|
146
|
-
}),
|
|
147
|
-
);
|
|
148
|
-
render(<PrCancelButton detail={detail({})} onCancelled={() => {}} />);
|
|
149
|
-
fireEvent.click(screen.getByRole('button', { name: /^cancel change request$/i }));
|
|
150
|
-
const confirmButtons = screen.getAllByRole('button', { name: /^cancel change request$/i });
|
|
151
|
-
const dialogConfirm = confirmButtons[confirmButtons.length - 1];
|
|
152
|
-
fireEvent.click(dialogConfirm);
|
|
153
|
-
// Double-click while busy
|
|
154
|
-
fireEvent.click(dialogConfirm);
|
|
155
|
-
await waitFor(() => expect(cancelMock).toHaveBeenCalledTimes(1));
|
|
156
|
-
resolveFirst({ prNumber: 42, cancelledAt: '2026-05-11T15:00:00.000Z' });
|
|
157
|
-
});
|
|
158
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { PrCancelConfirmDialog } from '../components/PrCancelConfirmDialog';
|
|
4
|
-
|
|
5
|
-
describe('PrCancelConfirmDialog', () => {
|
|
6
|
-
it('renders title, body copy, and both action buttons', () => {
|
|
7
|
-
render(<PrCancelConfirmDialog busy={false} onConfirm={() => {}} onCancel={() => {}} />);
|
|
8
|
-
expect(screen.getByRole('heading', { name: /cancel this change request/i })).toBeInTheDocument();
|
|
9
|
-
expect(screen.getByText(/won't delete your draft/i)).toBeInTheDocument();
|
|
10
|
-
expect(screen.getByRole('button', { name: /keep open/i })).toBeInTheDocument();
|
|
11
|
-
// The bottom confirm button has the destructive label.
|
|
12
|
-
expect(screen.getByRole('button', { name: /^cancel change request$/i })).toBeInTheDocument();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('Escape key fires onCancel when not busy', () => {
|
|
16
|
-
const onCancel = vi.fn();
|
|
17
|
-
render(<PrCancelConfirmDialog busy={false} onConfirm={() => {}} onCancel={onCancel} />);
|
|
18
|
-
fireEvent.keyDown(window, { key: 'Escape' });
|
|
19
|
-
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('Escape is suppressed while busy', () => {
|
|
23
|
-
const onCancel = vi.fn();
|
|
24
|
-
render(<PrCancelConfirmDialog busy={true} onConfirm={() => {}} onCancel={onCancel} />);
|
|
25
|
-
fireEvent.keyDown(window, { key: 'Escape' });
|
|
26
|
-
expect(onCancel).not.toHaveBeenCalled();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('Keep open button fires onCancel; Cancel change request button fires onConfirm', () => {
|
|
30
|
-
const onCancel = vi.fn();
|
|
31
|
-
const onConfirm = vi.fn();
|
|
32
|
-
render(<PrCancelConfirmDialog busy={false} onConfirm={onConfirm} onCancel={onCancel} />);
|
|
33
|
-
fireEvent.click(screen.getByRole('button', { name: /keep open/i }));
|
|
34
|
-
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
35
|
-
fireEvent.click(screen.getByRole('button', { name: /^cancel change request$/i }));
|
|
36
|
-
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('confirm button shows Cancelling… and is disabled when busy', () => {
|
|
40
|
-
render(<PrCancelConfirmDialog busy={true} onConfirm={() => {}} onCancel={() => {}} />);
|
|
41
|
-
const btn = screen.getByRole('button', { name: /cancelling/i });
|
|
42
|
-
expect(btn).toBeDisabled();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, act } from '@testing-library/react';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
import type { PullRequestDetail, WorkflowEvent } from '@bevel-software/platform-shared';
|
|
5
|
-
import { PrMergeButton } from '../components/PrMergeButton';
|
|
6
|
-
// The button doesn't seed chat directly — on a conflicted apply it calls the
|
|
7
|
-
// change-request port's `resolveCrConflicts`. In the enterprise build a
|
|
8
|
-
// registry provider binds that port to chat seeding; core tests mount a stub
|
|
9
|
-
// port and assert the port itself is invoked.
|
|
10
|
-
import { CrCreationPortContext, type CrCreationPort } from '../../../core/registry';
|
|
11
|
-
import { EventBusContext, type EventBusContextValue } from '../../workflow/state/event-bus.context';
|
|
12
|
-
import { mergePullRequest } from '../services/pr-merge.api';
|
|
13
|
-
import { fetchPrDetail } from '../services/pr-detail.api';
|
|
14
|
-
|
|
15
|
-
vi.mock('../services/pr-merge.api', () => ({
|
|
16
|
-
mergePullRequest: vi.fn().mockResolvedValue({ status: 'merging', number: 1 }),
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
vi.mock('../services/pr-detail.api', () => ({
|
|
20
|
-
fetchPrDetail: vi.fn(),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
/** A test double for the event bus that lets a test push events to subscribers. */
|
|
24
|
-
function makeFakeBus() {
|
|
25
|
-
const handlers: Record<string, ((e: WorkflowEvent) => void)[]> = {};
|
|
26
|
-
const bus: EventBusContextValue & { emit(e: WorkflowEvent): void } = {
|
|
27
|
-
subscribe(kind, handler) {
|
|
28
|
-
(handlers[kind] ??= []).push(handler as (e: WorkflowEvent) => void);
|
|
29
|
-
return () => {
|
|
30
|
-
handlers[kind] = (handlers[kind] ?? []).filter((h) => h !== handler);
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
setFocus() {},
|
|
34
|
-
emit(e) {
|
|
35
|
-
(handlers[e.kind] ?? []).forEach((h) => h(e));
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
return bus;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* `PrMergeButton` reads the change-request port to hand off merge-conflict
|
|
43
|
-
* outcomes (so a registered resolver — the enterprise agent flow — picks up
|
|
44
|
-
* the resolution instead of the user). Tests render under a stub port;
|
|
45
|
-
* conflict-path tests can pass a spying `resolveCrConflicts` to assert the
|
|
46
|
-
* hand-off payload.
|
|
47
|
-
*/
|
|
48
|
-
function makeStubPort(resolveCrConflicts: ReturnType<typeof vi.fn> = vi.fn()): CrCreationPort {
|
|
49
|
-
return { start: vi.fn(), resolveCrConflicts };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function renderWithChat(ui: ReactNode, resolveCrConflicts: ReturnType<typeof vi.fn> = vi.fn()) {
|
|
53
|
-
return render(
|
|
54
|
-
<CrCreationPortContext.Provider value={makeStubPort(resolveCrConflicts)}>
|
|
55
|
-
{ui}
|
|
56
|
-
</CrCreationPortContext.Provider>,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function renderWithBus(
|
|
61
|
-
ui: ReactNode,
|
|
62
|
-
bus: ReturnType<typeof makeFakeBus>,
|
|
63
|
-
resolveCrConflicts: ReturnType<typeof vi.fn> = vi.fn(),
|
|
64
|
-
) {
|
|
65
|
-
return render(
|
|
66
|
-
<EventBusContext.Provider value={bus}>
|
|
67
|
-
<CrCreationPortContext.Provider value={makeStubPort(resolveCrConflicts)}>
|
|
68
|
-
{ui}
|
|
69
|
-
</CrCreationPortContext.Provider>
|
|
70
|
-
</EventBusContext.Provider>,
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function detail(overrides: Partial<PullRequestDetail>): PullRequestDetail {
|
|
75
|
-
return {
|
|
76
|
-
number: 1,
|
|
77
|
-
title: 'Test PR',
|
|
78
|
-
author: { login: 'alice' },
|
|
79
|
-
branch: 'feature/x',
|
|
80
|
-
base: 'current-company-state',
|
|
81
|
-
state: overrides.state ?? 'open',
|
|
82
|
-
createdAt: '2026-04-20T10:00:00Z',
|
|
83
|
-
touchedNodePaths: [],
|
|
84
|
-
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
85
|
-
url: 'https://github.com/acme/repo/pull/1',
|
|
86
|
-
body: '',
|
|
87
|
-
headSha: 'head',
|
|
88
|
-
baseSha: 'base',
|
|
89
|
-
files: [],
|
|
90
|
-
comments: [],
|
|
91
|
-
approvals: [],
|
|
92
|
-
mergeableInBevel: overrides.mergeableInBevel ?? true,
|
|
93
|
-
mergeBlockedReasons: overrides.mergeBlockedReasons ?? [],
|
|
94
|
-
mergeWarnings: overrides.mergeWarnings ?? [],
|
|
95
|
-
// Default to admin (true) so existing tests describe the admin-with-bypass
|
|
96
|
-
// path. The non-admin path has its own dedicated test below.
|
|
97
|
-
viewerCanBypassMerge: overrides.viewerCanBypassMerge ?? true,
|
|
98
|
-
// Default true for parity with the admin assumption above — keeps existing
|
|
99
|
-
// tests focused on the merge gate; the cancel button has its own test file.
|
|
100
|
-
viewerCanCancel: overrides.viewerCanCancel ?? true,
|
|
101
|
-
...overrides,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
describe('PrMergeButton', () => {
|
|
106
|
-
it('is hidden when the PR is already merged', () => {
|
|
107
|
-
const { container } = renderWithChat(
|
|
108
|
-
<PrMergeButton detail={detail({ state: 'merged', mergeableInBevel: true })} onMerged={() => {}} />,
|
|
109
|
-
);
|
|
110
|
-
expect(container.firstChild).toBeNull();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('is hidden when the PR is closed', () => {
|
|
114
|
-
const { container } = renderWithChat(
|
|
115
|
-
<PrMergeButton detail={detail({ state: 'closed' })} onMerged={() => {}} />,
|
|
116
|
-
);
|
|
117
|
-
expect(container.firstChild).toBeNull();
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('is disabled when a hard block applies (mergeableInBevel = false)', () => {
|
|
121
|
-
renderWithChat(
|
|
122
|
-
<PrMergeButton
|
|
123
|
-
detail={detail({
|
|
124
|
-
mergeableInBevel: false,
|
|
125
|
-
mergeBlockedReasons: ['This pull request has no file changes to approve.'],
|
|
126
|
-
})}
|
|
127
|
-
onMerged={() => {}}
|
|
128
|
-
/>,
|
|
129
|
-
);
|
|
130
|
-
const btn = screen.getByRole('button', { name: /apply draft/i });
|
|
131
|
-
expect(btn).toBeDisabled();
|
|
132
|
-
expect(btn.getAttribute('title')).toContain('no file changes');
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it('joins multiple hard-block reasons into the tooltip on newlines', () => {
|
|
136
|
-
renderWithChat(
|
|
137
|
-
<PrMergeButton
|
|
138
|
-
detail={detail({
|
|
139
|
-
mergeableInBevel: false,
|
|
140
|
-
mergeBlockedReasons: [
|
|
141
|
-
'This pull request has already been merged.',
|
|
142
|
-
'This pull request has no file changes to approve.',
|
|
143
|
-
],
|
|
144
|
-
})}
|
|
145
|
-
onMerged={() => {}}
|
|
146
|
-
/>,
|
|
147
|
-
);
|
|
148
|
-
const btn = screen.getByRole('button', { name: /apply draft/i });
|
|
149
|
-
expect(btn.getAttribute('title')).toMatch(/already been merged/);
|
|
150
|
-
expect(btn.getAttribute('title')).toMatch(/no file changes/);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('is enabled with the default (purple) label when the gate is clean', () => {
|
|
154
|
-
renderWithChat(
|
|
155
|
-
<PrMergeButton
|
|
156
|
-
detail={detail({ mergeableInBevel: true, mergeWarnings: [] })}
|
|
157
|
-
onMerged={() => {}}
|
|
158
|
-
/>,
|
|
159
|
-
);
|
|
160
|
-
const btn = screen.getByRole('button', { name: /^apply draft to current company state$/i });
|
|
161
|
-
expect(btn).toBeEnabled();
|
|
162
|
-
expect(btn.getAttribute('title')).toMatch(/all files confirmed/i);
|
|
163
|
-
expect(btn.getAttribute('title')).toMatch(/Current company state/);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('stays enabled when warnings exist but no hard block (admin bypass path)', () => {
|
|
167
|
-
// Same "Apply draft …" label as the clean path — the bypass dialog
|
|
168
|
-
// appears AFTER the user clicks, not as a relabel up front. The
|
|
169
|
-
// amber color + tooltip carry the "something to review" signal.
|
|
170
|
-
renderWithChat(
|
|
171
|
-
<PrMergeButton
|
|
172
|
-
detail={detail({
|
|
173
|
-
mergeableInBevel: true,
|
|
174
|
-
mergeBlockedReasons: [],
|
|
175
|
-
mergeWarnings: ['Waiting on Bob to approve B.md.'],
|
|
176
|
-
viewerCanBypassMerge: true,
|
|
177
|
-
})}
|
|
178
|
-
onMerged={() => {}}
|
|
179
|
-
/>,
|
|
180
|
-
);
|
|
181
|
-
const btn = screen.getByRole('button', { name: /^apply draft to current company state$/i });
|
|
182
|
-
expect(btn).toBeEnabled();
|
|
183
|
-
expect(btn.getAttribute('title')).toMatch(/1 confirmation pending/i);
|
|
184
|
-
expect(btn.getAttribute('title')).toMatch(/click to review/i);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('drops the "to {base}" suffix in compact mode while keeping the full tooltip', () => {
|
|
188
|
-
renderWithChat(
|
|
189
|
-
<PrMergeButton
|
|
190
|
-
detail={detail({
|
|
191
|
-
mergeableInBevel: true,
|
|
192
|
-
mergeBlockedReasons: [],
|
|
193
|
-
mergeWarnings: ['Waiting on Bob to approve B.md.'],
|
|
194
|
-
viewerCanBypassMerge: true,
|
|
195
|
-
})}
|
|
196
|
-
onMerged={() => {}}
|
|
197
|
-
compact
|
|
198
|
-
/>,
|
|
199
|
-
);
|
|
200
|
-
const btn = screen.getByRole('button', { name: /^apply draft$/i });
|
|
201
|
-
expect(btn).toBeEnabled();
|
|
202
|
-
expect(btn.getAttribute('title')).toMatch(/1 confirmation pending/i);
|
|
203
|
-
expect(btn.getAttribute('title')).toMatch(/click to review/i);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('disables the merge button with admin-only copy when the viewer cannot bypass', () => {
|
|
207
|
-
// Non-admin user: backend would 403 on a bypass click. Frontend should
|
|
208
|
-
// surface that as a disabled button up front instead of letting the
|
|
209
|
-
// user open the bypass dialog only to hit an error.
|
|
210
|
-
renderWithChat(
|
|
211
|
-
<PrMergeButton
|
|
212
|
-
detail={detail({
|
|
213
|
-
mergeableInBevel: true,
|
|
214
|
-
mergeBlockedReasons: [],
|
|
215
|
-
mergeWarnings: ['Waiting on approval for test.md from Admin.'],
|
|
216
|
-
viewerCanBypassMerge: false,
|
|
217
|
-
})}
|
|
218
|
-
onMerged={() => {}}
|
|
219
|
-
/>,
|
|
220
|
-
);
|
|
221
|
-
const btn = screen.getByRole('button', { name: /waiting on confirmations/i });
|
|
222
|
-
expect(btn).toBeDisabled();
|
|
223
|
-
expect(btn.getAttribute('title')).toMatch(/only an admin can apply now/i);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe('async merge (202 + event bus)', () => {
|
|
227
|
-
it('shows "Applying…" on click and completes via change-request-merged', async () => {
|
|
228
|
-
vi.mocked(mergePullRequest).mockResolvedValueOnce({ status: 'merging', number: 1 });
|
|
229
|
-
const onMerged = vi.fn();
|
|
230
|
-
const bus = makeFakeBus();
|
|
231
|
-
renderWithBus(<PrMergeButton detail={detail({ mergeableInBevel: true })} onMerged={onMerged} />, bus);
|
|
232
|
-
|
|
233
|
-
fireEvent.click(screen.getByRole('button', { name: /apply draft/i }));
|
|
234
|
-
// Pending state shows immediately; the POST only acks (202).
|
|
235
|
-
expect(screen.getByRole('button', { name: /applying/i })).toBeInTheDocument();
|
|
236
|
-
expect(mergePullRequest).toHaveBeenCalledWith(1, {});
|
|
237
|
-
await act(async () => {}); // flush the awaited 202 ack
|
|
238
|
-
|
|
239
|
-
// onMerged fires only when the merge event for THIS CR lands.
|
|
240
|
-
expect(onMerged).not.toHaveBeenCalled();
|
|
241
|
-
act(() => bus.emit({ kind: 'change-request-merged', number: 1, id: 1, ts: '' }));
|
|
242
|
-
expect(onMerged).toHaveBeenCalledTimes(1);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('hands conflicts to the change-request port (does not error) when the merge reports conflicts', async () => {
|
|
246
|
-
vi.mocked(mergePullRequest).mockResolvedValueOnce({ status: 'merging', number: 1 });
|
|
247
|
-
const resolveCrConflicts = vi.fn();
|
|
248
|
-
const bus = makeFakeBus();
|
|
249
|
-
renderWithBus(<PrMergeButton detail={detail({ mergeableInBevel: true })} onMerged={() => {}} />, bus, resolveCrConflicts);
|
|
250
|
-
|
|
251
|
-
fireEvent.click(screen.getByRole('button', { name: /apply draft/i }));
|
|
252
|
-
await act(async () => {});
|
|
253
|
-
act(() =>
|
|
254
|
-
bus.emit({
|
|
255
|
-
kind: 'change-request-merge-failed',
|
|
256
|
-
forUserId: 'u',
|
|
257
|
-
number: 1,
|
|
258
|
-
reason: 'conflicts',
|
|
259
|
-
conflicts: true,
|
|
260
|
-
id: 1,
|
|
261
|
-
ts: '',
|
|
262
|
-
}),
|
|
263
|
-
);
|
|
264
|
-
expect(resolveCrConflicts).toHaveBeenCalledWith(
|
|
265
|
-
expect.objectContaining({ kind: 'apply', changeRequestNumber: 1, base: 'current-company-state' }),
|
|
266
|
-
);
|
|
267
|
-
expect(screen.queryByRole('alert')).toBeNull();
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('surfaces the reason as an error banner on a non-conflict merge failure', async () => {
|
|
271
|
-
vi.mocked(mergePullRequest).mockResolvedValueOnce({ status: 'merging', number: 1 });
|
|
272
|
-
const bus = makeFakeBus();
|
|
273
|
-
renderWithBus(<PrMergeButton detail={detail({ mergeableInBevel: true })} onMerged={() => {}} />, bus);
|
|
274
|
-
|
|
275
|
-
fireEvent.click(screen.getByRole('button', { name: /apply draft/i }));
|
|
276
|
-
await act(async () => {});
|
|
277
|
-
act(() =>
|
|
278
|
-
bus.emit({
|
|
279
|
-
kind: 'change-request-merge-failed',
|
|
280
|
-
forUserId: 'u',
|
|
281
|
-
number: 1,
|
|
282
|
-
reason: 'gh pr merge failed: timed out',
|
|
283
|
-
conflicts: false,
|
|
284
|
-
id: 1,
|
|
285
|
-
ts: '',
|
|
286
|
-
}),
|
|
287
|
-
);
|
|
288
|
-
expect(screen.getByRole('alert').textContent).toMatch(/timed out/);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('closes the bypass dialog (not just shows the error) when a bypass merge fails', async () => {
|
|
292
|
-
vi.mocked(mergePullRequest).mockResolvedValueOnce({ status: 'merging', number: 1 });
|
|
293
|
-
const bus = makeFakeBus();
|
|
294
|
-
renderWithBus(
|
|
295
|
-
<PrMergeButton
|
|
296
|
-
detail={detail({
|
|
297
|
-
mergeableInBevel: true,
|
|
298
|
-
mergeWarnings: ['Waiting on Bob to approve B.md.'],
|
|
299
|
-
viewerCanBypassMerge: true,
|
|
300
|
-
})}
|
|
301
|
-
onMerged={() => {}}
|
|
302
|
-
/>,
|
|
303
|
-
bus,
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
fireEvent.click(screen.getByRole('button', { name: /apply draft/i }));
|
|
307
|
-
// Confirm through the bypass dialog (acknowledge checkbox enables it).
|
|
308
|
-
fireEvent.click(screen.getByRole('checkbox'));
|
|
309
|
-
fireEvent.click(screen.getByRole('button', { name: /with bypass/i }));
|
|
310
|
-
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
|
311
|
-
await act(async () => {});
|
|
312
|
-
|
|
313
|
-
act(() =>
|
|
314
|
-
bus.emit({
|
|
315
|
-
kind: 'change-request-merge-failed',
|
|
316
|
-
forUserId: 'u',
|
|
317
|
-
number: 1,
|
|
318
|
-
reason: 'gh pr merge failed',
|
|
319
|
-
conflicts: false,
|
|
320
|
-
id: 1,
|
|
321
|
-
ts: '',
|
|
322
|
-
}),
|
|
323
|
-
);
|
|
324
|
-
// Dialog dismissed, error surfaced in the button row (not stranded behind it).
|
|
325
|
-
expect(screen.queryByRole('dialog')).toBeNull();
|
|
326
|
-
expect(screen.getByRole('alert').textContent).toMatch(/gh pr merge failed/);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
it('completes via the polling fallback when the merge event is lost (SSE drop)', async () => {
|
|
330
|
-
// Reproduces the reported bug: the apply lands server-side but the
|
|
331
|
-
// `change-request-merged` event never arrives (proxy 502 / backend
|
|
332
|
-
// restart took the SSE connection with it). The button must still
|
|
333
|
-
// resolve off the CR's real state instead of spinning "Applying…".
|
|
334
|
-
vi.useFakeTimers();
|
|
335
|
-
try {
|
|
336
|
-
vi.mocked(mergePullRequest).mockResolvedValueOnce({ status: 'merging', number: 1 });
|
|
337
|
-
// First poll: still open (merge in flight). Second poll: merged.
|
|
338
|
-
vi.mocked(fetchPrDetail)
|
|
339
|
-
.mockResolvedValueOnce(detail({ state: 'open' }))
|
|
340
|
-
.mockResolvedValueOnce(detail({ state: 'merged' }));
|
|
341
|
-
const onMerged = vi.fn();
|
|
342
|
-
const bus = makeFakeBus();
|
|
343
|
-
renderWithBus(<PrMergeButton detail={detail({ mergeableInBevel: true })} onMerged={onMerged} />, bus);
|
|
344
|
-
|
|
345
|
-
fireEvent.click(screen.getByRole('button', { name: /apply draft/i }));
|
|
346
|
-
await act(async () => {}); // flush the 202 ack → arms the poll
|
|
347
|
-
|
|
348
|
-
// NO SSE event arrives. First poll tick: CR still open → keep waiting.
|
|
349
|
-
await act(async () => { await vi.advanceTimersByTimeAsync(4_000); });
|
|
350
|
-
expect(onMerged).not.toHaveBeenCalled();
|
|
351
|
-
|
|
352
|
-
// Second poll tick: CR now reads merged → resolve without the event.
|
|
353
|
-
await act(async () => { await vi.advanceTimersByTimeAsync(4_000); });
|
|
354
|
-
expect(onMerged).toHaveBeenCalledTimes(1);
|
|
355
|
-
} finally {
|
|
356
|
-
vi.useRealTimers();
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|