@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
package/src/modules/library/__tests__/{GroupsIndexPage.test.tsx → PluginsIndexPage.test.tsx}
RENAMED
|
@@ -3,23 +3,23 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
|
3
3
|
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
4
4
|
import type { LibraryData } from '../hooks/useLibraryData';
|
|
5
5
|
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PluginSummary } from '../services/plugins.api';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* The all-
|
|
9
|
+
* The all-plugins index: which section a plugin lands in, what each row says, and
|
|
10
10
|
* where it goes. The locked section is the reason this page exists, so most of
|
|
11
|
-
* what is asserted here is about
|
|
11
|
+
* what is asserted here is about plugins the caller cannot enter.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
const dataMock = vi.hoisted(() => ({ useLibraryData: vi.fn() }));
|
|
15
15
|
vi.mock('../hooks/useLibraryData', () => ({ useLibraryData: dataMock.useLibraryData }));
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
vi.mock('../services/
|
|
19
|
-
|
|
17
|
+
const pluginsMock = vi.hoisted(() => ({ listPlugins: vi.fn(), listJoinRequests: vi.fn() }));
|
|
18
|
+
vi.mock('../services/plugins.api', () => ({
|
|
19
|
+
listPlugins: pluginsMock.listPlugins,
|
|
20
20
|
// The page carries the managers' join-request banners now — it is where the
|
|
21
21
|
// Library lands, so it is where an unanswered request is certain to be seen.
|
|
22
|
-
listJoinRequests:
|
|
22
|
+
listJoinRequests: pluginsMock.listJoinRequests,
|
|
23
23
|
reconcileJoinRequest: vi.fn(),
|
|
24
24
|
}));
|
|
25
25
|
|
|
@@ -28,13 +28,13 @@ import {
|
|
|
28
28
|
WorkspaceContext,
|
|
29
29
|
type WorkspaceContextValue,
|
|
30
30
|
} from '../../workspace/state/workspace.context';
|
|
31
|
-
import {
|
|
31
|
+
import { PluginsIndexPage } from '../components/PluginsIndexPage';
|
|
32
32
|
import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
|
|
33
33
|
|
|
34
34
|
const tool = (over: Partial<ToolSecrets> = {}): ToolSecrets => ({
|
|
35
35
|
slug: 'heyreach',
|
|
36
36
|
name: 'heyreach',
|
|
37
|
-
path: '
|
|
37
|
+
path: 'Plugins/GTM/heyreach.tool',
|
|
38
38
|
type: 'inline',
|
|
39
39
|
setup: null,
|
|
40
40
|
canWrite: false,
|
|
@@ -46,13 +46,13 @@ const CATALOG: LibraryData = {
|
|
|
46
46
|
loading: false,
|
|
47
47
|
error: null,
|
|
48
48
|
skills: [
|
|
49
|
-
{ name: 'outreach', description: '', path: '
|
|
49
|
+
{ name: 'outreach', description: '', path: 'Plugins/GTM/outreach' },
|
|
50
50
|
{ name: 'scratch', description: '', path: 'Skills/scratch' },
|
|
51
51
|
],
|
|
52
52
|
pendingSkills: [],
|
|
53
53
|
tools: [
|
|
54
54
|
tool(),
|
|
55
|
-
// An ungrouped sign-in — `Tools/slack.tool` is two segments, so no
|
|
55
|
+
// An ungrouped sign-in — `Tools/slack.tool` is two segments, so no plugin.
|
|
56
56
|
tool({
|
|
57
57
|
slug: 'slack',
|
|
58
58
|
name: 'slack',
|
|
@@ -76,9 +76,9 @@ const CATALOG: LibraryData = {
|
|
|
76
76
|
reload: vi.fn(),
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const summary = (over: Partial<
|
|
79
|
+
const summary = (over: Partial<PluginSummary> = {}): PluginSummary => ({
|
|
80
80
|
name: 'GTM',
|
|
81
|
-
folders: ['
|
|
81
|
+
folders: ['Plugins/GTM'],
|
|
82
82
|
canRead: true,
|
|
83
83
|
canWrite: false,
|
|
84
84
|
isOwner: false,
|
|
@@ -110,7 +110,7 @@ function renderIndex() {
|
|
|
110
110
|
<WorkspaceContext.Provider value={WORKSPACE}>
|
|
111
111
|
<LibraryProvider>
|
|
112
112
|
<Routes>
|
|
113
|
-
<Route path="/skills-and-tools" element={<
|
|
113
|
+
<Route path="/skills-and-tools" element={<PluginsIndexPage />} />
|
|
114
114
|
<Route path="*" element={<div />} />
|
|
115
115
|
</Routes>
|
|
116
116
|
<LocationProbe />
|
|
@@ -124,27 +124,27 @@ function renderIndex() {
|
|
|
124
124
|
const href = () => screen.getByLabelText('href').textContent;
|
|
125
125
|
const row = (name: RegExp | string) => screen.getByRole('button', { name });
|
|
126
126
|
|
|
127
|
-
describe('
|
|
127
|
+
describe('PluginsIndexPage', () => {
|
|
128
128
|
beforeEach(() => {
|
|
129
129
|
dataMock.useLibraryData.mockReturnValue(CATALOG);
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
pluginsMock.listPlugins.mockResolvedValue([summary()]);
|
|
131
|
+
pluginsMock.listJoinRequests.mockResolvedValue([]);
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
it('names itself and its two sections', async () => {
|
|
135
135
|
renderIndex();
|
|
136
|
-
expect(await screen.findByRole('heading', { name: 'All
|
|
136
|
+
expect(await screen.findByRole('heading', { name: 'All plugins', level: 1 })).toBeInTheDocument();
|
|
137
137
|
expect(
|
|
138
|
-
screen.getByText('A
|
|
138
|
+
screen.getByText('A plugin carries skills and tools for the people in it.'),
|
|
139
139
|
).toBeInTheDocument();
|
|
140
140
|
expect(screen.getByRole('heading', { name: 'Yours' })).toBeInTheDocument();
|
|
141
|
-
expect(await screen.findByRole('heading', { name: "
|
|
141
|
+
expect(await screen.findByRole('heading', { name: "Your plugins" })).toBeInTheDocument();
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
it("offers the caller's own
|
|
144
|
+
it("offers the caller's own plugin under Yours, and opens it", async () => {
|
|
145
145
|
renderIndex();
|
|
146
146
|
expect(
|
|
147
|
-
await screen.findByText('Your sign-ins and the skills no
|
|
147
|
+
await screen.findByText('Your sign-ins and the skills no plugin carries'),
|
|
148
148
|
).toBeInTheDocument();
|
|
149
149
|
// The lens is gone from this page — it lives in the sidebar.
|
|
150
150
|
expect(screen.queryByText('The skills you answer for')).not.toBeInTheDocument();
|
|
@@ -152,38 +152,38 @@ describe('GroupsIndexPage', () => {
|
|
|
152
152
|
await waitFor(() => expect(href()).toBe('/skills-and-tools/yours'));
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
it("keeps the caller's own
|
|
155
|
+
it("keeps the caller's own plugin listed even when nothing sits outside a plugin", async () => {
|
|
156
156
|
dataMock.useLibraryData.mockReturnValue({
|
|
157
157
|
...CATALOG,
|
|
158
|
-
skills: [{ name: 'outreach', description: '', path: '
|
|
158
|
+
skills: [{ name: 'outreach', description: '', path: 'Plugins/GTM/outreach' }],
|
|
159
159
|
tools: [tool()],
|
|
160
160
|
});
|
|
161
161
|
renderIndex();
|
|
162
|
-
await screen.findByRole('heading', { name: 'All
|
|
162
|
+
await screen.findByRole('heading', { name: 'All plugins', level: 1 });
|
|
163
163
|
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
|
|
164
|
-
// And never the lens: "Owned by me" is a view across
|
|
164
|
+
// And never the lens: "Owned by me" is a view across plugins, not a plugin.
|
|
165
165
|
expect(screen.queryByRole('button', { name: /^Owned by me/ })).not.toBeInTheDocument();
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
it("puts a readable
|
|
168
|
+
it("puts a readable plugin under Your plugins, with its run-by line and totals", async () => {
|
|
169
169
|
renderIndex();
|
|
170
170
|
const gtm = await screen.findByRole('button', { name: /^GTM/ });
|
|
171
171
|
expect(gtm).toHaveAccessibleName('GTM Run by Olga Ivanova 4 skills · 2 tools');
|
|
172
172
|
fireEvent.click(gtm);
|
|
173
|
-
await waitFor(() => expect(href()).toBe('/skills-and-tools/
|
|
173
|
+
await waitFor(() => expect(href()).toBe('/skills-and-tools/plugins/GTM'));
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
it('marks a
|
|
177
|
-
|
|
176
|
+
it('marks a plugin the caller can change with an Owner badge', async () => {
|
|
177
|
+
pluginsMock.listPlugins.mockResolvedValue([summary({ canWrite: true })]);
|
|
178
178
|
renderIndex();
|
|
179
179
|
expect(await screen.findByRole('button', { name: /^GTM Owner/ })).toBeInTheDocument();
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
it('shows the amber count when a
|
|
183
|
-
|
|
182
|
+
it('shows the amber count when a plugin has integrations to set up', async () => {
|
|
183
|
+
pluginsMock.listPlugins.mockResolvedValue([
|
|
184
184
|
summary({
|
|
185
185
|
name: 'Yours',
|
|
186
|
-
folders: ['
|
|
186
|
+
folders: ['Plugins/Yours'],
|
|
187
187
|
}),
|
|
188
188
|
summary(),
|
|
189
189
|
]);
|
|
@@ -208,22 +208,22 @@ describe('GroupsIndexPage', () => {
|
|
|
208
208
|
expect(await screen.findByRole('button', { name: /^GTM .* 1$/ })).toBeInTheDocument();
|
|
209
209
|
});
|
|
210
210
|
|
|
211
|
-
it('lists a DISCOVERABLE locked
|
|
212
|
-
|
|
211
|
+
it('lists a DISCOVERABLE locked plugin under Request access, Locked or Requested', async () => {
|
|
212
|
+
pluginsMock.listPlugins.mockResolvedValue([
|
|
213
213
|
summary(),
|
|
214
|
-
summary({ name: 'Finance', folders: ['
|
|
214
|
+
summary({ name: 'Finance', folders: ['Plugins/Finance'], canRead: false, canWrite: false }),
|
|
215
215
|
]);
|
|
216
216
|
renderIndex();
|
|
217
|
-
expect(await screen.findByRole('heading', { name: '
|
|
217
|
+
expect(await screen.findByRole('heading', { name: 'Request access' })).toBeInTheDocument();
|
|
218
218
|
expect(screen.getByRole('button', { name: /^Finance/ })).toBeInTheDocument();
|
|
219
219
|
expect(screen.getByTitle('Locked')).toBeInTheDocument();
|
|
220
220
|
|
|
221
221
|
// Once the caller's join request is open, the chip says THAT instead —
|
|
222
222
|
// the one thing the row can tell you that you did not already know.
|
|
223
|
-
|
|
223
|
+
pluginsMock.listPlugins.mockResolvedValue([
|
|
224
224
|
summary({
|
|
225
225
|
name: 'Finance',
|
|
226
|
-
folders: ['
|
|
226
|
+
folders: ['Plugins/Finance'],
|
|
227
227
|
canRead: false,
|
|
228
228
|
canWrite: false,
|
|
229
229
|
hasRequested: true,
|
|
@@ -234,50 +234,50 @@ describe('GroupsIndexPage', () => {
|
|
|
234
234
|
expect(await screen.findByTitle('Requested')).toBeInTheDocument();
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
-
it('never lists a
|
|
238
|
-
// The backend only returns accessible
|
|
239
|
-
// on top: a
|
|
240
|
-
|
|
237
|
+
it('never lists a plugin the endpoint omitted (fail-closed: absent = invisible)', async () => {
|
|
238
|
+
// The backend only returns accessible plugins, and this page adds nothing
|
|
239
|
+
// on top: a plugin the caller cannot access has no row, no name, no counts.
|
|
240
|
+
pluginsMock.listPlugins.mockResolvedValue([summary()]);
|
|
241
241
|
renderIndex();
|
|
242
242
|
await screen.findByRole('button', { name: /^GTM/ });
|
|
243
243
|
expect(screen.queryByRole('button', { name: /^Finance/ })).not.toBeInTheDocument();
|
|
244
|
-
expect(screen.queryByRole('heading', { name: '
|
|
244
|
+
expect(screen.queryByRole('heading', { name: 'Request access' })).not.toBeInTheDocument();
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
it('lists a
|
|
247
|
+
it('lists a plugin an item grant reaches inside, even without a summary', async () => {
|
|
248
248
|
dataMock.useLibraryData.mockReturnValue({
|
|
249
249
|
...CATALOG,
|
|
250
|
-
skills: [{ name: 'budget', description: '', path: '
|
|
250
|
+
skills: [{ name: 'budget', description: '', path: 'Plugins/Finance/budget' }],
|
|
251
251
|
});
|
|
252
252
|
renderIndex();
|
|
253
253
|
expect(await screen.findByRole('button', { name: /^Finance/ })).toBeInTheDocument();
|
|
254
254
|
});
|
|
255
255
|
|
|
256
|
-
it('lists a catalog-derived
|
|
257
|
-
|
|
256
|
+
it('lists a catalog-derived plugin with counts alone when no summary vouches for it', async () => {
|
|
257
|
+
pluginsMock.listPlugins.mockResolvedValue([]);
|
|
258
258
|
renderIndex();
|
|
259
|
-
// One skill and one tool in
|
|
259
|
+
// One skill and one tool in Plugins/GTM, and nothing claiming to know who
|
|
260
260
|
// runs it — so the row states what it can count, not what it cannot.
|
|
261
261
|
expect(await screen.findByRole('button', { name: 'GTM 1 skills · 1 tools' })).toBeInTheDocument();
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
-
it('offers a retry when the
|
|
265
|
-
|
|
264
|
+
it('offers a retry when the plugins endpoint fails, and keeps Yours', async () => {
|
|
265
|
+
pluginsMock.listPlugins.mockRejectedValue(new Error("Couldn't load plugins."));
|
|
266
266
|
renderIndex();
|
|
267
267
|
const banner = await screen.findByRole('alert');
|
|
268
|
-
expect(banner).toHaveTextContent("Couldn't load
|
|
268
|
+
expect(banner).toHaveTextContent("Couldn't load plugins.");
|
|
269
269
|
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
|
|
270
|
-
expect(screen.queryByRole('heading', { name: "
|
|
270
|
+
expect(screen.queryByRole('heading', { name: "Your plugins" })).not.toBeInTheDocument();
|
|
271
271
|
|
|
272
|
-
|
|
272
|
+
pluginsMock.listPlugins.mockResolvedValue([summary()]);
|
|
273
273
|
fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
|
|
274
274
|
expect(await screen.findByRole('button', { name: /^GTM/ })).toBeInTheDocument();
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
-
it('says it is loading before the first
|
|
278
|
-
|
|
277
|
+
it('says it is loading before the first plugin index arrives', () => {
|
|
278
|
+
pluginsMock.listPlugins.mockReturnValue(new Promise(() => {}));
|
|
279
279
|
renderIndex();
|
|
280
|
-
expect(screen.getByText('Loading
|
|
280
|
+
expect(screen.getByText('Loading plugins…')).toBeInTheDocument();
|
|
281
281
|
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
|
|
282
282
|
});
|
|
283
283
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { render, screen, fireEvent, createEvent } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import { PluginsSidebar, type PluginsSidebarProps } from '../components/PluginsSidebar';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Right-click in the Library nav, which has to answer the gesture the way
|
|
@@ -10,50 +10,50 @@ import { GroupsSidebar, type GroupsSidebarProps } from '../components/GroupsSide
|
|
|
10
10
|
* The sidebar itself only REPORTS the click: it suppresses the browser menu,
|
|
11
11
|
* reads the pointer and the row synchronously, and hands both up. Everything
|
|
12
12
|
* about which verbs are true for a given row lives in `LibraryLayout`, because
|
|
13
|
-
* that is where the
|
|
13
|
+
* that is where the plugin summaries are — so that is where those assertions
|
|
14
14
|
* live too.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
function renderSidebar(over: Partial<
|
|
17
|
+
function renderSidebar(over: Partial<PluginsSidebarProps> = {}) {
|
|
18
18
|
const onContextMenu = vi.fn();
|
|
19
19
|
const onSelect = vi.fn();
|
|
20
|
-
const props:
|
|
20
|
+
const props: PluginsSidebarProps = {
|
|
21
21
|
filter: { kind: 'all' },
|
|
22
22
|
onSelect,
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
{
|
|
23
|
+
plugins: [
|
|
24
|
+
{ plugin: 'Engineering', count: 4, attention: 0 },
|
|
25
|
+
{ plugin: 'GTM', count: 3, attention: 2 },
|
|
26
26
|
],
|
|
27
|
-
|
|
27
|
+
lockedPlugins: ['Finance'],
|
|
28
28
|
ownedCount: 2,
|
|
29
29
|
ownedAttention: 0,
|
|
30
|
-
|
|
30
|
+
personalPluginLabel: "Juan's Plugin",
|
|
31
31
|
ungroupedCount: 1,
|
|
32
32
|
attentionCount: 2,
|
|
33
33
|
onFinishSetup: vi.fn(),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
onCreatePlugin: vi.fn(),
|
|
35
|
+
pluginsIndexActive: false,
|
|
36
|
+
onOpenPluginsIndex: vi.fn(),
|
|
37
37
|
onContextMenu,
|
|
38
38
|
...over,
|
|
39
39
|
};
|
|
40
|
-
render(<
|
|
40
|
+
render(<PluginsSidebar {...props} />);
|
|
41
41
|
return { onContextMenu, onSelect };
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const nav = () => screen.getByRole('navigation', { name: 'Library
|
|
44
|
+
const nav = () => screen.getByRole('navigation', { name: 'Library plugins' });
|
|
45
45
|
const rightClick = (el: Element, at = { clientX: 120, clientY: 240 }) =>
|
|
46
46
|
fireEvent.contextMenu(el, at);
|
|
47
47
|
|
|
48
|
-
describe('
|
|
49
|
-
it('reports a
|
|
48
|
+
describe('PluginsSidebar: right-click', () => {
|
|
49
|
+
it('reports a plugin row with its filter, its name and the pointer', () => {
|
|
50
50
|
const { onContextMenu } = renderSidebar();
|
|
51
51
|
const gtm = screen.getByRole('button', { name: /^GTM/ });
|
|
52
52
|
rightClick(gtm, { clientX: 88, clientY: 310 });
|
|
53
53
|
|
|
54
54
|
expect(onContextMenu).toHaveBeenCalledTimes(1);
|
|
55
55
|
expect(onContextMenu).toHaveBeenCalledWith({
|
|
56
|
-
filter: { kind: 'group',
|
|
56
|
+
filter: { kind: 'group', plugin: 'GTM' },
|
|
57
57
|
label: 'GTM',
|
|
58
58
|
x: 88,
|
|
59
59
|
y: 310,
|
|
@@ -70,24 +70,24 @@ describe('GroupsSidebar: right-click', () => {
|
|
|
70
70
|
label: 'Owned by me',
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
rightClick(screen.getByRole('button', { name: /^Juan's
|
|
73
|
+
rightClick(screen.getByRole('button', { name: /^Juan's Plugin/ }));
|
|
74
74
|
expect(onContextMenu.mock.calls[1][0]).toMatchObject({
|
|
75
75
|
filter: { kind: 'ungrouped' },
|
|
76
|
-
label: "Juan's
|
|
76
|
+
label: "Juan's Plugin",
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* A locked row emits the same `{ kind: 'group' }` target a readable one does,
|
|
82
|
-
* for the same reason its CLICK does: a
|
|
82
|
+
* for the same reason its CLICK does: a plugin you are not in is still a place.
|
|
83
83
|
* The label drops the "(locked)" suffix — that is the accessible name, not the
|
|
84
|
-
*
|
|
84
|
+
* plugin's name, and the menu titles itself with the latter.
|
|
85
85
|
*/
|
|
86
|
-
it('reports a locked row exactly like a readable
|
|
86
|
+
it('reports a locked row exactly like a readable plugin', () => {
|
|
87
87
|
const { onContextMenu } = renderSidebar();
|
|
88
88
|
rightClick(screen.getByRole('button', { name: 'Finance (locked)' }));
|
|
89
89
|
expect(onContextMenu.mock.calls[0][0]).toMatchObject({
|
|
90
|
-
filter: { kind: 'group',
|
|
90
|
+
filter: { kind: 'group', plugin: 'Finance' },
|
|
91
91
|
label: 'Finance',
|
|
92
92
|
});
|
|
93
93
|
});
|
|
@@ -95,16 +95,16 @@ describe('GroupsSidebar: right-click', () => {
|
|
|
95
95
|
/**
|
|
96
96
|
* The home row has no `LibraryFilter` behind it — the index lists places, not
|
|
97
97
|
* a slice of the catalog — so it reports `null` and gets the nav's own menu:
|
|
98
|
-
* create a
|
|
98
|
+
* create a plugin, and none of the verbs that need a folder to point at.
|
|
99
99
|
*/
|
|
100
|
-
it('reports the All
|
|
100
|
+
it('reports the All plugins row with no filter, but with its own row and name', () => {
|
|
101
101
|
const { onContextMenu } = renderSidebar();
|
|
102
|
-
const home = screen.getByRole('button', { name: 'All
|
|
102
|
+
const home = screen.getByRole('button', { name: 'All plugins' });
|
|
103
103
|
rightClick(home);
|
|
104
104
|
expect(onContextMenu).toHaveBeenCalledTimes(1);
|
|
105
105
|
expect(onContextMenu.mock.calls[0][0]).toMatchObject({
|
|
106
106
|
filter: null,
|
|
107
|
-
label: 'All
|
|
107
|
+
label: 'All plugins',
|
|
108
108
|
row: home,
|
|
109
109
|
});
|
|
110
110
|
});
|
|
@@ -123,14 +123,14 @@ describe('GroupsSidebar: right-click', () => {
|
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* The nav wraps every row, so without `stopPropagation` a right-click on a
|
|
126
|
-
*
|
|
126
|
+
* plugin would report the plugin AND then the empty space — and the layout
|
|
127
127
|
* would render the empty-space menu, since the last call wins.
|
|
128
128
|
*/
|
|
129
129
|
it('does not also report the nav when the click landed on a row', () => {
|
|
130
130
|
const { onContextMenu } = renderSidebar();
|
|
131
131
|
rightClick(screen.getByRole('button', { name: /^Engineering/ }));
|
|
132
132
|
expect(onContextMenu).toHaveBeenCalledTimes(1);
|
|
133
|
-
expect(onContextMenu.mock.calls[0][0].filter).toEqual({ kind: 'group',
|
|
133
|
+
expect(onContextMenu.mock.calls[0][0].filter).toEqual({ kind: 'group', plugin: 'Engineering' });
|
|
134
134
|
});
|
|
135
135
|
|
|
136
136
|
it('suppresses the browser menu when the click is being handled', () => {
|
|
@@ -156,12 +156,12 @@ describe('GroupsSidebar: right-click', () => {
|
|
|
156
156
|
it('still navigates on a left click. The menu changes nothing about selection', () => {
|
|
157
157
|
const { onSelect, onContextMenu } = renderSidebar();
|
|
158
158
|
fireEvent.click(screen.getByRole('button', { name: /^GTM/ }));
|
|
159
|
-
expect(onSelect).toHaveBeenCalledWith({ kind: 'group',
|
|
159
|
+
expect(onSelect).toHaveBeenCalledWith({ kind: 'group', plugin: 'GTM' });
|
|
160
160
|
expect(onContextMenu).not.toHaveBeenCalled();
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
it('marks the current row from the target it navigates to', () => {
|
|
164
|
-
renderSidebar({ filter: { kind: 'group',
|
|
164
|
+
renderSidebar({ filter: { kind: 'group', plugin: 'GTM' } });
|
|
165
165
|
expect(screen.getByRole('button', { name: /^GTM/ })).toHaveAttribute('aria-current', 'true');
|
|
166
166
|
expect(screen.getByRole('button', { name: /^Engineering/ })).toHaveAttribute(
|
|
167
167
|
'aria-current',
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest';
|
|
2
2
|
import { render, screen, fireEvent, within } from '@testing-library/react';
|
|
3
|
-
import {
|
|
3
|
+
import { PluginsSidebar, type PluginsSidebarProps } from '../components/PluginsSidebar';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* The locked half of the nav:
|
|
6
|
+
* The locked half of the nav: plugins the caller cannot read still appear, below
|
|
7
7
|
* a break, with a lock where a count would be.
|
|
8
8
|
*
|
|
9
9
|
* Locked selection is a URL like any other — a locked row emits the SAME
|
|
10
|
-
* `{ kind: 'group' }` intent as a readable one, and the
|
|
11
|
-
* view the caller gets. That is deliberate: one route per
|
|
12
|
-
*
|
|
10
|
+
* `{ kind: 'group' }` intent as a readable one, and the plugin page decides which
|
|
11
|
+
* view the caller gets. That is deliberate: one route per plugin means a locked
|
|
12
|
+
* plugin can be linked to and bookmarked, and unlocking one changes nothing about
|
|
13
13
|
* where it lives.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
function renderSidebar(over: Partial<
|
|
16
|
+
function renderSidebar(over: Partial<PluginsSidebarProps> = {}) {
|
|
17
17
|
const onSelect = vi.fn();
|
|
18
|
-
const props:
|
|
18
|
+
const props: PluginsSidebarProps = {
|
|
19
19
|
filter: { kind: 'all' },
|
|
20
20
|
onSelect,
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
{
|
|
21
|
+
plugins: [
|
|
22
|
+
{ plugin: 'Engineering', count: 4, attention: 0 },
|
|
23
|
+
{ plugin: 'GTM', count: 3, attention: 2 },
|
|
24
24
|
],
|
|
25
|
-
|
|
25
|
+
lockedPlugins: ['Finance', 'Legal'],
|
|
26
26
|
ownedCount: 2,
|
|
27
27
|
ownedAttention: 0,
|
|
28
|
-
|
|
28
|
+
personalPluginLabel: "Juan's Plugin",
|
|
29
29
|
ungroupedCount: 1,
|
|
30
30
|
attentionCount: 2,
|
|
31
31
|
onFinishSetup: vi.fn(),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
onCreatePlugin: vi.fn(),
|
|
33
|
+
pluginsIndexActive: false,
|
|
34
|
+
onOpenPluginsIndex: vi.fn(),
|
|
35
35
|
|
|
36
36
|
...over,
|
|
37
37
|
};
|
|
38
|
-
render(<
|
|
38
|
+
render(<PluginsSidebar {...props} />);
|
|
39
39
|
return { onSelect };
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const nav = () => screen.getByRole('navigation', { name: 'Library
|
|
42
|
+
const nav = () => screen.getByRole('navigation', { name: 'Library plugins' });
|
|
43
43
|
|
|
44
|
-
describe('
|
|
44
|
+
describe('PluginsSidebar: locked plugins', () => {
|
|
45
45
|
it('names a locked row by its state, with no count in it', () => {
|
|
46
46
|
renderSidebar();
|
|
47
47
|
const finance = screen.getByRole('button', { name: 'Finance (locked)' });
|
|
@@ -51,18 +51,18 @@ describe('GroupsSidebar: locked groups', () => {
|
|
|
51
51
|
expect(finance.textContent).toBe('Finance');
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
it('puts the locked rows last, after every
|
|
54
|
+
it('puts the locked rows last, after every plugin the caller is in', () => {
|
|
55
55
|
renderSidebar();
|
|
56
56
|
const labels = within(nav())
|
|
57
57
|
.getAllByRole('button')
|
|
58
58
|
.map((b) => b.getAttribute('aria-label') ?? b.textContent);
|
|
59
59
|
expect(labels).toEqual([
|
|
60
|
-
'All
|
|
60
|
+
'All plugins',
|
|
61
61
|
'Everything',
|
|
62
62
|
'Owned by me2',
|
|
63
|
-
'New
|
|
64
|
-
// Your own space leads the
|
|
65
|
-
"Juan's
|
|
63
|
+
'New plugin',
|
|
64
|
+
// Your own space leads the plugins; the ones you cannot enter trail them.
|
|
65
|
+
"Juan's Plugin1",
|
|
66
66
|
'Engineering4',
|
|
67
67
|
'GTM2',
|
|
68
68
|
'Finance (locked)',
|
|
@@ -70,14 +70,14 @@ describe('GroupsSidebar: locked groups', () => {
|
|
|
70
70
|
]);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
it('navigates to the
|
|
73
|
+
it('navigates to the plugin route on click, exactly like a readable plugin', () => {
|
|
74
74
|
const { onSelect } = renderSidebar();
|
|
75
75
|
fireEvent.click(screen.getByRole('button', { name: 'Finance (locked)' }));
|
|
76
|
-
expect(onSelect).toHaveBeenCalledWith({ kind: 'group',
|
|
76
|
+
expect(onSelect).toHaveBeenCalledWith({ kind: 'group', plugin: 'Finance' });
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
it('marks the locked row current when its
|
|
80
|
-
renderSidebar({ filter: { kind: 'group',
|
|
79
|
+
it('marks the locked row current when its plugin is the route', () => {
|
|
80
|
+
renderSidebar({ filter: { kind: 'group', plugin: 'Finance' } });
|
|
81
81
|
expect(screen.getByRole('button', { name: 'Finance (locked)' })).toHaveAttribute(
|
|
82
82
|
'aria-current',
|
|
83
83
|
'true',
|
|
@@ -89,7 +89,7 @@ describe('GroupsSidebar: locked groups', () => {
|
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it('renders no locked section at all when nothing is locked', () => {
|
|
92
|
-
renderSidebar({
|
|
92
|
+
renderSidebar({ lockedPlugins: [] });
|
|
93
93
|
expect(screen.queryByRole('button', { name: /\(locked\)$/ })).not.toBeInTheDocument();
|
|
94
94
|
expect(screen.getByRole('button', { name: /^GTM/ })).toBeInTheDocument();
|
|
95
95
|
});
|