@bevel-software/platform-core-frontend 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/core/CoreAppShell.tsx +18 -17
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/bootstrap.ts +30 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/utils.ts +2 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +111 -1
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/api.ts +52 -4
- package/src/modules/access/components/ManageAccessDialog.tsx +112 -83
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/layout/components/SidebarFrame.tsx +1 -1
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +1 -1
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +1 -1
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +121 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +6 -0
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +5 -4
- package/src/modules/library/__tests__/PluginExtras.test.tsx +15 -0
- package/src/modules/library/__tests__/PluginPage.test.tsx +195 -1
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +1 -1
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +64 -3
- package/src/modules/library/__tests__/SkillPage.test.tsx +9 -2
- package/src/modules/library/__tests__/SkillsTree.test.tsx +172 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +7 -0
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +115 -4
- package/src/modules/library/__tests__/library-data.stale.test.tsx +90 -0
- package/src/modules/library/__tests__/library-paths.test.ts +32 -0
- package/src/modules/library/__tests__/link-membership.test.ts +120 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +32 -0
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +33 -0
- package/src/modules/library/components/LibraryCard.tsx +14 -0
- package/src/modules/library/components/LibraryLayout.tsx +24 -14
- package/src/modules/library/components/LinkSkillPanel.tsx +171 -0
- package/src/modules/library/components/LockedPluginView.tsx +2 -2
- package/src/modules/library/components/NewPluginDialog.tsx +4 -4
- package/src/modules/library/components/PageActions.tsx +21 -1
- package/src/modules/library/components/PersonalPluginPage.tsx +2 -1
- package/src/modules/library/components/PluginExtras.tsx +3 -1
- package/src/modules/library/components/PluginPage.tsx +92 -12
- package/src/modules/library/components/PluginsIndexPage.tsx +11 -6
- package/src/modules/library/components/PluginsSidebar.tsx +110 -53
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/SkillsTree.tsx +91 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/plugin-page-parts.tsx +32 -9
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +218 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +70 -6
- package/src/modules/library/components/tool-page/ToolPage.tsx +11 -2
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +180 -83
- package/src/modules/library/routes/library-paths.ts +21 -8
- package/src/modules/library/services/library.api.ts +55 -1
- package/src/modules/library/services/plugins.api.ts +94 -3
- package/src/modules/library/state/library-data.tsx +115 -22
- package/src/modules/library/utils/plugin-summary.ts +36 -0
- package/src/modules/library/utils/status.ts +74 -7
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +3 -2
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +169 -0
- package/src/modules/settings/components/DeploymentPage.tsx +15 -1
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +10 -0
- package/src/modules/settings/services/github-facade.api.ts +43 -0
- package/src/modules/setup/__tests__/setup.test.tsx +118 -0
- package/src/modules/setup/components/SetupGate.tsx +1 -1
- package/src/modules/setup/components/SetupScreen.tsx +195 -2
- package/src/modules/setup/services/setup.api.ts +78 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +295 -83
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +129 -6
- package/src/modules/toolbar/services/external-api-keys.api.ts +2 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +1 -0
- package/src/modules/workspace/components/FileExplorer.tsx +292 -236
- package/src/modules/workspace/components/FileRoute.tsx +37 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +1 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +70 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +17 -3
- package/src/modules/workspace/routing/kb-routes.ts +1 -1
- package/src/modules/workspace/state/workspace.context.ts +8 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +15 -0
- package/src/modules/workspace/utils/fileTree.ts +14 -16
- package/src/shared/__tests__/marketplace-url.test.ts +54 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/marketplace-url.ts +90 -0
- package/src/shared/theme/tokens.css +9 -0
|
@@ -56,10 +56,11 @@ function renderDialog(existing: string[] = ['GTM', 'Finance']) {
|
|
|
56
56
|
describe('NewPluginDialog', () => {
|
|
57
57
|
beforeEach(() => {
|
|
58
58
|
pluginsMock.createPlugin.mockReset();
|
|
59
|
-
// A folder
|
|
60
|
-
// with the typed name
|
|
59
|
+
// A folder AND an identity that both DIFFER from the input, so a dialog
|
|
60
|
+
// that navigates with the typed name — or with the folder — fails here.
|
|
61
61
|
pluginsMock.createPlugin.mockImplementation(async (name: string) => ({
|
|
62
62
|
folder: `${name}-canonical`,
|
|
63
|
+
name: `${name.toLowerCase()}-id`,
|
|
63
64
|
}));
|
|
64
65
|
});
|
|
65
66
|
|
|
@@ -75,8 +76,8 @@ describe('NewPluginDialog', () => {
|
|
|
75
76
|
|
|
76
77
|
// Trimmed — the endpoint owns everything after the name.
|
|
77
78
|
await waitFor(() => expect(pluginsMock.createPlugin).toHaveBeenCalledWith('Design'));
|
|
78
|
-
// The route is built from the SERVER's
|
|
79
|
-
await waitFor(() => expect(pathname()).toBe('/skills-and-tools/plugins/
|
|
79
|
+
// The route is built from the SERVER's identity — not the typed name, not the folder.
|
|
80
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools/plugins/design-id'));
|
|
80
81
|
expect(onCreated).toHaveBeenCalledTimes(1);
|
|
81
82
|
});
|
|
82
83
|
|
|
@@ -91,6 +91,21 @@ describe('ClientExtensionsSection', () => {
|
|
|
91
91
|
expect(screen.getByRole('button', { name: 'hooks/on-save.js' })).toBeInTheDocument();
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
+
it('finds the namespace dirs of a plugin nested below the root — the folder is a path, walked a segment at a time', async () => {
|
|
95
|
+
const nested: FileTreeEntry = dir('root', [
|
|
96
|
+
dir('knowledge-base', [
|
|
97
|
+
dir('Plugins', [dir('teams', [dir('deep', [dir('com.example.client', [dir('hooks', [file('on-open.js')])])])])]),
|
|
98
|
+
]),
|
|
99
|
+
]);
|
|
100
|
+
renderSection({ workspaceId: encodeURIComponent(DEFAULT_BRANCH), fileTree: nested }, 'teams/deep');
|
|
101
|
+
expect(await screen.findByText('com.example.client/')).toBeInTheDocument();
|
|
102
|
+
fireEvent.click(screen.getByRole('button', { name: 'hooks/on-open.js' }));
|
|
103
|
+
expect(navigateMock).toHaveBeenCalledWith(
|
|
104
|
+
expect.stringContaining('/knowledge-base/Plugins/teams/deep/com.example.client/hooks/on-open.js'),
|
|
105
|
+
expect.anything(),
|
|
106
|
+
);
|
|
107
|
+
});
|
|
108
|
+
|
|
94
109
|
/**
|
|
95
110
|
* `rawFile` steps past the app gate into the Knowledge editor — right for
|
|
96
111
|
* opaque client data, wrong for a `.tool`, which has a first-class tool
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
2
|
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
3
|
-
import { render, screen, act, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import { render, screen, act, fireEvent, waitFor, within } from '@testing-library/react';
|
|
4
4
|
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
5
5
|
import type { ReactNode } from 'react';
|
|
6
6
|
import {
|
|
@@ -28,6 +28,8 @@ const pluginsMock = vi.hoisted(() => ({
|
|
|
28
28
|
listJoinRequests: vi.fn(),
|
|
29
29
|
reconcileJoinRequest: vi.fn(),
|
|
30
30
|
requestPluginAccess: vi.fn(),
|
|
31
|
+
unlinkSkill: vi.fn(),
|
|
32
|
+
renamePlugin: vi.fn(),
|
|
31
33
|
}));
|
|
32
34
|
const libApiMock = vi.hoisted(() => ({ removeLibraryItem: vi.fn() }));
|
|
33
35
|
vi.mock('../services/library.api', async (importOriginal) => ({
|
|
@@ -40,6 +42,8 @@ vi.mock('../services/plugins.api', () => ({
|
|
|
40
42
|
listJoinRequests: pluginsMock.listJoinRequests,
|
|
41
43
|
reconcileJoinRequest: pluginsMock.reconcileJoinRequest,
|
|
42
44
|
requestPluginAccess: pluginsMock.requestPluginAccess,
|
|
45
|
+
unlinkSkill: pluginsMock.unlinkSkill,
|
|
46
|
+
renamePlugin: pluginsMock.renamePlugin,
|
|
43
47
|
AlreadyReadableError: class AlreadyReadableError extends Error {},
|
|
44
48
|
}));
|
|
45
49
|
|
|
@@ -193,6 +197,7 @@ describe('PluginPage', () => {
|
|
|
193
197
|
pluginsMock.listJoinRequests.mockResolvedValue([]);
|
|
194
198
|
pluginsMock.reconcileJoinRequest.mockResolvedValue(false);
|
|
195
199
|
pluginsMock.requestPluginAccess.mockResolvedValue(undefined);
|
|
200
|
+
pluginsMock.renamePlugin.mockReset();
|
|
196
201
|
});
|
|
197
202
|
|
|
198
203
|
it('lets a plugin MANAGER remove a skill, behind a confirm that says who loses it', async () => {
|
|
@@ -212,6 +217,54 @@ describe('PluginPage', () => {
|
|
|
212
217
|
expect(await screen.findByText(/Removed outreach from GTM/)).toBeInTheDocument();
|
|
213
218
|
});
|
|
214
219
|
|
|
220
|
+
it('removing a LINKED skill unlinks it — the skill stays where it lives', async () => {
|
|
221
|
+
dataMock.useLibraryData.mockReturnValue({
|
|
222
|
+
...CATALOG,
|
|
223
|
+
skills: [
|
|
224
|
+
...CATALOG.skills,
|
|
225
|
+
{
|
|
226
|
+
name: 'deploy',
|
|
227
|
+
description: 'Ships it.',
|
|
228
|
+
path: 'Skills/Eng/deploy',
|
|
229
|
+
plugins: [{ name: 'GTM', linked: true, granted: true }],
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
});
|
|
233
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ canWrite: true })]);
|
|
234
|
+
pluginsMock.unlinkSkill.mockResolvedValue({ root: 'Skills/Eng/deploy', revoked: true });
|
|
235
|
+
libApiMock.removeLibraryItem.mockClear();
|
|
236
|
+
renderPlugin('GTM');
|
|
237
|
+
|
|
238
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Remove deploy' }));
|
|
239
|
+
expect(await screen.findByText(/removes the link from GTM/)).toBeInTheDocument();
|
|
240
|
+
fireEvent.click(screen.getByRole('button', { name: 'Unlink' }));
|
|
241
|
+
|
|
242
|
+
await waitFor(() => expect(pluginsMock.unlinkSkill).toHaveBeenCalledWith('GTM', 'Skills/Eng/deploy'));
|
|
243
|
+
// Never the delete path: the shared skill is not this plugin's to delete.
|
|
244
|
+
expect(libApiMock.removeLibraryItem).not.toHaveBeenCalled();
|
|
245
|
+
expect(await screen.findByText(/Unlinked deploy from GTM/)).toBeInTheDocument();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('offers no remove for a LINK into a plugin whose links live in an external format', async () => {
|
|
249
|
+
dataMock.useLibraryData.mockReturnValue({
|
|
250
|
+
...CATALOG,
|
|
251
|
+
skills: [
|
|
252
|
+
...CATALOG.skills,
|
|
253
|
+
{
|
|
254
|
+
name: 'deploy',
|
|
255
|
+
description: 'Ships it.',
|
|
256
|
+
path: 'Skills/Eng/deploy',
|
|
257
|
+
plugins: [{ name: 'GTM', linked: true, granted: true }],
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
});
|
|
261
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ canWrite: true, linksAreManaged: false })]);
|
|
262
|
+
renderPlugin('GTM');
|
|
263
|
+
// The inline skill can still be removed; the link cannot be undone here.
|
|
264
|
+
await screen.findByRole('button', { name: 'Remove outreach' });
|
|
265
|
+
expect(screen.queryByRole('button', { name: 'Remove deploy' })).toBeNull();
|
|
266
|
+
});
|
|
267
|
+
|
|
215
268
|
it('offers no remove affordance to a non-manager', async () => {
|
|
216
269
|
renderPlugin('GTM'); // gtm() defaults to canWrite: false
|
|
217
270
|
await screen.findByText('outreach');
|
|
@@ -229,6 +282,109 @@ describe('PluginPage', () => {
|
|
|
229
282
|
expect(screen.getByRole('heading', { name: 'Tools' })).toBeInTheDocument();
|
|
230
283
|
});
|
|
231
284
|
|
|
285
|
+
it('is titled by the display name with the folder beneath it, and found by its identity', async () => {
|
|
286
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', displayName: 'Go To Market' })]);
|
|
287
|
+
renderPlugin('gtm');
|
|
288
|
+
expect(await screen.findByRole('heading', { name: 'Go To Market', level: 1 })).toBeInTheDocument();
|
|
289
|
+
expect(screen.getByText('Plugins/GTM')).toBeInTheDocument();
|
|
290
|
+
// The folder's skill files under the identity, not under the folder name.
|
|
291
|
+
expect(screen.getByTestId('library-card-skill-outreach')).toBeInTheDocument();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('offers Rename plugin to a MANAGER, and moves to the new identity once the rename lands', async () => {
|
|
295
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', displayName: 'GTM', canWrite: true })]);
|
|
296
|
+
pluginsMock.renamePlugin.mockResolvedValue({ name: 'go-to-market', displayName: 'GTM', rewritten: [] });
|
|
297
|
+
renderPlugin('gtm');
|
|
298
|
+
|
|
299
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
300
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename plugin' }));
|
|
301
|
+
const dialog = await screen.findByRole('dialog', { name: 'Rename GTM' });
|
|
302
|
+
fireEvent.change(within(dialog).getByLabelText('Identifier'), { target: { value: 'go-to-market' } });
|
|
303
|
+
// Changing the identifier is a rename of a principal — the dialog says so before the click.
|
|
304
|
+
expect(within(dialog).getByText(/Every grant of/)).toBeInTheDocument();
|
|
305
|
+
fireEvent.click(within(dialog).getByRole('button', { name: 'Rename' }));
|
|
306
|
+
|
|
307
|
+
await waitFor(() =>
|
|
308
|
+
expect(pluginsMock.renamePlugin).toHaveBeenCalledWith('gtm', { name: 'go-to-market', displayName: 'GTM' }),
|
|
309
|
+
);
|
|
310
|
+
// The identity is the URL: the page moves to the plugin's new address.
|
|
311
|
+
await waitFor(() => expect(href()).toBe('/skills-and-tools/plugins/go-to-market'));
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('refuses an identifier that is not kebab-case before asking the server', async () => {
|
|
315
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', displayName: 'GTM', canWrite: true })]);
|
|
316
|
+
renderPlugin('gtm');
|
|
317
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
318
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename plugin' }));
|
|
319
|
+
const dialog = await screen.findByRole('dialog', { name: 'Rename GTM' });
|
|
320
|
+
fireEvent.change(within(dialog).getByLabelText('Identifier'), { target: { value: 'Go To Market' } });
|
|
321
|
+
expect(within(dialog).getByText(/Lowercase letters, digits and single hyphens/)).toBeInTheDocument();
|
|
322
|
+
expect(within(dialog).getByRole('button', { name: 'Rename' })).toBeDisabled();
|
|
323
|
+
expect(pluginsMock.renamePlugin).not.toHaveBeenCalled();
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('refuses the reserved personal prefix before asking the server', async () => {
|
|
327
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', displayName: 'GTM', canWrite: true })]);
|
|
328
|
+
renderPlugin('gtm');
|
|
329
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
330
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename plugin' }));
|
|
331
|
+
const dialog = await screen.findByRole('dialog', { name: 'Rename GTM' });
|
|
332
|
+
fireEvent.change(within(dialog).getByLabelText('Identifier'), { target: { value: 'personal-gtm' } });
|
|
333
|
+
expect(within(dialog).getByText(/reserved for personal folders/)).toBeInTheDocument();
|
|
334
|
+
expect(within(dialog).getByRole('button', { name: 'Rename' })).toBeDisabled();
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('refuses an identifier longer than the slug the marketplace keys on, before asking the server', async () => {
|
|
338
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', displayName: 'GTM', canWrite: true })]);
|
|
339
|
+
renderPlugin('gtm');
|
|
340
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
341
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename plugin' }));
|
|
342
|
+
const dialog = await screen.findByRole('dialog', { name: 'Rename GTM' });
|
|
343
|
+
fireEvent.change(within(dialog).getByLabelText('Identifier'), { target: { value: `${'a'.repeat(60)}-${'b'.repeat(10)}` } });
|
|
344
|
+
expect(within(dialog).getByText(/at most 64 characters/)).toBeInTheDocument();
|
|
345
|
+
expect(within(dialog).getByRole('button', { name: 'Rename' })).toBeDisabled();
|
|
346
|
+
expect(pluginsMock.renamePlugin).not.toHaveBeenCalled();
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('lets a plugin whose identifier already wears the reserved prefix change its display name', async () => {
|
|
350
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'personal-legacy', displayName: 'Legacy', canWrite: true })]);
|
|
351
|
+
pluginsMock.renamePlugin.mockResolvedValue({ name: 'personal-legacy', displayName: 'Legacy Team', rewritten: [] });
|
|
352
|
+
renderPlugin('personal-legacy');
|
|
353
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
354
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Rename plugin' }));
|
|
355
|
+
const dialog = await screen.findByRole('dialog', { name: 'Rename Legacy' });
|
|
356
|
+
fireEvent.change(within(dialog).getByLabelText('Display name'), { target: { value: 'Legacy Team' } });
|
|
357
|
+
expect(within(dialog).queryByText(/reserved for personal folders/)).toBeNull();
|
|
358
|
+
fireEvent.click(within(dialog).getByRole('button', { name: 'Rename' }));
|
|
359
|
+
await waitFor(() =>
|
|
360
|
+
expect(pluginsMock.renamePlugin).toHaveBeenCalledWith('personal-legacy', { displayName: 'Legacy Team' }),
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('offers no Rename plugin for a plugin read from an external format — its repository owns the name', async () => {
|
|
365
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', canWrite: true, linksAreManaged: false })]);
|
|
366
|
+
renderPlugin('gtm');
|
|
367
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
368
|
+
await screen.findByRole('menu');
|
|
369
|
+
expect(screen.queryByRole('menuitem', { name: 'Rename plugin' })).toBeNull();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it('opens the manifest at the plugin FOLDER, which is not its identity', async () => {
|
|
373
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'go-to-market', displayName: 'GTM', canWrite: true })]);
|
|
374
|
+
renderPlugin('go-to-market');
|
|
375
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Manifest' }));
|
|
376
|
+
await waitFor(() =>
|
|
377
|
+
expect(href()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/GTM/plugin.json`),
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it('shows no Rename plugin to a non-manager', async () => {
|
|
382
|
+
renderPlugin('GTM'); // gtm() defaults to canWrite: false
|
|
383
|
+
fireEvent.click(await screen.findByRole('button', { name: 'More actions' }));
|
|
384
|
+
await screen.findByRole('menu');
|
|
385
|
+
expect(screen.queryByRole('menuitem', { name: 'Rename plugin' })).toBeNull();
|
|
386
|
+
});
|
|
387
|
+
|
|
232
388
|
it('opens an mcp-declared tool card at its `?server=` URL, not the bare file URL', async () => {
|
|
233
389
|
// Several servers share one declaring mcp.json, so the bare file URL is
|
|
234
390
|
// ambiguous — navigating there bounced the click straight back to this
|
|
@@ -313,6 +469,44 @@ describe('PluginPage', () => {
|
|
|
313
469
|
await waitFor(() => expect(href()).toBe('/connect'));
|
|
314
470
|
});
|
|
315
471
|
|
|
472
|
+
it('names a linked skill the members cannot read, above the integrations banner', async () => {
|
|
473
|
+
dataMock.useLibraryData.mockReturnValue({
|
|
474
|
+
...CATALOG,
|
|
475
|
+
tools: [connectedTool(), unsetTool()],
|
|
476
|
+
skills: [
|
|
477
|
+
...CATALOG.skills,
|
|
478
|
+
{
|
|
479
|
+
name: 'deploy',
|
|
480
|
+
description: 'Ships it.',
|
|
481
|
+
path: 'Skills/Eng/deploy',
|
|
482
|
+
plugins: [{ name: 'GTM', linked: true, granted: false }],
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
});
|
|
486
|
+
renderPlugin('GTM');
|
|
487
|
+
const urgent = await screen.findByText(
|
|
488
|
+
/1 linked skill can't be read by GTM's members: its access rules no longer name them\. Repair the link from the skill page\./,
|
|
489
|
+
);
|
|
490
|
+
expect(urgent.closest('[role="status"]')).toHaveClass('bg-urgent-soft');
|
|
491
|
+
// The tools banner still counts only the tools: the broken link is not
|
|
492
|
+
// an integration to connect.
|
|
493
|
+
const tools = screen.getByText("1 integration needs setup: connect it to unblock this plugin's skills.");
|
|
494
|
+
expect(urgent.compareDocumentPosition(tools) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
it("warns about a broken link even when the caller cannot read that skill — the server's count wins", async () => {
|
|
498
|
+
// The manager the missing grant locks out: the skill is NOT in their
|
|
499
|
+
// catalog, so nothing in `items` could say a link is broken. The summary
|
|
500
|
+
// carries the index's own count.
|
|
501
|
+
dataMock.useLibraryData.mockReturnValue({ ...CATALOG, tools: [connectedTool()] });
|
|
502
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ canWrite: true, brokenLinks: 2 })]);
|
|
503
|
+
renderPlugin('GTM');
|
|
504
|
+
expect(
|
|
505
|
+
await screen.findByText(/2 linked skills can't be read by GTM's members: their access rules no longer name them\. Repair the links from the skill pages\./),
|
|
506
|
+
).toBeInTheDocument();
|
|
507
|
+
expect(screen.queryByText(/integrations? needs? setup/)).not.toBeInTheDocument();
|
|
508
|
+
});
|
|
509
|
+
|
|
316
510
|
it('pluralises the attention banner', async () => {
|
|
317
511
|
dataMock.useLibraryData.mockReturnValue({
|
|
318
512
|
...CATALOG,
|
|
@@ -42,7 +42,7 @@ function renderSidebar(over: Partial<PluginsSidebarProps> = {}) {
|
|
|
42
42
|
return { onContextMenu, onSelect };
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const nav = () => screen.getByRole('navigation', { name: 'Library
|
|
45
|
+
const nav = () => screen.getByRole('navigation', { name: 'Library navigation' });
|
|
46
46
|
const rightClick = (el: Element, at = { clientX: 120, clientY: 240 }) =>
|
|
47
47
|
fireEvent.contextMenu(el, at);
|
|
48
48
|
|
|
@@ -40,7 +40,7 @@ function renderSidebar(over: Partial<PluginsSidebarProps> = {}) {
|
|
|
40
40
|
return { onSelect };
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const nav = () => screen.getByRole('navigation', { name: 'Library
|
|
43
|
+
const nav = () => screen.getByRole('navigation', { name: 'Library navigation' });
|
|
44
44
|
|
|
45
45
|
describe('PluginsSidebar: locked plugins', () => {
|
|
46
46
|
it('names a locked row by its state, with no count in it', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, type Mock } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
|
2
|
+
import { render, screen, fireEvent, cleanup, within } from '@testing-library/react';
|
|
3
3
|
import { PluginsSidebar, type PluginsSidebarProps } from '../components/PluginsSidebar';
|
|
4
4
|
import type { LibraryFilter } from '../utils/status';
|
|
5
5
|
|
|
@@ -46,6 +46,41 @@ function renderSidebar(over: Partial<PluginsSidebarProps> = {}) {
|
|
|
46
46
|
const row = (name: RegExp | string) => screen.getByRole('button', { name });
|
|
47
47
|
|
|
48
48
|
describe('PluginsSidebar', () => {
|
|
49
|
+
it('shows a plugin by its label and navigates by its identity — locked rows too', () => {
|
|
50
|
+
const { onSelect } = renderSidebar({
|
|
51
|
+
plugins: [{ plugin: 'gtm', label: 'Go To Market', count: 3, attention: 0 }],
|
|
52
|
+
lockedPlugins: [{ name: 'finance', label: 'Finance' }],
|
|
53
|
+
});
|
|
54
|
+
fireEvent.click(row(/^Go To Market/));
|
|
55
|
+
expect(onSelect).toHaveBeenCalledWith({ kind: 'group', plugin: 'gtm' });
|
|
56
|
+
expect(screen.queryByRole('button', { name: /^gtm/ })).toBeNull();
|
|
57
|
+
|
|
58
|
+
fireEvent.click(row('Finance (locked)'));
|
|
59
|
+
expect(onSelect).toHaveBeenCalledWith({ kind: 'group', plugin: 'finance' });
|
|
60
|
+
expect(screen.queryByRole('button', { name: /^finance/ })).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('two plugins wearing one label are still two rows, each navigating to its own identity', () => {
|
|
64
|
+
// React tells on a list keyed by something two children share; the rows
|
|
65
|
+
// are keyed by what they ARE, so it has nothing to say.
|
|
66
|
+
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
67
|
+
try {
|
|
68
|
+
const { onSelect } = renderSidebar({
|
|
69
|
+
plugins: [
|
|
70
|
+
{ plugin: 'sales-eu', label: 'Sales', count: 1, attention: 0 },
|
|
71
|
+
{ plugin: 'sales-us', label: 'Sales', count: 2, attention: 0 },
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
const rows = screen.getAllByRole('button', { name: /^Sales/ });
|
|
75
|
+
expect(rows).toHaveLength(2);
|
|
76
|
+
fireEvent.click(rows[1]);
|
|
77
|
+
expect(onSelect).toHaveBeenLastCalledWith({ kind: 'group', plugin: 'sales-us' });
|
|
78
|
+
expect(consoleError).not.toHaveBeenCalled();
|
|
79
|
+
} finally {
|
|
80
|
+
consoleError.mockRestore();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
49
84
|
it('leads with All plugins. The Library opens there, so the nav starts there', () => {
|
|
50
85
|
const { onOpenPluginsIndex } = renderSidebar();
|
|
51
86
|
const rows = screen.getAllByRole('button');
|
|
@@ -67,9 +102,20 @@ describe('PluginsSidebar', () => {
|
|
|
67
102
|
expect(row(/^All plugins/)).toHaveAttribute('aria-current', 'false');
|
|
68
103
|
});
|
|
69
104
|
|
|
70
|
-
it('heads the plugin rows with what
|
|
105
|
+
it('heads the plugin rows with what they are: plugins', () => {
|
|
71
106
|
renderSidebar();
|
|
72
|
-
expect(screen.getByText('
|
|
107
|
+
expect(screen.getByText('Plugins')).toBeInTheDocument();
|
|
108
|
+
expect(screen.queryByText('Included in your MCP')).not.toBeInTheDocument();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('renders the Skills tree it is handed right under All plugins, before the lenses', () => {
|
|
112
|
+
renderSidebar({ skillsTree: <div data-testid="skills-tree">tree</div> });
|
|
113
|
+
const tree = screen.getByTestId('skills-tree');
|
|
114
|
+
const home = screen.getByRole('button', { name: 'All plugins' });
|
|
115
|
+
const library = screen.getByText('Library');
|
|
116
|
+
// Document order: All plugins → the tree → the Library heading.
|
|
117
|
+
expect(home.compareDocumentPosition(tree) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
118
|
+
expect(tree.compareDocumentPosition(library) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
73
119
|
});
|
|
74
120
|
|
|
75
121
|
it("leads the plugins with the caller's own space", () => {
|
|
@@ -122,11 +168,26 @@ describe('PluginsSidebar', () => {
|
|
|
122
168
|
renderSidebar();
|
|
123
169
|
// GTM: 3 items but 2 integrations need setup — amber wins the slot.
|
|
124
170
|
expect(row(/^GTM/)).toHaveAccessibleName('GTM 2');
|
|
171
|
+
expect(within(row(/^GTM/)).getByText('2')).toHaveClass('text-wait');
|
|
125
172
|
expect(row(/^Engineering/)).toHaveAccessibleName('Engineering 4');
|
|
126
173
|
// Never a grey 0: an empty plugin shows no count at all.
|
|
127
174
|
expect(row(/^Product/)).toHaveAccessibleName('Product');
|
|
128
175
|
});
|
|
129
176
|
|
|
177
|
+
it('turns the count orange when members are locked out of a linked skill', () => {
|
|
178
|
+
renderSidebar({
|
|
179
|
+
plugins: [
|
|
180
|
+
{ plugin: 'GTM', count: 3, attention: 2, urgent: true },
|
|
181
|
+
{ plugin: 'Ops', count: 3, attention: 1, urgent: false },
|
|
182
|
+
],
|
|
183
|
+
});
|
|
184
|
+
// Blocking other people outranks a tool the reader has not set up.
|
|
185
|
+
const gtm = within(row(/^GTM/)).getByText('2');
|
|
186
|
+
expect(gtm).toHaveClass('text-urgent');
|
|
187
|
+
expect(gtm).not.toHaveClass('text-wait');
|
|
188
|
+
expect(within(row(/^Ops/)).getByText('1')).toHaveClass('text-wait');
|
|
189
|
+
});
|
|
190
|
+
|
|
130
191
|
it('emits the right LibraryFilter per row', () => {
|
|
131
192
|
const { onSelect } = renderSidebar();
|
|
132
193
|
const expected: [RegExp, LibraryFilter][] = [
|
|
@@ -33,6 +33,10 @@ vi.mock('../services/library.api', () => ({
|
|
|
33
33
|
getSkillFile: apiMock.getSkillFile,
|
|
34
34
|
proposeChange: apiMock.proposeChange,
|
|
35
35
|
listSkills: vi.fn(),
|
|
36
|
+
// The write-access request surface: nothing pending, nothing asked.
|
|
37
|
+
listSkillAccessRequests: vi.fn(async () => []),
|
|
38
|
+
reconcileSkillAccessRequest: vi.fn(async () => false),
|
|
39
|
+
requestSkillAccess: vi.fn(async () => ({ number: 1 })),
|
|
36
40
|
// Real behaviour, not a stub: the page resolves the caller's own request by
|
|
37
41
|
// this branch name, so a `vi.fn()` returning undefined would quietly disable
|
|
38
42
|
// the very lookup these tests are checking.
|
|
@@ -368,7 +372,9 @@ describe('SkillPage', () => {
|
|
|
368
372
|
expect(apiMock.getSkill).toHaveBeenCalledWith('newsletter');
|
|
369
373
|
|
|
370
374
|
// Needed integration derived from allowed-tools, with its connection state.
|
|
371
|
-
|
|
375
|
+
// Its own load, not the heading's: awaited, or a slow runner sees the
|
|
376
|
+
// heading before the integrations have resolved.
|
|
377
|
+
expect(await screen.findByText('slack')).toBeInTheDocument();
|
|
372
378
|
expect(screen.getByText('Needs your sign-in')).toBeInTheDocument();
|
|
373
379
|
expect(screen.getByRole('button', { name: /Connect/ })).toBeInTheDocument();
|
|
374
380
|
|
|
@@ -1306,7 +1312,8 @@ describe('SkillPage: deciding on a change', () => {
|
|
|
1306
1312
|
expect(screen.getByRole('menuitem', { name: 'Version history' })).toBeInTheDocument();
|
|
1307
1313
|
|
|
1308
1314
|
// Reached by keyboard, so no outside pointerdown ever dismissed the menu.
|
|
1309
|
-
|
|
1315
|
+
// Edit appears once the access verdict lands — its own load, awaited.
|
|
1316
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
|
|
1310
1317
|
await screen.findByRole('textbox', { name: /Edit SKILL\.md/ });
|
|
1311
1318
|
fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
|
|
1312
1319
|
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, within } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
4
|
+
import { DEFAULT_BRANCH, type FileTreeEntry } from '@bevel-software/platform-shared';
|
|
5
|
+
import { WorkspaceContext, type WorkspaceContextValue } from '../../workspace/state/workspace.context';
|
|
6
|
+
import { makeWorkspaceFixture } from '../../workspace/__tests__/testFixtures';
|
|
7
|
+
import { SkillsTree } from '../components/SkillsTree';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The Skills section of the Library nav: the shared root as Knowledge's tree
|
|
11
|
+
* rows, the root itself a collapsible folder row like Knowledge and Data in
|
|
12
|
+
* the explorer, with the two things that differ from Knowledge — where a
|
|
13
|
+
* click goes (the skill page, on the default branch) and which row is
|
|
14
|
+
* current (the file the URL names).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const KB = 'knowledge-base';
|
|
18
|
+
|
|
19
|
+
const file = (rel: string): FileTreeEntry => ({ name: rel.split('/').pop()!, relativePath: rel, type: 'file' });
|
|
20
|
+
const dir = (rel: string, children: FileTreeEntry[]): FileTreeEntry => ({
|
|
21
|
+
name: rel.split('/').pop()!,
|
|
22
|
+
relativePath: rel,
|
|
23
|
+
type: 'directory',
|
|
24
|
+
children,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const TREE: FileTreeEntry = dir('.', [
|
|
28
|
+
dir(KB, [
|
|
29
|
+
dir(`${KB}/KnowledgeBase`, [file(`${KB}/KnowledgeBase/Handbook.md`)]),
|
|
30
|
+
dir(`${KB}/Skills`, [
|
|
31
|
+
dir(`${KB}/Skills/Engineering`, [
|
|
32
|
+
dir(`${KB}/Skills/Engineering/deploy`, [file(`${KB}/Skills/Engineering/deploy/SKILL.md`)]),
|
|
33
|
+
]),
|
|
34
|
+
dir(`${KB}/Skills/Sales`, [
|
|
35
|
+
dir(`${KB}/Skills/Sales/discovery-call`, [
|
|
36
|
+
file(`${KB}/Skills/Sales/discovery-call/SKILL.md`),
|
|
37
|
+
file(`${KB}/Skills/Sales/discovery-call/checklist.md`),
|
|
38
|
+
]),
|
|
39
|
+
]),
|
|
40
|
+
]),
|
|
41
|
+
]),
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
function LocationProbe() {
|
|
45
|
+
const location = useLocation();
|
|
46
|
+
return <div aria-label="pathname">{location.pathname}</div>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function renderTree(url: string, over: Partial<WorkspaceContextValue> = {}) {
|
|
50
|
+
const workspace = makeWorkspaceFixture({ fileTree: TREE, kbDirName: KB, ...over });
|
|
51
|
+
const view = render(
|
|
52
|
+
<MemoryRouter initialEntries={[url]}>
|
|
53
|
+
<WorkspaceContext.Provider value={workspace}>
|
|
54
|
+
<SkillsTree />
|
|
55
|
+
<LocationProbe />
|
|
56
|
+
</WorkspaceContext.Provider>
|
|
57
|
+
</MemoryRouter>,
|
|
58
|
+
);
|
|
59
|
+
return { workspace, ...view };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const row = (name: string) => screen.getByRole('button', { name });
|
|
63
|
+
|
|
64
|
+
describe('SkillsTree', () => {
|
|
65
|
+
it('draws the root as a folder row, open with its scopes collapsed under it', () => {
|
|
66
|
+
renderTree('/skills-and-tools');
|
|
67
|
+
expect(row('Skills')).toHaveAttribute('aria-expanded', 'true');
|
|
68
|
+
// The scopes sit under the root, collapsed until opened.
|
|
69
|
+
expect(row('Engineering')).toBeInTheDocument();
|
|
70
|
+
expect(row('Sales')).toBeInTheDocument();
|
|
71
|
+
expect(screen.queryByText('deploy')).not.toBeInTheDocument();
|
|
72
|
+
expect(screen.queryByText('discovery-call')).not.toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('collapses and reopens like any folder — Knowledge and Data get the same row', () => {
|
|
76
|
+
renderTree('/skills-and-tools');
|
|
77
|
+
fireEvent.click(row('Skills'));
|
|
78
|
+
expect(row('Skills')).toHaveAttribute('aria-expanded', 'false');
|
|
79
|
+
expect(screen.queryByRole('button', { name: 'Engineering' })).not.toBeInTheDocument();
|
|
80
|
+
fireEvent.click(row('Skills'));
|
|
81
|
+
expect(row('Engineering')).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('reveals and marks the file the URL names — the Library never sets an open tab', () => {
|
|
85
|
+
renderTree(`/workspace/${DEFAULT_BRANCH}/${KB}/Skills/Sales/discovery-call/checklist.md`, {
|
|
86
|
+
openFilePath: null,
|
|
87
|
+
});
|
|
88
|
+
expect(row('checklist.md')).toHaveAttribute('aria-current', 'true');
|
|
89
|
+
expect(row('SKILL.md')).toHaveAttribute('aria-current', 'false');
|
|
90
|
+
// The other scope stays shut: only the named file's folders open.
|
|
91
|
+
expect(screen.queryByText('deploy')).not.toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('opens a clicked file on its skill page, on the default branch, whatever is checked out', () => {
|
|
95
|
+
renderTree('/skills-and-tools');
|
|
96
|
+
fireEvent.click(row('Sales'));
|
|
97
|
+
fireEvent.click(row('discovery-call'));
|
|
98
|
+
fireEvent.click(row('SKILL.md'));
|
|
99
|
+
expect(screen.getByLabelText('pathname')).toHaveTextContent(
|
|
100
|
+
`/workspace/${DEFAULT_BRANCH}/${KB}/Skills/Sales/discovery-call/SKILL.md`,
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('renders nothing when the tree has no Skills root — no folder over nothing', () => {
|
|
105
|
+
const noSkills = dir('.', [dir(KB, [dir(`${KB}/KnowledgeBase`, [])])]);
|
|
106
|
+
renderTree('/skills-and-tools', { fileTree: noSkills });
|
|
107
|
+
expect(screen.queryByText('Skills')).not.toBeInTheDocument();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('takes a drop on the root row, uploading into Skills/', () => {
|
|
111
|
+
const dispatchUpload = vi.fn().mockResolvedValue(undefined);
|
|
112
|
+
renderTree('/skills-and-tools', { dispatchUpload });
|
|
113
|
+
const dropped = new File(['x'], 'notes.md');
|
|
114
|
+
fireEvent.drop(row('Skills'), {
|
|
115
|
+
dataTransfer: { getData: () => '', items: undefined, files: [dropped] },
|
|
116
|
+
});
|
|
117
|
+
expect(dispatchUpload).toHaveBeenCalledWith({ kind: 'files', files: [dropped] }, `${KB}/Skills`);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('cannot be dragged away — a reserved root stays where the platform put it', () => {
|
|
121
|
+
renderTree('/skills-and-tools');
|
|
122
|
+
expect(row('Skills').closest('[draggable]')).toHaveAttribute('draggable', 'false');
|
|
123
|
+
expect(row('Engineering').closest('[draggable]')).toHaveAttribute('draggable', 'true');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("opens the folder's menu on the root row, minus what a reserved root must not do", () => {
|
|
127
|
+
renderTree('/skills-and-tools');
|
|
128
|
+
fireEvent.contextMenu(row('Skills'));
|
|
129
|
+
const menu = screen.getByRole('menu', { name: 'Actions for Skills' });
|
|
130
|
+
expect(within(menu).getByRole('menuitem', { name: /New folder/ })).toBeInTheDocument();
|
|
131
|
+
expect(within(menu).getByRole('menuitem', { name: /Manage access/ })).toBeInTheDocument();
|
|
132
|
+
expect(within(menu).queryByRole('menuitem', { name: /Rename/ })).not.toBeInTheDocument();
|
|
133
|
+
expect(within(menu).queryByRole('menuitem', { name: /Delete/ })).not.toBeInTheDocument();
|
|
134
|
+
expect(within(menu).queryByRole('menuitem', { name: /Pin/ })).not.toBeInTheDocument();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('hands focus back to the root row when its menu closes on Escape', () => {
|
|
138
|
+
renderTree('/skills-and-tools');
|
|
139
|
+
fireEvent.contextMenu(row('Skills'));
|
|
140
|
+
screen.getByRole('menu', { name: 'Actions for Skills' });
|
|
141
|
+
fireEvent.keyDown(document, { key: 'Escape' });
|
|
142
|
+
expect(screen.queryByRole('menu', { name: 'Actions for Skills' })).not.toBeInTheDocument();
|
|
143
|
+
expect(document.activeElement).toBe(row('Skills'));
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('keeps a right-click anywhere in the section from reaching the nav behind it', () => {
|
|
147
|
+
const onNav = vi.fn();
|
|
148
|
+
const workspace = makeWorkspaceFixture({ fileTree: TREE, kbDirName: KB });
|
|
149
|
+
render(
|
|
150
|
+
<MemoryRouter initialEntries={['/skills-and-tools']}>
|
|
151
|
+
<WorkspaceContext.Provider value={workspace}>
|
|
152
|
+
<div onContextMenu={onNav}>
|
|
153
|
+
<SkillsTree />
|
|
154
|
+
</div>
|
|
155
|
+
</WorkspaceContext.Provider>
|
|
156
|
+
</MemoryRouter>,
|
|
157
|
+
);
|
|
158
|
+
fireEvent.contextMenu(row('Skills'));
|
|
159
|
+
fireEvent.contextMenu(screen.getByTestId('skills-tree'));
|
|
160
|
+
expect(onNav).not.toHaveBeenCalled();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("the root row's New folder button creates a scope directly under the root", () => {
|
|
164
|
+
const createDirectory = vi.fn().mockResolvedValue(undefined);
|
|
165
|
+
renderTree('/skills-and-tools', { createDirectory });
|
|
166
|
+
fireEvent.click(screen.getByRole('button', { name: 'New folder in Skills' }));
|
|
167
|
+
const input = screen.getByPlaceholderText('folder name');
|
|
168
|
+
fireEvent.change(input, { target: { value: 'Marketing' } });
|
|
169
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
170
|
+
expect(createDirectory).toHaveBeenCalledWith(`${KB}/Skills/Marketing`);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -46,6 +46,13 @@ vi.mock('../services/library.api', () => ({
|
|
|
46
46
|
getSkill: libraryMock.getSkill,
|
|
47
47
|
}));
|
|
48
48
|
|
|
49
|
+
// The page resolves the tool's plugin through `useLibrary()`. With an empty
|
|
50
|
+
// catalog the folder name stands in as the label — which is what the frame
|
|
51
|
+
// tests assert on — and the provider's own fetches stay out of the picture.
|
|
52
|
+
vi.mock('../state/library-data', () => ({
|
|
53
|
+
useLibrary: () => ({ pluginSummaries: [] }),
|
|
54
|
+
}));
|
|
55
|
+
|
|
49
56
|
const sourceMock = vi.hoisted(() => ({ readFileOnBranch: vi.fn() }));
|
|
50
57
|
vi.mock('../../change-requests/services/change-requests.api', () => sourceMock);
|
|
51
58
|
|