@bevel-software/platform-core-frontend 0.25.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/core/CoreAppShell.tsx +87 -25
- package/src/core/ProductName.tsx +49 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
- package/src/core/__tests__/core-contributions.test.ts +16 -0
- package/src/core/core-contributions.ts +17 -0
- package/src/core/registry.ts +51 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/components/ManageAccessDialog.tsx +1 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/auth/components/LoginScreen.tsx +4 -1
- package/src/modules/auth/services/account.api.ts +28 -1
- package/src/modules/auth/services/sso.ts +1 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
- package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
- package/src/modules/change-requests/services/change-requests.api.ts +15 -2
- package/src/modules/change-requests/utils/readFailure.ts +22 -0
- package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
- package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
- package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
- package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
- package/src/modules/embed/__tests__/mount.test.tsx +157 -0
- package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
- package/src/modules/embed/components/EmbedView.tsx +545 -0
- package/src/modules/embed/embed-config.ts +132 -0
- package/src/modules/embed/embed-host.ts +120 -0
- package/src/modules/embed/mount.tsx +80 -0
- package/src/modules/embed/services/embed-token.ts +22 -0
- package/src/modules/embed/services/embed.api.ts +158 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
- package/src/modules/git/branch-delete-menu-item.tsx +24 -0
- package/src/modules/git/components/BranchSwitcher.tsx +29 -5
- package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
- package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
- package/src/modules/git/components/PullNeededBanner.tsx +15 -49
- package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
- package/src/modules/git/index.ts +15 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
- package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
- package/src/modules/git/services/error-messages.ts +58 -1
- package/src/modules/git/services/pull-failure.ts +68 -0
- package/src/modules/git/state/branch-delete-confirm.ts +46 -0
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
- package/src/modules/layout/breakpoints.ts +8 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
- package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
- package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
- package/src/modules/library/__tests__/ToolPage.test.tsx +53 -0
- package/src/modules/library/components/LibraryPage.tsx +22 -0
- package/src/modules/library/components/PluginExtras.tsx +23 -6
- package/src/modules/library/components/PluginPage.tsx +6 -1
- package/src/modules/library/components/tool-page/ToolPage.tsx +45 -1
- package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- package/src/modules/library/services/tools.api.ts +27 -0
- package/src/modules/library/state/plugins-revision.ts +28 -0
- package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
- package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
- package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
- package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
- package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
- package/src/modules/onboarding/components/InviteButton.tsx +35 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
- package/src/modules/onboarding/components/RootLanding.tsx +8 -24
- package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
- package/src/modules/onboarding/first-page-prompt.ts +89 -0
- package/src/modules/onboarding/invite-emails.ts +175 -0
- package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
- package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
- package/src/modules/onboarding/state/agent-connection.ts +167 -0
- package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
- package/src/modules/onboarding/state/onboarding.ts +133 -59
- package/src/modules/onboarding/state/starter-packs.ts +169 -0
- package/src/modules/settings/settings-nav-items.tsx +8 -3
- package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
- package/src/modules/setup/__tests__/setup.test.tsx +65 -81
- package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
- package/src/modules/setup/components/SetupGate.tsx +46 -1
- package/src/modules/setup/components/SetupScreen.tsx +92 -152
- package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +3 -3
- package/src/modules/setup/utils/suggested-branch.ts +27 -0
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
- package/src/modules/toolbar/commands/actions.tsx +324 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
- package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
- package/src/modules/toolbar/components/Toolbar.tsx +10 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +4 -4
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
- package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
- package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
- package/src/modules/toolbar/search/rank.ts +111 -0
- package/src/modules/toolbar/search/sources.ts +169 -0
- package/src/modules/workflow/hooks/useFileLock.ts +10 -7
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
- package/src/modules/workflow/services/lock.api.ts +17 -2
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
- package/src/modules/workspace/components/EditorTabs.tsx +39 -15
- package/src/modules/workspace/components/FileExplorer.tsx +39 -6
- package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
- package/src/modules/workspace/components/FileRoute.tsx +12 -7
- package/src/modules/workspace/components/FileViewer.tsx +271 -74
- package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +101 -11
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
- package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
- package/src/modules/workspace/components/renderers/index.ts +26 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
- package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
- package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
- package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
- package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
- package/src/modules/workspace/routing/kb-routes.ts +66 -12
- package/src/modules/workspace/state/editable-page.ts +42 -0
- package/src/modules/workspace/state/workspace.context.ts +13 -4
- package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +26 -14
- package/src/modules/workspace/utils/display-file-name.ts +102 -0
- package/src/modules/workspace/utils/fileTree.ts +49 -14
- package/src/modules/workspace/utils/treeConfirm.ts +22 -5
- package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
- package/src/shared/components/ConfirmProvider.tsx +156 -0
- package/src/shared/components/Dialog.tsx +7 -0
- package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
- package/src/shared/components/confirm-context.ts +94 -0
- package/src/shared/components/index.ts +3 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +2 -2
- package/src/shared/mcp/connect-snippets.ts +8 -5
- package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from '../../state/workspace.context';
|
|
12
12
|
import { makeWorkspaceFixture } from '../../__tests__/testFixtures';
|
|
13
13
|
import { OpenChangeRequestsContext } from '../../state/open-change-requests.context';
|
|
14
|
+
import { ConfirmProvider } from '../../../../shared/components';
|
|
14
15
|
|
|
15
16
|
function makeTab(path: string, overrides: Partial<OpenTab> = {}): OpenTab {
|
|
16
17
|
const content = overrides.content ?? `content:${path}`;
|
|
@@ -76,6 +77,7 @@ function Wrap({
|
|
|
76
77
|
}) {
|
|
77
78
|
return (
|
|
78
79
|
<MemoryRouter>
|
|
80
|
+
<ConfirmProvider>
|
|
79
81
|
<WorkspaceContext.Provider value={workspace}>
|
|
80
82
|
<OpenChangeRequestsContext.Provider
|
|
81
83
|
value={{ paths: new Set(changeRequestPaths), forPath: () => [], minePaths: new Map(), mineNumbers: new Set() }}
|
|
@@ -83,6 +85,7 @@ function Wrap({
|
|
|
83
85
|
{children}
|
|
84
86
|
</OpenChangeRequestsContext.Provider>
|
|
85
87
|
</WorkspaceContext.Provider>
|
|
88
|
+
</ConfirmProvider>
|
|
86
89
|
</MemoryRouter>
|
|
87
90
|
);
|
|
88
91
|
}
|
|
@@ -114,6 +117,28 @@ describe('EditorTabs', () => {
|
|
|
114
117
|
expect(activeTab.getAttribute('aria-selected')).toBe('true');
|
|
115
118
|
});
|
|
116
119
|
|
|
120
|
+
it("names a plugin's plugin.json Plugin settings, the path on hover", () => {
|
|
121
|
+
const tabs = [makeTab('knowledge-base/Plugins/GTM/plugin.json'), makeTab('knowledge-base/Plugins/GTM/mcp.json')];
|
|
122
|
+
const ws = makeWorkspace(tabs, 'knowledge-base/Plugins/GTM/plugin.json');
|
|
123
|
+
render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
|
|
124
|
+
|
|
125
|
+
const [settings, mcp] = screen.getAllByRole('tab');
|
|
126
|
+
expect(settings.querySelector('.truncate')?.textContent).toBe('Plugin settings');
|
|
127
|
+
expect(settings).toHaveAttribute('title', 'knowledge-base/Plugins/GTM/plugin.json');
|
|
128
|
+
expect(screen.getByRole('button', { name: 'Close Plugin settings' })).toBeInTheDocument();
|
|
129
|
+
expect(mcp.querySelector('.truncate')?.textContent).toBe('mcp.json');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("names a folder's access.md Who has access", () => {
|
|
133
|
+
const tabs = [makeTab('knowledge-base/KnowledgeBase/Legal/access.md')];
|
|
134
|
+
const ws = makeWorkspace(tabs, 'knowledge-base/KnowledgeBase/Legal/access.md');
|
|
135
|
+
render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
|
|
136
|
+
|
|
137
|
+
const tab = screen.getByRole('tab');
|
|
138
|
+
expect(tab.querySelector('.truncate')?.textContent).toBe('Who has access');
|
|
139
|
+
expect(tab).toHaveAttribute('title', 'knowledge-base/KnowledgeBase/Legal/access.md');
|
|
140
|
+
});
|
|
141
|
+
|
|
117
142
|
it('shows a dirty dot when a tab has unsaved changes', () => {
|
|
118
143
|
const tabs = [makeTab('a.md', { isDirty: true })];
|
|
119
144
|
const ws = makeWorkspace(tabs, 'a.md');
|
|
@@ -193,8 +218,29 @@ describe('EditorTabs', () => {
|
|
|
193
218
|
await user.click(screen.getByText('Close others'));
|
|
194
219
|
|
|
195
220
|
expect(closeTab).toHaveBeenCalledTimes(2);
|
|
196
|
-
|
|
197
|
-
expect(closeTab.mock.calls[
|
|
221
|
+
// Pinned to the workspace the tabs were picked in.
|
|
222
|
+
expect(closeTab.mock.calls[0]).toEqual([tabs[0], { skipConfirm: true, workspaceId: 'ws-1' }]);
|
|
223
|
+
expect(closeTab.mock.calls[1]).toEqual([tabs[2], { skipConfirm: true, workspaceId: 'ws-1' }]);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('a bulk close leaves the URL alone when the workspace moves partway through', async () => {
|
|
227
|
+
const user = userEvent.setup();
|
|
228
|
+
mockNavigate.mockClear();
|
|
229
|
+
// The first close lands; then the workspace moves to another branch and
|
|
230
|
+
// closeTab refuses the rest.
|
|
231
|
+
const closeTab = vi
|
|
232
|
+
.fn<WorkspaceContextValue['closeTab']>()
|
|
233
|
+
.mockResolvedValueOnce({ closed: true, newActivePath: 'b.md' })
|
|
234
|
+
.mockResolvedValue({ closed: false, newActivePath: 'elsewhere.md' });
|
|
235
|
+
const tabs = [makeTab('a.md'), makeTab('b.md'), makeTab('c.md')];
|
|
236
|
+
const ws = makeWorkspace(tabs, 'c.md', { closeTab });
|
|
237
|
+
render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
|
|
238
|
+
|
|
239
|
+
fireEvent.contextMenu(screen.getAllByRole('tab')[0]); // right-click on a
|
|
240
|
+
await user.click(screen.getByText('Close all'));
|
|
241
|
+
|
|
242
|
+
await vi.waitFor(() => expect(closeTab).toHaveBeenCalledTimes(3));
|
|
243
|
+
expect(mockNavigate).not.toHaveBeenCalled();
|
|
198
244
|
});
|
|
199
245
|
|
|
200
246
|
it('"Close tabs to the right" only closes tabs after the target', async () => {
|
|
@@ -212,26 +258,47 @@ describe('EditorTabs', () => {
|
|
|
212
258
|
expect(closeTab.mock.calls[1][0]).toEqual(tabs[2]);
|
|
213
259
|
});
|
|
214
260
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
261
|
+
describe("bulk close with unsaved tabs asks ONE question in the app's dialog", () => {
|
|
262
|
+
async function openCloseAll() {
|
|
263
|
+
const user = userEvent.setup();
|
|
264
|
+
const closeTab = vi.fn<WorkspaceContextValue['closeTab']>(async () => ({ closed: true, newActivePath: null }));
|
|
265
|
+
// The browser's dialogs suppressed: never the thing that answers.
|
|
266
|
+
const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(false);
|
|
267
|
+
const tabs = [
|
|
268
|
+
makeTab('a.md', { isDirty: true }),
|
|
269
|
+
makeTab('b.md'),
|
|
270
|
+
makeTab('c.md', { isDirty: true }),
|
|
271
|
+
];
|
|
272
|
+
const ws = makeWorkspace(tabs, 'b.md', { closeTab });
|
|
273
|
+
render(<Wrap workspace={ws}><EditorTabs /></Wrap>);
|
|
274
|
+
|
|
275
|
+
fireEvent.contextMenu(screen.getAllByRole('tab')[1]); // right-click on b
|
|
276
|
+
await user.click(screen.getByText('Close all'));
|
|
277
|
+
const dialog = await screen.findByRole('dialog');
|
|
278
|
+
return { user, closeTab, confirmSpy, dialog };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
it('lists the unsaved files with today\'s wording, and Close anyway closes every tab', async () => {
|
|
282
|
+
const { user, closeTab, confirmSpy, dialog } = await openCloseAll();
|
|
283
|
+
expect(screen.getAllByRole('dialog')).toHaveLength(1);
|
|
284
|
+
expect(dialog.textContent).toContain('You have unsaved changes in:\n - a.md\n - c.md\nClose anyway?');
|
|
285
|
+
expect(within(dialog).queryByText("Don't ask again")).toBeNull();
|
|
286
|
+
await user.click(within(dialog).getByRole('button', { name: 'Close anyway' }));
|
|
287
|
+
// All three tabs requested for close, with skipConfirm.
|
|
288
|
+
await vi.waitFor(() => expect(closeTab).toHaveBeenCalledTimes(3));
|
|
289
|
+
expect(closeTab.mock.calls.every((c) => c[1]?.skipConfirm === true)).toBe(true);
|
|
290
|
+
// Pinned to the workspace the question was asked in, so a branch switch
|
|
291
|
+
// while it was up closes nothing on the new branch.
|
|
292
|
+
expect(closeTab.mock.calls.every((c) => c[1]?.workspaceId === 'ws-1')).toBe(true);
|
|
293
|
+
expect(confirmSpy).not.toHaveBeenCalled();
|
|
294
|
+
});
|
|
229
295
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
296
|
+
it('Cancel closes nothing', async () => {
|
|
297
|
+
const { user, closeTab, dialog } = await openCloseAll();
|
|
298
|
+
await user.click(within(dialog).getByRole('button', { name: 'Cancel' }));
|
|
299
|
+
expect(screen.queryByRole('dialog')).toBeNull();
|
|
300
|
+
expect(closeTab).not.toHaveBeenCalled();
|
|
301
|
+
});
|
|
235
302
|
});
|
|
236
303
|
|
|
237
304
|
it('reorders via drag and drop', () => {
|
|
@@ -3149,9 +3149,10 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3149
3149
|
file(`${KB}/access.md`),
|
|
3150
3150
|
file(`${KB}/roles.yaml`),
|
|
3151
3151
|
file(`${KB}/.bevelignore`),
|
|
3152
|
+
// The organisation's own conventions file: the platform's guide is
|
|
3153
|
+
// served from code, so an AGENTS.md is content wherever it sits —
|
|
3154
|
+
// the server says the same.
|
|
3152
3155
|
file(`${KB}/AGENTS.md`),
|
|
3153
|
-
// Read from the repository root and nowhere else, so a nested one
|
|
3154
|
-
// is ordinary content — the server says the same.
|
|
3155
3156
|
file(`${KB}/Handbook/AGENTS.md`),
|
|
3156
3157
|
file(`${KB}/Handbook/notes.md`),
|
|
3157
3158
|
{ name: 'Sales', relativePath: `${KB}/Sales`, type: 'directory', children: [] },
|
|
@@ -3160,7 +3161,9 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3160
3161
|
],
|
|
3161
3162
|
});
|
|
3162
3163
|
|
|
3163
|
-
const PLATFORM = ['access.md', 'roles.yaml', '.bevelignore'
|
|
3164
|
+
const PLATFORM = ['access.md', 'roles.yaml', '.bevelignore'];
|
|
3165
|
+
/** What a platform file's row says: access.md reads as "Who has access". */
|
|
3166
|
+
const shown = (name: string) => (name === 'access.md' ? 'Who has access' : name);
|
|
3164
3167
|
|
|
3165
3168
|
let alertSpy: ReturnType<typeof vi.spyOn>;
|
|
3166
3169
|
|
|
@@ -3179,7 +3182,7 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3179
3182
|
|
|
3180
3183
|
it.each(PLATFORM)('%s cannot be dragged: the row refuses to start one', (name) => {
|
|
3181
3184
|
renderExplorer({ fileTree: TREE });
|
|
3182
|
-
expect(row(name)).toHaveAttribute('draggable', 'false');
|
|
3185
|
+
expect(row(shown(name))).toHaveAttribute('draggable', 'false');
|
|
3183
3186
|
});
|
|
3184
3187
|
|
|
3185
3188
|
it.each(PLATFORM)('a drop carrying %s is refused with the sentence, and nothing is sent', async (name) => {
|
|
@@ -3199,7 +3202,7 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3199
3202
|
|
|
3200
3203
|
it.each(PLATFORM)('the Rename action on %s says the sentence and opens nothing', async (name) => {
|
|
3201
3204
|
const { moveEntry } = renderExplorer({ fileTree: TREE });
|
|
3202
|
-
fireEvent.contextMenu(row(name));
|
|
3205
|
+
fireEvent.contextMenu(row(shown(name)));
|
|
3203
3206
|
const rename = screen.getByRole('menuitem', { name: /Rename/i });
|
|
3204
3207
|
expect(rename).toHaveAttribute('aria-disabled', 'true');
|
|
3205
3208
|
expect(rename).toHaveAttribute('title', sentence(name));
|
|
@@ -3207,7 +3210,7 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3207
3210
|
fireEvent.click(rename);
|
|
3208
3211
|
});
|
|
3209
3212
|
// No rename box: the row still shows its name, and nothing was sent.
|
|
3210
|
-
expect(screen.getAllByText(name)[0]).toBeInTheDocument();
|
|
3213
|
+
expect(screen.getAllByText(shown(name))[0]).toBeInTheDocument();
|
|
3211
3214
|
expect(moveEntry).not.toHaveBeenCalled();
|
|
3212
3215
|
});
|
|
3213
3216
|
|
|
@@ -3310,7 +3313,7 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3310
3313
|
|
|
3311
3314
|
it("the root's own copy still cannot be dragged, admin or not", () => {
|
|
3312
3315
|
renderExplorer({ fileTree: MISPLACED, isAdmin: true });
|
|
3313
|
-
expect(row('access
|
|
3316
|
+
expect(row('Who has access')).toHaveAttribute('draggable', 'false');
|
|
3314
3317
|
});
|
|
3315
3318
|
|
|
3316
3319
|
it('a non-admin gets no exception: the misplaced row is refused like any other', async () => {
|
|
@@ -3364,12 +3367,23 @@ describe('FileExplorer: platform files stay put', () => {
|
|
|
3364
3367
|
expect(rename).toHaveAttribute('title', sentence('access.md'));
|
|
3365
3368
|
});
|
|
3366
3369
|
|
|
3367
|
-
it('
|
|
3370
|
+
it('an access.md row reads Who has access, with the file name on hover', () => {
|
|
3371
|
+
renderExplorer({ fileTree: TREE });
|
|
3372
|
+
const access = row('Who has access');
|
|
3373
|
+
expect(access).toHaveAttribute('data-tree-path', `${KB}/access.md`);
|
|
3374
|
+
expect(access).toHaveAttribute('title', 'access.md');
|
|
3375
|
+
expect(screen.queryByText('access.md')).not.toBeInTheDocument();
|
|
3376
|
+
// Other platform files are not renamed for display.
|
|
3377
|
+
expect(row('roles.yaml')).not.toHaveAttribute('title');
|
|
3378
|
+
});
|
|
3379
|
+
|
|
3380
|
+
it('an AGENTS.md is content, not a platform file, at the root and nested: it drags like any other row', () => {
|
|
3368
3381
|
renderExplorer({ fileTree: TREE });
|
|
3369
|
-
// Both rows are named AGENTS.md; the nested one is the second.
|
|
3370
3382
|
const rows = screen.getAllByText('AGENTS.md').map((n) => n.closest('button')!);
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3383
|
+
for (const at of [`${KB}/AGENTS.md`, `${KB}/Handbook/AGENTS.md`]) {
|
|
3384
|
+
const row = rows.find((r) => r.getAttribute('data-tree-path') === at);
|
|
3385
|
+
expect(row, at).toHaveAttribute('draggable', 'true');
|
|
3386
|
+
}
|
|
3373
3387
|
});
|
|
3374
3388
|
});
|
|
3375
3389
|
|
|
@@ -4067,3 +4081,79 @@ describe("FileExplorer folder menu: a deployment's own entries", () => {
|
|
|
4067
4081
|
expect(screen.queryByRole('menu')).toBeNull();
|
|
4068
4082
|
});
|
|
4069
4083
|
});
|
|
4084
|
+
|
|
4085
|
+
// Delete follows its own rule, narrower than the move's: the root's
|
|
4086
|
+
// `access.md` and `roles.yaml` are the repository's own and deleted by nobody,
|
|
4087
|
+
// with the sentence the server refuses with; a nested `access.md` is deleted
|
|
4088
|
+
// like any file its caller may write — the server's write gate decides.
|
|
4089
|
+
describe('FileExplorer: deleting platform files', () => {
|
|
4090
|
+
const KB = 'knowledge-base';
|
|
4091
|
+
const sentence = (name: string) => `${name} is the repository's own file and cannot be deleted.`;
|
|
4092
|
+
const file = (p: string): FileTreeEntry => ({ name: p.slice(p.lastIndexOf('/') + 1), relativePath: p, type: 'file' });
|
|
4093
|
+
|
|
4094
|
+
const TREE: FileTreeEntry = rootedAtCheckout({
|
|
4095
|
+
name: '.',
|
|
4096
|
+
relativePath: '.',
|
|
4097
|
+
type: 'directory',
|
|
4098
|
+
children: [
|
|
4099
|
+
{
|
|
4100
|
+
name: KB,
|
|
4101
|
+
relativePath: KB,
|
|
4102
|
+
type: 'directory',
|
|
4103
|
+
children: [
|
|
4104
|
+
file(`${KB}/access.md`),
|
|
4105
|
+
file(`${KB}/roles.yaml`),
|
|
4106
|
+
{
|
|
4107
|
+
name: 'Team',
|
|
4108
|
+
relativePath: `${KB}/Team`,
|
|
4109
|
+
type: 'directory',
|
|
4110
|
+
children: [file(`${KB}/Team/access.md`), file(`${KB}/Team/roles.yaml`)],
|
|
4111
|
+
},
|
|
4112
|
+
],
|
|
4113
|
+
},
|
|
4114
|
+
],
|
|
4115
|
+
});
|
|
4116
|
+
|
|
4117
|
+
beforeEach(() => {
|
|
4118
|
+
cleanup();
|
|
4119
|
+
mockAuthFetch.mockReset();
|
|
4120
|
+
});
|
|
4121
|
+
|
|
4122
|
+
// The rows show the file's plain name (`access.md` reads "Who has access");
|
|
4123
|
+
// the sentence keeps the file's own.
|
|
4124
|
+
it.each([
|
|
4125
|
+
['access.md', 'Who has access'],
|
|
4126
|
+
['roles.yaml', 'roles.yaml'],
|
|
4127
|
+
])('the root %s shows Delete disabled with the sentence, for an admin too', async (name, label) => {
|
|
4128
|
+
const deleteEntry = vi.fn(async () => {});
|
|
4129
|
+
renderExplorer({ fileTree: TREE, deleteEntry, isAdmin: true });
|
|
4130
|
+
// The root's copy is the first row of that name.
|
|
4131
|
+
fireEvent.contextMenu(screen.getAllByText(label)[0].closest('button')!);
|
|
4132
|
+
const del = screen.getByRole('menuitem', { name: /Delete/i });
|
|
4133
|
+
expect(del).toHaveAttribute('aria-disabled', 'true');
|
|
4134
|
+
expect(del).toHaveAttribute('title', sentence(name));
|
|
4135
|
+
await act(async () => {
|
|
4136
|
+
fireEvent.click(del);
|
|
4137
|
+
});
|
|
4138
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
4139
|
+
expect(deleteEntry).not.toHaveBeenCalled();
|
|
4140
|
+
});
|
|
4141
|
+
|
|
4142
|
+
it('a nested access.md offers Delete, and deletes once confirmed', async () => {
|
|
4143
|
+
const deleteEntry = vi.fn(async () => {});
|
|
4144
|
+
renderExplorer({ fileTree: TREE, deleteEntry, isAdmin: true });
|
|
4145
|
+
const rows = screen.getAllByText('Who has access');
|
|
4146
|
+
expect(rows).toHaveLength(2);
|
|
4147
|
+
fireEvent.contextMenu(rows[1].closest('button')!);
|
|
4148
|
+
const del = screen.getByRole('menuitem', { name: /Delete/i });
|
|
4149
|
+
expect(del).not.toHaveAttribute('aria-disabled');
|
|
4150
|
+
expect(del).not.toHaveAttribute('title');
|
|
4151
|
+
await act(async () => {
|
|
4152
|
+
fireEvent.click(del);
|
|
4153
|
+
});
|
|
4154
|
+
await act(async () => {
|
|
4155
|
+
fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
|
|
4156
|
+
});
|
|
4157
|
+
expect(deleteEntry).toHaveBeenCalledWith(`${KB}/Team/access.md`);
|
|
4158
|
+
});
|
|
4159
|
+
});
|
|
@@ -101,7 +101,12 @@ function makeHydrateResult(overrides: Partial<HydrateResult> = {}): HydrateResul
|
|
|
101
101
|
|
|
102
102
|
function LocationProbe() {
|
|
103
103
|
const location = useLocation();
|
|
104
|
-
return
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<div aria-label="pathname">{location.pathname}</div>
|
|
107
|
+
<div aria-label="location-state">{JSON.stringify(location.state)}</div>
|
|
108
|
+
</>
|
|
109
|
+
);
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
/** Stands in for a file-tree click: navigates to a clean file URL. */
|
|
@@ -133,7 +138,13 @@ function SameBranchClickProbe() {
|
|
|
133
138
|
|
|
134
139
|
function renderAt(
|
|
135
140
|
url: string,
|
|
136
|
-
opts: {
|
|
141
|
+
opts: {
|
|
142
|
+
git?: GitContextValue;
|
|
143
|
+
workspace?: WorkspaceContextValue;
|
|
144
|
+
canonicalize?: boolean;
|
|
145
|
+
/** Router state on the first entry, as a navigation would have left it. */
|
|
146
|
+
state?: unknown;
|
|
147
|
+
} = {},
|
|
137
148
|
): {
|
|
138
149
|
workspace: WorkspaceContextValue;
|
|
139
150
|
git: GitContextValue;
|
|
@@ -192,7 +203,7 @@ function renderAt(
|
|
|
192
203
|
}
|
|
193
204
|
|
|
194
205
|
const tree = () => (
|
|
195
|
-
<MemoryRouter initialEntries={[url]}>
|
|
206
|
+
<MemoryRouter initialEntries={[opts.state === undefined ? url : { pathname: url, state: opts.state }]}>
|
|
196
207
|
<Tree>
|
|
197
208
|
<Routes>
|
|
198
209
|
<Route path="/workspace/:branch/*" element={<FileRoute canonicalize={opts.canonicalize} />} />
|
|
@@ -247,6 +258,15 @@ describe('FileRoute: the canonical id URL', () => {
|
|
|
247
258
|
);
|
|
248
259
|
});
|
|
249
260
|
|
|
261
|
+
it('keeps the entry’s router state across the swap, so a request not yet acted on survives it', async () => {
|
|
262
|
+
routesMock.fetchNodeId.mockResolvedValue('web_search');
|
|
263
|
+
renderAt(`/workspace/main/${PATH}`, { ...openOn(), state: { rawFile: true } });
|
|
264
|
+
await waitFor(() =>
|
|
265
|
+
expect(screen.getByLabelText('pathname')).toHaveTextContent('/workspace/main/web_search'),
|
|
266
|
+
);
|
|
267
|
+
expect(screen.getByLabelText('location-state')).toHaveTextContent('{"rawFile":true}');
|
|
268
|
+
});
|
|
269
|
+
|
|
250
270
|
it('keeps the path URL when canonicalising is off — the Library frame renders it there, and an id URL is no library location', async () => {
|
|
251
271
|
routesMock.fetchNodeId.mockResolvedValue('web_search');
|
|
252
272
|
renderAt(`/workspace/main/${PATH}`, { ...openOn(), canonicalize: false });
|