@bevel-software/platform-core-frontend 0.26.0 → 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/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/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- 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 +56 -15
- 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 +81 -84
- 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__/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 +92 -4
- 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 +16 -0
- 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 +15 -0
- 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/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -99,12 +99,12 @@ describe('SetupScreen: the ways of having a repository', () => {
|
|
|
99
99
|
it('offers them as tabs, in the order the deployment gives', () => {
|
|
100
100
|
show();
|
|
101
101
|
const tabs = within(screen.getByRole('tablist', { name: 'Where the repository is' })).getAllByRole('tab');
|
|
102
|
-
expect(tabs.map((t) => t.textContent)).toEqual(['
|
|
102
|
+
expect(tabs.map((t) => t.textContent)).toEqual(['Hexis takes care of it', 'Address and token']);
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
it('opens a new deployment on the first: the repository it keeps itself', () => {
|
|
106
106
|
show();
|
|
107
|
-
expect(tab('
|
|
107
|
+
expect(tab('Hexis takes care of it')).toHaveAttribute('aria-selected', 'true');
|
|
108
108
|
expect(screen.getByTestId('managed-repository')).toHaveTextContent('There is nothing to connect and nothing to enter');
|
|
109
109
|
// Nothing to type, nothing to test.
|
|
110
110
|
expect(address()).toBeNull();
|
|
@@ -122,7 +122,7 @@ describe('SetupScreen: the ways of having a repository', () => {
|
|
|
122
122
|
|
|
123
123
|
it('gives each tab a panel of its own', async () => {
|
|
124
124
|
show();
|
|
125
|
-
for (const name of ['
|
|
125
|
+
for (const name of ['Hexis takes care of it', 'Address and token']) {
|
|
126
126
|
await userEvent.click(tab(name));
|
|
127
127
|
const panel = document.getElementById(tab(name).getAttribute('aria-controls')!);
|
|
128
128
|
expect(panel).toHaveAttribute('role', 'tabpanel');
|
|
@@ -161,7 +161,7 @@ describe('SetupScreen: saving a repository the deployment keeps', () => {
|
|
|
161
161
|
await userEvent.click(tab('Address and token'));
|
|
162
162
|
await userEvent.type(address()!, 'https://git.example.com/acme/kb.git');
|
|
163
163
|
await userEvent.type(screen.getByLabelText('Access token', { exact: false }), 'a-token');
|
|
164
|
-
await userEvent.click(tab('
|
|
164
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
165
165
|
await save();
|
|
166
166
|
await waitFor(() => expect(api.saveSettings).toHaveBeenCalledWith({ gitMode: 'managed' }));
|
|
167
167
|
expect(api.testConnection).not.toHaveBeenCalled();
|
|
@@ -177,7 +177,7 @@ describe('SetupScreen: saving a repository the deployment keeps', () => {
|
|
|
177
177
|
await screen.findByText('The host turned that token down.');
|
|
178
178
|
expect(screen.getByRole('button', { name: 'Save and continue' })).toBeDisabled();
|
|
179
179
|
|
|
180
|
-
await userEvent.click(tab('
|
|
180
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
181
181
|
expect(screen.getByRole('button', { name: 'Save and continue' })).toBeEnabled();
|
|
182
182
|
await save();
|
|
183
183
|
await waitFor(() => expect(api.saveSettings).toHaveBeenCalled());
|
|
@@ -223,7 +223,7 @@ describe('SetupScreen: saving a repository reached by its address', () => {
|
|
|
223
223
|
it('opens the tab a refused address or token is on', async () => {
|
|
224
224
|
api.saveSettings.mockRejectedValue(new SettingsProblems({ gitToken: 'The host turned that token down.' }));
|
|
225
225
|
show({ configured: true, mode: 'managed', variant: 'settings' });
|
|
226
|
-
expect(tab('
|
|
226
|
+
expect(tab('Hexis takes care of it')).toHaveAttribute('aria-selected', 'true');
|
|
227
227
|
await save();
|
|
228
228
|
expect(await screen.findByText('The host turned that token down.')).toBeInTheDocument();
|
|
229
229
|
expect(tab('Address and token')).toHaveAttribute('aria-selected', 'true');
|
|
@@ -233,7 +233,7 @@ describe('SetupScreen: saving a repository reached by its address', () => {
|
|
|
233
233
|
describe('SetupScreen: moving a deployment to another repository', () => {
|
|
234
234
|
it('says what saving will do, before it is pressed', async () => {
|
|
235
235
|
show({ configured: true, variant: 'settings' });
|
|
236
|
-
await userEvent.click(tab('
|
|
236
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
237
237
|
const warning = screen.getByTestId('moves-repository');
|
|
238
238
|
expect(warning).toHaveTextContent('moves this deployment to another repository');
|
|
239
239
|
expect(warning).toHaveTextContent('Nothing is deleted');
|
|
@@ -263,13 +263,13 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
263
263
|
it('does not move on a save the admin was not asked about', async () => {
|
|
264
264
|
asksFirst();
|
|
265
265
|
show({ configured: true, variant: 'settings' });
|
|
266
|
-
await userEvent.click(tab('
|
|
266
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
267
267
|
await userEvent.type(screen.getByLabelText('Knowledge folder', { exact: false }), 'Docs');
|
|
268
268
|
await save();
|
|
269
269
|
|
|
270
270
|
// Asked at the button, naming what is left and what is moved to.
|
|
271
271
|
const asked = await question();
|
|
272
|
-
expect(asked).toHaveTextContent('Move this deployment from “Address and token” to “
|
|
272
|
+
expect(asked).toHaveTextContent('Move this deployment from “Address and token” to “Hexis takes care of it”?');
|
|
273
273
|
expect(asked).toHaveTextContent('Nothing is deleted');
|
|
274
274
|
expect(asked).toHaveTextContent('with no restart');
|
|
275
275
|
// One refused attempt, and the save button waits for the answer.
|
|
@@ -280,7 +280,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
280
280
|
it('sends the move once the admin has said yes, and nothing of the repository it leaves', async () => {
|
|
281
281
|
asksFirst();
|
|
282
282
|
show({ configured: true, variant: 'settings' });
|
|
283
|
-
await userEvent.click(tab('
|
|
283
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
284
284
|
await save();
|
|
285
285
|
await question();
|
|
286
286
|
await confirmMove();
|
|
@@ -300,7 +300,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
300
300
|
repository={{ mode: 'token', chosen: 'token', modes: ['managed', 'github-app', 'token'] }}
|
|
301
301
|
/>,
|
|
302
302
|
);
|
|
303
|
-
await userEvent.click(tab('
|
|
303
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
304
304
|
await save();
|
|
305
305
|
await question();
|
|
306
306
|
await confirmMove();
|
|
@@ -325,7 +325,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
325
325
|
repository={{ mode: 'token', chosen: 'token', modes: ['managed', 'github-app', 'token'] }}
|
|
326
326
|
/>,
|
|
327
327
|
);
|
|
328
|
-
await userEvent.click(tab('
|
|
328
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
329
329
|
await save();
|
|
330
330
|
await question();
|
|
331
331
|
await userEvent.click(tab('GitHub'));
|
|
@@ -336,7 +336,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
336
336
|
it('closes the open change requests when the admin picks that, and says so', async () => {
|
|
337
337
|
asksFirst(2);
|
|
338
338
|
show({ configured: true, variant: 'settings' });
|
|
339
|
-
await userEvent.click(tab('
|
|
339
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
340
340
|
await save();
|
|
341
341
|
await question();
|
|
342
342
|
await userEvent.click(screen.getByRole('radio', { name: /Close them as/ }));
|
|
@@ -354,7 +354,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
354
354
|
return { ...saved('managed', true), repositoryChange: { choice: confirm, closedChangeRequests: 0 } };
|
|
355
355
|
});
|
|
356
356
|
show({ configured: true, variant: 'settings' });
|
|
357
|
-
await userEvent.click(tab('
|
|
357
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
358
358
|
await save();
|
|
359
359
|
await question();
|
|
360
360
|
expect(screen.queryAllByRole('radio')).toEqual([]);
|
|
@@ -369,7 +369,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
369
369
|
it('cancelling leaves the deployment where it is', async () => {
|
|
370
370
|
asksFirst(2);
|
|
371
371
|
show({ configured: true, variant: 'settings' });
|
|
372
|
-
await userEvent.click(tab('
|
|
372
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
373
373
|
await save();
|
|
374
374
|
expect(await question()).toHaveTextContent('There are 2 open change requests.');
|
|
375
375
|
await userEvent.click(screen.getByRole('button', { name: 'Cancel' }));
|
|
@@ -381,7 +381,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
381
381
|
it('asks nothing of a save that stays where the deployment is', async () => {
|
|
382
382
|
api.saveSettings.mockResolvedValue(saved('token', true));
|
|
383
383
|
show({ configured: true, variant: 'settings' });
|
|
384
|
-
await userEvent.click(tab('
|
|
384
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
385
385
|
await userEvent.click(tab('Address and token'));
|
|
386
386
|
await userEvent.type(screen.getByLabelText('Knowledge folder', { exact: false }), 'Docs');
|
|
387
387
|
await save();
|
|
@@ -394,7 +394,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
394
394
|
show();
|
|
395
395
|
await userEvent.click(tab('Address and token'));
|
|
396
396
|
expect(screen.queryByTestId('moves-repository')).toBeNull();
|
|
397
|
-
await userEvent.click(tab('
|
|
397
|
+
await userEvent.click(tab('Hexis takes care of it'));
|
|
398
398
|
await save();
|
|
399
399
|
await waitFor(() => expect(api.saveSettings).toHaveBeenCalledWith({ gitMode: 'managed' }));
|
|
400
400
|
expect(screen.queryByTestId('repository-change-confirm')).toBeNull();
|
|
@@ -409,7 +409,7 @@ describe('SetupScreen: moving a deployment to another repository', () => {
|
|
|
409
409
|
describe('SetupScreen: a way chosen that is not in effect yet', () => {
|
|
410
410
|
it('opens on the way chosen, and says the deployment is still on the one it has', () => {
|
|
411
411
|
show({ configured: true, mode: 'token', chosen: 'managed', variant: 'settings' });
|
|
412
|
-
expect(tab('
|
|
412
|
+
expect(tab('Hexis takes care of it')).toHaveAttribute('aria-selected', 'true');
|
|
413
413
|
const pending = screen.getByTestId('move-pending');
|
|
414
414
|
expect(pending).toHaveTextContent('A restart is pending');
|
|
415
415
|
expect(pending).toHaveTextContent('still working on “Address and token”');
|
|
@@ -446,12 +446,12 @@ describe('SetupScreen: a way chosen that is not in effect yet', () => {
|
|
|
446
446
|
describe('SetupScreen: a way chosen by the environment', () => {
|
|
447
447
|
it('shows the other ways as not the screen to choose, and says which variable chose', async () => {
|
|
448
448
|
show({ mode: 'managed', pinned: 'GIT_MODE', variant: 'settings' });
|
|
449
|
-
expect(tab('
|
|
450
|
-
expect(tab('
|
|
449
|
+
expect(tab('Hexis takes care of it')).toHaveAttribute('aria-selected', 'true');
|
|
450
|
+
expect(tab('Hexis takes care of it')).toBeEnabled();
|
|
451
451
|
expect(tab('Address and token')).toBeDisabled();
|
|
452
452
|
expect(screen.getByTestId('repository-pinned')).toHaveTextContent('Set by the GIT_MODE environment variable');
|
|
453
453
|
await userEvent.click(tab('Address and token'));
|
|
454
|
-
expect(tab('
|
|
454
|
+
expect(tab('Hexis takes care of it')).toHaveAttribute('aria-selected', 'true');
|
|
455
455
|
expect(screen.queryByTestId('repository-change-confirm')).toBeNull();
|
|
456
456
|
});
|
|
457
457
|
|
|
@@ -365,6 +365,47 @@ describe('SetupScreen', () => {
|
|
|
365
365
|
* putting the stored value back changes nothing — the save must not be held
|
|
366
366
|
* behind a repository test for an edit that no longer exists.
|
|
367
367
|
*/
|
|
368
|
+
/**
|
|
369
|
+
* The leftover-branch cleanup is an on/off setting: a checkbox, ticked while
|
|
370
|
+
* unset (the server's default is on), saved as `true` / `false`.
|
|
371
|
+
*/
|
|
372
|
+
it('settings mode: the leftover-branch cleanup is a checkbox, on by default, saved as false when cleared', async () => {
|
|
373
|
+
const stored = [
|
|
374
|
+
...SETTINGS.map((s) =>
|
|
375
|
+
s.key === 'kbRepoUrl'
|
|
376
|
+
? { ...s, source: 'stored' as const, value: 'https://example.com/kb.git', configured: true }
|
|
377
|
+
: s.key === 'defaultBranch' || s.key === 'protectedBranches'
|
|
378
|
+
? { ...s, source: 'stored' as const, value: 'main', configured: true }
|
|
379
|
+
: s,
|
|
380
|
+
),
|
|
381
|
+
{
|
|
382
|
+
key: 'retireMergedBranches',
|
|
383
|
+
envVar: 'RETIRE_MERGED_BRANCHES',
|
|
384
|
+
section: KB,
|
|
385
|
+
source: 'unset' as const,
|
|
386
|
+
value: '',
|
|
387
|
+
configured: false,
|
|
388
|
+
secret: false,
|
|
389
|
+
restartToApply: false,
|
|
390
|
+
},
|
|
391
|
+
];
|
|
392
|
+
render(<SetupScreen settings={stored} onSaved={vi.fn()} variant="settings" />);
|
|
393
|
+
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: true, settings: stored });
|
|
394
|
+
|
|
395
|
+
// It sits under Advanced, closed by default: opened first, as a person would.
|
|
396
|
+
const advanced = screen.getByText(/^Advanced/, { selector: 'summary' });
|
|
397
|
+
await userEvent.click(advanced);
|
|
398
|
+
expect(advanced.closest('details')).toHaveAttribute('open');
|
|
399
|
+
const box = screen.getByRole('checkbox', { name: 'Remove branches left over from merged change requests' });
|
|
400
|
+
expect(box).toBeChecked();
|
|
401
|
+
await userEvent.click(box);
|
|
402
|
+
expect(box).not.toBeChecked();
|
|
403
|
+
await userEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
|
|
404
|
+
|
|
405
|
+
await waitFor(() => expect(api.saveSettings).toHaveBeenCalled());
|
|
406
|
+
expect(api.saveSettings).toHaveBeenCalledWith(expect.objectContaining({ retireMergedBranches: 'false' }));
|
|
407
|
+
});
|
|
408
|
+
|
|
368
409
|
it('settings mode: a field restored to its stored value does not gate the save', async () => {
|
|
369
410
|
const stored = SETTINGS.map((s) =>
|
|
370
411
|
s.key === 'kbRepoUrl'
|
|
@@ -967,13 +1008,13 @@ describe('SetupScreen — remote sync panel', () => {
|
|
|
967
1008
|
},
|
|
968
1009
|
};
|
|
969
1010
|
|
|
970
|
-
it('shows the address a hook calls on first run, without
|
|
1011
|
+
it('shows the address a hook calls on first run, without an Update now button', () => {
|
|
971
1012
|
render(<SetupScreen settings={[...SETTINGS, SYNC_SETTING]} sync={SYNC} onSaved={() => {}} />);
|
|
972
1013
|
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
973
|
-
expect(screen.getByRole('button', { name: 'Copy the
|
|
1014
|
+
expect(screen.getByRole('button', { name: 'Copy the hook address' })).toBeTruthy();
|
|
974
1015
|
// The 'setup' variant never offers the button or the history, whatever the
|
|
975
1016
|
// record says: on first run the repository behind them is not connected yet.
|
|
976
|
-
expect(screen.queryByRole('button', { name: '
|
|
1017
|
+
expect(screen.queryByRole('button', { name: 'Update now' })).toBeNull();
|
|
977
1018
|
});
|
|
978
1019
|
|
|
979
1020
|
it('shows the address on the Deployment page too', () => {
|
|
@@ -981,7 +1022,7 @@ describe('SetupScreen — remote sync panel', () => {
|
|
|
981
1022
|
<SetupScreen settings={[...SETTINGS, SYNC_SETTING]} sync={SYNC} onSaved={() => {}} variant="settings" />,
|
|
982
1023
|
);
|
|
983
1024
|
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
984
|
-
expect(screen.getByRole('button', { name: '
|
|
1025
|
+
expect(screen.getByRole('button', { name: 'Update now' })).toBeTruthy();
|
|
985
1026
|
});
|
|
986
1027
|
|
|
987
1028
|
it('keeps the panel when the secret is set by the environment', () => {
|
|
@@ -991,12 +1032,12 @@ describe('SetupScreen — remote sync panel', () => {
|
|
|
991
1032
|
);
|
|
992
1033
|
// The secret itself is locked, listed under the environment…
|
|
993
1034
|
expect(screen.getByText('KB_SYNC_SECRET')).toBeTruthy();
|
|
994
|
-
// …but the address, the history and
|
|
1035
|
+
// …but the address, the history and Update now are still there.
|
|
995
1036
|
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
996
|
-
expect(screen.getByRole('button', { name: '
|
|
1037
|
+
expect(screen.getByRole('button', { name: 'Update now' })).toBeTruthy();
|
|
997
1038
|
});
|
|
998
1039
|
|
|
999
|
-
it('on the Deployment page: says what the last sync did, and
|
|
1040
|
+
it('on the Deployment page: says what the last sync did, and Update now reports the result', async () => {
|
|
1000
1041
|
api.syncNow.mockResolvedValue({
|
|
1001
1042
|
ok: true,
|
|
1002
1043
|
status: 'synced',
|
|
@@ -1014,10 +1055,10 @@ describe('SetupScreen — remote sync panel', () => {
|
|
|
1014
1055
|
variant="settings"
|
|
1015
1056
|
/>,
|
|
1016
1057
|
);
|
|
1017
|
-
expect(screen.getByText(/Last
|
|
1058
|
+
expect(screen.getByText(/Last update .* by github-signature: main updated\./)).toBeTruthy();
|
|
1018
1059
|
|
|
1019
|
-
await userEvent.click(screen.getByRole('button', { name: '
|
|
1020
|
-
await waitFor(() => expect(screen.getByText('
|
|
1060
|
+
await userEvent.click(screen.getByRole('button', { name: 'Update now' }));
|
|
1061
|
+
await waitFor(() => expect(screen.getByText('Updated: main updated, ali/x up to date.')).toBeTruthy());
|
|
1021
1062
|
expect(api.syncNow).toHaveBeenCalledTimes(1);
|
|
1022
1063
|
// The status carries the last-sync record, so the page refetches it.
|
|
1023
1064
|
expect(onSaved).toHaveBeenCalled();
|
|
@@ -1039,8 +1080,8 @@ describe('SetupScreen — remote sync panel', () => {
|
|
|
1039
1080
|
variant="settings"
|
|
1040
1081
|
/>,
|
|
1041
1082
|
);
|
|
1042
|
-
expect(screen.getByText('No
|
|
1043
|
-
await userEvent.click(screen.getByRole('button', { name: '
|
|
1083
|
+
expect(screen.getByText('No updates since this server started.')).toBeTruthy();
|
|
1084
|
+
await userEvent.click(screen.getByRole('button', { name: 'Update now' }));
|
|
1044
1085
|
await waitFor(() =>
|
|
1045
1086
|
expect(screen.getByText(/main is not in sync yet: a\.md changed both/)).toBeTruthy(),
|
|
1046
1087
|
);
|
|
@@ -1253,7 +1294,7 @@ describe('SetupScreen — a failed knowledge-base initialization', () => {
|
|
|
1253
1294
|
});
|
|
1254
1295
|
|
|
1255
1296
|
describe('SetupScreen — sync panel when the whole knowledge base is env-set', () => {
|
|
1256
|
-
it('still renders the address and
|
|
1297
|
+
it('still renders the address and Update now, in a section of its own', () => {
|
|
1257
1298
|
const KB_FROM_ENV: SettingStatus[] = SETTINGS.map((s) =>
|
|
1258
1299
|
s.section === 'knowledge-base' ? { ...s, source: 'env', configured: true } : s,
|
|
1259
1300
|
);
|
|
@@ -1269,8 +1310,8 @@ describe('SetupScreen — sync panel when the whole knowledge base is env-set',
|
|
|
1269
1310
|
/>,
|
|
1270
1311
|
);
|
|
1271
1312
|
expect(screen.getByText('https://hexis.example.test/api/sync/<branch>')).toBeTruthy();
|
|
1272
|
-
expect(screen.getByRole('button', { name: '
|
|
1273
|
-
expect(screen.getByRole('heading', { name: '
|
|
1313
|
+
expect(screen.getByRole('button', { name: 'Update now' })).toBeTruthy();
|
|
1314
|
+
expect(screen.getByRole('heading', { name: 'Updates from your git host' })).toBeTruthy();
|
|
1274
1315
|
});
|
|
1275
1316
|
});
|
|
1276
1317
|
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { act, renderHook } from '@testing-library/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The one connection probe both setup screens read: which answer is the
|
|
6
|
+
* answer on screen when requests overlap or the answers change under one.
|
|
7
|
+
* Only the request is mocked; the ordering is the hook's own.
|
|
8
|
+
*/
|
|
9
|
+
const api = vi.hoisted(() => ({ testConnection: vi.fn() }));
|
|
10
|
+
vi.mock('../services/setup.api', () => api);
|
|
11
|
+
|
|
12
|
+
import { ConnectionProbeFailed, useConnectionProbe } from '../hooks/useConnectionProbe';
|
|
13
|
+
import type { ConnectionTest } from '../services/setup.api';
|
|
14
|
+
|
|
15
|
+
function deferred<T>() {
|
|
16
|
+
let resolve!: (value: T) => void;
|
|
17
|
+
let reject!: (reason: unknown) => void;
|
|
18
|
+
const promise = new Promise<T>((res, rej) => {
|
|
19
|
+
resolve = res;
|
|
20
|
+
reject = rej;
|
|
21
|
+
});
|
|
22
|
+
return { promise, resolve, reject };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const YES = { ok: true, branches: ['main'] } as ConnectionTest;
|
|
26
|
+
const NO = { ok: false, error: 'The host said no.' } as ConnectionTest;
|
|
27
|
+
const ANSWERS = { kbRepoUrl: 'https://example.com/acme/kb.git', gitToken: 't' };
|
|
28
|
+
|
|
29
|
+
type Asked = ReturnType<ReturnType<typeof useConnectionProbe>['ask']>;
|
|
30
|
+
|
|
31
|
+
describe('useConnectionProbe', () => {
|
|
32
|
+
// A queued answer a failed test never consumed must not feed the next one.
|
|
33
|
+
beforeEach(() => api.testConnection.mockReset());
|
|
34
|
+
|
|
35
|
+
it("shows the newest request's answer when two for the same answers land newest-first", async () => {
|
|
36
|
+
const first = deferred<ConnectionTest>();
|
|
37
|
+
const second = deferred<ConnectionTest>();
|
|
38
|
+
api.testConnection.mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);
|
|
39
|
+
const { result } = renderHook(() => useConnectionProbe());
|
|
40
|
+
|
|
41
|
+
let older!: Asked;
|
|
42
|
+
let newer!: Asked;
|
|
43
|
+
act(() => {
|
|
44
|
+
older = result.current.ask(ANSWERS);
|
|
45
|
+
newer = result.current.ask(ANSWERS);
|
|
46
|
+
});
|
|
47
|
+
expect(result.current.testing).toBe(true);
|
|
48
|
+
|
|
49
|
+
await act(async () => {
|
|
50
|
+
second.resolve(YES);
|
|
51
|
+
await newer;
|
|
52
|
+
});
|
|
53
|
+
expect(result.current.result).toEqual(YES);
|
|
54
|
+
expect(result.current.proven).toBe(true);
|
|
55
|
+
|
|
56
|
+
// The older request lands last, with a refusal: stale, so it neither
|
|
57
|
+
// replaces the yes on screen nor counts as proof against it.
|
|
58
|
+
await act(async () => {
|
|
59
|
+
first.resolve(NO);
|
|
60
|
+
await expect(older).resolves.toEqual({ result: NO, stale: true });
|
|
61
|
+
});
|
|
62
|
+
expect(result.current.result).toEqual(YES);
|
|
63
|
+
expect(result.current.proven).toBe(true);
|
|
64
|
+
expect(result.current.testing).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('an older request that fails after a newer one answered is a stale failure, and the answer stands', async () => {
|
|
68
|
+
const first = deferred<ConnectionTest>();
|
|
69
|
+
const second = deferred<ConnectionTest>();
|
|
70
|
+
api.testConnection.mockReturnValueOnce(first.promise).mockReturnValueOnce(second.promise);
|
|
71
|
+
const { result } = renderHook(() => useConnectionProbe());
|
|
72
|
+
|
|
73
|
+
let older!: Asked;
|
|
74
|
+
let newer!: Asked;
|
|
75
|
+
act(() => {
|
|
76
|
+
older = result.current.ask(ANSWERS);
|
|
77
|
+
newer = result.current.ask(ANSWERS);
|
|
78
|
+
});
|
|
79
|
+
await act(async () => {
|
|
80
|
+
second.resolve(YES);
|
|
81
|
+
await newer;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
await act(async () => {
|
|
85
|
+
first.reject(new Error('network down'));
|
|
86
|
+
await expect(older).rejects.toMatchObject({ name: 'ConnectionProbeFailed', message: 'network down', stale: true });
|
|
87
|
+
});
|
|
88
|
+
await expect(older).rejects.toBeInstanceOf(ConnectionProbeFailed);
|
|
89
|
+
expect(result.current.result).toEqual(YES);
|
|
90
|
+
expect(result.current.testing).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('an edit while a request is out makes its answer stale and leaves nothing on screen', async () => {
|
|
94
|
+
const only = deferred<ConnectionTest>();
|
|
95
|
+
api.testConnection.mockReturnValueOnce(only.promise);
|
|
96
|
+
const { result } = renderHook(() => useConnectionProbe());
|
|
97
|
+
|
|
98
|
+
let asked!: Asked;
|
|
99
|
+
act(() => {
|
|
100
|
+
asked = result.current.ask(ANSWERS);
|
|
101
|
+
});
|
|
102
|
+
act(() => result.current.invalidate());
|
|
103
|
+
|
|
104
|
+
await act(async () => {
|
|
105
|
+
only.resolve(YES);
|
|
106
|
+
await expect(asked).resolves.toEqual({ result: YES, stale: true });
|
|
107
|
+
});
|
|
108
|
+
expect(result.current.result).toBeNull();
|
|
109
|
+
expect(result.current.proven).toBe(false);
|
|
110
|
+
expect(result.current.testing).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('a lone request that answers in order is the answer on screen', async () => {
|
|
114
|
+
api.testConnection.mockResolvedValueOnce(YES);
|
|
115
|
+
const { result } = renderHook(() => useConnectionProbe());
|
|
116
|
+
await act(async () => {
|
|
117
|
+
await expect(result.current.ask(ANSWERS)).resolves.toEqual({ result: YES, stale: false });
|
|
118
|
+
});
|
|
119
|
+
expect(result.current.result).toEqual(YES);
|
|
120
|
+
expect(result.current.proven).toBe(true);
|
|
121
|
+
expect(api.testConnection).toHaveBeenLastCalledWith(ANSWERS);
|
|
122
|
+
});
|
|
123
|
+
});
|