@bevel-software/platform-core-frontend 0.15.1 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +20 -9
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +11 -3
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/email.ts +37 -1
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +721 -126
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +140 -6
- package/src/modules/access/components/ManageAccessDialog.tsx +1299 -561
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/audit/__tests__/AuditLogPage.test.tsx +312 -0
- package/src/modules/audit/components/AuditEventsPanel.tsx +319 -0
- package/src/modules/audit/components/AuditLogPage.tsx +373 -0
- package/src/modules/audit/components/principal-grouping.ts +49 -0
- package/src/modules/audit/services/audit.api.ts +98 -0
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +108 -3
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +103 -98
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +20 -5
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +97 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +13 -4
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +100 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +258 -6
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +16 -56
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +155 -152
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +386 -80
- package/src/modules/library/__tests__/SkillsTree.test.tsx +293 -4
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +87 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +173 -26
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +121 -28
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +47 -4
- package/src/modules/library/__tests__/link-membership.test.ts +13 -4
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +36 -1
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +74 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +146 -45
- package/src/modules/library/components/LibraryLayout.tsx +119 -256
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +1 -3
- package/src/modules/library/components/LockedPluginView.tsx +62 -34
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +16 -2
- package/src/modules/library/components/PageActions.tsx +11 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +121 -22
- package/src/modules/library/components/PluginExtras.tsx +140 -17
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +157 -41
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +239 -263
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +141 -28
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +103 -17
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +6 -12
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +274 -122
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +106 -16
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +77 -27
- package/src/modules/library/routes/library-paths.ts +26 -28
- package/src/modules/library/services/library.api.ts +38 -20
- package/src/modules/library/services/plugins.api.ts +69 -8
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +170 -32
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +75 -9
- package/src/modules/library/utils/status.ts +135 -33
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +8 -1
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +9 -24
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +10 -30
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +67 -4
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +7 -6
- package/src/modules/settings/services/github-facade.api.ts +23 -0
- package/src/modules/settings/settings-nav-items.tsx +13 -3
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +497 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +532 -43
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +141 -4
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +177 -118
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +542 -42
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +5 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1295 -191
- package/src/modules/workspace/components/FileRoute.tsx +353 -36
- package/src/modules/workspace/components/FileViewer.tsx +172 -46
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2533 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +731 -18
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +381 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +22 -3
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +424 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +206 -29
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +134 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +125 -19
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +220 -6
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +112 -36
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +6 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +33 -5
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +25 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -270
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx
ADDED
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
4
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
|
+
import type { FileApprovalState, PullRequestSummary } from '@bevel-software/platform-shared';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A change request whose target has moved on brings ITSELF up to date when
|
|
9
|
+
* the person opening it is allowed to — no button, no confirmation — and says
|
|
10
|
+
* so in words a business user reads. Razvan's point on core-staging: nobody
|
|
11
|
+
* outside engineering knows what `main` is, and nobody should have to press a
|
|
12
|
+
* button to get a proposal that merges cleanly back into shape.
|
|
13
|
+
*
|
|
14
|
+
* What these pin: the automatic update for the three viewers who may run it,
|
|
15
|
+
* silence for the one who may not, the conflict path, once-per-open, and the
|
|
16
|
+
* guard that no state of this dialog ever prints the default branch name.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const detailMock = vi.hoisted(() => ({ fetchPrDetail: vi.fn() }));
|
|
20
|
+
vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: detailMock.fetchPrDetail }));
|
|
21
|
+
|
|
22
|
+
const filesApi = vi.hoisted(() => ({
|
|
23
|
+
readFileOnBranch: vi.fn(),
|
|
24
|
+
readFileAtForkPoint: vi.fn(),
|
|
25
|
+
}));
|
|
26
|
+
vi.mock('../services/change-requests.api', () => filesApi);
|
|
27
|
+
vi.mock('../../pr/services/pr-approvals.api', () => ({
|
|
28
|
+
approvePrFile: vi.fn(),
|
|
29
|
+
revertPrFile: vi.fn(),
|
|
30
|
+
unapprovePrFile: vi.fn(),
|
|
31
|
+
}));
|
|
32
|
+
const mergeApi = vi.hoisted(() => ({
|
|
33
|
+
mergePullRequest: vi.fn(),
|
|
34
|
+
refreshChangeRequestFromTarget: vi.fn(),
|
|
35
|
+
}));
|
|
36
|
+
vi.mock('../../pr/services/pr-merge.api', () => mergeApi);
|
|
37
|
+
vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
38
|
+
cancelPullRequest: vi.fn(),
|
|
39
|
+
deleteChangeRequest: vi.fn(),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
43
|
+
import { GitApiError } from '../../git/services/git.api';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The default branch's git name, as the deployment sets it. No rendered
|
|
47
|
+
* sentence in this dialog may contain it — that is the whole point of the
|
|
48
|
+
* ticket, and `GUARD` below is what holds it.
|
|
49
|
+
*/
|
|
50
|
+
const TARGET = 'main';
|
|
51
|
+
const FORK = 'f'.repeat(40);
|
|
52
|
+
const BEFORE = 'price: 100\n';
|
|
53
|
+
const PROPOSED = 'price: 120\n';
|
|
54
|
+
|
|
55
|
+
const CR = {
|
|
56
|
+
number: 105,
|
|
57
|
+
title: 'Deal pricing',
|
|
58
|
+
authorId: 'abc',
|
|
59
|
+
author: { login: 'alice', name: 'Alice Doe' },
|
|
60
|
+
appAuthor: { name: 'Alice Doe' },
|
|
61
|
+
branch: 'alice/deal-pricing',
|
|
62
|
+
base: TARGET,
|
|
63
|
+
state: 'open',
|
|
64
|
+
createdAt: '2026-09-16T00:00:00.000Z',
|
|
65
|
+
touchedNodePaths: ['Sales/deal.yaml'],
|
|
66
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
67
|
+
url: '/change-requests/105',
|
|
68
|
+
} as unknown as PullRequestSummary;
|
|
69
|
+
|
|
70
|
+
const approval: FileApprovalState = {
|
|
71
|
+
path: 'Sales/deal.yaml',
|
|
72
|
+
eligibleApprovers: { roles: ['Admin'], users: [] },
|
|
73
|
+
approvedBy: [],
|
|
74
|
+
inMergeGate: false,
|
|
75
|
+
isApproved: false,
|
|
76
|
+
viewerCanApprove: false,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function detail(over: Record<string, unknown> = {}) {
|
|
80
|
+
return {
|
|
81
|
+
...CR,
|
|
82
|
+
body: '',
|
|
83
|
+
headSha: 'h'.repeat(40),
|
|
84
|
+
baseSha: 'b'.repeat(40),
|
|
85
|
+
files: [
|
|
86
|
+
{
|
|
87
|
+
path: 'Sales/deal.yaml',
|
|
88
|
+
status: 'modified' as const,
|
|
89
|
+
additions: 1,
|
|
90
|
+
deletions: 1,
|
|
91
|
+
isBinary: false,
|
|
92
|
+
sha: '',
|
|
93
|
+
rawUrl: '',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
comments: [],
|
|
97
|
+
approvals: [approval],
|
|
98
|
+
mergeableInBevel: true,
|
|
99
|
+
mergeBlockedReasons: [],
|
|
100
|
+
mergeWarnings: [],
|
|
101
|
+
viewerCanBypassMerge: false,
|
|
102
|
+
viewerCanCancel: false,
|
|
103
|
+
mergeBaseSha: FORK,
|
|
104
|
+
behind: true,
|
|
105
|
+
viewerCanUpdate: true,
|
|
106
|
+
...over,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const RUNNING = 'Bringing this up to date with what everyone sees…';
|
|
111
|
+
const DONE = 'Brought up to date with what everyone sees.';
|
|
112
|
+
const READER_NOTICE =
|
|
113
|
+
'What everyone sees has changed since this was proposed. Its author, or someone who can apply it, brings it up to date by opening it.';
|
|
114
|
+
|
|
115
|
+
const conflict = () =>
|
|
116
|
+
new GitApiError(409, `Conflicts merging "${TARGET}" into "alice/deal-pricing".`, {
|
|
117
|
+
kind: 'change-request-conflicts',
|
|
118
|
+
conflictedPaths: ['Sales/deal.yaml'],
|
|
119
|
+
error: 'Conflicts',
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
beforeEach(() => {
|
|
123
|
+
detailMock.fetchPrDetail.mockReset();
|
|
124
|
+
mergeApi.refreshChangeRequestFromTarget.mockReset().mockResolvedValue({});
|
|
125
|
+
filesApi.readFileAtForkPoint
|
|
126
|
+
.mockReset()
|
|
127
|
+
.mockImplementation(async (_n: number, sha: string) => ({ content: BEFORE, forkSha: sha }));
|
|
128
|
+
filesApi.readFileOnBranch.mockReset().mockResolvedValue(PROPOSED);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The three viewers the route lets update a request. The dialog reads one
|
|
133
|
+
* flag (`viewerCanUpdate`) for all three — which of them the caller IS is
|
|
134
|
+
* decided by `computeViewerCanUpdate` on the server and pinned there — so
|
|
135
|
+
* each case here carries the detail that predicate would have answered `true`
|
|
136
|
+
* for, and asserts the dialog acts on it.
|
|
137
|
+
*/
|
|
138
|
+
const MAY_UPDATE: [string, Record<string, unknown>][] = [
|
|
139
|
+
['its author', { viewerCanUpdate: true, viewerCanCancel: true }],
|
|
140
|
+
['an admin', { viewerCanUpdate: true, viewerCanBypassMerge: true }],
|
|
141
|
+
[
|
|
142
|
+
'someone who may apply it',
|
|
143
|
+
{
|
|
144
|
+
viewerCanUpdate: true,
|
|
145
|
+
approvals: [{ ...approval, inMergeGate: true, viewerCanApprove: true }],
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
describe('ChangeRequestDialog: a stale request brings itself up to date', () => {
|
|
151
|
+
it.each(MAY_UPDATE)('updates itself on open for %s — no button, no confirmation', async (_who, over) => {
|
|
152
|
+
detailMock.fetchPrDetail
|
|
153
|
+
.mockResolvedValueOnce(detail(over))
|
|
154
|
+
.mockResolvedValue(detail({ ...over, behind: false }));
|
|
155
|
+
|
|
156
|
+
const { container } = render(
|
|
157
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
await waitFor(() => expect(mergeApi.refreshChangeRequestFromTarget).toHaveBeenCalledWith(105));
|
|
161
|
+
expect(await screen.findByText(DONE)).toBeInTheDocument();
|
|
162
|
+
// Nothing was pressed to get here, and there is nothing left to press.
|
|
163
|
+
expect(screen.queryByRole('button', { name: 'Update' })).not.toBeInTheDocument();
|
|
164
|
+
expect(screen.queryByText(RUNNING)).not.toBeInTheDocument();
|
|
165
|
+
// The fresh files are what is on screen — the proposal, not an error.
|
|
166
|
+
await waitFor(() => expect(container.querySelector('ins')?.textContent).toBe('price: 120'));
|
|
167
|
+
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('shows the status line and NO file content while the update runs', async () => {
|
|
171
|
+
let land: (v: unknown) => void = () => {};
|
|
172
|
+
mergeApi.refreshChangeRequestFromTarget.mockImplementation(
|
|
173
|
+
() => new Promise((resolve) => (land = resolve)),
|
|
174
|
+
);
|
|
175
|
+
detailMock.fetchPrDetail
|
|
176
|
+
.mockResolvedValueOnce(detail())
|
|
177
|
+
.mockResolvedValue(detail({ behind: false }));
|
|
178
|
+
|
|
179
|
+
const { container } = render(
|
|
180
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
expect(await screen.findByText(RUNNING)).toBeInTheDocument();
|
|
184
|
+
// Not the pre-update text, and not a diff of it: the proposal on screen
|
|
185
|
+
// must never be the one against text that has already moved.
|
|
186
|
+
expect(container.textContent).not.toContain('price: 120');
|
|
187
|
+
expect(container.querySelector('ins')).toBeNull();
|
|
188
|
+
expect(filesApi.readFileOnBranch).not.toHaveBeenCalled();
|
|
189
|
+
expect(filesApi.readFileAtForkPoint).not.toHaveBeenCalled();
|
|
190
|
+
expect(screen.queryByRole('button', { name: 'Apply changes' })).not.toBeInTheDocument();
|
|
191
|
+
|
|
192
|
+
land({});
|
|
193
|
+
expect(await screen.findByText(DONE)).toBeInTheDocument();
|
|
194
|
+
expect(screen.queryByText(RUNNING)).not.toBeInTheDocument();
|
|
195
|
+
await waitFor(() => expect(container.querySelector('ins')?.textContent).toBe('price: 120'));
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('never runs for a viewer who may not update it — they get the plain-words notice, no button', async () => {
|
|
199
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail({ viewerCanUpdate: false }));
|
|
200
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
201
|
+
|
|
202
|
+
expect(await screen.findByText(READER_NOTICE)).toBeInTheDocument();
|
|
203
|
+
expect(screen.queryByRole('button', { name: 'Update' })).not.toBeInTheDocument();
|
|
204
|
+
expect(screen.queryByText(RUNNING)).not.toBeInTheDocument();
|
|
205
|
+
expect(mergeApi.refreshChangeRequestFromTarget).not.toHaveBeenCalled();
|
|
206
|
+
// They still read the request as proposed.
|
|
207
|
+
await waitFor(() => expect(screen.getByText(/1 file/)).toBeInTheDocument());
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('never runs on a request that is no longer open', async () => {
|
|
211
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail({ state: 'merged', behind: true }));
|
|
212
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
213
|
+
|
|
214
|
+
await waitFor(() => expect(screen.getByText(/1 file/)).toBeInTheDocument());
|
|
215
|
+
expect(mergeApi.refreshChangeRequestFromTarget).not.toHaveBeenCalled();
|
|
216
|
+
expect(screen.queryByText(RUNNING)).not.toBeInTheDocument();
|
|
217
|
+
expect(screen.queryByText(READER_NOTICE)).not.toBeInTheDocument();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('says nothing at all about updating when the request is already up to date', async () => {
|
|
221
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail({ behind: false }));
|
|
222
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
223
|
+
|
|
224
|
+
await waitFor(() => expect(screen.getByText(/1 file/)).toBeInTheDocument());
|
|
225
|
+
expect(mergeApi.refreshChangeRequestFromTarget).not.toHaveBeenCalled();
|
|
226
|
+
expect(screen.queryByText(DONE)).not.toBeInTheDocument();
|
|
227
|
+
expect(screen.queryByText(RUNNING)).not.toBeInTheDocument();
|
|
228
|
+
expect(screen.queryByText(READER_NOTICE)).not.toBeInTheDocument();
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it.each([
|
|
232
|
+
['plainly', (ui: ReactElement) => ui],
|
|
233
|
+
['under StrictMode, which mounts every effect twice', (ui: ReactElement) => <StrictMode>{ui}</StrictMode>],
|
|
234
|
+
])('runs at most once per open, however many times the detail changes under it — %s', async (_how, wrap) => {
|
|
235
|
+
// The re-read after the merge still reports `behind` — a second change
|
|
236
|
+
// landed on the target while this one was merging. The dialog must not
|
|
237
|
+
// chase it: one update per open, and the next open picks up the rest.
|
|
238
|
+
//
|
|
239
|
+
// The StrictMode row is why the guard is a REF: React mounts, unmounts and
|
|
240
|
+
// re-mounts every effect in development, and a guard held in state is read
|
|
241
|
+
// as its initial value by the second mount. It double-mounts the detail
|
|
242
|
+
// fetch too, so the count below also pins that a request is not merged
|
|
243
|
+
// twice because the dialog was mounted twice.
|
|
244
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
245
|
+
render(wrap(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />));
|
|
246
|
+
|
|
247
|
+
await waitFor(() => expect(mergeApi.refreshChangeRequestFromTarget).toHaveBeenCalledTimes(1));
|
|
248
|
+
await waitFor(() => expect(screen.getByText(DONE)).toBeInTheDocument());
|
|
249
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
250
|
+
expect(mergeApi.refreshChangeRequestFromTarget).toHaveBeenCalledTimes(1);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it('opened ABOUT a file, it reads nothing until the update has settled', async () => {
|
|
254
|
+
// A dialog opened from a file surface knows its selection before the
|
|
255
|
+
// detail arrives (`initialPath`). That must not become a read: until the
|
|
256
|
+
// detail says whether this request is behind, the branch copy it would
|
|
257
|
+
// fetch is the one the update is about to replace.
|
|
258
|
+
let land: (v: unknown) => void = () => {};
|
|
259
|
+
mergeApi.refreshChangeRequestFromTarget.mockImplementation(
|
|
260
|
+
() => new Promise((resolve) => (land = resolve)),
|
|
261
|
+
);
|
|
262
|
+
detailMock.fetchPrDetail
|
|
263
|
+
.mockResolvedValueOnce(detail())
|
|
264
|
+
.mockResolvedValue(detail({ behind: false }));
|
|
265
|
+
|
|
266
|
+
render(
|
|
267
|
+
<ChangeRequestDialog
|
|
268
|
+
cr={CR}
|
|
269
|
+
initialPath="Sales/deal.yaml"
|
|
270
|
+
onClose={() => {}}
|
|
271
|
+
onResolved={() => {}}
|
|
272
|
+
/>,
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
expect(await screen.findByText(RUNNING)).toBeInTheDocument();
|
|
276
|
+
expect(filesApi.readFileOnBranch).not.toHaveBeenCalled();
|
|
277
|
+
expect(filesApi.readFileAtForkPoint).not.toHaveBeenCalled();
|
|
278
|
+
|
|
279
|
+
land({});
|
|
280
|
+
expect(await screen.findByText(DONE)).toBeInTheDocument();
|
|
281
|
+
// And afterwards it reads the file it was opened about — against the head
|
|
282
|
+
// the merge left.
|
|
283
|
+
await waitFor(() =>
|
|
284
|
+
expect(filesApi.readFileOnBranch).toHaveBeenCalledWith(CR.branch, 'Sales/deal.yaml'),
|
|
285
|
+
);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('two people opening the same stale request at once: the second finds nothing to merge, and neither sees an error', async () => {
|
|
289
|
+
// The server answers an already-merged update with a plain, successful
|
|
290
|
+
// detail — nothing merged, nothing to report.
|
|
291
|
+
detailMock.fetchPrDetail
|
|
292
|
+
.mockResolvedValueOnce(detail())
|
|
293
|
+
.mockResolvedValue(detail({ behind: false }));
|
|
294
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
295
|
+
|
|
296
|
+
expect(await screen.findByText(DONE)).toBeInTheDocument();
|
|
297
|
+
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe('ChangeRequestDialog: an update that cannot be combined', () => {
|
|
302
|
+
it('says so in plain words, keeps the conflict help, and offers no button', async () => {
|
|
303
|
+
mergeApi.refreshChangeRequestFromTarget.mockRejectedValue(conflict());
|
|
304
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
305
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
306
|
+
|
|
307
|
+
const banner = await screen.findByRole('alert');
|
|
308
|
+
expect(banner.textContent).toContain(
|
|
309
|
+
"what everyone sees has changed since this was proposed, and the two can't be combined automatically",
|
|
310
|
+
);
|
|
311
|
+
// NOT the apply refusal: nobody tried to apply anything.
|
|
312
|
+
expect(banner.textContent).not.toContain("Can't apply");
|
|
313
|
+
expect(screen.getByText(/Fastest fix: ask your agent to resolve it/)).toBeInTheDocument();
|
|
314
|
+
expect(screen.getByText(/Change request #105 can no longer be applied/)).toBeInTheDocument();
|
|
315
|
+
expect(screen.queryByRole('button', { name: 'Update' })).not.toBeInTheDocument();
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('is not retried on that open', async () => {
|
|
319
|
+
mergeApi.refreshChangeRequestFromTarget.mockRejectedValue(conflict());
|
|
320
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
321
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
322
|
+
|
|
323
|
+
await screen.findByRole('alert');
|
|
324
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
325
|
+
expect(mergeApi.refreshChangeRequestFromTarget).toHaveBeenCalledTimes(1);
|
|
326
|
+
// The failed attempt never re-read the detail either.
|
|
327
|
+
expect(detailMock.fetchPrDetail).toHaveBeenCalledTimes(1);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('any other refusal is reported as itself, without the conflict help', async () => {
|
|
331
|
+
mergeApi.refreshChangeRequestFromTarget.mockRejectedValue(
|
|
332
|
+
new GitApiError(403, 'Only the author of this change request, or someone who may apply it, can update it.'),
|
|
333
|
+
);
|
|
334
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
335
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
336
|
+
|
|
337
|
+
expect(await screen.findByText(/Only the author of this change request/)).toBeInTheDocument();
|
|
338
|
+
expect(screen.queryByText(/Fastest fix/)).not.toBeInTheDocument();
|
|
339
|
+
// Refused, but the request is readable: the files are still shown.
|
|
340
|
+
await waitFor(() => expect(screen.getByText(/1 file/)).toBeInTheDocument());
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* The guard. Every state of the dialog, rendered, searched for the default
|
|
346
|
+
* branch's git name as a whole word.
|
|
347
|
+
*
|
|
348
|
+
* ONE carve-out, deliberate: the prompt inside `ConflictHelp` is a block of
|
|
349
|
+
* verbatim data for the author's AGENT, which needs both refs to do the merge
|
|
350
|
+
* it is being asked to do. It is marked as data in the prompt itself, it is
|
|
351
|
+
* the one thing on the surface not addressed to the reader, and the ticket
|
|
352
|
+
* keeps it as it is ("with the existing conflict help"). Everything the
|
|
353
|
+
* dialog SAYS is held to the rule.
|
|
354
|
+
*/
|
|
355
|
+
function prose(container: HTMLElement): string {
|
|
356
|
+
const copy = container.cloneNode(true) as HTMLElement;
|
|
357
|
+
for (const block of copy.querySelectorAll('pre')) block.remove();
|
|
358
|
+
return copy.textContent ?? '';
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const NAMES_TARGET = new RegExp(`\\b${TARGET}\\b`, 'i');
|
|
362
|
+
|
|
363
|
+
describe('ChangeRequestDialog: never names the default branch to a business user', () => {
|
|
364
|
+
async function rendered(over: Record<string, unknown>, settle: () => Promise<unknown>) {
|
|
365
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail(over));
|
|
366
|
+
const { container } = render(
|
|
367
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
368
|
+
);
|
|
369
|
+
await settle();
|
|
370
|
+
return container;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
it('after it has brought itself up to date', async () => {
|
|
374
|
+
const c = await rendered({}, () => screen.findByText(DONE));
|
|
375
|
+
expect(prose(c)).not.toMatch(NAMES_TARGET);
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('while it is bringing itself up to date', async () => {
|
|
379
|
+
mergeApi.refreshChangeRequestFromTarget.mockImplementation(() => new Promise(() => {}));
|
|
380
|
+
const c = await rendered({}, () => screen.findByText(RUNNING));
|
|
381
|
+
expect(prose(c)).not.toMatch(NAMES_TARGET);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('when the update conflicts', async () => {
|
|
385
|
+
mergeApi.refreshChangeRequestFromTarget.mockRejectedValue(conflict());
|
|
386
|
+
const c = await rendered({}, () => screen.findByRole('alert'));
|
|
387
|
+
expect(prose(c)).not.toMatch(NAMES_TARGET);
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
it('for a viewer who may not update it', async () => {
|
|
391
|
+
const c = await rendered({ viewerCanUpdate: false }, () => screen.findByText(READER_NOTICE));
|
|
392
|
+
expect(prose(c)).not.toMatch(NAMES_TARGET);
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('on a deleted file — the note says whose version would go, in plain words', async () => {
|
|
396
|
+
const c = await rendered(
|
|
397
|
+
{
|
|
398
|
+
behind: false,
|
|
399
|
+
// The note only has something to sit above for a file the dialog
|
|
400
|
+
// can actually SHOW the doomed version of — a document with a
|
|
401
|
+
// viewer, read from the target because the request's branch no
|
|
402
|
+
// longer has the path at all.
|
|
403
|
+
files: [
|
|
404
|
+
{
|
|
405
|
+
path: 'Sales/signed-contract.pdf',
|
|
406
|
+
status: 'removed' as const,
|
|
407
|
+
additions: 0,
|
|
408
|
+
deletions: 0,
|
|
409
|
+
isBinary: true,
|
|
410
|
+
sha: '',
|
|
411
|
+
rawUrl: '',
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
approvals: [{ ...approval, path: 'Sales/signed-contract.pdf' }],
|
|
415
|
+
},
|
|
416
|
+
() => screen.findByText(/This request DELETES this file/),
|
|
417
|
+
);
|
|
418
|
+
expect(screen.getByText(/This request DELETES this file/).textContent).toContain(
|
|
419
|
+
'Below is the version everyone sees today, which would go.',
|
|
420
|
+
);
|
|
421
|
+
expect(prose(c)).not.toMatch(NAMES_TARGET);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it("but the request's own draft name in the header row stays as it is", async () => {
|
|
425
|
+
const c = await rendered({ behind: false }, () => screen.findByText(/1 file/));
|
|
426
|
+
// The author's branch is theirs and is still shown; only the DEFAULT
|
|
427
|
+
// branch's name is the one a business user never has to decode.
|
|
428
|
+
expect(c.textContent).toContain('alice/deal-pricing');
|
|
429
|
+
expect(prose(c)).not.toMatch(NAMES_TARGET);
|
|
430
|
+
});
|
|
431
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import type { FileApprovalState, PullRequestSummary } from '@bevel-software/platform-shared';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A change request shows only what its author changed. Alice proposed
|
|
7
|
+
* `price: 120`; Bob then edited `status` directly on the target. Read against
|
|
8
|
+
* the target tip, Alice's request showed Bob's line as a deletion — so the
|
|
9
|
+
* dialog reads the "before" side at the fork point.
|
|
10
|
+
*
|
|
11
|
+
* Which fork point, once a stale request brings itself up to date on open, is
|
|
12
|
+
* the other half of this: the merge MOVES the fork point, so every read has to
|
|
13
|
+
* wait for it and then read the one the merge left.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const detailMock = vi.hoisted(() => ({ fetchPrDetail: vi.fn() }));
|
|
17
|
+
vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: detailMock.fetchPrDetail }));
|
|
18
|
+
|
|
19
|
+
const ORIGINAL = 'price: 100\nstatus: draft\n';
|
|
20
|
+
const TARGET_TIP = 'price: 100\nstatus: signed\n'; // Bob's later direct edit
|
|
21
|
+
const PROPOSED = 'price: 120\nstatus: draft\n'; // Alice's branch
|
|
22
|
+
const FORK = 'f'.repeat(40);
|
|
23
|
+
const MERGED_FORK = 'e'.repeat(40);
|
|
24
|
+
|
|
25
|
+
const filesApi = vi.hoisted(() => ({
|
|
26
|
+
readFileOnBranch: vi.fn(),
|
|
27
|
+
readFileAtForkPoint: vi.fn(),
|
|
28
|
+
}));
|
|
29
|
+
vi.mock('../services/change-requests.api', () => filesApi);
|
|
30
|
+
vi.mock('../../pr/services/pr-approvals.api', () => ({
|
|
31
|
+
approvePrFile: vi.fn(),
|
|
32
|
+
revertPrFile: vi.fn(),
|
|
33
|
+
unapprovePrFile: vi.fn(),
|
|
34
|
+
}));
|
|
35
|
+
const mergeApi = vi.hoisted(() => ({
|
|
36
|
+
mergePullRequest: vi.fn(),
|
|
37
|
+
refreshChangeRequestFromTarget: vi.fn(),
|
|
38
|
+
}));
|
|
39
|
+
vi.mock('../../pr/services/pr-merge.api', () => mergeApi);
|
|
40
|
+
vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
41
|
+
cancelPullRequest: vi.fn(),
|
|
42
|
+
deleteChangeRequest: vi.fn(),
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
46
|
+
|
|
47
|
+
const CR = {
|
|
48
|
+
number: 21,
|
|
49
|
+
title: 'Deal pricing',
|
|
50
|
+
authorId: 'abc',
|
|
51
|
+
author: { login: 'alice', name: 'Alice Doe' },
|
|
52
|
+
appAuthor: { name: 'Alice Doe' },
|
|
53
|
+
branch: 'alice/deal-pricing',
|
|
54
|
+
base: 'main',
|
|
55
|
+
state: 'open',
|
|
56
|
+
createdAt: '2026-09-16T00:00:00.000Z',
|
|
57
|
+
touchedNodePaths: ['Sales/deal.yaml'],
|
|
58
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
59
|
+
url: '/change-requests/21',
|
|
60
|
+
} as unknown as PullRequestSummary;
|
|
61
|
+
|
|
62
|
+
const approval: FileApprovalState = {
|
|
63
|
+
path: 'Sales/deal.yaml',
|
|
64
|
+
eligibleApprovers: { roles: ['Admin'], users: [] },
|
|
65
|
+
approvedBy: [],
|
|
66
|
+
inMergeGate: false,
|
|
67
|
+
isApproved: false,
|
|
68
|
+
viewerCanApprove: false,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function detail(over: Record<string, unknown> = {}) {
|
|
72
|
+
return {
|
|
73
|
+
...CR,
|
|
74
|
+
body: '',
|
|
75
|
+
headSha: 'h'.repeat(40),
|
|
76
|
+
baseSha: 'b'.repeat(40),
|
|
77
|
+
files: [
|
|
78
|
+
{
|
|
79
|
+
path: 'Sales/deal.yaml',
|
|
80
|
+
status: 'modified' as const,
|
|
81
|
+
additions: 1,
|
|
82
|
+
deletions: 1,
|
|
83
|
+
isBinary: false,
|
|
84
|
+
sha: '',
|
|
85
|
+
rawUrl: '',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
comments: [],
|
|
89
|
+
approvals: [approval],
|
|
90
|
+
mergeableInBevel: true,
|
|
91
|
+
mergeBlockedReasons: [],
|
|
92
|
+
mergeWarnings: [],
|
|
93
|
+
viewerCanBypassMerge: false,
|
|
94
|
+
viewerCanCancel: false,
|
|
95
|
+
mergeBaseSha: FORK,
|
|
96
|
+
behind: true,
|
|
97
|
+
viewerCanUpdate: true,
|
|
98
|
+
...over,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
detailMock.fetchPrDetail.mockReset();
|
|
104
|
+
mergeApi.refreshChangeRequestFromTarget.mockReset();
|
|
105
|
+
filesApi.readFileAtForkPoint
|
|
106
|
+
.mockReset()
|
|
107
|
+
.mockImplementation(async (_n: number, sha: string) => ({ content: ORIGINAL, forkSha: sha }));
|
|
108
|
+
filesApi.readFileOnBranch
|
|
109
|
+
.mockReset()
|
|
110
|
+
.mockImplementation(async (branch: string) => (branch === 'main' ? TARGET_TIP : PROPOSED));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe('ChangeRequestDialog: diff from the fork point', () => {
|
|
114
|
+
it("marks only the author's change — a later edit on the target is not shown as a deletion", async () => {
|
|
115
|
+
// A READER: the request stays behind under them (nobody brings it up to
|
|
116
|
+
// date by looking at it), which is exactly the state the fork-point read
|
|
117
|
+
// exists for.
|
|
118
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail({ viewerCanUpdate: false }));
|
|
119
|
+
const { container } = render(
|
|
120
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
await waitFor(() => expect(container.querySelector('ins')).not.toBeNull());
|
|
124
|
+
const removed = [...container.querySelectorAll('del')].map((n) => n.textContent);
|
|
125
|
+
const added = [...container.querySelectorAll('ins')].map((n) => n.textContent);
|
|
126
|
+
expect(removed).toEqual(['price: 100']);
|
|
127
|
+
expect(added).toEqual(['price: 120']);
|
|
128
|
+
expect(container.textContent).not.toContain('status: signed');
|
|
129
|
+
|
|
130
|
+
// The before-side came from the fork point, never the target tip.
|
|
131
|
+
expect(filesApi.readFileAtForkPoint).toHaveBeenCalledWith(21, FORK, 'Sales/deal.yaml');
|
|
132
|
+
expect(filesApi.readFileOnBranch).not.toHaveBeenCalledWith('main', 'Sales/deal.yaml');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('a request that is up to date reads its files straight away, against its own fork point', async () => {
|
|
136
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail({ behind: false }));
|
|
137
|
+
const { container } = render(
|
|
138
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
await waitFor(() => expect(container.querySelector('ins')).not.toBeNull());
|
|
142
|
+
expect(mergeApi.refreshChangeRequestFromTarget).not.toHaveBeenCalled();
|
|
143
|
+
expect(filesApi.readFileAtForkPoint).toHaveBeenCalledWith(21, FORK, 'Sales/deal.yaml');
|
|
144
|
+
expect([...container.querySelectorAll('del')].map((n) => n.textContent)).toEqual(['price: 100']);
|
|
145
|
+
expect([...container.querySelectorAll('ins')].map((n) => n.textContent)).toEqual(['price: 120']);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe('ChangeRequestDialog: the files after the request brings itself up to date', () => {
|
|
150
|
+
it("re-reads the open file against the fresh fork point, and still marks only the author's line", async () => {
|
|
151
|
+
detailMock.fetchPrDetail
|
|
152
|
+
.mockResolvedValueOnce(detail())
|
|
153
|
+
.mockResolvedValue(detail({ behind: false, mergeBaseSha: MERGED_FORK }));
|
|
154
|
+
// After the merge the branch carries Bob's line too, and the fork point is
|
|
155
|
+
// the target tip it was merged from.
|
|
156
|
+
filesApi.readFileOnBranch.mockImplementation(async () => 'price: 120\nstatus: signed\n');
|
|
157
|
+
filesApi.readFileAtForkPoint.mockImplementation(async (_n: number, sha: string) => ({
|
|
158
|
+
content: TARGET_TIP,
|
|
159
|
+
forkSha: sha,
|
|
160
|
+
}));
|
|
161
|
+
mergeApi.refreshChangeRequestFromTarget.mockResolvedValue({});
|
|
162
|
+
|
|
163
|
+
const { container } = render(
|
|
164
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
await waitFor(() => expect(mergeApi.refreshChangeRequestFromTarget).toHaveBeenCalledWith(21));
|
|
168
|
+
await waitFor(() => expect(container.querySelector('ins')).not.toBeNull());
|
|
169
|
+
expect(detailMock.fetchPrDetail).toHaveBeenLastCalledWith(21, { fresh: true });
|
|
170
|
+
expect(filesApi.readFileAtForkPoint).toHaveBeenCalledWith(21, MERGED_FORK, 'Sales/deal.yaml');
|
|
171
|
+
// NEVER against the fork point the update replaced: a read fired before
|
|
172
|
+
// the merge would diff the proposal against a commit that no longer
|
|
173
|
+
// describes what the author started from.
|
|
174
|
+
expect(filesApi.readFileAtForkPoint).not.toHaveBeenCalledWith(21, FORK, 'Sales/deal.yaml');
|
|
175
|
+
expect([...container.querySelectorAll('del')].map((n) => n.textContent)).toEqual(['price: 100']);
|
|
176
|
+
expect([...container.querySelectorAll('ins')].map((n) => n.textContent)).toEqual(['price: 120']);
|
|
177
|
+
await waitFor(() => expect(screen.queryByText('Loading…')).not.toBeInTheDocument());
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('an update that lands but cannot be reloaded says so, and still reads the open file', async () => {
|
|
181
|
+
detailMock.fetchPrDetail.mockResolvedValueOnce(detail()).mockRejectedValue(new Error('503'));
|
|
182
|
+
mergeApi.refreshChangeRequestFromTarget.mockResolvedValue({});
|
|
183
|
+
filesApi.readFileOnBranch.mockImplementation(async () => 'price: 125\nstatus: draft\n');
|
|
184
|
+
const { container } = render(
|
|
185
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(
|
|
189
|
+
await screen.findByText(/Updated, but couldn't reload this change request/),
|
|
190
|
+
).toBeInTheDocument();
|
|
191
|
+
await waitFor(() => expect(container.querySelector('ins')?.textContent).toBe('price: 125'));
|
|
192
|
+
});
|
|
193
|
+
});
|