@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
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
-
import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
|
|
4
|
-
import type { LibraryData } from '../hooks/useLibraryData';
|
|
5
|
-
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
6
|
-
import type { GroupSummary } from '../services/groups.api';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The all-groups index: which section a group lands in, what each row says, and
|
|
10
|
-
* where it goes. The locked section is the reason this page exists, so most of
|
|
11
|
-
* what is asserted here is about groups the caller cannot enter.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const dataMock = vi.hoisted(() => ({ useLibraryData: vi.fn() }));
|
|
15
|
-
vi.mock('../hooks/useLibraryData', () => ({ useLibraryData: dataMock.useLibraryData }));
|
|
16
|
-
|
|
17
|
-
const groupsMock = vi.hoisted(() => ({ listGroups: vi.fn(), listJoinRequests: vi.fn() }));
|
|
18
|
-
vi.mock('../services/groups.api', () => ({
|
|
19
|
-
listGroups: groupsMock.listGroups,
|
|
20
|
-
// The page carries the managers' join-request banners now — it is where the
|
|
21
|
-
// Library lands, so it is where an unanswered request is certain to be seen.
|
|
22
|
-
listJoinRequests: groupsMock.listJoinRequests,
|
|
23
|
-
reconcileJoinRequest: vi.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
import { LibraryProvider } from '../state/library-data';
|
|
27
|
-
import {
|
|
28
|
-
WorkspaceContext,
|
|
29
|
-
type WorkspaceContextValue,
|
|
30
|
-
} from '../../workspace/state/workspace.context';
|
|
31
|
-
import { GroupsIndexPage } from '../components/GroupsIndexPage';
|
|
32
|
-
import { withAuth, TEST_PERSONAL_GROUP } from './auth-harness';
|
|
33
|
-
|
|
34
|
-
const tool = (over: Partial<ToolSecrets> = {}): ToolSecrets => ({
|
|
35
|
-
slug: 'heyreach',
|
|
36
|
-
name: 'heyreach',
|
|
37
|
-
path: 'Groups/GTM/heyreach.tool',
|
|
38
|
-
type: 'inline',
|
|
39
|
-
setup: null,
|
|
40
|
-
canWrite: false,
|
|
41
|
-
variables: [],
|
|
42
|
-
...over,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const CATALOG: LibraryData = {
|
|
46
|
-
loading: false,
|
|
47
|
-
error: null,
|
|
48
|
-
skills: [
|
|
49
|
-
{ name: 'outreach', description: '', path: 'Groups/GTM/outreach' },
|
|
50
|
-
{ name: 'scratch', description: '', path: 'Skills/scratch' },
|
|
51
|
-
],
|
|
52
|
-
pendingSkills: [],
|
|
53
|
-
tools: [
|
|
54
|
-
tool(),
|
|
55
|
-
// An ungrouped sign-in — `Tools/slack.tool` is two segments, so no group.
|
|
56
|
-
tool({
|
|
57
|
-
slug: 'slack',
|
|
58
|
-
name: 'slack',
|
|
59
|
-
path: 'Tools/slack.tool',
|
|
60
|
-
variables: [
|
|
61
|
-
{
|
|
62
|
-
name: 'API_KEY',
|
|
63
|
-
scope: 'user',
|
|
64
|
-
label: null,
|
|
65
|
-
key: 'slack_API_KEY',
|
|
66
|
-
adminConfigured: false,
|
|
67
|
-
userConfigured: false,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
}),
|
|
71
|
-
],
|
|
72
|
-
ownedSkills: new Set(['outreach']),
|
|
73
|
-
allowedToolsBySkill: new Map(),
|
|
74
|
-
crs: [],
|
|
75
|
-
myCrNumbers: new Set<number>(),
|
|
76
|
-
reload: vi.fn(),
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const summary = (over: Partial<GroupSummary> = {}): GroupSummary => ({
|
|
80
|
-
name: 'GTM',
|
|
81
|
-
folders: ['Groups/GTM'],
|
|
82
|
-
canRead: true,
|
|
83
|
-
canWrite: false,
|
|
84
|
-
isOwner: false,
|
|
85
|
-
skillCount: 4,
|
|
86
|
-
toolCount: 2,
|
|
87
|
-
owners: { roles: [], users: [{ name: 'Olga Ivanova', email: 'olga@bevel.software' }] },
|
|
88
|
-
writers: { roles: ['Admin'], users: [] },
|
|
89
|
-
readers: { restricted: true, roles: ['GTM Team'], users: [] },
|
|
90
|
-
hasRequested: false,
|
|
91
|
-
requestNumber: null,
|
|
92
|
-
...over,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
function LocationProbe() {
|
|
96
|
-
const location = useLocation();
|
|
97
|
-
return <div aria-label="href">{location.pathname + location.search}</div>;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** `kbDirName` is what the request banners' Manage-access affordance needs. */
|
|
101
|
-
const WORKSPACE = {
|
|
102
|
-
workspaceId: 'target-company-state',
|
|
103
|
-
kbDirName: 'knowledge-base',
|
|
104
|
-
} as unknown as WorkspaceContextValue;
|
|
105
|
-
|
|
106
|
-
function renderIndex() {
|
|
107
|
-
return render(
|
|
108
|
-
<MemoryRouter initialEntries={['/skills-and-tools']}>
|
|
109
|
-
{withAuth(
|
|
110
|
-
<WorkspaceContext.Provider value={WORKSPACE}>
|
|
111
|
-
<LibraryProvider>
|
|
112
|
-
<Routes>
|
|
113
|
-
<Route path="/skills-and-tools" element={<GroupsIndexPage />} />
|
|
114
|
-
<Route path="*" element={<div />} />
|
|
115
|
-
</Routes>
|
|
116
|
-
<LocationProbe />
|
|
117
|
-
</LibraryProvider>
|
|
118
|
-
</WorkspaceContext.Provider>,
|
|
119
|
-
)}
|
|
120
|
-
</MemoryRouter>,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const href = () => screen.getByLabelText('href').textContent;
|
|
125
|
-
const row = (name: RegExp | string) => screen.getByRole('button', { name });
|
|
126
|
-
|
|
127
|
-
describe('GroupsIndexPage', () => {
|
|
128
|
-
beforeEach(() => {
|
|
129
|
-
dataMock.useLibraryData.mockReturnValue(CATALOG);
|
|
130
|
-
groupsMock.listGroups.mockResolvedValue([summary()]);
|
|
131
|
-
groupsMock.listJoinRequests.mockResolvedValue([]);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('names itself and its two sections', async () => {
|
|
135
|
-
renderIndex();
|
|
136
|
-
expect(await screen.findByRole('heading', { name: 'All groups', level: 1 })).toBeInTheDocument();
|
|
137
|
-
expect(
|
|
138
|
-
screen.getByText('A group carries skills and tools for the people in it.'),
|
|
139
|
-
).toBeInTheDocument();
|
|
140
|
-
expect(screen.getByRole('heading', { name: 'Yours' })).toBeInTheDocument();
|
|
141
|
-
expect(await screen.findByRole('heading', { name: "Groups you're in" })).toBeInTheDocument();
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it("offers the caller's own group under Yours, and opens it", async () => {
|
|
145
|
-
renderIndex();
|
|
146
|
-
expect(
|
|
147
|
-
await screen.findByText('Your sign-ins and the skills no group carries'),
|
|
148
|
-
).toBeInTheDocument();
|
|
149
|
-
// The lens is gone from this page — it lives in the sidebar.
|
|
150
|
-
expect(screen.queryByText('The skills you answer for')).not.toBeInTheDocument();
|
|
151
|
-
fireEvent.click(row(new RegExp(`^${TEST_PERSONAL_GROUP}`)));
|
|
152
|
-
await waitFor(() => expect(href()).toBe('/skills-and-tools/yours'));
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("keeps the caller's own group listed even when nothing sits outside a group", async () => {
|
|
156
|
-
dataMock.useLibraryData.mockReturnValue({
|
|
157
|
-
...CATALOG,
|
|
158
|
-
skills: [{ name: 'outreach', description: '', path: 'Groups/GTM/outreach' }],
|
|
159
|
-
tools: [tool()],
|
|
160
|
-
});
|
|
161
|
-
renderIndex();
|
|
162
|
-
await screen.findByRole('heading', { name: 'All groups', level: 1 });
|
|
163
|
-
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
|
|
164
|
-
// And never the lens: "Owned by me" is a view across groups, not a group.
|
|
165
|
-
expect(screen.queryByRole('button', { name: /^Owned by me/ })).not.toBeInTheDocument();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("puts a readable group under Groups you're in, with its run-by line and totals", async () => {
|
|
169
|
-
renderIndex();
|
|
170
|
-
const gtm = await screen.findByRole('button', { name: /^GTM/ });
|
|
171
|
-
expect(gtm).toHaveAccessibleName('GTM Run by Olga Ivanova 4 skills · 2 tools');
|
|
172
|
-
fireEvent.click(gtm);
|
|
173
|
-
await waitFor(() => expect(href()).toBe('/skills-and-tools/groups/GTM'));
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('marks a group the caller can change with an Owner badge', async () => {
|
|
177
|
-
groupsMock.listGroups.mockResolvedValue([summary({ canWrite: true })]);
|
|
178
|
-
renderIndex();
|
|
179
|
-
expect(await screen.findByRole('button', { name: /^GTM Owner/ })).toBeInTheDocument();
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('shows the amber count when a group has integrations to set up', async () => {
|
|
183
|
-
groupsMock.listGroups.mockResolvedValue([
|
|
184
|
-
summary({
|
|
185
|
-
name: 'Yours',
|
|
186
|
-
folders: ['Groups/Yours'],
|
|
187
|
-
}),
|
|
188
|
-
summary(),
|
|
189
|
-
]);
|
|
190
|
-
dataMock.useLibraryData.mockReturnValue({
|
|
191
|
-
...CATALOG,
|
|
192
|
-
tools: [
|
|
193
|
-
tool({
|
|
194
|
-
variables: [
|
|
195
|
-
{
|
|
196
|
-
name: 'API_KEY',
|
|
197
|
-
scope: 'user',
|
|
198
|
-
label: null,
|
|
199
|
-
key: 'heyreach_API_KEY',
|
|
200
|
-
adminConfigured: false,
|
|
201
|
-
userConfigured: false,
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
}),
|
|
205
|
-
],
|
|
206
|
-
});
|
|
207
|
-
renderIndex();
|
|
208
|
-
expect(await screen.findByRole('button', { name: /^GTM .* 1$/ })).toBeInTheDocument();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('lists a DISCOVERABLE locked group under Ask to join, Locked or Requested', async () => {
|
|
212
|
-
groupsMock.listGroups.mockResolvedValue([
|
|
213
|
-
summary(),
|
|
214
|
-
summary({ name: 'Finance', folders: ['Groups/Finance'], canRead: false, canWrite: false }),
|
|
215
|
-
]);
|
|
216
|
-
renderIndex();
|
|
217
|
-
expect(await screen.findByRole('heading', { name: 'Ask to join' })).toBeInTheDocument();
|
|
218
|
-
expect(screen.getByRole('button', { name: /^Finance/ })).toBeInTheDocument();
|
|
219
|
-
expect(screen.getByTitle('Locked')).toBeInTheDocument();
|
|
220
|
-
|
|
221
|
-
// Once the caller's join request is open, the chip says THAT instead —
|
|
222
|
-
// the one thing the row can tell you that you did not already know.
|
|
223
|
-
groupsMock.listGroups.mockResolvedValue([
|
|
224
|
-
summary({
|
|
225
|
-
name: 'Finance',
|
|
226
|
-
folders: ['Groups/Finance'],
|
|
227
|
-
canRead: false,
|
|
228
|
-
canWrite: false,
|
|
229
|
-
hasRequested: true,
|
|
230
|
-
requestNumber: 9,
|
|
231
|
-
}),
|
|
232
|
-
]);
|
|
233
|
-
renderIndex();
|
|
234
|
-
expect(await screen.findByTitle('Requested')).toBeInTheDocument();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('never lists a group the endpoint omitted (fail-closed: absent = invisible)', async () => {
|
|
238
|
-
// The backend only returns accessible groups, and this page adds nothing
|
|
239
|
-
// on top: a group the caller cannot access has no row, no name, no counts.
|
|
240
|
-
groupsMock.listGroups.mockResolvedValue([summary()]);
|
|
241
|
-
renderIndex();
|
|
242
|
-
await screen.findByRole('button', { name: /^GTM/ });
|
|
243
|
-
expect(screen.queryByRole('button', { name: /^Finance/ })).not.toBeInTheDocument();
|
|
244
|
-
expect(screen.queryByRole('heading', { name: 'Ask to join' })).not.toBeInTheDocument();
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('lists a group an item grant reaches inside, even without a summary', async () => {
|
|
248
|
-
dataMock.useLibraryData.mockReturnValue({
|
|
249
|
-
...CATALOG,
|
|
250
|
-
skills: [{ name: 'budget', description: '', path: 'Groups/Finance/budget' }],
|
|
251
|
-
});
|
|
252
|
-
renderIndex();
|
|
253
|
-
expect(await screen.findByRole('button', { name: /^Finance/ })).toBeInTheDocument();
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
it('lists a catalog-derived group with counts alone when no summary vouches for it', async () => {
|
|
257
|
-
groupsMock.listGroups.mockResolvedValue([]);
|
|
258
|
-
renderIndex();
|
|
259
|
-
// One skill and one tool in Groups/GTM, and nothing claiming to know who
|
|
260
|
-
// runs it — so the row states what it can count, not what it cannot.
|
|
261
|
-
expect(await screen.findByRole('button', { name: 'GTM 1 skills · 1 tools' })).toBeInTheDocument();
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('offers a retry when the groups endpoint fails, and keeps Yours', async () => {
|
|
265
|
-
groupsMock.listGroups.mockRejectedValue(new Error("Couldn't load groups."));
|
|
266
|
-
renderIndex();
|
|
267
|
-
const banner = await screen.findByRole('alert');
|
|
268
|
-
expect(banner).toHaveTextContent("Couldn't load groups.");
|
|
269
|
-
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
|
|
270
|
-
expect(screen.queryByRole('heading', { name: "Groups you're in" })).not.toBeInTheDocument();
|
|
271
|
-
|
|
272
|
-
groupsMock.listGroups.mockResolvedValue([summary()]);
|
|
273
|
-
fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
|
|
274
|
-
expect(await screen.findByRole('button', { name: /^GTM/ })).toBeInTheDocument();
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('says it is loading before the first group index arrives', () => {
|
|
278
|
-
groupsMock.listGroups.mockReturnValue(new Promise(() => {}));
|
|
279
|
-
renderIndex();
|
|
280
|
-
expect(screen.getByText('Loading groups…')).toBeInTheDocument();
|
|
281
|
-
expect(screen.getByRole('button', { name: new RegExp(`^${TEST_PERSONAL_GROUP}`) })).toBeInTheDocument();
|
|
282
|
-
});
|
|
283
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, type Mock } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, cleanup } from '@testing-library/react';
|
|
3
|
-
import { GroupsSidebar, type GroupsSidebarProps } from '../components/GroupsSidebar';
|
|
4
|
-
import type { LibraryFilter } from '../utils/status';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The sidebar as a pure view: given a filter and counts, which row is current,
|
|
8
|
-
* what its count slot says, and which intent a click emits. It owns no state
|
|
9
|
-
* and no navigation, so nothing here needs a router.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
function renderSidebar(over: Partial<GroupsSidebarProps> = {}) {
|
|
13
|
-
const onSelect = vi.fn();
|
|
14
|
-
const onFinishSetup = vi.fn();
|
|
15
|
-
const props: GroupsSidebarProps = {
|
|
16
|
-
filter: { kind: 'all' },
|
|
17
|
-
onSelect,
|
|
18
|
-
groups: [
|
|
19
|
-
{ group: 'Engineering', count: 4, attention: 0 },
|
|
20
|
-
{ group: 'GTM', count: 3, attention: 2 },
|
|
21
|
-
{ group: 'Product', count: 0, attention: 0 },
|
|
22
|
-
],
|
|
23
|
-
lockedGroups: [],
|
|
24
|
-
ownedCount: 2,
|
|
25
|
-
ownedAttention: 0,
|
|
26
|
-
personalGroupLabel: "Juan's Group",
|
|
27
|
-
ungroupedCount: 1,
|
|
28
|
-
attentionCount: 2,
|
|
29
|
-
onFinishSetup,
|
|
30
|
-
onCreateGroup: vi.fn(),
|
|
31
|
-
groupsIndexActive: false,
|
|
32
|
-
onOpenGroupsIndex: vi.fn(),
|
|
33
|
-
|
|
34
|
-
...over,
|
|
35
|
-
};
|
|
36
|
-
render(<GroupsSidebar {...props} />);
|
|
37
|
-
return {
|
|
38
|
-
onSelect,
|
|
39
|
-
onFinishSetup,
|
|
40
|
-
onCreateGroup: props.onCreateGroup as Mock,
|
|
41
|
-
onOpenGroupsIndex: props.onOpenGroupsIndex as Mock,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const row = (name: RegExp | string) => screen.getByRole('button', { name });
|
|
46
|
-
|
|
47
|
-
describe('GroupsSidebar', () => {
|
|
48
|
-
it('leads with All groups. The Library opens there, so the nav starts there', () => {
|
|
49
|
-
const { onOpenGroupsIndex } = renderSidebar();
|
|
50
|
-
const rows = screen.getAllByRole('button');
|
|
51
|
-
expect(rows[0]).toHaveAccessibleName('All groups');
|
|
52
|
-
fireEvent.click(rows[0]);
|
|
53
|
-
expect(onOpenGroupsIndex).toHaveBeenCalledTimes(1);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('marks All groups current on the index, and nothing else', () => {
|
|
57
|
-
renderSidebar({ filter: null, groupsIndexActive: true });
|
|
58
|
-
expect(row(/^All groups/)).toHaveAttribute('aria-current', 'true');
|
|
59
|
-
expect(row(/^Everything/)).toHaveAttribute('aria-current', 'false');
|
|
60
|
-
expect(row(/^Owned by me/)).toHaveAttribute('aria-current', 'false');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('keeps Everything as a lens of its own, since the root is the index now', () => {
|
|
64
|
-
renderSidebar({ filter: { kind: 'all' } });
|
|
65
|
-
expect(row(/^Everything/)).toHaveAttribute('aria-current', 'true');
|
|
66
|
-
expect(row(/^All groups/)).toHaveAttribute('aria-current', 'false');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('heads the group rows with what the list is: the set in your MCP', () => {
|
|
70
|
-
renderSidebar();
|
|
71
|
-
expect(screen.getByText('Included in your MCP')).toBeInTheDocument();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("leads the groups with the caller's own space", () => {
|
|
75
|
-
renderSidebar({ filter: { kind: 'ungrouped' } });
|
|
76
|
-
expect(row(/^Juan's Group/)).toHaveAttribute('aria-current', 'true');
|
|
77
|
-
expect(row(/^Owned by me/)).toHaveAttribute('aria-current', 'false');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('offers a way to make a group', () => {
|
|
81
|
-
const { onCreateGroup } = renderSidebar();
|
|
82
|
-
fireEvent.click(screen.getByRole('button', { name: 'New group' }));
|
|
83
|
-
expect(onCreateGroup).toHaveBeenCalledTimes(1);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('marks the selected group current and leaves the others alone', () => {
|
|
87
|
-
renderSidebar({ filter: { kind: 'group', group: 'GTM' } });
|
|
88
|
-
expect(row(/^GTM/)).toHaveAttribute('aria-current', 'true');
|
|
89
|
-
expect(row(/^Engineering/)).toHaveAttribute('aria-current', 'false');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('shows the attention count instead of the item count when something needs setup', () => {
|
|
93
|
-
renderSidebar();
|
|
94
|
-
// GTM: 3 items but 2 integrations need setup — amber wins the slot.
|
|
95
|
-
expect(row(/^GTM/)).toHaveAccessibleName('GTM 2');
|
|
96
|
-
expect(row(/^Engineering/)).toHaveAccessibleName('Engineering 4');
|
|
97
|
-
// Never a grey 0: an empty group shows no count at all.
|
|
98
|
-
expect(row(/^Product/)).toHaveAccessibleName('Product');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('emits the right LibraryFilter per row', () => {
|
|
102
|
-
const { onSelect } = renderSidebar();
|
|
103
|
-
const expected: [RegExp, LibraryFilter][] = [
|
|
104
|
-
[/^Everything/, { kind: 'all' }],
|
|
105
|
-
[/^Owned by me/, { kind: 'owned' }],
|
|
106
|
-
[/^GTM/, { kind: 'group', group: 'GTM' }],
|
|
107
|
-
[/^Juan's Group/, { kind: 'ungrouped' }],
|
|
108
|
-
];
|
|
109
|
-
for (const [name, filter] of expected) {
|
|
110
|
-
onSelect.mockClear();
|
|
111
|
-
fireEvent.click(row(name));
|
|
112
|
-
expect(onSelect).toHaveBeenCalledWith(filter);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("keeps the caller's own group listed even when it is empty", () => {
|
|
117
|
-
// It is a PLACE, not a filtered view: a group you are always in does not
|
|
118
|
-
// vanish because you have not put anything in it yet.
|
|
119
|
-
renderSidebar({ ungroupedCount: 0 });
|
|
120
|
-
expect(row(/^Juan's Group/)).toBeInTheDocument();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('shows the owned count in grey, and amber only when something waits on you', () => {
|
|
124
|
-
renderSidebar({ ownedCount: 26, ownedAttention: 0 });
|
|
125
|
-
expect(row(/^Owned by me/)).toHaveAccessibleName('Owned by me 26');
|
|
126
|
-
|
|
127
|
-
cleanup();
|
|
128
|
-
renderSidebar({ ownedCount: 26, ownedAttention: 1 });
|
|
129
|
-
expect(row(/^Owned by me/)).toHaveAccessibleName('Owned by me 1');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('sends the setup footer to Connect', () => {
|
|
133
|
-
const { onFinishSetup } = renderSidebar();
|
|
134
|
-
fireEvent.click(row(/integrations need setup/));
|
|
135
|
-
expect(onFinishSetup).toHaveBeenCalledTimes(1);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('hides the setup footer when nothing needs setup', () => {
|
|
139
|
-
renderSidebar({ attentionCount: 0 });
|
|
140
|
-
expect(screen.queryByRole('button', { name: /needs? setup/ })).not.toBeInTheDocument();
|
|
141
|
-
});
|
|
142
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useJoinRequests } from '../hooks/useJoinRequests';
|
|
3
|
-
import { AccessRequestsBanner } from './AccessRequestsBanner';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* One group's join requests, fetching their own data.
|
|
7
|
-
*
|
|
8
|
-
* A component rather than a hook call in each page because the gallery shows
|
|
9
|
-
* a banner per group the caller manages, and a hook cannot be called in a
|
|
10
|
-
* loop. Rendering one of these per group keeps that legal and gives the group
|
|
11
|
-
* page the identical surface for free.
|
|
12
|
-
*
|
|
13
|
-
* Render it only for groups the caller MANAGES: the endpoint answers `[]` to
|
|
14
|
-
* everyone else, so an ungated render is harmless but pointlessly chatty.
|
|
15
|
-
*/
|
|
16
|
-
export interface GroupJoinRequestsProps {
|
|
17
|
-
group: string;
|
|
18
|
-
/** The group's constituent folders — for the Manage-access affordance. */
|
|
19
|
-
folders: string[];
|
|
20
|
-
onManage(folder: string): void;
|
|
21
|
-
/**
|
|
22
|
-
* Bump to refetch. The pages raise it after the Manage-access dialog
|
|
23
|
-
* closes: granting there can settle a request, and this surface would
|
|
24
|
-
* otherwise keep offering proposals that have already landed until its
|
|
25
|
-
* next natural fetch.
|
|
26
|
-
*/
|
|
27
|
-
reloadSignal?: number;
|
|
28
|
-
className?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function GroupJoinRequests({
|
|
32
|
-
group,
|
|
33
|
-
folders,
|
|
34
|
-
onManage,
|
|
35
|
-
reloadSignal = 0,
|
|
36
|
-
className,
|
|
37
|
-
}: GroupJoinRequestsProps) {
|
|
38
|
-
const requests = useJoinRequests(group, folders[0] ?? null);
|
|
39
|
-
const { reload } = requests;
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (reloadSignal > 0) reload();
|
|
43
|
-
}, [reloadSignal, reload]);
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<AccessRequestsBanner
|
|
47
|
-
group={group}
|
|
48
|
-
folders={folders}
|
|
49
|
-
requests={requests.requests}
|
|
50
|
-
onManage={onManage}
|
|
51
|
-
onAccept={(r, p) => void requests.accept(r, p)}
|
|
52
|
-
onDecline={(r) => void requests.decline(r)}
|
|
53
|
-
className={className}
|
|
54
|
-
/>
|
|
55
|
-
);
|
|
56
|
-
}
|