@bevel-software/platform-core-frontend 0.7.4 → 0.8.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/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/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} +101 -101
- package/src/modules/library/__tests__/{GroupsIndexPage.test.tsx → PluginsIndexPage.test.tsx} +57 -57
- package/src/modules/library/__tests__/{GroupsSidebar.contextmenu.test.tsx → PluginsSidebar.contextmenu.test.tsx} +31 -31
- package/src/modules/library/__tests__/{GroupsSidebar.locked.test.tsx → PluginsSidebar.locked.test.tsx} +28 -28
- package/src/modules/library/__tests__/{GroupsSidebar.test.tsx → PluginsSidebar.test.tsx} +39 -39
- 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__/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 +70 -70
- 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 +5 -5
- package/src/modules/library/components/PageActions.tsx +3 -3
- package/src/modules/library/components/PersonalAddDialog.tsx +5 -5
- package/src/modules/library/components/{PersonalGroupPage.tsx → PersonalPluginPage.tsx} +17 -17
- 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/{GroupJoinRequests.tsx → PluginJoinRequests.tsx} +12 -12
- package/src/modules/library/components/{GroupPage.tsx → PluginPage.tsx} +72 -69
- package/src/modules/library/components/{GroupsIndexPage.tsx → PluginsIndexPage.tsx} +46 -46
- package/src/modules/library/components/{GroupsSidebar.tsx → PluginsSidebar.tsx} +55 -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} +35 -24
- 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 +30 -17
- 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 +46 -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__/onboarding.test.tsx +86 -8
- package/src/modules/onboarding/agent-clients.ts +18 -14
- package/src/modules/onboarding/components/WelcomePage.tsx +19 -8
- 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/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/__tests__/FileExplorer.test.tsx +14 -14
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +7 -2
- package/src/modules/workspace/utils/__tests__/diff.test.ts +1 -1
- package/src/modules/workspace/utils/fileTree.ts +3 -3
- 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
|
@@ -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();
|
package/src/modules/library/__tests__/{LockedGroupView.test.tsx → LockedPluginView.test.tsx}
RENAMED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
2
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
3
|
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
-
import type {
|
|
4
|
+
import type { PluginSummary } from '../services/plugins.api';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* The locked
|
|
7
|
+
* The locked plugin page: what it is allowed to say, and what asking to join
|
|
8
8
|
* does.
|
|
9
9
|
*
|
|
10
10
|
* Copy is asserted verbatim throughout because it IS the feature — a locked
|
|
11
|
-
*
|
|
12
|
-
* describe the
|
|
11
|
+
* plugin's whole surface is four sentences, and every one of them was chosen to
|
|
12
|
+
* describe the plugin without describing its contents.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
const apiMock = vi.hoisted(() => ({
|
|
16
|
-
|
|
16
|
+
requestPluginAccess: vi.fn(),
|
|
17
17
|
AlreadyReadableError: class AlreadyReadableError extends Error {},
|
|
18
18
|
}));
|
|
19
|
-
vi.mock('../services/
|
|
20
|
-
|
|
19
|
+
vi.mock('../services/plugins.api', () => ({
|
|
20
|
+
requestPluginAccess: apiMock.requestPluginAccess,
|
|
21
21
|
AlreadyReadableError: apiMock.AlreadyReadableError,
|
|
22
22
|
}));
|
|
23
23
|
|
|
24
24
|
import { LibraryToastProvider } from '../state/toast';
|
|
25
|
-
import {
|
|
25
|
+
import { LockedPluginView } from '../components/LockedPluginView';
|
|
26
26
|
import { joinNames, firstNames } from '../utils/names';
|
|
27
27
|
|
|
28
|
-
const finance = (over: Partial<
|
|
28
|
+
const finance = (over: Partial<PluginSummary> = {}): PluginSummary => ({
|
|
29
29
|
name: 'Finance',
|
|
30
|
-
folders: ['
|
|
30
|
+
folders: ['Plugins/Finance'],
|
|
31
31
|
canRead: false,
|
|
32
32
|
canWrite: false,
|
|
33
33
|
isOwner: false,
|
|
@@ -41,15 +41,15 @@ const finance = (over: Partial<GroupSummary> = {}): GroupSummary => ({
|
|
|
41
41
|
...over,
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
function renderLocked(
|
|
44
|
+
function renderLocked(plugin: PluginSummary = finance()) {
|
|
45
45
|
const onRequested = vi.fn();
|
|
46
46
|
const onUnlocked = vi.fn();
|
|
47
47
|
const onManage = vi.fn();
|
|
48
48
|
const view = render(
|
|
49
49
|
<MemoryRouter>
|
|
50
50
|
<LibraryToastProvider>
|
|
51
|
-
<
|
|
52
|
-
|
|
51
|
+
<LockedPluginView
|
|
52
|
+
plugin={plugin}
|
|
53
53
|
onRequested={onRequested}
|
|
54
54
|
onUnlocked={onUnlocked}
|
|
55
55
|
onManage={onManage}
|
|
@@ -62,19 +62,19 @@ function renderLocked(group: GroupSummary = finance()) {
|
|
|
62
62
|
|
|
63
63
|
const askButton = () => screen.getByRole('button', { name: 'Subscribe to its skills and tools' });
|
|
64
64
|
|
|
65
|
-
describe('
|
|
65
|
+
describe('LockedPluginView', () => {
|
|
66
66
|
beforeEach(() => {
|
|
67
|
-
apiMock.
|
|
68
|
-
apiMock.
|
|
67
|
+
apiMock.requestPluginAccess.mockReset();
|
|
68
|
+
apiMock.requestPluginAccess.mockResolvedValue(undefined);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
it('states the
|
|
71
|
+
it('states the plugin, who runs it, and how much is in it. And nothing else', () => {
|
|
72
72
|
renderLocked();
|
|
73
73
|
expect(screen.getByRole('heading', { name: 'Finance', level: 1 })).toBeInTheDocument();
|
|
74
74
|
expect(screen.getByText('Locked')).toBeInTheDocument();
|
|
75
75
|
expect(screen.getByText('Run by Olga Ivanova.')).toBeInTheDocument();
|
|
76
|
-
expect(screen.getByText('2 skills · 1 tool. Visible
|
|
77
|
-
expect(screen.getByRole('link', { name: 'All
|
|
76
|
+
expect(screen.getByText('2 skills · 1 tool. Visible once you have access.')).toBeInTheDocument();
|
|
77
|
+
expect(screen.getByRole('link', { name: 'All plugins' })).toHaveAttribute(
|
|
78
78
|
'href',
|
|
79
79
|
'/skills-and-tools',
|
|
80
80
|
);
|
|
@@ -91,12 +91,12 @@ describe('LockedGroupView', () => {
|
|
|
91
91
|
|
|
92
92
|
it('pluralises the counts line honestly', () => {
|
|
93
93
|
renderLocked(finance({ skillCount: 1, toolCount: 0 }));
|
|
94
|
-
expect(screen.getByText('1 skill · 0 tools. Visible
|
|
94
|
+
expect(screen.getByText('1 skill · 0 tools. Visible once you have access.')).toBeInTheDocument();
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it('asks once, disables while in flight, and flips to the Requested box', async () => {
|
|
98
98
|
let release = () => {};
|
|
99
|
-
apiMock.
|
|
99
|
+
apiMock.requestPluginAccess.mockReturnValue(
|
|
100
100
|
new Promise<void>((resolve) => {
|
|
101
101
|
release = () => resolve();
|
|
102
102
|
}),
|
|
@@ -106,12 +106,12 @@ describe('LockedGroupView', () => {
|
|
|
106
106
|
fireEvent.click(askButton());
|
|
107
107
|
expect(askButton()).toBeDisabled();
|
|
108
108
|
fireEvent.click(askButton());
|
|
109
|
-
expect(apiMock.
|
|
110
|
-
expect(apiMock.
|
|
109
|
+
expect(apiMock.requestPluginAccess).toHaveBeenCalledTimes(1);
|
|
110
|
+
expect(apiMock.requestPluginAccess).toHaveBeenCalledWith('Finance');
|
|
111
111
|
|
|
112
112
|
release();
|
|
113
113
|
expect(
|
|
114
|
-
await screen.findByText('Requested: Olga Ivanova decides who
|
|
114
|
+
await screen.findByText('Requested: Olga Ivanova decides who gets access.'),
|
|
115
115
|
).toBeInTheDocument();
|
|
116
116
|
expect(
|
|
117
117
|
screen.queryByRole('button', { name: 'Subscribe to its skills and tools' }),
|
|
@@ -123,13 +123,13 @@ describe('LockedGroupView', () => {
|
|
|
123
123
|
renderLocked();
|
|
124
124
|
fireEvent.click(askButton());
|
|
125
125
|
expect(
|
|
126
|
-
await screen.findByText('Asked Olga. You get its skills and tools
|
|
126
|
+
await screen.findByText('Asked Olga. You get its skills and tools once they grant access.'),
|
|
127
127
|
).toBeInTheDocument();
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it('shows the Requested box with no button when the server already has one', () => {
|
|
131
131
|
renderLocked(finance({ hasRequested: true }));
|
|
132
|
-
expect(screen.getByText('Requested: Olga Ivanova decides who
|
|
132
|
+
expect(screen.getByText('Requested: Olga Ivanova decides who gets access.')).toBeInTheDocument();
|
|
133
133
|
expect(
|
|
134
134
|
screen.queryByRole('button', { name: 'Subscribe to its skills and tools' }),
|
|
135
135
|
).not.toBeInTheDocument();
|
|
@@ -141,11 +141,11 @@ describe('LockedGroupView', () => {
|
|
|
141
141
|
fireEvent.click(askButton());
|
|
142
142
|
expect(
|
|
143
143
|
await screen.findByText(
|
|
144
|
-
'Asked the admins. You get its skills and tools
|
|
144
|
+
'Asked the admins. You get its skills and tools once they grant access.',
|
|
145
145
|
),
|
|
146
146
|
).toBeInTheDocument();
|
|
147
147
|
expect(
|
|
148
|
-
screen.getByText('Requested: the workspace admins decide who
|
|
148
|
+
screen.getByText('Requested: the workspace admins decide who gets access.'),
|
|
149
149
|
).toBeInTheDocument();
|
|
150
150
|
});
|
|
151
151
|
|
|
@@ -159,8 +159,8 @@ describe('LockedGroupView', () => {
|
|
|
159
159
|
expect(screen.getByText('Run by Juan Viera, Admin.')).toBeInTheDocument();
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
it('opens the
|
|
163
|
-
apiMock.
|
|
162
|
+
it('opens the plugin rather than complaining when access already landed', async () => {
|
|
163
|
+
apiMock.requestPluginAccess.mockRejectedValue(new apiMock.AlreadyReadableError());
|
|
164
164
|
const { onUnlocked, onRequested } = renderLocked();
|
|
165
165
|
fireEvent.click(askButton());
|
|
166
166
|
await waitFor(() => expect(onUnlocked).toHaveBeenCalledTimes(1));
|
|
@@ -169,7 +169,7 @@ describe('LockedGroupView', () => {
|
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
it('re-enables the button and says so when the request fails', async () => {
|
|
172
|
-
apiMock.
|
|
172
|
+
apiMock.requestPluginAccess.mockRejectedValue(new Error('boom'));
|
|
173
173
|
const { onRequested } = renderLocked();
|
|
174
174
|
fireEvent.click(askButton());
|
|
175
175
|
expect(await screen.findByText("Couldn't send that: try again.")).toBeInTheDocument();
|
|
@@ -178,9 +178,9 @@ describe('LockedGroupView', () => {
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
it('gives a locked-out admin the self-service way in', () => {
|
|
181
|
-
const { onManage } = renderLocked(finance({ canWrite: true, folders: ['
|
|
181
|
+
const { onManage } = renderLocked(finance({ canWrite: true, folders: ['Plugins/Finance'] }));
|
|
182
182
|
fireEvent.click(screen.getByRole('button', { name: 'Manage access' }));
|
|
183
|
-
expect(onManage).toHaveBeenCalledWith('
|
|
183
|
+
expect(onManage).toHaveBeenCalledWith('Plugins/Finance');
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
it('offers no Manage access to somebody who cannot write the folder', () => {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import type { McpServerView } from '../services/tools.api';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The server-scoped editor. What is worth pinning: the section renders nothing
|
|
8
|
+
* for a `.tool`-backed manual (GET 404 → null), non-writers get facts and no
|
|
9
|
+
* button, and a RENAME with configured secrets is interrupted by a dialog that
|
|
10
|
+
* names the count — the save must not fire until "Rename anyway".
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const apiMock = vi.hoisted(() => ({
|
|
14
|
+
getMcpServer: vi.fn<() => Promise<McpServerView | null>>(),
|
|
15
|
+
putMcpServer: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
vi.mock('../services/tools.api', async (importOriginal) => ({
|
|
18
|
+
...(await importOriginal<typeof import('../services/tools.api')>()),
|
|
19
|
+
getMcpServer: apiMock.getMcpServer,
|
|
20
|
+
putMcpServer: apiMock.putMcpServer,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
import { McpServerSection } from '../components/tool-page/McpServerSection';
|
|
24
|
+
|
|
25
|
+
const VIEW: McpServerView = {
|
|
26
|
+
name: 'vendor',
|
|
27
|
+
transport: 'streamable-http',
|
|
28
|
+
url: 'https://v.example/mcp',
|
|
29
|
+
literalHeaders: { 'X-V': '2' },
|
|
30
|
+
authHeaders: { Authorization: 'Bearer ${VENDOR_KEY}' },
|
|
31
|
+
variables: [{ name: 'VENDOR_KEY', scope: 'user' }],
|
|
32
|
+
local: false,
|
|
33
|
+
canWrite: true,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function renderSection(configuredCount = 2) {
|
|
37
|
+
const onSaved = vi.fn();
|
|
38
|
+
const onError = vi.fn();
|
|
39
|
+
render(
|
|
40
|
+
<MemoryRouter>
|
|
41
|
+
<McpServerSection slug="vendor" configuredCount={configuredCount} onSaved={onSaved} onError={onError} />
|
|
42
|
+
</MemoryRouter>,
|
|
43
|
+
);
|
|
44
|
+
return { onSaved, onError };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
beforeEach(() => {
|
|
48
|
+
apiMock.getMcpServer.mockReset();
|
|
49
|
+
apiMock.putMcpServer.mockReset();
|
|
50
|
+
apiMock.putMcpServer.mockResolvedValue({ name: 'vendor' });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('McpServerSection', () => {
|
|
54
|
+
it('renders nothing for a .tool-backed manual', async () => {
|
|
55
|
+
apiMock.getMcpServer.mockResolvedValue(null);
|
|
56
|
+
renderSection();
|
|
57
|
+
await waitFor(() => expect(apiMock.getMcpServer).toHaveBeenCalled());
|
|
58
|
+
expect(screen.queryByText('Server')).not.toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('shows the facts, and the edit button only to writers', async () => {
|
|
62
|
+
apiMock.getMcpServer.mockResolvedValue({ ...VIEW, canWrite: false });
|
|
63
|
+
renderSection();
|
|
64
|
+
expect(await screen.findByText('https://v.example/mcp')).toBeInTheDocument();
|
|
65
|
+
expect(screen.queryByRole('button', { name: 'Edit server' })).not.toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('saves without ceremony when the name is unchanged', async () => {
|
|
69
|
+
apiMock.getMcpServer.mockResolvedValue(VIEW);
|
|
70
|
+
const { onSaved } = renderSection();
|
|
71
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
|
|
72
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
73
|
+
await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
|
|
74
|
+
// No newName in the payload — an unchanged name is not a rename.
|
|
75
|
+
expect(apiMock.putMcpServer.mock.calls[0]![1]).not.toHaveProperty('newName');
|
|
76
|
+
await waitFor(() => expect(onSaved).toHaveBeenCalled());
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('confirms a rename even when this caller sees nothing configured', async () => {
|
|
80
|
+
// Other members' user-scoped values and sign-ins are invisible to this
|
|
81
|
+
// page, so a zero count proves nothing — the confirm must still gate.
|
|
82
|
+
apiMock.getMcpServer.mockResolvedValue(VIEW);
|
|
83
|
+
renderSection(0);
|
|
84
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
|
|
85
|
+
fireEvent.change(screen.getByRole('textbox', { name: /Name/ }), {
|
|
86
|
+
target: { value: 'vendor_eu' },
|
|
87
|
+
});
|
|
88
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
89
|
+
expect(apiMock.putMcpServer).not.toHaveBeenCalled();
|
|
90
|
+
expect(await screen.findByText(/other members' values, which this page cannot see/)).toBeInTheDocument();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('round-trips cwd/env on a stdio save — the form has no fields for them', async () => {
|
|
94
|
+
// The PUT rebuilds the entry from the payload, so omitting `cwd`/`env`
|
|
95
|
+
// would erase values a hand-edited mcp.json carries.
|
|
96
|
+
apiMock.getMcpServer.mockResolvedValue({
|
|
97
|
+
name: 'vendor',
|
|
98
|
+
transport: 'stdio',
|
|
99
|
+
command: 'npx',
|
|
100
|
+
args: ['-y', 'vendor'],
|
|
101
|
+
cwd: './srv',
|
|
102
|
+
env: { VENDOR_MODE: 'ci' },
|
|
103
|
+
literalHeaders: {},
|
|
104
|
+
authHeaders: {},
|
|
105
|
+
variables: [],
|
|
106
|
+
local: true,
|
|
107
|
+
canWrite: true,
|
|
108
|
+
});
|
|
109
|
+
renderSection();
|
|
110
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
|
|
111
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
112
|
+
await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
|
|
113
|
+
expect(apiMock.putMcpServer.mock.calls[0]![1]).toMatchObject({
|
|
114
|
+
command: 'npx',
|
|
115
|
+
args: ['-y', 'vendor'],
|
|
116
|
+
cwd: './srv',
|
|
117
|
+
env: { VENDOR_MODE: 'ci' },
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('interrupts a rename with the disconnect count, and saves only on "Rename anyway"', async () => {
|
|
122
|
+
apiMock.getMcpServer.mockResolvedValue(VIEW);
|
|
123
|
+
renderSection(2);
|
|
124
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit server' }));
|
|
125
|
+
fireEvent.change(screen.getByRole('textbox', { name: /Name/ }), {
|
|
126
|
+
target: { value: 'vendor_eu' },
|
|
127
|
+
});
|
|
128
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
129
|
+
|
|
130
|
+
// The save did NOT fire — the dialog is the gate, and it says the cost.
|
|
131
|
+
expect(apiMock.putMcpServer).not.toHaveBeenCalled();
|
|
132
|
+
expect(await screen.findByText(/at least 2 are configured from your view alone/)).toBeInTheDocument();
|
|
133
|
+
|
|
134
|
+
fireEvent.click(screen.getByRole('button', { name: 'Rename anyway' }));
|
|
135
|
+
await waitFor(() => expect(apiMock.putMcpServer).toHaveBeenCalledTimes(1));
|
|
136
|
+
expect(apiMock.putMcpServer.mock.calls[0]![1]).toMatchObject({ newName: 'vendor_eu' });
|
|
137
|
+
});
|
|
138
|
+
});
|