@bevel-software/platform-core-frontend 0.25.2 → 0.27.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/package.json +2 -2
- package/src/core/CoreAppShell.tsx +87 -25
- package/src/core/ProductName.tsx +49 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
- package/src/core/__tests__/core-contributions.test.ts +16 -0
- package/src/core/core-contributions.ts +17 -0
- package/src/core/registry.ts +51 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/components/ManageAccessDialog.tsx +1 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/auth/components/LoginScreen.tsx +4 -1
- package/src/modules/auth/services/account.api.ts +28 -1
- package/src/modules/auth/services/sso.ts +1 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
- package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
- package/src/modules/change-requests/services/change-requests.api.ts +15 -2
- package/src/modules/change-requests/utils/readFailure.ts +22 -0
- package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
- package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
- package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
- package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
- package/src/modules/embed/__tests__/mount.test.tsx +157 -0
- package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
- package/src/modules/embed/components/EmbedView.tsx +545 -0
- package/src/modules/embed/embed-config.ts +132 -0
- package/src/modules/embed/embed-host.ts +120 -0
- package/src/modules/embed/mount.tsx +80 -0
- package/src/modules/embed/services/embed-token.ts +22 -0
- package/src/modules/embed/services/embed.api.ts +158 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
- package/src/modules/git/branch-delete-menu-item.tsx +24 -0
- package/src/modules/git/components/BranchSwitcher.tsx +29 -5
- package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
- package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
- package/src/modules/git/components/PullNeededBanner.tsx +15 -49
- package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
- package/src/modules/git/index.ts +15 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
- package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
- package/src/modules/git/services/error-messages.ts +58 -1
- package/src/modules/git/services/pull-failure.ts +68 -0
- package/src/modules/git/state/branch-delete-confirm.ts +46 -0
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
- package/src/modules/layout/breakpoints.ts +8 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
- package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
- package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
- package/src/modules/library/__tests__/ToolPage.test.tsx +53 -0
- package/src/modules/library/components/LibraryPage.tsx +22 -0
- package/src/modules/library/components/PluginExtras.tsx +23 -6
- package/src/modules/library/components/PluginPage.tsx +6 -1
- package/src/modules/library/components/tool-page/ToolPage.tsx +45 -1
- package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- package/src/modules/library/services/tools.api.ts +27 -0
- package/src/modules/library/state/plugins-revision.ts +28 -0
- package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
- package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
- package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
- package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
- package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
- package/src/modules/onboarding/components/InviteButton.tsx +35 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
- package/src/modules/onboarding/components/RootLanding.tsx +8 -24
- package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
- package/src/modules/onboarding/first-page-prompt.ts +89 -0
- package/src/modules/onboarding/invite-emails.ts +175 -0
- package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
- package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
- package/src/modules/onboarding/state/agent-connection.ts +167 -0
- package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
- package/src/modules/onboarding/state/onboarding.ts +133 -59
- package/src/modules/onboarding/state/starter-packs.ts +169 -0
- package/src/modules/settings/settings-nav-items.tsx +8 -3
- package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
- package/src/modules/setup/__tests__/setup.test.tsx +65 -81
- package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
- package/src/modules/setup/components/SetupGate.tsx +46 -1
- package/src/modules/setup/components/SetupScreen.tsx +92 -152
- package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +3 -3
- package/src/modules/setup/utils/suggested-branch.ts +27 -0
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
- package/src/modules/toolbar/commands/actions.tsx +324 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
- package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
- package/src/modules/toolbar/components/Toolbar.tsx +10 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +4 -4
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
- package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
- package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
- package/src/modules/toolbar/search/rank.ts +111 -0
- package/src/modules/toolbar/search/sources.ts +169 -0
- package/src/modules/workflow/hooks/useFileLock.ts +10 -7
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
- package/src/modules/workflow/services/lock.api.ts +17 -2
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
- package/src/modules/workspace/components/EditorTabs.tsx +39 -15
- package/src/modules/workspace/components/FileExplorer.tsx +39 -6
- package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
- package/src/modules/workspace/components/FileRoute.tsx +12 -7
- package/src/modules/workspace/components/FileViewer.tsx +271 -74
- package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +101 -11
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
- package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
- package/src/modules/workspace/components/renderers/index.ts +26 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
- package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
- package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
- package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
- package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
- package/src/modules/workspace/routing/kb-routes.ts +66 -12
- package/src/modules/workspace/state/editable-page.ts +42 -0
- package/src/modules/workspace/state/workspace.context.ts +13 -4
- package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +26 -14
- package/src/modules/workspace/utils/display-file-name.ts +102 -0
- package/src/modules/workspace/utils/fileTree.ts +49 -14
- package/src/modules/workspace/utils/treeConfirm.ts +22 -5
- package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
- package/src/shared/components/ConfirmProvider.tsx +156 -0
- package/src/shared/components/Dialog.tsx +7 -0
- package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
- package/src/shared/components/confirm-context.ts +94 -0
- package/src/shared/components/index.ts +3 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +2 -2
- package/src/shared/mcp/connect-snippets.ts +8 -5
- package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { render, screen, within } from '@testing-library/react';
|
|
1
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
+
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { MemoryRouter, useLocation } from 'react-router-dom';
|
|
5
5
|
import { AppSwitcher } from '../AppSwitcher';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ActiveAppIdContext,
|
|
8
|
+
AppRegistryContext,
|
|
9
|
+
makeRegistry,
|
|
10
|
+
type AppDef,
|
|
11
|
+
} from '../../../../core/registry';
|
|
7
12
|
|
|
8
13
|
/** Exposes the router's current pathname so navigation can be asserted. */
|
|
9
14
|
function LocationProbe() {
|
|
@@ -11,42 +16,62 @@ function LocationProbe() {
|
|
|
11
16
|
return <div data-testid="pathname">{location.pathname}</div>;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Move the viewport. happy-dom answers `matchMedia` out of `innerWidth`, so
|
|
21
|
+
* this is how a test crosses the toolbar's compact breakpoint.
|
|
22
|
+
*/
|
|
23
|
+
function setViewportWidth(width: number): void {
|
|
24
|
+
const testWindow = window as typeof window & {
|
|
25
|
+
happyDOM: { setInnerWidth(value: number): void };
|
|
26
|
+
};
|
|
27
|
+
testWindow.happyDOM.setInnerWidth(width);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// The switcher reads apps from the registry — in the app the shell merges
|
|
31
|
+
// the core apps in (see CoreAppShell CORE_APPS); the harness mirrors that.
|
|
32
|
+
const coreLikeApps: AppDef[] = [
|
|
33
|
+
{
|
|
34
|
+
id: 'knowledge',
|
|
35
|
+
label: 'Knowledge',
|
|
36
|
+
path: '/workspace',
|
|
37
|
+
description: 'Browse and edit your knowledge base',
|
|
38
|
+
order: 10,
|
|
39
|
+
element: <div />,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'skills-tools',
|
|
43
|
+
label: 'Skills & Tools',
|
|
44
|
+
path: '/skills-and-tools',
|
|
45
|
+
description: 'What your assistant can do, and what it connects to',
|
|
46
|
+
order: 20,
|
|
47
|
+
element: <div />,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const assistantApp: AppDef = {
|
|
52
|
+
id: 'assistant',
|
|
53
|
+
label: 'Assistant',
|
|
54
|
+
path: '/assistant',
|
|
55
|
+
description: 'Chat with your knowledge base',
|
|
56
|
+
order: 30,
|
|
57
|
+
element: <div />,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const insightsApp: AppDef = {
|
|
61
|
+
id: 'insights',
|
|
62
|
+
label: 'Insights',
|
|
63
|
+
path: '/insights',
|
|
64
|
+
order: 40,
|
|
65
|
+
element: <div />,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function renderSwitcher(opts?: {
|
|
69
|
+
path?: string;
|
|
70
|
+
/** Registry apps past the two core ones. */
|
|
71
|
+
extraApps?: AppDef[];
|
|
72
|
+
shellActiveId?: string;
|
|
73
|
+
}) {
|
|
74
|
+
const registry = makeRegistry({ apps: [...coreLikeApps, ...(opts?.extraApps ?? [])] });
|
|
50
75
|
const tree = (
|
|
51
76
|
<MemoryRouter initialEntries={[opts?.path ?? '/']}>
|
|
52
77
|
<AppSwitcher />
|
|
@@ -64,22 +89,129 @@ function renderSwitcher(opts?: { path?: string; extraApps?: boolean; shellActive
|
|
|
64
89
|
);
|
|
65
90
|
}
|
|
66
91
|
|
|
67
|
-
|
|
92
|
+
beforeEach(() => {
|
|
93
|
+
setViewportWidth(1400);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('AppSwitcher as a segmented toggle (few apps, wide toolbar)', () => {
|
|
97
|
+
const nav = () => screen.getByRole('navigation', { name: 'Apps' });
|
|
98
|
+
|
|
99
|
+
it('shows the brand as text and both core apps side by side, with no menu', () => {
|
|
100
|
+
renderSwitcher({ path: '/workspace' });
|
|
101
|
+
expect(screen.getByText(/^Hexis by/).closest('button')).toBeNull();
|
|
102
|
+
const links = within(nav()).getAllByRole('link');
|
|
103
|
+
expect(links.map((l) => l.textContent)).toEqual(['Knowledge', 'Skills & Tools']);
|
|
104
|
+
expect(screen.queryByRole('button', { name: 'Switch app' })).not.toBeInTheDocument();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('marks the app matching the current location as current', () => {
|
|
108
|
+
renderSwitcher({ path: '/workspace/main/Skills' });
|
|
109
|
+
expect(within(nav()).getByRole('link', { name: 'Knowledge' })).toHaveAttribute(
|
|
110
|
+
'aria-current',
|
|
111
|
+
'page',
|
|
112
|
+
);
|
|
113
|
+
expect(within(nav()).getByRole('link', { name: 'Skills & Tools' })).not.toHaveAttribute(
|
|
114
|
+
'aria-current',
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// See the menu's equivalent below: a skill page at its canonical
|
|
119
|
+
// /workspace URL CLAIMS Skills & Tools, and the toggle follows the claim.
|
|
120
|
+
it('honours a shell-provided active app over the URL prefix', () => {
|
|
121
|
+
renderSwitcher({
|
|
122
|
+
path: '/workspace/main/knowledge-base/Plugins/Sales/create-sales-deck/SKILL.md',
|
|
123
|
+
shellActiveId: 'skills-tools',
|
|
124
|
+
});
|
|
125
|
+
expect(within(nav()).getByRole('link', { name: 'Skills & Tools' })).toHaveAttribute(
|
|
126
|
+
'aria-current',
|
|
127
|
+
'page',
|
|
128
|
+
);
|
|
129
|
+
expect(within(nav()).getByRole('link', { name: 'Knowledge' })).not.toHaveAttribute(
|
|
130
|
+
'aria-current',
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('marks no app as current on a standalone settings page', () => {
|
|
135
|
+
renderSwitcher({ path: '/secrets' });
|
|
136
|
+
for (const link of within(nav()).getAllByRole('link')) {
|
|
137
|
+
expect(link).not.toHaveAttribute('aria-current');
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('navigates to the chosen app and moves the current mark with it', async () => {
|
|
142
|
+
renderSwitcher({ path: '/workspace' });
|
|
143
|
+
await userEvent.click(within(nav()).getByRole('link', { name: 'Skills & Tools' }));
|
|
144
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/skills-and-tools');
|
|
145
|
+
expect(within(nav()).getByRole('link', { name: 'Skills & Tools' })).toHaveAttribute(
|
|
146
|
+
'aria-current',
|
|
147
|
+
'page',
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('stays put when the current app is clicked from a deep link inside it', async () => {
|
|
152
|
+
renderSwitcher({ path: '/workspace/main/Skills' });
|
|
153
|
+
await userEvent.click(within(nav()).getByRole('link', { name: 'Knowledge' }));
|
|
154
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace/main/Skills');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('leaves a modified or middle click on the current app to the browser, for a new tab', () => {
|
|
158
|
+
renderSwitcher({ path: '/workspace/main/Skills' });
|
|
159
|
+
const link = within(nav()).getByRole('link', { name: 'Knowledge' });
|
|
160
|
+
// `fireEvent` answers whether the default action survived: false means cancelled.
|
|
161
|
+
expect(fireEvent.click(link)).toBe(false);
|
|
162
|
+
expect(fireEvent.click(link, { ctrlKey: true })).toBe(true);
|
|
163
|
+
expect(fireEvent.click(link, { metaKey: true })).toBe(true);
|
|
164
|
+
expect(fireEvent.click(link, { shiftKey: true })).toBe(true);
|
|
165
|
+
expect(fireEvent.click(link, { button: 1 })).toBe(true);
|
|
166
|
+
expect(screen.getByTestId('pathname')).toHaveTextContent('/workspace/main/Skills');
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('still fits a third, registry-contributed app', () => {
|
|
170
|
+
renderSwitcher({ extraApps: [assistantApp] });
|
|
171
|
+
expect(within(nav()).getAllByRole('link').map((l) => l.textContent)).toEqual([
|
|
172
|
+
'Knowledge',
|
|
173
|
+
'Skills & Tools',
|
|
174
|
+
'Assistant',
|
|
175
|
+
]);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('falls back to the menu with four apps', () => {
|
|
179
|
+
renderSwitcher({ extraApps: [assistantApp, insightsApp] });
|
|
180
|
+
expect(screen.queryByRole('navigation', { name: 'Apps' })).not.toBeInTheDocument();
|
|
181
|
+
expect(screen.getByRole('button', { name: 'Switch app' })).toBeInTheDocument();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('falls back to the menu on a compact toolbar', () => {
|
|
185
|
+
setViewportWidth(600);
|
|
186
|
+
renderSwitcher({ path: '/workspace' });
|
|
187
|
+
expect(screen.queryByRole('navigation', { name: 'Apps' })).not.toBeInTheDocument();
|
|
188
|
+
expect(screen.getByRole('button', { name: 'Switch app' })).toHaveTextContent('Knowledge');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The menu is what more than three apps get, so these run against a
|
|
194
|
+
* four-app registry; the compact case is covered by the fallback test above.
|
|
195
|
+
*/
|
|
196
|
+
describe('AppSwitcher as a menu (more than three apps)', () => {
|
|
197
|
+
const renderMenu = (opts?: { path?: string; shellActiveId?: string }) =>
|
|
198
|
+
renderSwitcher({ ...opts, extraApps: [assistantApp, insightsApp] });
|
|
199
|
+
|
|
68
200
|
it('renders the brand as the trigger and no menu until clicked', () => {
|
|
69
|
-
|
|
70
|
-
expect(screen.getByText('Bevel')).toBeInTheDocument();
|
|
201
|
+
renderMenu();
|
|
202
|
+
expect(screen.getByText('Hexis by Bevel')).toBeInTheDocument();
|
|
71
203
|
expect(screen.queryByRole('menu')).not.toBeInTheDocument();
|
|
72
204
|
});
|
|
73
205
|
|
|
74
206
|
it('names the current app next to the brand', () => {
|
|
75
|
-
|
|
207
|
+
renderMenu({ path: '/skills-and-tools' });
|
|
76
208
|
const trigger = screen.getByRole('button', { name: 'Switch app' });
|
|
77
209
|
expect(trigger).toHaveTextContent('Bevel');
|
|
78
210
|
expect(trigger).toHaveTextContent('Skills & Tools');
|
|
79
211
|
});
|
|
80
212
|
|
|
81
213
|
it('names the current app on a deep link inside it', () => {
|
|
82
|
-
|
|
214
|
+
renderMenu({ path: '/workspace/main/Skills' });
|
|
83
215
|
expect(screen.getByRole('button', { name: 'Switch app' })).toHaveTextContent(
|
|
84
216
|
'Knowledge',
|
|
85
217
|
);
|
|
@@ -92,7 +224,7 @@ describe('AppSwitcher', () => {
|
|
|
92
224
|
* name the surface on screen, not the app that owns the URL prefix.
|
|
93
225
|
*/
|
|
94
226
|
it('honours a shell-provided active app over the URL prefix', () => {
|
|
95
|
-
|
|
227
|
+
renderMenu({
|
|
96
228
|
path: '/workspace/main/knowledge-base/Plugins/Sales/create-sales-deck/SKILL.md',
|
|
97
229
|
shellActiveId: 'skills-tools',
|
|
98
230
|
});
|
|
@@ -102,7 +234,7 @@ describe('AppSwitcher', () => {
|
|
|
102
234
|
});
|
|
103
235
|
|
|
104
236
|
it('shows the brand alone where no app is active', () => {
|
|
105
|
-
|
|
237
|
+
renderMenu({ path: '/secrets' });
|
|
106
238
|
const trigger = screen.getByRole('button', { name: 'Switch app' });
|
|
107
239
|
expect(trigger).toHaveTextContent('Bevel');
|
|
108
240
|
expect(trigger).not.toHaveTextContent('Knowledge');
|
|
@@ -110,7 +242,7 @@ describe('AppSwitcher', () => {
|
|
|
110
242
|
});
|
|
111
243
|
|
|
112
244
|
it('updates the named app after switching', async () => {
|
|
113
|
-
|
|
245
|
+
renderMenu({ path: '/workspace' });
|
|
114
246
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
115
247
|
await userEvent.click(screen.getByRole('menuitem', { name: /Skills & Tools/ }));
|
|
116
248
|
expect(screen.getByRole('button', { name: 'Switch app' })).toHaveTextContent(
|
|
@@ -119,7 +251,7 @@ describe('AppSwitcher', () => {
|
|
|
119
251
|
});
|
|
120
252
|
|
|
121
253
|
it('opens the Apps list with the two core apps', async () => {
|
|
122
|
-
|
|
254
|
+
renderMenu();
|
|
123
255
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
124
256
|
const menu = screen.getByRole('menu');
|
|
125
257
|
expect(within(menu).getByText('Apps')).toBeInTheDocument();
|
|
@@ -128,38 +260,39 @@ describe('AppSwitcher', () => {
|
|
|
128
260
|
});
|
|
129
261
|
|
|
130
262
|
it('appends registry-contributed apps after the core ones', async () => {
|
|
131
|
-
|
|
263
|
+
renderMenu();
|
|
132
264
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
133
265
|
const items = screen.getAllByRole('menuitem');
|
|
134
266
|
expect(items.map((i) => i.textContent)).toEqual([
|
|
135
267
|
expect.stringContaining('Knowledge'),
|
|
136
268
|
expect.stringContaining('Skills & Tools'),
|
|
137
269
|
expect.stringContaining('Assistant'),
|
|
270
|
+
expect.stringContaining('Insights'),
|
|
138
271
|
]);
|
|
139
272
|
});
|
|
140
273
|
|
|
141
274
|
it('marks the app matching the current location as current', async () => {
|
|
142
|
-
|
|
275
|
+
renderMenu({ path: '/skills-and-tools' });
|
|
143
276
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
144
277
|
const current = screen.getByLabelText('Current app');
|
|
145
278
|
expect(current.closest('[role="menuitem"]')).toHaveTextContent('Skills & Tools');
|
|
146
279
|
});
|
|
147
280
|
|
|
148
281
|
it('marks Knowledge as current on a KB deep link', async () => {
|
|
149
|
-
|
|
282
|
+
renderMenu({ path: '/workspace/main/Skills' });
|
|
150
283
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
151
284
|
const current = screen.getByLabelText('Current app');
|
|
152
285
|
expect(current.closest('[role="menuitem"]')).toHaveTextContent('Knowledge');
|
|
153
286
|
});
|
|
154
287
|
|
|
155
288
|
it('marks no app as current on a standalone settings page', async () => {
|
|
156
|
-
|
|
289
|
+
renderMenu({ path: '/secrets' });
|
|
157
290
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
158
291
|
expect(screen.queryByLabelText('Current app')).not.toBeInTheDocument();
|
|
159
292
|
});
|
|
160
293
|
|
|
161
294
|
it('navigates to the selected app and closes the menu', async () => {
|
|
162
|
-
|
|
295
|
+
renderMenu();
|
|
163
296
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
164
297
|
await userEvent.click(screen.getByRole('menuitem', { name: /Skills & Tools/ }));
|
|
165
298
|
expect(screen.getByTestId('pathname')).toHaveTextContent('/skills-and-tools');
|
|
@@ -167,7 +300,7 @@ describe('AppSwitcher', () => {
|
|
|
167
300
|
});
|
|
168
301
|
|
|
169
302
|
it('closes on Escape without navigating', async () => {
|
|
170
|
-
|
|
303
|
+
renderMenu();
|
|
171
304
|
await userEvent.click(screen.getByRole('button', { name: 'Switch app' }));
|
|
172
305
|
await userEvent.keyboard('{Escape}');
|
|
173
306
|
expect(screen.queryByRole('menu')).not.toBeInTheDocument();
|
|
@@ -215,11 +215,11 @@ describe('the interactive tab: Claude and ChatGPT first, each family on its own
|
|
|
215
215
|
mount(PUBLIC_URL);
|
|
216
216
|
const values = snippets();
|
|
217
217
|
expect(values).toContain(
|
|
218
|
-
`claude mcp add skills-tools-knowledge --env HEXIS_URL="${window.location.origin}" -- npx -y @bevel-software/hexis-mcp`,
|
|
218
|
+
`claude mcp add skills-tools-knowledge --env HEXIS_URL="${window.location.origin}" -- npx -y @bevel-software/hexis-mcp@latest`,
|
|
219
219
|
);
|
|
220
220
|
const json = values.find((v) => v.includes('mcpServers') && v.includes('"command"'));
|
|
221
221
|
const parsed = JSON.parse(json!).mcpServers['skills-tools-knowledge'];
|
|
222
|
-
expect(parsed.args).toEqual(['-y', '@bevel-software/hexis-mcp']);
|
|
222
|
+
expect(parsed.args).toEqual(['-y', '@bevel-software/hexis-mcp@latest']);
|
|
223
223
|
expect(parsed.env.HEXIS_URL).toBe(window.location.origin);
|
|
224
224
|
// Keyless = interactive: the browser-sign-in mode carries no key env.
|
|
225
225
|
expect(parsed.env.HEXIS_CONNECTION_KEY).toBeUndefined();
|
|
@@ -332,12 +332,12 @@ describe('the key-bearing snippets quote the deployment too', () => {
|
|
|
332
332
|
|
|
333
333
|
// 7. the Claude Code stdio one-liner
|
|
334
334
|
expect(values).toContain(
|
|
335
|
-
`claude mcp add skills-tools-knowledge --env HEXIS_URL="${window.location.origin}" --env HEXIS_CONNECTION_KEY="${KEY}" -- npx -y @bevel-software/hexis-mcp`,
|
|
335
|
+
`claude mcp add skills-tools-knowledge --env HEXIS_URL="${window.location.origin}" --env HEXIS_CONNECTION_KEY="${KEY}" -- npx -y @bevel-software/hexis-mcp@latest`,
|
|
336
336
|
);
|
|
337
337
|
// 8. the JSON config that spawns the package
|
|
338
338
|
const json = values.find((v) => v.includes('mcpServers') && v.includes('"command"'));
|
|
339
339
|
const parsed = JSON.parse(json!).mcpServers['skills-tools-knowledge'];
|
|
340
|
-
expect(parsed.args).toEqual(['-y', '@bevel-software/hexis-mcp']);
|
|
340
|
+
expect(parsed.args).toEqual(['-y', '@bevel-software/hexis-mcp@latest']);
|
|
341
341
|
expect(parsed.env.HEXIS_URL).toBe(window.location.origin);
|
|
342
342
|
expect(parsed.env.HEXIS_CONNECTION_KEY).toBe(KEY);
|
|
343
343
|
expect(json).not.toContain(PUBLIC_URL);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
+
import { AuthContext, type AuthContextValue } from '../../../auth/state/auth.context';
|
|
6
|
+
import { AdminContext } from '../../../admin/state/admin.context';
|
|
7
|
+
import type { AdminMenuItem } from '../../../../core/registry';
|
|
8
|
+
import { ProfileMenu } from '../ProfileMenu';
|
|
9
|
+
|
|
10
|
+
// Every admin row hidden from this person — not reachable with today's core
|
|
11
|
+
// rows, which are always shown, so the sections are stubbed here.
|
|
12
|
+
const hidden = (id: string, label: string): AdminMenuItem => ({
|
|
13
|
+
id,
|
|
14
|
+
section: 'admin',
|
|
15
|
+
label,
|
|
16
|
+
path: `/${id}`,
|
|
17
|
+
isShown: () => false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
vi.mock('../../../settings/settings-nav-items', () => ({
|
|
21
|
+
useMenuSections: () => ({
|
|
22
|
+
defaultItems: [{ id: 'account', label: 'Account', path: '/account' }],
|
|
23
|
+
adminItems: [hidden('hidden-a', 'Hidden A'), hidden('hidden-b', 'Hidden B')],
|
|
24
|
+
}),
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const auth: AuthContextValue = {
|
|
28
|
+
user: { id: 'user-1', email: 'user@example.com', name: 'Test User', avatarUrl: '' },
|
|
29
|
+
token: 'token',
|
|
30
|
+
isLoading: false,
|
|
31
|
+
login: async () => {},
|
|
32
|
+
logout: () => {},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe('ProfileMenu', () => {
|
|
36
|
+
it('draws no Admin only section when every admin row is hidden', async () => {
|
|
37
|
+
render(
|
|
38
|
+
<MemoryRouter>
|
|
39
|
+
<AuthContext.Provider value={auth}>
|
|
40
|
+
<AdminContext.Provider
|
|
41
|
+
value={{
|
|
42
|
+
isAdmin: true,
|
|
43
|
+
unreadCount: 0,
|
|
44
|
+
lastSeen: null,
|
|
45
|
+
markSeen: () => {},
|
|
46
|
+
refresh: () => {},
|
|
47
|
+
rolesConfigCorrupted: false,
|
|
48
|
+
rolesConfigErrors: [],
|
|
49
|
+
runRolesRecovery: async () => {},
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<ProfileMenu />
|
|
53
|
+
</AdminContext.Provider>
|
|
54
|
+
</AuthContext.Provider>
|
|
55
|
+
</MemoryRouter>,
|
|
56
|
+
);
|
|
57
|
+
await userEvent.click(screen.getByRole('button', { name: 'Test User' }));
|
|
58
|
+
const panel = screen.getByRole('group', { name: 'You and your settings' });
|
|
59
|
+
expect(within(panel).getByRole('button', { name: 'Account' })).toBeInTheDocument();
|
|
60
|
+
expect(within(panel).queryByText('Admin only')).toBeNull();
|
|
61
|
+
expect(within(panel).queryByRole('group')).toBeNull();
|
|
62
|
+
expect(within(panel).queryByRole('button', { name: /Hidden/ })).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
});
|