@bevel-software/platform-core-frontend 0.26.0 → 0.28.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__/ProductName.test.tsx +46 -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/maker-url.ts +30 -0
- package/src/core/registry.ts +78 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/lib/__tests__/latest-request.test.ts +48 -0
- package/src/lib/latest-request.ts +45 -0
- package/src/modules/access/__tests__/ManageAccessDialog.no-sso-invite.test.tsx +222 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/api.ts +19 -3
- package/src/modules/access/components/ManageAccessDialog.tsx +61 -8
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +16 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +284 -39
- package/src/modules/admin/components/AdminRolesPage.tsx +13 -14
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/admin/components/UserAccountsPage.tsx +91 -107
- package/src/modules/admin/services/roles.api.ts +14 -1
- package/src/modules/auth/__tests__/LoginScreen.test.tsx +80 -5
- package/src/modules/auth/__tests__/sso-strict-probe.test.ts +66 -0
- package/src/modules/auth/components/LoginScreen.tsx +101 -73
- package/src/modules/auth/services/account.api.ts +59 -3
- package/src/modules/auth/services/sso.ts +30 -10
- package/src/modules/auth/state/use-sign-in-methods.ts +41 -0
- 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__/InviteButton.test.tsx +214 -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 +164 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1458 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +811 -0
- package/src/modules/onboarding/__tests__/invite-emails.test.ts +247 -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 +670 -0
- package/src/modules/onboarding/components/InviteButton.tsx +139 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +741 -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 +123 -0
- package/src/modules/onboarding/invite-emails.ts +313 -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 +35 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +39 -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 +330 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +71 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +125 -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 +230 -52
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +864 -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__/useCreatePage.test.ts +137 -0
- package/src/modules/workspace/hooks/__tests__/useKnowledgeWriteTarget.test.ts +302 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +206 -0
- package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +238 -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
|
@@ -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
|
+
});
|