@bevel-software/platform-core-frontend 0.7.5 → 0.9.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/LICENSE +202 -202
- package/THIRD-PARTY-NOTICES.md +344 -988
- package/package.json +5 -5
- package/src/core/CoreAppShell.tsx +4 -4
- package/src/core/__tests__/ShellRoutes.test.tsx +1 -1
- package/src/core/__tests__/bootstrap.test.ts +47 -2
- package/src/core/bootstrap.ts +20 -0
- package/src/core/registry.ts +16 -4
- package/src/css-side-effect-imports.d.ts +7 -7
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +1 -1
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +5 -5
- package/src/modules/access/api.ts +5 -5
- package/src/modules/access/components/ManageAccessDialog.tsx +21 -20
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/components/AdminRolesPage.tsx +1 -1
- package/src/modules/admin/state/admin.context.tsx +15 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +2 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +1 -1
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +1 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +4 -4
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +4 -4
- package/src/modules/layout/__tests__/breakpoints.test.ts +1 -1
- package/src/modules/layout/components/SidebarFrame.tsx +2 -2
- package/src/modules/library/__tests__/{AddToGroupDialog.test.tsx → AddToPluginDialog.test.tsx} +34 -34
- package/src/modules/library/__tests__/LibraryCard.test.tsx +30 -11
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +84 -59
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +51 -51
- package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx} +33 -33
- package/src/modules/library/__tests__/McpServerSection.test.tsx +138 -0
- package/src/modules/library/__tests__/{NewGroupDialog.test.tsx → NewPluginDialog.test.tsx} +22 -22
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +7 -7
- package/src/modules/library/__tests__/PluginExtras.test.tsx +131 -0
- package/src/modules/library/__tests__/{GroupJoinRequests.test.tsx → PluginJoinRequests.test.tsx} +24 -24
- package/src/modules/library/__tests__/{GroupPage.test.tsx → PluginPage.test.tsx} +197 -106
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +363 -0
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +32 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +29 -28
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +171 -0
- package/src/modules/library/__tests__/{GroupsSidebarMenu.test.tsx → PluginsSidebarMenu.test.tsx} +18 -18
- package/src/modules/library/__tests__/SkillPage.test.tsx +8 -8
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +2 -2
- package/src/modules/library/__tests__/ToolPage.test.tsx +41 -12
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +1 -1
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +57 -57
- package/src/modules/library/__tests__/auth-harness.tsx +4 -4
- package/src/modules/library/__tests__/library-data.test.ts +82 -0
- package/src/modules/library/__tests__/status.test.ts +19 -19
- package/src/modules/library/__tests__/tools.api.test.ts +70 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +4 -4
- package/src/modules/library/components/AccessRequestsBanner.tsx +8 -8
- package/src/modules/library/components/{AddToGroupDialog.tsx → AddToPluginDialog.tsx} +11 -11
- package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
- package/src/modules/library/components/{DeleteGroupDialog.tsx → DeletePluginDialog.tsx} +9 -9
- package/src/modules/library/components/LibraryCard.tsx +26 -2
- package/src/modules/library/components/LibraryLayout.tsx +80 -71
- package/src/modules/library/components/LibraryPage.tsx +8 -8
- package/src/modules/library/components/LockGlyph.tsx +1 -1
- package/src/modules/library/components/{LockedGroupView.tsx → LockedPluginView.tsx} +35 -35
- package/src/modules/library/components/{ManagedGroupRequests.tsx → ManagedPluginRequests.tsx} +13 -13
- package/src/modules/library/components/{NewGroupDialog.tsx → NewPluginDialog.tsx} +24 -24
- package/src/modules/library/components/NewSkillPanel.tsx +23 -5
- package/src/modules/library/components/PageActions.tsx +34 -11
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +29 -19
- package/src/modules/library/components/PluginExtras.tsx +195 -0
- package/src/modules/library/components/{GroupIndexRow.tsx → PluginIndexRow.tsx} +6 -6
- package/src/modules/library/components/PluginJoinRequests.tsx +77 -0
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +112 -72
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +91 -48
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +105 -55
- package/src/modules/library/components/{GroupsSidebarMenu.tsx → PluginsSidebarMenu.tsx} +15 -15
- package/src/modules/library/components/{group-page-parts.tsx → plugin-page-parts.tsx} +218 -27
- package/src/modules/library/components/skill-page/SkillPage.tsx +12 -12
- package/src/modules/library/components/tool-page/McpServerSection.tsx +380 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +22 -5
- package/src/modules/library/hooks/useJoinRequests.ts +8 -8
- package/src/modules/library/routes/LibraryRoutes.tsx +32 -19
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +24 -24
- package/src/modules/library/routes/library-paths.ts +36 -36
- package/src/modules/library/services/library.api.ts +9 -9
- package/src/modules/library/services/{groups.api.ts → plugins.api.ts} +43 -43
- package/src/modules/library/services/tools.api.ts +54 -0
- package/src/modules/library/state/library-data.tsx +67 -46
- package/src/modules/library/utils/names.ts +1 -1
- package/src/modules/library/utils/{personal-group.ts → personal-plugin.ts} +8 -8
- package/src/modules/library/utils/{group-summary.ts → plugin-summary.ts} +14 -14
- package/src/modules/library/utils/status.ts +17 -17
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +318 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +143 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +30 -22
- package/src/modules/onboarding/components/WelcomeRoute.tsx +57 -0
- package/src/modules/onboarding/welcome-state.ts +36 -0
- package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -1
- package/src/modules/review/components/ReviewPanel.tsx +11 -11
- package/src/modules/review/components/__tests__/{isGroupItemPath.test.ts → isPluginItemPath.test.ts} +24 -24
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +3 -3
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +1 -1
- package/src/modules/settings/components/SettingsLayout.tsx +1 -1
- package/src/modules/settings/components/SettingsNav.tsx +5 -5
- package/src/modules/setup/__tests__/setup.test.tsx +203 -0
- package/src/modules/setup/components/SetupScreen.tsx +235 -68
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +29 -107
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +1 -1
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +228 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +3 -3
- package/src/modules/workspace/components/FileExplorer.tsx +12 -12
- package/src/modules/workspace/components/FileRoute.tsx +8 -1
- package/src/modules/workspace/components/FileViewer.tsx +95 -38
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +20 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +227 -18
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +25 -0
- package/src/modules/workspace/routing/kb-routes.ts +23 -1
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +54 -3
- package/src/shared/components/Surface.tsx +15 -0
- package/src/shared/mcp/ClaudeInstallLink.tsx +88 -0
- package/src/shared/mcp/ConnectionInstructions.tsx +51 -0
- package/src/shared/mcp/CopyBlock.tsx +42 -0
- package/src/shared/mcp/__tests__/ClaudeInstallLink.test.tsx +40 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +431 -0
- package/src/shared/mcp/__tests__/useCopyFeedback.test.ts +112 -0
- package/src/shared/mcp/connect-snippets.ts +353 -0
- package/src/shared/mcp/index.ts +28 -0
- package/src/shared/mcp/useCopyFeedback.ts +46 -0
- package/src/test-setup.ts +11 -0
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +0 -283
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +0 -142
- package/src/modules/library/components/GroupJoinRequests.tsx +0 -56
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { AdminContext } from '../../admin/state/admin.context';
|
|
11
11
|
import type { LibraryData } from '../hooks/useLibraryData';
|
|
12
12
|
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
13
|
-
import type {
|
|
13
|
+
import type { PluginSummary } from '../services/plugins.api';
|
|
14
14
|
import type { ToolPageState } from '../hooks/useToolPage';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -24,22 +24,22 @@ import type { ToolPageState } from '../hooks/useToolPage';
|
|
|
24
24
|
const dataMock = vi.hoisted(() => ({ useLibraryData: vi.fn() }));
|
|
25
25
|
vi.mock('../hooks/useLibraryData', () => ({ useLibraryData: dataMock.useLibraryData }));
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const pluginsMock = vi.hoisted(() => ({
|
|
28
|
+
listPlugins: vi.fn(),
|
|
29
29
|
listJoinRequests: vi.fn(),
|
|
30
30
|
}));
|
|
31
|
-
vi.mock('../services/
|
|
32
|
-
|
|
33
|
-
listJoinRequests:
|
|
31
|
+
vi.mock('../services/plugins.api', () => ({
|
|
32
|
+
listPlugins: pluginsMock.listPlugins,
|
|
33
|
+
listJoinRequests: pluginsMock.listJoinRequests,
|
|
34
34
|
reconcileJoinRequest: vi.fn(),
|
|
35
|
-
|
|
35
|
+
requestPluginAccess: vi.fn(),
|
|
36
36
|
AlreadyReadableError: class AlreadyReadableError extends Error {},
|
|
37
37
|
}));
|
|
38
38
|
|
|
39
39
|
const toolPageMock = vi.hoisted(() => ({ useToolPage: vi.fn() }));
|
|
40
40
|
vi.mock('../hooks/useToolPage', () => ({ useToolPage: toolPageMock.useToolPage }));
|
|
41
41
|
|
|
42
|
-
// ManageAccessDialog (reachable from the
|
|
42
|
+
// ManageAccessDialog (reachable from the plugin page's Share) fetches through
|
|
43
43
|
// this module. Nothing opens it in a routing test, but the stub keeps any
|
|
44
44
|
// accidental mount from waiting on a refused connection.
|
|
45
45
|
vi.mock('../../access/api', async (importOriginal) => {
|
|
@@ -67,7 +67,7 @@ import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
|
|
|
67
67
|
const tool = (over: Partial<ToolSecrets>): ToolSecrets => ({
|
|
68
68
|
slug: 'heyreach',
|
|
69
69
|
name: 'heyreach',
|
|
70
|
-
path: '
|
|
70
|
+
path: 'Plugins/GTM/heyreach.tool',
|
|
71
71
|
type: 'inline',
|
|
72
72
|
setup: null,
|
|
73
73
|
canWrite: false,
|
|
@@ -79,9 +79,9 @@ const CATALOG: LibraryData = {
|
|
|
79
79
|
loading: false,
|
|
80
80
|
error: null,
|
|
81
81
|
skills: [
|
|
82
|
-
{ name: 'outreach', description: 'Runs the GTM outreach.', path: '
|
|
83
|
-
{ name: 'roadmap', description: 'Keeps the roadmap.', path: '
|
|
84
|
-
{ name: 'scratch', description: 'A skill in no
|
|
82
|
+
{ name: 'outreach', description: 'Runs the GTM outreach.', path: 'Plugins/GTM/outreach' },
|
|
83
|
+
{ name: 'roadmap', description: 'Keeps the roadmap.', path: 'Plugins/Product/roadmap' },
|
|
84
|
+
{ name: 'scratch', description: 'A skill in no plugin.', path: 'Skills/scratch' },
|
|
85
85
|
],
|
|
86
86
|
pendingSkills: [],
|
|
87
87
|
tools: [
|
|
@@ -96,10 +96,10 @@ const CATALOG: LibraryData = {
|
|
|
96
96
|
reload: vi.fn(),
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
const
|
|
99
|
+
const PLUGINS: PluginSummary[] = [
|
|
100
100
|
{
|
|
101
101
|
name: 'GTM',
|
|
102
|
-
folders: ['
|
|
102
|
+
folders: ['Plugins/GTM'],
|
|
103
103
|
canRead: true,
|
|
104
104
|
canWrite: true,
|
|
105
105
|
isOwner: false,
|
|
@@ -135,7 +135,7 @@ function LocationProbe() {
|
|
|
135
135
|
/**
|
|
136
136
|
* The shell's providers, which the Library sits inside for real
|
|
137
137
|
* (`CoreAppShell` mounts both above every app surface). The tool page reads
|
|
138
|
-
* `isAdmin` and `kbDirName` from them; the locked-
|
|
138
|
+
* `isAdmin` and `kbDirName` from them; the locked-plugin and request surfaces
|
|
139
139
|
* read `kbDirName` to address `access.md`.
|
|
140
140
|
*/
|
|
141
141
|
function wrap(children: ReactNode) {
|
|
@@ -181,17 +181,17 @@ const pathname = () => screen.getByLabelText('pathname').textContent;
|
|
|
181
181
|
describe('LibraryRoutes', () => {
|
|
182
182
|
beforeEach(() => {
|
|
183
183
|
dataMock.useLibraryData.mockReturnValue(CATALOG);
|
|
184
|
-
|
|
184
|
+
pluginsMock.listPlugins.mockResolvedValue(PLUGINS);
|
|
185
185
|
toolPageMock.useToolPage.mockReturnValue(TOOL_PAGE_STATE);
|
|
186
|
-
|
|
186
|
+
pluginsMock.listJoinRequests.mockResolvedValue([]);
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
-
it('opens on the all-
|
|
189
|
+
it('opens on the all-plugins index at /skills-and-tools', async () => {
|
|
190
190
|
renderAt('/skills-and-tools');
|
|
191
191
|
expect(
|
|
192
|
-
await screen.findByRole('heading', { name: 'All
|
|
192
|
+
await screen.findByRole('heading', { name: 'All plugins', level: 1 }),
|
|
193
193
|
).toBeInTheDocument();
|
|
194
|
-
expect(screen.getByRole('button', { name: /^All
|
|
194
|
+
expect(screen.getByRole('button', { name: /^All plugins/ })).toHaveAttribute(
|
|
195
195
|
'aria-current',
|
|
196
196
|
'true',
|
|
197
197
|
);
|
|
@@ -222,7 +222,7 @@ describe('LibraryRoutes', () => {
|
|
|
222
222
|
expect(screen.getByRole('button', { name: /^Owned by me/ })).toHaveAttribute('aria-current', 'true');
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
it("/skills-and-tools/yours is the caller's own
|
|
225
|
+
it("/skills-and-tools/yours is the caller's own plugin, as a plugin page", async () => {
|
|
226
226
|
renderAt('/skills-and-tools/yours');
|
|
227
227
|
expect(
|
|
228
228
|
await screen.findByRole('heading', { name: TEST_PERSONAL_GROUP, level: 1 }),
|
|
@@ -231,21 +231,21 @@ describe('LibraryRoutes', () => {
|
|
|
231
231
|
'aria-current',
|
|
232
232
|
'true',
|
|
233
233
|
);
|
|
234
|
-
// The
|
|
234
|
+
// The plugin-page furniture, not a filtered gallery: sections and a trail.
|
|
235
235
|
expect(screen.getByRole('heading', { name: 'Skills', level: 2 })).toBeInTheDocument();
|
|
236
236
|
expect(screen.getByRole('heading', { name: 'Tools', level: 2 })).toBeInTheDocument();
|
|
237
237
|
expect(screen.getByRole('navigation', { name: 'Breadcrumb' })).toBeInTheDocument();
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
it('a
|
|
241
|
-
// Membership is what puts a
|
|
242
|
-
// the member rows from catalog items alone made a freshly created
|
|
240
|
+
it('a plugin you are in appears in the nav even when it is EMPTY', async () => {
|
|
241
|
+
// Membership is what puts a plugin in your MCP; content is not. Deriving
|
|
242
|
+
// the member rows from catalog items alone made a freshly created plugin
|
|
243
243
|
// vanish from the very list headed "Included in your MCP".
|
|
244
|
-
|
|
245
|
-
...
|
|
244
|
+
pluginsMock.listPlugins.mockResolvedValue([
|
|
245
|
+
...PLUGINS,
|
|
246
246
|
{
|
|
247
247
|
name: 'Fresh',
|
|
248
|
-
folders: ['
|
|
248
|
+
folders: ['Plugins/Fresh'],
|
|
249
249
|
canRead: true,
|
|
250
250
|
canWrite: true,
|
|
251
251
|
skillCount: 0,
|
|
@@ -258,32 +258,32 @@ describe('LibraryRoutes', () => {
|
|
|
258
258
|
},
|
|
259
259
|
]);
|
|
260
260
|
renderAt('/skills-and-tools');
|
|
261
|
-
const nav = await screen.findByRole('navigation', { name: 'Library
|
|
261
|
+
const nav = await screen.findByRole('navigation', { name: 'Library plugins' });
|
|
262
262
|
// In the member half, with a zero count — never below the gap as locked.
|
|
263
263
|
expect(await within(nav).findByRole('button', { name: /^Fresh/ })).toBeInTheDocument();
|
|
264
264
|
expect(within(nav).queryByRole('button', { name: 'Fresh (locked)' })).toBeNull();
|
|
265
265
|
});
|
|
266
266
|
|
|
267
|
-
it('a sidebar
|
|
267
|
+
it('a sidebar plugin click navigates to /skills-and-tools/plugins/<name>', async () => {
|
|
268
268
|
renderAt('/skills-and-tools');
|
|
269
269
|
fireEvent.click(await screen.findByRole('button', { name: /^GTM/ }));
|
|
270
|
-
await waitFor(() => expect(pathname()).toBe('/skills-and-tools/
|
|
271
|
-
// The
|
|
270
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools/plugins/GTM'));
|
|
271
|
+
// The plugin page itself lands in a later work package; the ROUTE resolves
|
|
272
272
|
// now, which is why the sidebar can already point at it.
|
|
273
273
|
expect(screen.getByRole('button', { name: /^GTM/ })).toHaveAttribute('aria-current', 'true');
|
|
274
|
-
expect(screen.queryByRole('heading', { name: 'All
|
|
274
|
+
expect(screen.queryByRole('heading', { name: 'All plugins', level: 1 })).not.toBeInTheDocument();
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
-
it('sends the old /
|
|
278
|
-
renderAt('/skills-and-tools/
|
|
277
|
+
it('sends the old /plugins index path home, where the index lives now', async () => {
|
|
278
|
+
renderAt('/skills-and-tools/plugins');
|
|
279
279
|
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
280
280
|
expect(
|
|
281
|
-
await screen.findByRole('heading', { name: 'All
|
|
281
|
+
await screen.findByRole('heading', { name: 'All plugins', level: 1 }),
|
|
282
282
|
).toBeInTheDocument();
|
|
283
283
|
});
|
|
284
284
|
|
|
285
|
-
it("a
|
|
286
|
-
renderAt('/skills-and-tools/
|
|
285
|
+
it("a plugin deep link renders that plugin's cards and no others", async () => {
|
|
286
|
+
renderAt('/skills-and-tools/plugins/GTM');
|
|
287
287
|
expect(await screen.findByRole('heading', { name: 'GTM', level: 1 })).toBeInTheDocument();
|
|
288
288
|
expect(screen.getByTestId('library-card-skill-outreach')).toBeInTheDocument();
|
|
289
289
|
expect(screen.getByTestId('library-card-integration-heyreach')).toBeInTheDocument();
|
|
@@ -293,50 +293,75 @@ describe('LibraryRoutes', () => {
|
|
|
293
293
|
// `/propose` was retired with the role fork it served. An unknown path under
|
|
294
294
|
// the Library falls back to the root, which is what this now asserts.
|
|
295
295
|
it('sends the retired propose path back home', async () => {
|
|
296
|
-
renderAt('/skills-and-tools/propose?
|
|
296
|
+
renderAt('/skills-and-tools/propose?plugin=GTM');
|
|
297
297
|
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
298
298
|
});
|
|
299
299
|
|
|
300
|
-
it("reaches the index from a
|
|
301
|
-
renderAt('/skills-and-tools/
|
|
302
|
-
fireEvent.click(await screen.findByRole('link', { name: 'All
|
|
300
|
+
it("reaches the index from a plugin page breadcrumb, at the root it lives at", async () => {
|
|
301
|
+
renderAt('/skills-and-tools/plugins/GTM');
|
|
302
|
+
fireEvent.click(await screen.findByRole('link', { name: 'All plugins' }));
|
|
303
303
|
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
304
304
|
expect(
|
|
305
|
-
await screen.findByRole('heading', { name: 'All
|
|
305
|
+
await screen.findByRole('heading', { name: 'All plugins', level: 1 }),
|
|
306
306
|
).toBeInTheDocument();
|
|
307
307
|
});
|
|
308
308
|
|
|
309
|
-
it('leads the sidebar with All
|
|
310
|
-
renderAt('/skills-and-tools/
|
|
311
|
-
const
|
|
312
|
-
expect(
|
|
313
|
-
fireEvent.click(
|
|
309
|
+
it('leads the sidebar with All plugins, from anywhere in the Library', async () => {
|
|
310
|
+
renderAt('/skills-and-tools/plugins/GTM');
|
|
311
|
+
const allPlugins = await screen.findByRole('button', { name: /^All plugins/ });
|
|
312
|
+
expect(allPlugins).toHaveAttribute('aria-current', 'false');
|
|
313
|
+
fireEvent.click(allPlugins);
|
|
314
314
|
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
315
|
-
expect(screen.getByRole('button', { name: /^All
|
|
315
|
+
expect(screen.getByRole('button', { name: /^All plugins/ })).toHaveAttribute(
|
|
316
316
|
'aria-current',
|
|
317
317
|
'true',
|
|
318
318
|
);
|
|
319
319
|
});
|
|
320
320
|
|
|
321
|
-
it('a
|
|
321
|
+
it('a plugin deep link with a URL-hostile name round-trips', async () => {
|
|
322
322
|
dataMock.useLibraryData.mockReturnValue({
|
|
323
323
|
...CATALOG,
|
|
324
|
-
skills: [{ name: 'pricing', description: '', path: '
|
|
324
|
+
skills: [{ name: 'pricing', description: '', path: 'Plugins/Sales & Ops/pricing' }],
|
|
325
325
|
tools: [],
|
|
326
326
|
});
|
|
327
|
-
renderAt(`/skills-and-tools/
|
|
327
|
+
renderAt(`/skills-and-tools/plugins/${encodeURIComponent('Sales & Ops')}`);
|
|
328
328
|
await waitFor(() =>
|
|
329
329
|
expect(screen.getByRole('button', { name: /^Sales & Ops/ })).toHaveAttribute('aria-current', 'true'),
|
|
330
330
|
);
|
|
331
331
|
});
|
|
332
332
|
|
|
333
|
+
it('redirects a legacy /groups/:plugin deep link to the plugin page', async () => {
|
|
334
|
+
// The pre-rename URL shape. Links to it exist in the wild; without the
|
|
335
|
+
// alias the `*` fallback would send them home instead of to the plugin.
|
|
336
|
+
renderAt('/skills-and-tools/groups/GTM');
|
|
337
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools/plugins/GTM'));
|
|
338
|
+
expect(await screen.findByRole('heading', { name: 'GTM', level: 1 })).toBeInTheDocument();
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('redirects a legacy /groups link with a URL-hostile name, encoding intact', async () => {
|
|
342
|
+
dataMock.useLibraryData.mockReturnValue({
|
|
343
|
+
...CATALOG,
|
|
344
|
+
skills: [{ name: 'pricing', description: '', path: 'Plugins/Sales & Ops/pricing' }],
|
|
345
|
+
tools: [],
|
|
346
|
+
});
|
|
347
|
+
renderAt(`/skills-and-tools/groups/${encodeURIComponent('Sales & Ops')}`);
|
|
348
|
+
await waitFor(() =>
|
|
349
|
+
expect(pathname()).toBe(`/skills-and-tools/plugins/${encodeURIComponent('Sales & Ops')}`),
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('sends the legacy /groups index home, like /plugins', async () => {
|
|
354
|
+
renderAt('/skills-and-tools/groups');
|
|
355
|
+
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
356
|
+
});
|
|
357
|
+
|
|
333
358
|
it('/skills-and-tools/tools/:slug redirects to the canonical workspace URL, hash intact', async () => {
|
|
334
359
|
// The legacy address is the OAuth callback's landing target, so the
|
|
335
360
|
// redirect must carry the `#…` outcome fragment to the canonical page.
|
|
336
361
|
renderAt('/skills-and-tools/tools/heyreach#authorized');
|
|
337
362
|
await waitFor(() =>
|
|
338
363
|
expect(pathname()).toBe(
|
|
339
|
-
`/workspace/${DEFAULT_BRANCH}/knowledge-base/
|
|
364
|
+
`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/GTM/heyreach.tool#authorized`,
|
|
340
365
|
),
|
|
341
366
|
);
|
|
342
367
|
});
|
|
@@ -345,7 +370,7 @@ describe('LibraryRoutes', () => {
|
|
|
345
370
|
renderAt('/skills-and-tools/skills/outreach');
|
|
346
371
|
await waitFor(() =>
|
|
347
372
|
expect(pathname()).toBe(
|
|
348
|
-
`/workspace/${DEFAULT_BRANCH}/knowledge-base/
|
|
373
|
+
`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/GTM/outreach/SKILL.md`,
|
|
349
374
|
),
|
|
350
375
|
);
|
|
351
376
|
});
|
|
@@ -355,7 +380,7 @@ describe('LibraryRoutes', () => {
|
|
|
355
380
|
fireEvent.click(await screen.findByRole('button', { name: /^heyreach/ }));
|
|
356
381
|
|
|
357
382
|
await waitFor(() =>
|
|
358
|
-
expect(pathname()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/
|
|
383
|
+
expect(pathname()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/GTM/heyreach.tool`),
|
|
359
384
|
);
|
|
360
385
|
expect(screen.queryByRole('dialog')).toBeNull();
|
|
361
386
|
});
|
|
@@ -364,15 +389,15 @@ describe('LibraryRoutes', () => {
|
|
|
364
389
|
renderAt('/skills-and-tools/nope');
|
|
365
390
|
await waitFor(() => expect(pathname()).toBe('/skills-and-tools'));
|
|
366
391
|
expect(
|
|
367
|
-
await screen.findByRole('heading', { name: 'All
|
|
392
|
+
await screen.findByRole('heading', { name: 'All plugins', level: 1 }),
|
|
368
393
|
).toBeInTheDocument();
|
|
369
394
|
});
|
|
370
395
|
|
|
371
|
-
it('renders the gallery even when the
|
|
372
|
-
|
|
396
|
+
it('renders the gallery even when the plugins endpoint fails', async () => {
|
|
397
|
+
pluginsMock.listPlugins.mockRejectedValue(new Error("Couldn't load plugins."));
|
|
373
398
|
renderAt('/skills-and-tools/everything');
|
|
374
399
|
expect(await screen.findByRole('heading', { name: 'Everything', level: 1 })).toBeInTheDocument();
|
|
375
|
-
// Sidebar
|
|
400
|
+
// Sidebar plugins are catalog-derived, so they survive the endpoint being down.
|
|
376
401
|
expect(screen.getByRole('button', { name: /^GTM/ })).toBeInTheDocument();
|
|
377
402
|
});
|
|
378
403
|
});
|
|
@@ -8,37 +8,37 @@ import {
|
|
|
8
8
|
} from '../../workspace/state/workspace.context';
|
|
9
9
|
import { AdminContext } from '../../admin/state/admin.context';
|
|
10
10
|
import type { LibraryData } from '../hooks/useLibraryData';
|
|
11
|
-
import type {
|
|
11
|
+
import type { PluginSummary } from '../services/plugins.api';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The Library nav's right-click menu, wired up for real.
|
|
15
15
|
*
|
|
16
|
-
* `
|
|
17
|
-
* `
|
|
16
|
+
* `PluginsSidebar.contextmenu` proves the nav REPORTS the gesture and
|
|
17
|
+
* `PluginsSidebarMenu` proves the panel behaves; neither can prove the thing
|
|
18
18
|
* that actually matters, which is that the layout hands each kind of row the
|
|
19
|
-
* verbs that are true of it. That decision needs the
|
|
19
|
+
* verbs that are true of it. That decision needs the plugin summaries and the
|
|
20
20
|
* workspace's KB dir, so it only exists once the whole surface is mounted —
|
|
21
21
|
* hence this file.
|
|
22
22
|
*
|
|
23
23
|
* Same seams as `LibraryRoutes.test.tsx`: the catalog is mocked at its hook and
|
|
24
|
-
* the
|
|
24
|
+
* the plugin index at its API, because what is under test is the menu, not the
|
|
25
25
|
* fetching.
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
const dataMock = vi.hoisted(() => ({ useLibraryData: vi.fn() }));
|
|
29
29
|
vi.mock('../hooks/useLibraryData', () => ({ useLibraryData: dataMock.useLibraryData }));
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const pluginsMock = vi.hoisted(() => ({
|
|
32
|
+
listPlugins: vi.fn(),
|
|
33
33
|
listJoinRequests: vi.fn(),
|
|
34
|
-
|
|
34
|
+
deletePlugin: vi.fn(),
|
|
35
35
|
}));
|
|
36
|
-
vi.mock('../services/
|
|
37
|
-
|
|
38
|
-
listJoinRequests:
|
|
39
|
-
|
|
36
|
+
vi.mock('../services/plugins.api', () => ({
|
|
37
|
+
listPlugins: pluginsMock.listPlugins,
|
|
38
|
+
listJoinRequests: pluginsMock.listJoinRequests,
|
|
39
|
+
deletePlugin: pluginsMock.deletePlugin,
|
|
40
40
|
reconcileJoinRequest: vi.fn(),
|
|
41
|
-
|
|
41
|
+
requestPluginAccess: vi.fn(),
|
|
42
42
|
AlreadyReadableError: class AlreadyReadableError extends Error {},
|
|
43
43
|
}));
|
|
44
44
|
|
|
@@ -70,8 +70,8 @@ const CATALOG: LibraryData = {
|
|
|
70
70
|
loading: false,
|
|
71
71
|
error: null,
|
|
72
72
|
skills: [
|
|
73
|
-
{ name: 'outreach', description: 'Runs the GTM outreach.', path: '
|
|
74
|
-
{ name: 'scratch', description: 'A skill in no
|
|
73
|
+
{ name: 'outreach', description: 'Runs the GTM outreach.', path: 'Plugins/GTM/outreach' },
|
|
74
|
+
{ name: 'scratch', description: 'A skill in no plugin.', path: 'Skills/scratch' },
|
|
75
75
|
],
|
|
76
76
|
tools: [],
|
|
77
77
|
ownedSkills: new Set(['outreach']),
|
|
@@ -82,9 +82,9 @@ const CATALOG: LibraryData = {
|
|
|
82
82
|
reload: vi.fn(),
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
const summary = (over: Partial<
|
|
85
|
+
const summary = (over: Partial<PluginSummary>): PluginSummary => ({
|
|
86
86
|
name: 'GTM',
|
|
87
|
-
folders: ['
|
|
87
|
+
folders: ['Plugins/GTM'],
|
|
88
88
|
canRead: true,
|
|
89
89
|
canWrite: true,
|
|
90
90
|
isOwner: false,
|
|
@@ -98,11 +98,11 @@ const summary = (over: Partial<GroupSummary>): GroupSummary => ({
|
|
|
98
98
|
...over,
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const PLUGINS: PluginSummary[] = [
|
|
102
102
|
summary({}),
|
|
103
103
|
// Not readable and not writable, and no item of it reaches the catalog — the
|
|
104
104
|
// sidebar's locked half.
|
|
105
|
-
summary({ name: 'Finance', folders: ['
|
|
105
|
+
summary({ name: 'Finance', folders: ['Plugins/Finance'], canRead: false, canWrite: false }),
|
|
106
106
|
];
|
|
107
107
|
|
|
108
108
|
function wrap(children: ReactNode) {
|
|
@@ -142,7 +142,7 @@ function renderLibrary(path = '/skills-and-tools') {
|
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
const nav = () => screen.getByRole('navigation', { name: 'Library
|
|
145
|
+
const nav = () => screen.getByRole('navigation', { name: 'Library plugins' });
|
|
146
146
|
const menuItems = () =>
|
|
147
147
|
within(screen.getByRole('menu'))
|
|
148
148
|
.getAllByRole('menuitem')
|
|
@@ -150,7 +150,7 @@ const menuItems = () =>
|
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* A row in the NAV, by name. Scoped rather than global because the Library
|
|
153
|
-
* opens on the all-
|
|
153
|
+
* opens on the all-plugins index, whose rows name the same plugins the nav does —
|
|
154
154
|
* `GTM` is two buttons on this screen, and only one of them is the nav's.
|
|
155
155
|
*/
|
|
156
156
|
const navRow = (name: RegExp | string) => within(nav()).findByRole('button', { name });
|
|
@@ -166,9 +166,9 @@ async function openMenuOn(name: RegExp | string) {
|
|
|
166
166
|
describe('Library sidebar: right-click, end to end', () => {
|
|
167
167
|
beforeEach(() => {
|
|
168
168
|
dataMock.useLibraryData.mockReturnValue(CATALOG);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
pluginsMock.listPlugins.mockResolvedValue(PLUGINS);
|
|
170
|
+
pluginsMock.listJoinRequests.mockResolvedValue([]);
|
|
171
|
+
pluginsMock.deletePlugin.mockResolvedValue(undefined);
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
// Only the globals this file stubs — NOT `restoreAllMocks`, which would strip
|
|
@@ -176,37 +176,37 @@ describe('Library sidebar: right-click, end to end', () => {
|
|
|
176
176
|
// returning undefined for whichever test happens to run next.
|
|
177
177
|
afterEach(() => vi.unstubAllGlobals());
|
|
178
178
|
|
|
179
|
-
it('gives a
|
|
179
|
+
it('gives a plugin row the full menu, titled after the plugin', async () => {
|
|
180
180
|
renderLibrary();
|
|
181
181
|
await openMenuOn(/^GTM/);
|
|
182
182
|
expect(screen.getByRole('menu', { name: 'Actions for GTM' })).toBeInTheDocument();
|
|
183
|
-
expect(menuItems()).toEqual(['Add a skill or tool', 'New
|
|
183
|
+
expect(menuItems()).toEqual(['Add a skill or tool', 'New plugin', 'Copy link', 'Manage access']);
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
/**
|
|
187
187
|
* A lens is a slice of the catalog, not a folder — there is nothing to add a
|
|
188
|
-
* skill TO and no `access.md` behind it. The same call the
|
|
188
|
+
* skill TO and no `access.md` behind it. The same call the plugin page's
|
|
189
189
|
* `PageActions` makes when it hides `Share` on the personal page.
|
|
190
190
|
*/
|
|
191
191
|
it('gives a lens row only the verbs a slice of the catalog can answer', async () => {
|
|
192
192
|
renderLibrary();
|
|
193
193
|
await openMenuOn(/^Owned by me/);
|
|
194
|
-
expect(menuItems()).toEqual(['New
|
|
194
|
+
expect(menuItems()).toEqual(['New plugin', 'Copy link']);
|
|
195
195
|
|
|
196
196
|
fireEvent.keyDown(document, { key: 'Escape' });
|
|
197
197
|
await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
|
|
198
198
|
|
|
199
199
|
await openMenuOn(new RegExp(`^${TEST_PERSONAL_GROUP}`));
|
|
200
|
-
expect(menuItems()).toEqual(['New
|
|
200
|
+
expect(menuItems()).toEqual(['New plugin', 'Copy link']);
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
|
-
* `Manage access` is UNGATED on `canWrite`, exactly as the
|
|
204
|
+
* `Manage access` is UNGATED on `canWrite`, exactly as the plugin page's
|
|
205
205
|
* `Share` is: for a non-writer the dialog renders read-only, which is
|
|
206
206
|
* precisely what "who is this shared with?" should answer — and for an admin
|
|
207
|
-
* locked out of a
|
|
207
|
+
* locked out of a plugin it is the self-service way back in.
|
|
208
208
|
*/
|
|
209
|
-
it('offers Manage access on a locked
|
|
209
|
+
it('offers Manage access on a locked plugin too', async () => {
|
|
210
210
|
renderLibrary();
|
|
211
211
|
await openMenuOn('Finance (locked)');
|
|
212
212
|
expect(screen.getByRole('menu', { name: 'Actions for Finance' })).toBeInTheDocument();
|
|
@@ -220,26 +220,26 @@ describe('Library sidebar: right-click, end to end', () => {
|
|
|
220
220
|
* `canWrite: true, isOwner: false` — the full-menu test above is therefore
|
|
221
221
|
* also the proof that a mere MANAGER does not see the item.
|
|
222
222
|
*/
|
|
223
|
-
it('offers Delete
|
|
224
|
-
|
|
223
|
+
it('offers Delete plugin to an owner, and drives the confirm → delete round-trip', async () => {
|
|
224
|
+
pluginsMock.listPlugins.mockResolvedValue([summary({ isOwner: true })]);
|
|
225
225
|
renderLibrary();
|
|
226
226
|
await openMenuOn(/^GTM/);
|
|
227
227
|
expect(menuItems()).toEqual([
|
|
228
228
|
'Add a skill or tool',
|
|
229
|
-
'New
|
|
229
|
+
'New plugin',
|
|
230
230
|
'Copy link',
|
|
231
231
|
'Manage access',
|
|
232
|
-
'Delete
|
|
232
|
+
'Delete plugin',
|
|
233
233
|
]);
|
|
234
234
|
|
|
235
|
-
fireEvent.click(screen.getByRole('menuitem', { name: 'Delete
|
|
235
|
+
fireEvent.click(screen.getByRole('menuitem', { name: 'Delete plugin' }));
|
|
236
236
|
// The menu hands over to the confirmation — nothing is deleted yet.
|
|
237
237
|
const dialog = await screen.findByRole('dialog');
|
|
238
238
|
expect(screen.queryByRole('menu')).toBeNull();
|
|
239
|
-
expect(
|
|
239
|
+
expect(pluginsMock.deletePlugin).not.toHaveBeenCalled();
|
|
240
240
|
|
|
241
|
-
fireEvent.click(within(dialog).getByRole('button', { name: 'Delete
|
|
242
|
-
await waitFor(() => expect(
|
|
241
|
+
fireEvent.click(within(dialog).getByRole('button', { name: 'Delete plugin' }));
|
|
242
|
+
await waitFor(() => expect(pluginsMock.deletePlugin).toHaveBeenCalledWith('GTM'));
|
|
243
243
|
// The layout says so — same voice as every other completed verb here.
|
|
244
244
|
expect(await screen.findByText('Deleted GTM.')).toBeInTheDocument();
|
|
245
245
|
});
|
|
@@ -249,28 +249,28 @@ describe('Library sidebar: right-click, end to end', () => {
|
|
|
249
249
|
await navRow(/^GTM/);
|
|
250
250
|
fireEvent.contextMenu(nav(), { clientX: 40, clientY: 400 });
|
|
251
251
|
await screen.findByRole('menu');
|
|
252
|
-
expect(menuItems()).toEqual(['New
|
|
252
|
+
expect(menuItems()).toEqual(['New plugin']);
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
it('opens the new-
|
|
255
|
+
it('opens the new-plugin dialog from the menu', async () => {
|
|
256
256
|
renderLibrary();
|
|
257
257
|
await openMenuOn(/^GTM/);
|
|
258
|
-
fireEvent.click(screen.getByRole('menuitem', { name: 'New
|
|
258
|
+
fireEvent.click(screen.getByRole('menuitem', { name: 'New plugin' }));
|
|
259
259
|
expect(await screen.findByRole('dialog')).toBeInTheDocument();
|
|
260
260
|
expect(screen.queryByRole('menu')).toBeNull();
|
|
261
261
|
});
|
|
262
262
|
|
|
263
|
-
it('opens the add dialog for the
|
|
263
|
+
it('opens the add dialog for the plugin that was clicked, not the page you are on', async () => {
|
|
264
264
|
renderLibrary('/skills-and-tools/owned');
|
|
265
265
|
await openMenuOn(/^GTM/);
|
|
266
266
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Add a skill or tool' }));
|
|
267
|
-
// The dialog titles itself with its
|
|
268
|
-
// ROW's
|
|
267
|
+
// The dialog titles itself with its plugin — proof the layout captured the
|
|
268
|
+
// ROW's plugin, and not the route it happened to be sitting on.
|
|
269
269
|
const dialog = await screen.findByRole('dialog');
|
|
270
270
|
expect(within(dialog).getByText('Add a skill or tool to GTM')).toBeInTheDocument();
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
it('opens Manage access on the
|
|
273
|
+
it('opens Manage access on the plugin folder, under the KB dir', async () => {
|
|
274
274
|
const access = await import('../../access/api');
|
|
275
275
|
renderLibrary();
|
|
276
276
|
await openMenuOn(/^GTM/);
|
|
@@ -282,11 +282,11 @@ describe('Library sidebar: right-click, end to end', () => {
|
|
|
282
282
|
* WORKSPACE path (`<kbDirName>/<folder>`), the dialog strips that prefix
|
|
283
283
|
* back off, and what reaches the resolver is the REPO-relative folder —
|
|
284
284
|
* which is the only address `access.md` is written at. Get either half
|
|
285
|
-
* wrong and this is `undefined/
|
|
285
|
+
* wrong and this is `undefined/Plugins/GTM` or `knowledge-base/Plugins/GTM`,
|
|
286
286
|
* and the dialog silently resolves a folder that does not exist. It is the
|
|
287
|
-
* same handoff `
|
|
287
|
+
* same handoff `PluginPage` makes, which is why it has to match exactly.
|
|
288
288
|
*/
|
|
289
|
-
expect(vi.mocked(access.fetchFileAccess).mock.calls[0][1]).toBe('
|
|
289
|
+
expect(vi.mocked(access.fetchFileAccess).mock.calls[0][1]).toBe('Plugins/GTM');
|
|
290
290
|
});
|
|
291
291
|
|
|
292
292
|
it("copies the clicked row's own URL, not the one you are standing on", async () => {
|
|
@@ -299,7 +299,7 @@ describe('Library sidebar: right-click, end to end', () => {
|
|
|
299
299
|
|
|
300
300
|
await waitFor(() =>
|
|
301
301
|
expect(writeText).toHaveBeenCalledWith(
|
|
302
|
-
`${window.location.origin}/skills-and-tools/
|
|
302
|
+
`${window.location.origin}/skills-and-tools/plugins/GTM`,
|
|
303
303
|
),
|
|
304
304
|
);
|
|
305
305
|
expect(await screen.findByText('Link copied.')).toBeInTheDocument();
|