@bevel-software/platform-core-frontend 0.14.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +109 -4
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +268 -37
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +66 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +615 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -3
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +126 -52
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +118 -0
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +34 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A surface that opens the dialog ABOUT one file — the explorer's proposed
|
|
7
|
+
* row — hands it `initialPath`. The row is a link to the request's view of
|
|
8
|
+
* THAT file: landing on the request's first file instead is landing somewhere
|
|
9
|
+
* the reader did not click, and on a bundle of twenty proposals it is a
|
|
10
|
+
* different document entirely.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const detailMock = vi.hoisted(() => ({ fetchPrDetail: vi.fn() }));
|
|
14
|
+
vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: detailMock.fetchPrDetail }));
|
|
15
|
+
|
|
16
|
+
const branchApi = vi.hoisted(() => ({ readFileOnBranch: vi.fn(async () => 'branch copy') }));
|
|
17
|
+
vi.mock('../services/change-requests.api', () => ({
|
|
18
|
+
readFileOnBranch: branchApi.readFileOnBranch,
|
|
19
|
+
}));
|
|
20
|
+
vi.mock('../../pr/services/pr-approvals.api', () => ({
|
|
21
|
+
approvePrFile: vi.fn(),
|
|
22
|
+
revertPrFile: vi.fn(),
|
|
23
|
+
unapprovePrFile: vi.fn(),
|
|
24
|
+
}));
|
|
25
|
+
vi.mock('../../pr/services/pr-merge.api', () => ({ mergePullRequest: vi.fn(), refreshChangeRequestFromTarget: vi.fn() }));
|
|
26
|
+
vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
27
|
+
cancelPullRequest: vi.fn(),
|
|
28
|
+
deleteChangeRequest: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
32
|
+
|
|
33
|
+
const CR = {
|
|
34
|
+
number: 12,
|
|
35
|
+
title: 'Changes from Ana. Knowledge',
|
|
36
|
+
authorId: 'abc',
|
|
37
|
+
author: { login: 'user-abc', name: 'Ana' },
|
|
38
|
+
appAuthor: { name: 'Ana' },
|
|
39
|
+
branch: 'suggestions/ana-1/knowledge',
|
|
40
|
+
base: 'main',
|
|
41
|
+
state: 'open',
|
|
42
|
+
createdAt: '2026-08-07T00:00:00.000Z',
|
|
43
|
+
touchedNodePaths: ['Knowledge/first.md', 'Sales/brief.md'],
|
|
44
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
45
|
+
url: '/change-requests/12',
|
|
46
|
+
} as unknown as PullRequestSummary;
|
|
47
|
+
|
|
48
|
+
/** Two files, in a fixed order, so "the first one" is unambiguous. */
|
|
49
|
+
const DETAIL = {
|
|
50
|
+
...CR,
|
|
51
|
+
body: '',
|
|
52
|
+
headSha: 'h',
|
|
53
|
+
baseSha: 'b',
|
|
54
|
+
files: ['Knowledge/first.md', 'Sales/brief.md'].map((path) => ({
|
|
55
|
+
path,
|
|
56
|
+
status: 'added' as const,
|
|
57
|
+
additions: 1,
|
|
58
|
+
deletions: 0,
|
|
59
|
+
isBinary: false,
|
|
60
|
+
sha: '',
|
|
61
|
+
rawUrl: '',
|
|
62
|
+
})),
|
|
63
|
+
comments: [],
|
|
64
|
+
approvals: [],
|
|
65
|
+
mergeableInBevel: true,
|
|
66
|
+
mergeBlockedReasons: [],
|
|
67
|
+
mergeWarnings: [],
|
|
68
|
+
viewerCanBypassMerge: false,
|
|
69
|
+
viewerCanCancel: false,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** The file the tree marks as selected. */
|
|
73
|
+
const selectedInTree = () =>
|
|
74
|
+
screen
|
|
75
|
+
.getAllByRole('treeitem')
|
|
76
|
+
.find((row) => row.getAttribute('aria-selected') === 'true')
|
|
77
|
+
?.textContent;
|
|
78
|
+
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
detailMock.fetchPrDetail.mockReset();
|
|
81
|
+
branchApi.readFileOnBranch.mockClear();
|
|
82
|
+
detailMock.fetchPrDetail.mockResolvedValue(DETAIL);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('ChangeRequestDialog: the file it opens at', () => {
|
|
86
|
+
it('lands on the request first changed file when no caller names one', async () => {
|
|
87
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
88
|
+
expect(await screen.findByText(/Knowledge\/first\.md/)).toBeInTheDocument();
|
|
89
|
+
await waitFor(() => expect(selectedInTree()).toContain('first.md'));
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('lands on the caller file — selected in the tree, named in the header, read for its diff', async () => {
|
|
93
|
+
render(
|
|
94
|
+
<ChangeRequestDialog
|
|
95
|
+
cr={CR}
|
|
96
|
+
initialPath="Sales/brief.md"
|
|
97
|
+
onClose={() => {}}
|
|
98
|
+
onResolved={() => {}}
|
|
99
|
+
/>,
|
|
100
|
+
);
|
|
101
|
+
// Named above the diff pane, and the pane is reading THAT file's copy off
|
|
102
|
+
// the request's branch — not the first file's.
|
|
103
|
+
expect(await screen.findByText(/Sales\/brief\.md/)).toBeInTheDocument();
|
|
104
|
+
await waitFor(() => expect(selectedInTree()).toContain('brief.md'));
|
|
105
|
+
expect(branchApi.readFileOnBranch).toHaveBeenCalledWith(CR.branch, 'Sales/brief.md');
|
|
106
|
+
expect(branchApi.readFileOnBranch).not.toHaveBeenCalledWith(CR.branch, 'Knowledge/first.md');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('falls back to the first file for a link the request no longer contains', async () => {
|
|
110
|
+
// A `?cr=&file=` link outlives the request it was copied from: the file
|
|
111
|
+
// is renamed, or reverted out of it, or the link is simply old. The seed
|
|
112
|
+
// holds while the detail is in flight — that is the landing it exists
|
|
113
|
+
// for — and the detail is what ends it: a file the request does not
|
|
114
|
+
// contain leaves the pane reporting that file unreadable, which is the
|
|
115
|
+
// request not opening at all as far as the reader can tell.
|
|
116
|
+
render(
|
|
117
|
+
<ChangeRequestDialog
|
|
118
|
+
cr={CR}
|
|
119
|
+
initialPath="Sales/gone.md"
|
|
120
|
+
onClose={() => {}}
|
|
121
|
+
onResolved={() => {}}
|
|
122
|
+
/>,
|
|
123
|
+
);
|
|
124
|
+
await waitFor(() => expect(selectedInTree()).toContain('first.md'));
|
|
125
|
+
expect(await screen.findByText(/Knowledge\/first\.md/)).toBeInTheDocument();
|
|
126
|
+
expect(branchApi.readFileOnBranch).toHaveBeenCalledWith(CR.branch, 'Knowledge/first.md');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('seeds the selection rather than pinning it — the reader can still click away', async () => {
|
|
130
|
+
render(
|
|
131
|
+
<ChangeRequestDialog
|
|
132
|
+
cr={CR}
|
|
133
|
+
initialPath="Sales/brief.md"
|
|
134
|
+
onClose={() => {}}
|
|
135
|
+
onResolved={() => {}}
|
|
136
|
+
/>,
|
|
137
|
+
);
|
|
138
|
+
await waitFor(() => expect(selectedInTree()).toContain('brief.md'));
|
|
139
|
+
(await screen.findByRole('button', { name: 'first.md' })).click();
|
|
140
|
+
await waitFor(() => expect(selectedInTree()).toContain('first.md'));
|
|
141
|
+
});
|
|
142
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import type { PrFileStatus, PullRequestSummary } from '@bevel-software/platform-shared';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A MOVED file in the change-request view.
|
|
7
|
+
*
|
|
8
|
+
* The pane reads the selected path on both branches. For a rename the
|
|
9
|
+
* selection is the NEW path — a path the default branch has never had — so
|
|
10
|
+
* that read 404s, and the pane, which had no way to tell a failed read from a
|
|
11
|
+
* slow one, sat on "Loading…" for as long as anyone cared to watch. The
|
|
12
|
+
* before-side of a move is the file at `previousPath`; these tests pin the
|
|
13
|
+
* three readings that follow from it (rename with edits, pure move, no
|
|
14
|
+
* readable old path), plus the general failed-read state and the unchanged
|
|
15
|
+
* behaviour for an ordinary modified file.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const detailMock = vi.hoisted(() => ({ fetchPrDetail: vi.fn() }));
|
|
19
|
+
vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: detailMock.fetchPrDetail }));
|
|
20
|
+
|
|
21
|
+
const readMock = vi.hoisted(() => ({ readFileOnBranch: vi.fn() }));
|
|
22
|
+
vi.mock('../services/change-requests.api', () => ({
|
|
23
|
+
readFileOnBranch: readMock.readFileOnBranch,
|
|
24
|
+
}));
|
|
25
|
+
vi.mock('../../pr/services/pr-approvals.api', () => ({
|
|
26
|
+
approvePrFile: vi.fn(),
|
|
27
|
+
revertPrFile: vi.fn(),
|
|
28
|
+
unapprovePrFile: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('../../pr/services/pr-merge.api', () => ({ mergePullRequest: vi.fn() }));
|
|
31
|
+
vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
32
|
+
cancelPullRequest: vi.fn(),
|
|
33
|
+
deleteChangeRequest: vi.fn(),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
37
|
+
|
|
38
|
+
/** What `test-setup.ts` pins the default branch to. */
|
|
39
|
+
const MAIN = 'target-company-state';
|
|
40
|
+
const CR_BRANCH = 'ali.raza/move-the-runbook';
|
|
41
|
+
|
|
42
|
+
const OLD_PATH = 'Ops/runbook.yaml';
|
|
43
|
+
const NEW_PATH = 'Docs/Ops/runbook.yaml';
|
|
44
|
+
|
|
45
|
+
const CR: PullRequestSummary = {
|
|
46
|
+
number: 12,
|
|
47
|
+
title: 'Move the runbook under Docs',
|
|
48
|
+
authorId: 'abc',
|
|
49
|
+
author: { login: 'user-abc', name: 'Ali' },
|
|
50
|
+
appAuthor: { name: 'Ali' },
|
|
51
|
+
branch: CR_BRANCH,
|
|
52
|
+
base: 'main',
|
|
53
|
+
state: 'open',
|
|
54
|
+
createdAt: '2026-08-07T00:00:00.000Z',
|
|
55
|
+
touchedNodePaths: [],
|
|
56
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
57
|
+
url: '/change-requests/12',
|
|
58
|
+
} as unknown as PullRequestSummary;
|
|
59
|
+
|
|
60
|
+
function detailWith(file: {
|
|
61
|
+
path: string;
|
|
62
|
+
status: PrFileStatus;
|
|
63
|
+
previousPath?: string;
|
|
64
|
+
}) {
|
|
65
|
+
return {
|
|
66
|
+
...CR,
|
|
67
|
+
body: '',
|
|
68
|
+
headSha: 'h',
|
|
69
|
+
baseSha: 'b',
|
|
70
|
+
files: [{ ...file, additions: 1, deletions: 1, isBinary: false, sha: '', rawUrl: '' }],
|
|
71
|
+
comments: [],
|
|
72
|
+
approvals: [],
|
|
73
|
+
mergeableInBevel: true,
|
|
74
|
+
mergeBlockedReasons: [],
|
|
75
|
+
mergeWarnings: [],
|
|
76
|
+
viewerCanBypassMerge: false,
|
|
77
|
+
viewerCanCancel: false,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Reads answered per (branch, path); anything unlisted rejects, as the API does. */
|
|
82
|
+
function reads(answers: Record<string, string>) {
|
|
83
|
+
readMock.readFileOnBranch.mockImplementation(async (branch: string, path: string) => {
|
|
84
|
+
const key = `${branch}::${path}`;
|
|
85
|
+
if (!(key in answers)) throw new Error(`404 ${key}`);
|
|
86
|
+
return answers[key];
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const marks = () => ({
|
|
91
|
+
removed: [...document.querySelectorAll('del')].map((n) => n.textContent),
|
|
92
|
+
added: [...document.querySelectorAll('ins')].map((n) => n.textContent),
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
detailMock.fetchPrDetail.mockReset();
|
|
97
|
+
readMock.readFileOnBranch.mockReset();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('ChangeRequestDialog: a moved file', () => {
|
|
101
|
+
it('diffs the OLD path on the default branch against the new one, and names the move', async () => {
|
|
102
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
103
|
+
detailWith({ path: NEW_PATH, status: 'renamed', previousPath: OLD_PATH }),
|
|
104
|
+
);
|
|
105
|
+
reads({
|
|
106
|
+
[`${MAIN}::${OLD_PATH}`]: 'steps:\n - stop the writer\n',
|
|
107
|
+
[`${CR_BRANCH}::${NEW_PATH}`]: 'steps:\n - stop the writer, then drain\n',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
111
|
+
|
|
112
|
+
expect(await screen.findByText(`Moved: ${OLD_PATH} → ${NEW_PATH}`)).toBeInTheDocument();
|
|
113
|
+
// The standard marked-up reading: the edit, not the move, is what is marked.
|
|
114
|
+
await screen.findByText('- stop the writer, then drain', { exact: false });
|
|
115
|
+
expect(marks().removed).toEqual([' - stop the writer']);
|
|
116
|
+
expect(marks().added).toEqual([' - stop the writer, then drain']);
|
|
117
|
+
expect(screen.queryByText('Loading…')).not.toBeInTheDocument();
|
|
118
|
+
// Never the new path on the default branch — that read is the 404 that hung.
|
|
119
|
+
expect(readMock.readFileOnBranch).not.toHaveBeenCalledWith(MAIN, NEW_PATH);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('a pure move shows the move note and the content, with nothing marked', async () => {
|
|
123
|
+
const body = 'steps:\n - stop the writer\n';
|
|
124
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
125
|
+
detailWith({ path: NEW_PATH, status: 'renamed', previousPath: OLD_PATH }),
|
|
126
|
+
);
|
|
127
|
+
reads({ [`${MAIN}::${OLD_PATH}`]: body, [`${CR_BRANCH}::${NEW_PATH}`]: body });
|
|
128
|
+
|
|
129
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
130
|
+
|
|
131
|
+
expect(await screen.findByText(`Moved: ${OLD_PATH} → ${NEW_PATH}`)).toBeInTheDocument();
|
|
132
|
+
await screen.findByText('- stop the writer', { exact: false });
|
|
133
|
+
expect(marks()).toEqual({ removed: [], added: [] });
|
|
134
|
+
expect(screen.queryByText('Loading…')).not.toBeInTheDocument();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('an unreadable old path says so and shows the NEW content, unmarked', async () => {
|
|
138
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
139
|
+
detailWith({ path: NEW_PATH, status: 'renamed', previousPath: OLD_PATH }),
|
|
140
|
+
);
|
|
141
|
+
// The old path is gone from the default branch too (or unreadable there).
|
|
142
|
+
reads({ [`${CR_BRANCH}::${NEW_PATH}`]: 'steps:\n - stop the writer\n' });
|
|
143
|
+
|
|
144
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
145
|
+
|
|
146
|
+
expect(await screen.findByText(/old path couldn't be read/)).toBeInTheDocument();
|
|
147
|
+
// Review proceeds on what the request actually proposes.
|
|
148
|
+
await screen.findByText('- stop the writer', { exact: false });
|
|
149
|
+
expect(marks()).toEqual({ removed: [], added: [] });
|
|
150
|
+
expect(screen.queryByText('Loading…')).not.toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('a rename with no previousPath at all lands in the same fallback', async () => {
|
|
154
|
+
detailMock.fetchPrDetail.mockResolvedValue({
|
|
155
|
+
...detailWith({ path: NEW_PATH, status: 'renamed' }),
|
|
156
|
+
});
|
|
157
|
+
reads({
|
|
158
|
+
[`${MAIN}::${NEW_PATH}`]: 'never asked for',
|
|
159
|
+
[`${CR_BRANCH}::${NEW_PATH}`]: 'steps:\n - stop the writer\n',
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
163
|
+
|
|
164
|
+
expect(await screen.findByText(/old path couldn't be read/)).toBeInTheDocument();
|
|
165
|
+
await screen.findByText('- stop the writer', { exact: false });
|
|
166
|
+
// With no old path there is nothing to name, so no move line is claimed.
|
|
167
|
+
expect(screen.queryByText(/^Moved:/)).not.toBeInTheDocument();
|
|
168
|
+
expect(screen.queryByText('Loading…')).not.toBeInTheDocument();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('ChangeRequestDialog: a default-branch read that fails', () => {
|
|
173
|
+
it("resolves to the pane's couldn't-be-read state rather than an endless Loading", async () => {
|
|
174
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
175
|
+
detailWith({ path: NEW_PATH, status: 'modified' }),
|
|
176
|
+
);
|
|
177
|
+
reads({ [`${CR_BRANCH}::${NEW_PATH}`]: 'steps:\n - stop the writer\n' });
|
|
178
|
+
|
|
179
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
180
|
+
|
|
181
|
+
expect(await screen.findByText(/couldn't be read/)).toBeInTheDocument();
|
|
182
|
+
expect(screen.queryByText('Loading…')).not.toBeInTheDocument();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('an ordinary modified file still reads exactly as it did', async () => {
|
|
186
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
187
|
+
detailWith({ path: NEW_PATH, status: 'modified' }),
|
|
188
|
+
);
|
|
189
|
+
reads({
|
|
190
|
+
[`${MAIN}::${NEW_PATH}`]: 'steps:\n - stop the writer\n',
|
|
191
|
+
[`${CR_BRANCH}::${NEW_PATH}`]: 'steps:\n - stop the writer, then drain\n',
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
195
|
+
|
|
196
|
+
await screen.findByText('- stop the writer, then drain', { exact: false });
|
|
197
|
+
expect(marks().removed).toEqual([' - stop the writer']);
|
|
198
|
+
expect(marks().added).toEqual([' - stop the writer, then drain']);
|
|
199
|
+
expect(screen.queryByText(/^Moved:/)).not.toBeInTheDocument();
|
|
200
|
+
expect(screen.queryByText(/couldn't be read/)).not.toBeInTheDocument();
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -31,6 +31,7 @@ vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
|
31
31
|
|
|
32
32
|
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
33
33
|
import { AuthContext } from '../../auth/state/auth.context';
|
|
34
|
+
import { readFileOnBranch } from '../services/change-requests.api';
|
|
34
35
|
|
|
35
36
|
const CR: PullRequestSummary = {
|
|
36
37
|
number: 12,
|
|
@@ -91,6 +92,7 @@ const approval = (over: Partial<FileApprovalState>): FileApprovalState => ({
|
|
|
91
92
|
approvedBy: [],
|
|
92
93
|
isApproved: false,
|
|
93
94
|
viewerCanApprove: false,
|
|
95
|
+
inMergeGate: true,
|
|
94
96
|
...over,
|
|
95
97
|
});
|
|
96
98
|
|
|
@@ -126,7 +128,7 @@ describe('ChangeRequestDialog: the apply gate and the per-file verbs', () => {
|
|
|
126
128
|
);
|
|
127
129
|
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
128
130
|
// The waiting line takes the button's place — naming who is being waited on.
|
|
129
|
-
expect(await screen.findByText(
|
|
131
|
+
expect(await screen.findByText('Waiting on Admin')).toBeInTheDocument();
|
|
130
132
|
expect(screen.queryByRole('button', { name: 'Apply changes' })).not.toBeInTheDocument();
|
|
131
133
|
});
|
|
132
134
|
|
|
@@ -155,21 +157,96 @@ describe('ChangeRequestDialog: the apply gate and the per-file verbs', () => {
|
|
|
155
157
|
expect(await screen.findByRole('button', { name: 'Apply changes' })).toBeInTheDocument();
|
|
156
158
|
});
|
|
157
159
|
|
|
158
|
-
it('
|
|
160
|
+
it('one file pending for the viewer: the header approves it, the footer counts it', async () => {
|
|
159
161
|
detailMock.fetchPrDetail.mockResolvedValue(
|
|
160
162
|
detailWith([approval({ viewerCanApprove: true })]),
|
|
161
163
|
);
|
|
162
164
|
approvalsApi.approvePrFile.mockResolvedValue([
|
|
163
|
-
approval({
|
|
165
|
+
approval({
|
|
166
|
+
viewerCanApprove: true,
|
|
167
|
+
isApproved: true,
|
|
168
|
+
approvedBy: [
|
|
169
|
+
{ email: 'olga@bevel.software', name: 'Olga', approvedAt: '', isStale: false, isSelfApproval: false },
|
|
170
|
+
],
|
|
171
|
+
}),
|
|
164
172
|
]);
|
|
165
|
-
render(
|
|
166
|
-
|
|
173
|
+
render(
|
|
174
|
+
<AuthContext.Provider
|
|
175
|
+
value={{ user: { id: 'u1', email: 'olga@bevel.software', name: 'Olga' } } as never}
|
|
176
|
+
>
|
|
177
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />
|
|
178
|
+
</AuthContext.Provider>,
|
|
179
|
+
);
|
|
180
|
+
expect(await screen.findByText('Your approval is needed on 1 file')).toBeInTheDocument();
|
|
181
|
+
// One file needs no "all" button.
|
|
182
|
+
expect(screen.queryByRole('button', { name: 'Approve all mine' })).not.toBeInTheDocument();
|
|
183
|
+
// The tree's check is status, not a control.
|
|
184
|
+
expect(screen.getByRole('img', { name: 'Waiting on your approval' })).toBeInTheDocument();
|
|
185
|
+
expect(screen.queryByRole('button', { name: /Confirm Docs/ })).not.toBeInTheDocument();
|
|
186
|
+
|
|
187
|
+
fireEvent.click(screen.getByRole('button', { name: 'Approve this file' }));
|
|
167
188
|
expect(approvalsApi.approvePrFile).toHaveBeenCalledWith(12, 'Docs/a.md');
|
|
168
|
-
|
|
169
|
-
expect(
|
|
189
|
+
expect(await screen.findByRole('button', { name: 'Approved – Undo' })).toBeInTheDocument();
|
|
190
|
+
expect(screen.getByRole('img', { name: 'Approved by you' })).toBeInTheDocument();
|
|
191
|
+
expect(screen.queryByText(/Your approval is needed/)).not.toBeInTheDocument();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('the header button sits right after the header text in the tab order', async () => {
|
|
195
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
196
|
+
detailWith([approval({ viewerCanApprove: true })]),
|
|
197
|
+
);
|
|
198
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
199
|
+
const button = await screen.findByRole('button', { name: 'Approve this file' });
|
|
200
|
+
const header = screen.getByText(/what changes is marked/);
|
|
201
|
+
expect(button.previousElementSibling).toBe(header);
|
|
202
|
+
expect(button).not.toHaveAttribute('tabindex');
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('two files pending: "Approve all mine" approves both, one after the other', async () => {
|
|
206
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
207
|
+
detailWith([
|
|
208
|
+
approval({ path: 'Docs/a.md', viewerCanApprove: true }),
|
|
209
|
+
approval({ path: 'Docs/b.md', viewerCanApprove: true }),
|
|
210
|
+
]),
|
|
211
|
+
);
|
|
212
|
+
approvalsApi.approvePrFile.mockReset();
|
|
213
|
+
approvalsApi.approvePrFile
|
|
214
|
+
.mockResolvedValueOnce([
|
|
215
|
+
approval({ path: 'Docs/a.md', viewerCanApprove: true, isApproved: true }),
|
|
216
|
+
approval({ path: 'Docs/b.md', viewerCanApprove: true }),
|
|
217
|
+
])
|
|
218
|
+
.mockResolvedValueOnce([
|
|
219
|
+
approval({ path: 'Docs/a.md', viewerCanApprove: true, isApproved: true }),
|
|
220
|
+
approval({ path: 'Docs/b.md', viewerCanApprove: true, isApproved: true }),
|
|
221
|
+
]);
|
|
222
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
223
|
+
expect(await screen.findByText('Your approval is needed on 2 files')).toBeInTheDocument();
|
|
224
|
+
|
|
225
|
+
fireEvent.click(screen.getByRole('button', { name: 'Approve all mine' }));
|
|
226
|
+
await waitFor(() => expect(approvalsApi.approvePrFile).toHaveBeenCalledTimes(2));
|
|
227
|
+
expect(approvalsApi.approvePrFile).toHaveBeenNthCalledWith(1, 12, 'Docs/a.md');
|
|
228
|
+
expect(approvalsApi.approvePrFile).toHaveBeenNthCalledWith(2, 12, 'Docs/b.md');
|
|
229
|
+
expect(await screen.findByRole('button', { name: 'Apply changes' })).toBeInTheDocument();
|
|
230
|
+
expect(screen.queryByText(/Your approval is needed/)).not.toBeInTheDocument();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('none pending for the viewer: no header button, the footer names who it waits on', async () => {
|
|
234
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
235
|
+
detailWith([
|
|
236
|
+
approval({
|
|
237
|
+
eligibleApprovers: { roles: ['Legal'], users: [{ name: 'Juan', email: 'juan@bevel.software' }] },
|
|
238
|
+
}),
|
|
239
|
+
]),
|
|
240
|
+
);
|
|
241
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
242
|
+
expect(await screen.findByText('Waiting on Legal, Juan')).toBeInTheDocument();
|
|
243
|
+
expect(screen.queryByText(/Your approval is needed/)).not.toBeInTheDocument();
|
|
244
|
+
expect(screen.queryByRole('button', { name: 'Approve this file' })).not.toBeInTheDocument();
|
|
245
|
+
expect(screen.queryByRole('button', { name: 'Approved – Undo' })).not.toBeInTheDocument();
|
|
246
|
+
expect(screen.queryByRole('button', { name: 'Approve all mine' })).not.toBeInTheDocument();
|
|
170
247
|
});
|
|
171
248
|
|
|
172
|
-
it("the viewer's own
|
|
249
|
+
it("undo: the viewer's own approval reads Approved – Undo, and pressing it withdraws", async () => {
|
|
173
250
|
detailMock.fetchPrDetail.mockResolvedValue(
|
|
174
251
|
detailWith([
|
|
175
252
|
approval({
|
|
@@ -189,10 +266,97 @@ describe('ChangeRequestDialog: the apply gate and the per-file verbs', () => {
|
|
|
189
266
|
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />
|
|
190
267
|
</AuthContext.Provider>,
|
|
191
268
|
);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
);
|
|
269
|
+
expect(await screen.findByRole('img', { name: 'Approved by you' })).toBeInTheDocument();
|
|
270
|
+
fireEvent.click(screen.getByRole('button', { name: 'Approved – Undo' }));
|
|
195
271
|
await waitFor(() => expect(approvalsApi.unapprovePrFile).toHaveBeenCalledWith(12, 'Docs/a.md'));
|
|
272
|
+
expect(await screen.findByRole('button', { name: 'Approve this file' })).toBeInTheDocument();
|
|
273
|
+
expect(screen.getByText('Your approval is needed on 1 file')).toBeInTheDocument();
|
|
274
|
+
expect(screen.getByRole('img', { name: 'Waiting on your approval' })).toBeInTheDocument();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('confirmed by someone else: waits on nobody, but the header still lets the viewer add theirs', async () => {
|
|
278
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
279
|
+
detailWith([
|
|
280
|
+
approval({
|
|
281
|
+
viewerCanApprove: true,
|
|
282
|
+
isApproved: true,
|
|
283
|
+
approvedBy: [
|
|
284
|
+
{ email: 'juan@bevel.software', name: 'Juan', approvedAt: '', isStale: false, isSelfApproval: false },
|
|
285
|
+
],
|
|
286
|
+
}),
|
|
287
|
+
]),
|
|
288
|
+
);
|
|
289
|
+
render(
|
|
290
|
+
<AuthContext.Provider
|
|
291
|
+
value={{ user: { id: 'u1', email: 'olga@bevel.software', name: 'Olga' } } as never}
|
|
292
|
+
>
|
|
293
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />
|
|
294
|
+
</AuthContext.Provider>,
|
|
295
|
+
);
|
|
296
|
+
expect(await screen.findByRole('button', { name: 'Apply changes' })).toBeInTheDocument();
|
|
297
|
+
expect(screen.getByRole('img', { name: 'Confirmed by Admin' })).toBeInTheDocument();
|
|
298
|
+
expect(screen.queryByRole('img', { name: 'Waiting on your approval' })).not.toBeInTheDocument();
|
|
299
|
+
expect(screen.queryByText(/Your approval is needed/)).not.toBeInTheDocument();
|
|
300
|
+
expect(screen.getByRole('button', { name: 'Approve this file' })).toBeInTheDocument();
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('files outside the merge gate hold nothing up and name nobody', async () => {
|
|
304
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
305
|
+
detailWith([
|
|
306
|
+
approval({ path: 'Docs/a.md', isApproved: true }),
|
|
307
|
+
// The server says the gate ignores it (not markdown), owner named or not.
|
|
308
|
+
approval({
|
|
309
|
+
path: 'assets/shot.png',
|
|
310
|
+
eligibleApprovers: { roles: ['Legal'], users: [] },
|
|
311
|
+
inMergeGate: false,
|
|
312
|
+
}),
|
|
313
|
+
]),
|
|
314
|
+
);
|
|
315
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
316
|
+
expect(await screen.findByRole('button', { name: 'Apply changes' })).toBeInTheDocument();
|
|
317
|
+
expect(screen.queryByText(/Waiting on/)).not.toBeInTheDocument();
|
|
318
|
+
// Nor does the tree's badge on the ignored file.
|
|
319
|
+
expect(screen.queryByRole('img', { name: /Waiting on/ })).not.toBeInTheDocument();
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('Apply records approvals only on files the gate binds', async () => {
|
|
323
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
324
|
+
detailWith([
|
|
325
|
+
approval({ path: 'Docs/a.md', viewerCanApprove: true }),
|
|
326
|
+
approval({
|
|
327
|
+
path: 'assets/shot.png',
|
|
328
|
+
eligibleApprovers: { roles: ['Admin'], users: [] },
|
|
329
|
+
viewerCanApprove: true,
|
|
330
|
+
inMergeGate: false,
|
|
331
|
+
}),
|
|
332
|
+
]),
|
|
333
|
+
);
|
|
334
|
+
approvalsApi.approvePrFile.mockReset();
|
|
335
|
+
approvalsApi.approvePrFile.mockResolvedValue([]);
|
|
336
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
337
|
+
|
|
338
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Bypass approval and apply' }));
|
|
339
|
+
await waitFor(() => expect(approvalsApi.approvePrFile).toHaveBeenCalledWith(12, 'Docs/a.md'));
|
|
340
|
+
// The approving loop is over once the merge step is named.
|
|
341
|
+
expect(await screen.findByRole('button', { name: 'Applying…' })).toBeInTheDocument();
|
|
342
|
+
expect(approvalsApi.approvePrFile).not.toHaveBeenCalledWith(12, 'assets/shot.png');
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('while applying, the approve controls stand down', async () => {
|
|
346
|
+
const twoPending = detailWith([
|
|
347
|
+
approval({ path: 'Docs/a.md', viewerCanApprove: true }),
|
|
348
|
+
approval({ path: 'Docs/b.md', viewerCanApprove: true }),
|
|
349
|
+
]);
|
|
350
|
+
detailMock.fetchPrDetail.mockResolvedValue(twoPending);
|
|
351
|
+
approvalsApi.approvePrFile.mockReset();
|
|
352
|
+
approvalsApi.approvePrFile.mockReturnValue(new Promise(() => {}));
|
|
353
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
354
|
+
|
|
355
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Bypass approval and apply' }));
|
|
356
|
+
await waitFor(() =>
|
|
357
|
+
expect(screen.getByRole('button', { name: 'Approve this file' })).toBeDisabled(),
|
|
358
|
+
);
|
|
359
|
+
expect(screen.getByRole('button', { name: 'Approve all mine' })).toBeDisabled();
|
|
196
360
|
});
|
|
197
361
|
|
|
198
362
|
it('right-click reverts, with its own confirm; the last file resolves the dialog', async () => {
|
|
@@ -232,7 +396,7 @@ describe('ChangeRequestDialog: the apply gate and the per-file verbs', () => {
|
|
|
232
396
|
it('no Delete request for non-admins', async () => {
|
|
233
397
|
detailMock.fetchPrDetail.mockResolvedValue(detailWith([approval({})]));
|
|
234
398
|
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
235
|
-
await screen.findByText(
|
|
399
|
+
await screen.findByText('Waiting on Admin');
|
|
236
400
|
expect(screen.queryByRole('button', { name: 'Delete request' })).not.toBeInTheDocument();
|
|
237
401
|
});
|
|
238
402
|
|
|
@@ -270,8 +434,36 @@ describe('ChangeRequestDialog: the apply gate and the per-file verbs', () => {
|
|
|
270
434
|
it('offers no verbs to a viewer who cannot approve the file', async () => {
|
|
271
435
|
detailMock.fetchPrDetail.mockResolvedValue(detailWith([approval({})]));
|
|
272
436
|
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
273
|
-
await screen.findByText(
|
|
437
|
+
await screen.findByText('Waiting on Admin');
|
|
274
438
|
expect(screen.queryByRole('button', { name: 'Accept file' })).not.toBeInTheDocument();
|
|
275
439
|
expect(screen.queryByRole('button', { name: 'Revert file' })).not.toBeInTheDocument();
|
|
276
440
|
});
|
|
277
441
|
});
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* The bytes of an image in a change request live on the request's branch, and
|
|
445
|
+
* a screenshot the request adds is not in the checked-out tree at all. The
|
|
446
|
+
* dialog passes no resolver, so the viewer names each image instead of
|
|
447
|
+
* showing another revision's copy (`?ref=` in TODOS.md is the way to show it).
|
|
448
|
+
*/
|
|
449
|
+
describe('ChangeRequestDialog: images in a markdown diff', () => {
|
|
450
|
+
it("names a workspace image the request adds instead of showing the checked-out tree's copy", async () => {
|
|
451
|
+
detailMock.fetchPrDetail.mockResolvedValue(
|
|
452
|
+
detailWith([approval({ path: 'Docs/a.md', isApproved: true })]),
|
|
453
|
+
);
|
|
454
|
+
vi.mocked(readFileOnBranch).mockImplementation(async (branch: string) =>
|
|
455
|
+
branch === CR.branch ? 'text\n\n\n' : 'text\n',
|
|
456
|
+
);
|
|
457
|
+
try {
|
|
458
|
+
const { container } = render(
|
|
459
|
+
<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />,
|
|
460
|
+
);
|
|
461
|
+
expect(
|
|
462
|
+
await screen.findByRole('img', { name: /Image not shown: \.\/assets\/shot.png/ }),
|
|
463
|
+
).toBeInTheDocument();
|
|
464
|
+
expect(container.querySelector('img')).toBeNull();
|
|
465
|
+
} finally {
|
|
466
|
+
vi.mocked(readFileOnBranch).mockImplementation(async () => 'branch copy');
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
});
|