@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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useCallback, useContext, useEffect, useSyncExternalStore } from 'react';
|
|
2
|
+
import { AuthContext } from '../../auth/state/auth.context';
|
|
3
|
+
import {
|
|
4
|
+
StarterPackApiError,
|
|
5
|
+
chooseStarterPack,
|
|
6
|
+
fetchStarterPacks,
|
|
7
|
+
type StarterPackApplied,
|
|
8
|
+
type StarterPacksAnswer,
|
|
9
|
+
} from '../services/starter-packs.api';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The starter-pack answer, shared by the two places that read it: the
|
|
13
|
+
* knowledge base's empty state (which asks "What does your team do?" while it
|
|
14
|
+
* is offered) and the Get set up list (whose first-page prompt follows the
|
|
15
|
+
* pack that was chosen). One request per signed-in user per page load, and a
|
|
16
|
+
* choice made in one is seen by the other at once, without asking the server
|
|
17
|
+
* twice.
|
|
18
|
+
*
|
|
19
|
+
* Kept PER SIGNED-IN USER — the store hangs off the auth context's user
|
|
20
|
+
* object, which the session holds for as long as that person is signed in
|
|
21
|
+
* — so a tab that switches accounts never shows one person's answer to the
|
|
22
|
+
* next, and a fresh session starts from nothing. A failed request is
|
|
23
|
+
* remembered as nothing known: the card stays away and the generic prompt
|
|
24
|
+
* stands, which is what the app did before there were packs.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
interface Store {
|
|
28
|
+
answer: StarterPacksAnswer | null;
|
|
29
|
+
/** The first request has come back, either way. */
|
|
30
|
+
settled: boolean;
|
|
31
|
+
inFlight: Promise<void> | null;
|
|
32
|
+
/** Asked for again while a request was out: one more request follows it. */
|
|
33
|
+
again: boolean;
|
|
34
|
+
version: number;
|
|
35
|
+
listeners: Set<() => void>;
|
|
36
|
+
subscribe(listener: () => void): () => void;
|
|
37
|
+
snapshot(): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const stores = new WeakMap<object, Store>();
|
|
41
|
+
|
|
42
|
+
function storeFor(user: object): Store {
|
|
43
|
+
const found = stores.get(user);
|
|
44
|
+
if (found) return found;
|
|
45
|
+
const store: Store = {
|
|
46
|
+
answer: null,
|
|
47
|
+
settled: false,
|
|
48
|
+
inFlight: null,
|
|
49
|
+
again: false,
|
|
50
|
+
version: 0,
|
|
51
|
+
listeners: new Set(),
|
|
52
|
+
subscribe(listener) {
|
|
53
|
+
store.listeners.add(listener);
|
|
54
|
+
return () => store.listeners.delete(listener);
|
|
55
|
+
},
|
|
56
|
+
snapshot: () => store.version,
|
|
57
|
+
};
|
|
58
|
+
stores.set(user, store);
|
|
59
|
+
return store;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function remember(store: Store, answer: StarterPacksAnswer | null): void {
|
|
63
|
+
store.answer = answer;
|
|
64
|
+
store.settled = true;
|
|
65
|
+
store.version++;
|
|
66
|
+
store.listeners.forEach((l) => l());
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The answer, requested once: concurrent first reads (the viewer's and the column's) share one request. */
|
|
70
|
+
function load(store: Store): Promise<void> {
|
|
71
|
+
if (store.inFlight) return store.inFlight;
|
|
72
|
+
const request = fetchStarterPacks()
|
|
73
|
+
.then(
|
|
74
|
+
(answer) => remember(store, answer),
|
|
75
|
+
() => {
|
|
76
|
+
if (!store.settled) remember(store, null);
|
|
77
|
+
},
|
|
78
|
+
)
|
|
79
|
+
.finally(() => {
|
|
80
|
+
store.inFlight = null;
|
|
81
|
+
if (store.again) {
|
|
82
|
+
store.again = false;
|
|
83
|
+
void load(store);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
store.inFlight = request;
|
|
87
|
+
return request;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Ask again, because something changed (a page filled in, a choice made):
|
|
92
|
+
* a request already out may have been answered before the change, so one
|
|
93
|
+
* more follows it, and whoever asked waits for the one that saw the change.
|
|
94
|
+
*/
|
|
95
|
+
function refresh(store: Store): Promise<void> {
|
|
96
|
+
if (!store.inFlight) return load(store);
|
|
97
|
+
store.again = true;
|
|
98
|
+
return store.inFlight.then(() => store.inFlight ?? Promise.resolve());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const nobody = {
|
|
102
|
+
subscribe: () => () => {},
|
|
103
|
+
snapshot: () => 0,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export interface StarterPacksState {
|
|
107
|
+
/** The server's answer; null until it arrives, or when it could not be had. */
|
|
108
|
+
answer: StarterPacksAnswer | null;
|
|
109
|
+
/** The first request has come back, either way — or there is no account to ask for. */
|
|
110
|
+
settled: boolean;
|
|
111
|
+
/** Ask again — after the tree changed under a chosen pack's pages, say. */
|
|
112
|
+
reload(): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Answer the question (a pack's id, or `none`); resolves to what was added,
|
|
115
|
+
* and the answer is re-read. `settle` runs after the server answered and
|
|
116
|
+
* BEFORE the shared answer changes under its readers: for what must be in
|
|
117
|
+
* place by then (the tree, with the pack's pages in it). Its failure is
|
|
118
|
+
* not the choice's.
|
|
119
|
+
*/
|
|
120
|
+
choose(id: string, settle?: (applied: StarterPackApplied) => Promise<unknown>): Promise<StarterPackApplied>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function useStarterPacks({ enabled = true }: { enabled?: boolean } = {}): StarterPacksState {
|
|
124
|
+
const auth = useContext(AuthContext);
|
|
125
|
+
const user = auth?.user ?? null;
|
|
126
|
+
const store = user ? storeFor(user) : null;
|
|
127
|
+
useSyncExternalStore(store?.subscribe ?? nobody.subscribe, store?.snapshot ?? nobody.snapshot, nobody.snapshot);
|
|
128
|
+
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (!enabled || !store || store.settled) return;
|
|
131
|
+
void load(store);
|
|
132
|
+
}, [enabled, store]);
|
|
133
|
+
|
|
134
|
+
const reload = useCallback(async () => {
|
|
135
|
+
if (store) await refresh(store);
|
|
136
|
+
}, [store]);
|
|
137
|
+
|
|
138
|
+
const choose = useCallback(
|
|
139
|
+
async (id: string, settle?: (applied: StarterPackApplied) => Promise<unknown>) => {
|
|
140
|
+
let applied: StarterPackApplied;
|
|
141
|
+
try {
|
|
142
|
+
applied = await chooseStarterPack(id);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
// Refused because the question is no longer asked — answered in
|
|
145
|
+
// another tab, say: the answer is read again, so the card goes. A
|
|
146
|
+
// lock refusal wears the same status; its re-read finds the offer
|
|
147
|
+
// still standing, and the card stays to say so.
|
|
148
|
+
if (err instanceof StarterPackApiError && err.status === 409 && store) await refresh(store);
|
|
149
|
+
throw err;
|
|
150
|
+
}
|
|
151
|
+
if (settle) await settle(applied).catch(() => null);
|
|
152
|
+
if (store) {
|
|
153
|
+
// The question is answered whatever the re-read says: never show it
|
|
154
|
+
// again on the strength of a request that failed.
|
|
155
|
+
if (store.answer) remember(store, { ...store.answer, offered: false, chosen: id });
|
|
156
|
+
await refresh(store);
|
|
157
|
+
}
|
|
158
|
+
return applied;
|
|
159
|
+
},
|
|
160
|
+
[store],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
answer: store?.answer ?? null,
|
|
165
|
+
settled: !store || store.settled,
|
|
166
|
+
reload,
|
|
167
|
+
choose,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -19,8 +19,9 @@ import { useAppRegistry, type AdminMenuItem } from '../../core/registry';
|
|
|
19
19
|
* Connected apps, feedback, LLM configuration, …) is registry-contributed —
|
|
20
20
|
* see the enterprise shell's `adminMenuItems`. The `order` values interleave
|
|
21
21
|
* the two lists to reproduce the historical row order. In THIS repo the
|
|
22
|
-
* registry is empty (`makeRegistry({})`), so the menu is these
|
|
23
|
-
*
|
|
22
|
+
* registry is empty (`makeRegistry({})`), so the menu is these rows plus the
|
|
23
|
+
* core modules' own action rows the shell merges in (git's "Ask before
|
|
24
|
+
* deleting branches", while it applies); the enterprise app gets all thirteen.
|
|
24
25
|
*
|
|
25
26
|
* Skills & Tools is deliberately NOT here. It is an APP (see `CORE_APPS` in
|
|
26
27
|
* CoreAppShell), and apps belong to the app switcher — which already lists it
|
|
@@ -32,7 +33,11 @@ import { useAppRegistry, type AdminMenuItem } from '../../core/registry';
|
|
|
32
33
|
* to one. The closures said the same thing twice — where the row goes, and how
|
|
33
34
|
* to go there — and only the second half was legible to anything that was not
|
|
34
35
|
* a click. The `dialog` and `onSelect` contracts on {@link AdminMenuItem} stay
|
|
35
|
-
* fully supported for registry
|
|
36
|
+
* fully supported for rows that arrive through the registry — and not every
|
|
37
|
+
* such row is the enterprise shell's: `CoreAppShell` merges core modules' own
|
|
38
|
+
* action rows into `registry.adminMenuItems` (git's "Ask before deleting
|
|
39
|
+
* branches", an `onSelect` row with no `path`, which therefore never reaches
|
|
40
|
+
* the settings nav).
|
|
36
41
|
*/
|
|
37
42
|
export const CORE_MENU_ITEMS: AdminMenuItem[] = [
|
|
38
43
|
{
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
|
|
5
|
+
const api = vi.hoisted(() => ({
|
|
6
|
+
fetchSetupStatus: vi.fn(),
|
|
7
|
+
saveSettings: vi.fn(),
|
|
8
|
+
testConnection: vi.fn(),
|
|
9
|
+
testOidc: vi.fn(),
|
|
10
|
+
syncNow: vi.fn(),
|
|
11
|
+
fetchGitHubApp: vi.fn(),
|
|
12
|
+
fetchGitHubRepositories: vi.fn(),
|
|
13
|
+
startGitHubAppRegistration: vi.fn(),
|
|
14
|
+
startGitHubAppInstallation: vi.fn(),
|
|
15
|
+
startGitHubAppRefresh: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
vi.mock('../services/setup.api', async () => {
|
|
18
|
+
// The error classes are real: the screen tells a refusal from a failure by `instanceof`.
|
|
19
|
+
const actual = await vi.importActual<typeof import('../services/setup.api')>('../services/setup.api');
|
|
20
|
+
return { ...actual, ...api };
|
|
21
|
+
});
|
|
22
|
+
vi.mock('../../settings/services/github-facade.api', () => ({
|
|
23
|
+
fetchGitHubFacade: vi.fn(),
|
|
24
|
+
rotateGitHubFacade: vi.fn(),
|
|
25
|
+
fetchMarketplaceRegistration: vi.fn(async () => false),
|
|
26
|
+
setMarketplaceRegistration: vi.fn(),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
import { SetupGate } from '../components/SetupGate';
|
|
30
|
+
import { AppRegistryContext, EMPTY_REGISTRY } from '../../../core/registry';
|
|
31
|
+
import {
|
|
32
|
+
KbInitFailed,
|
|
33
|
+
SettingsProblems,
|
|
34
|
+
type GitHubAppStatus,
|
|
35
|
+
type GitMode,
|
|
36
|
+
type RepositoryStatus,
|
|
37
|
+
type SettingStatus,
|
|
38
|
+
} from '../services/setup.api';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The first-run storage question: what a fresh deployment shows its admin
|
|
42
|
+
* before the full setup form, and when it steps aside for that form.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const setting = (key: string, extra: Partial<SettingStatus> = {}): SettingStatus => ({
|
|
46
|
+
key,
|
|
47
|
+
section: 'knowledge-base',
|
|
48
|
+
source: 'unset',
|
|
49
|
+
value: '',
|
|
50
|
+
configured: false,
|
|
51
|
+
secret: false,
|
|
52
|
+
restartToApply: false,
|
|
53
|
+
...extra,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const SETTINGS: SettingStatus[] = [
|
|
57
|
+
setting('gitMode', { restartToApply: true }),
|
|
58
|
+
setting('githubRepository'),
|
|
59
|
+
setting('kbRepoUrl'),
|
|
60
|
+
setting('gitToken', { secret: true, value: undefined }),
|
|
61
|
+
setting('defaultBranch'),
|
|
62
|
+
setting('protectedBranches'),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const MODES: GitMode[] = ['managed', 'github-app', 'token'];
|
|
66
|
+
const FRESH: RepositoryStatus = { mode: null, chosen: null, modes: MODES };
|
|
67
|
+
const INSTALLED: GitHubAppStatus = {
|
|
68
|
+
registeredBy: 'setup',
|
|
69
|
+
app: { slug: 'hexis-acme', url: 'https://github.com/apps/hexis-acme' },
|
|
70
|
+
installation: { id: '77', account: 'acme' },
|
|
71
|
+
repository: null,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const realLocation = window.location;
|
|
75
|
+
let reload: ReturnType<typeof vi.fn>;
|
|
76
|
+
let assign: ReturnType<typeof vi.fn>;
|
|
77
|
+
function standAt(search = '') {
|
|
78
|
+
reload = vi.fn();
|
|
79
|
+
assign = vi.fn();
|
|
80
|
+
Object.defineProperty(window, 'location', {
|
|
81
|
+
configurable: true,
|
|
82
|
+
value: { ...realLocation, href: `https://kb.acme.test/${search}`, search, origin: 'https://kb.acme.test', reload, assign },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** `null`: a server that knows one way only, and so reports none. */
|
|
87
|
+
function statusWith(repository: RepositoryStatus | null) {
|
|
88
|
+
return { complete: false, isAdmin: true, settings: SETTINGS, ...(repository ? { repository } : {}) };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function showGate(repository: RepositoryStatus | null = FRESH, registry = EMPTY_REGISTRY) {
|
|
92
|
+
api.fetchSetupStatus.mockResolvedValue(statusWith(repository));
|
|
93
|
+
render(
|
|
94
|
+
<AppRegistryContext.Provider value={registry}>
|
|
95
|
+
<SetupGate>
|
|
96
|
+
<div>The application</div>
|
|
97
|
+
</SetupGate>
|
|
98
|
+
</AppRegistryContext.Provider>,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const question = () => screen.findByRole('heading', { name: 'Where should your knowledge base live?' });
|
|
103
|
+
const fullForm = () => screen.findByRole('heading', { name: 'Set up this deployment' });
|
|
104
|
+
const managedCard = () => screen.getByRole('radio', { name: 'Hexis takes care of it' });
|
|
105
|
+
const gitHubCard = () => screen.queryByRole('radio', { name: 'My own GitHub' });
|
|
106
|
+
const proceed = () => userEvent.click(screen.getByRole('button', { name: 'Continue' }));
|
|
107
|
+
|
|
108
|
+
beforeEach(() => {
|
|
109
|
+
for (const fn of Object.values(api)) fn.mockReset();
|
|
110
|
+
api.fetchGitHubApp.mockResolvedValue(INSTALLED);
|
|
111
|
+
api.fetchGitHubRepositories.mockResolvedValue({
|
|
112
|
+
repositories: [{ fullName: 'acme/kb', private: true, defaultBranch: 'main', writable: true }],
|
|
113
|
+
more: false,
|
|
114
|
+
});
|
|
115
|
+
sessionStorage.clear();
|
|
116
|
+
standAt();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
afterEach(() => {
|
|
120
|
+
Object.defineProperty(window, 'location', { configurable: true, value: realLocation });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('SetupGate: the first-run storage question', () => {
|
|
124
|
+
it('is what a fresh deployment shows its admin, with the managed repository chosen', async () => {
|
|
125
|
+
showGate();
|
|
126
|
+
await question();
|
|
127
|
+
expect(screen.queryByRole('heading', { name: 'Set up this deployment' })).toBeNull();
|
|
128
|
+
expect(screen.getAllByRole('radio').map((r) => r.getAttribute('aria-checked'))).toEqual(['true', 'false']);
|
|
129
|
+
expect(managedCard()).toHaveAccessibleDescription(/Ready right away/);
|
|
130
|
+
expect(screen.getByText('Recommended')).toBeInTheDocument();
|
|
131
|
+
expect(screen.queryByText('The application')).toBeNull();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('saves the managed repository with nothing else, and opens the knowledge base once setup is complete', async () => {
|
|
135
|
+
showGate();
|
|
136
|
+
await question();
|
|
137
|
+
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: true, settings: SETTINGS });
|
|
138
|
+
await proceed();
|
|
139
|
+
expect(api.saveSettings).toHaveBeenCalledWith({ gitMode: 'managed' });
|
|
140
|
+
await waitFor(() => expect(assign).toHaveBeenCalledWith('/workspace'));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('hands over to the full form when the save leaves something still to answer', async () => {
|
|
144
|
+
showGate();
|
|
145
|
+
await question();
|
|
146
|
+
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: false, settings: SETTINGS });
|
|
147
|
+
api.fetchSetupStatus.mockResolvedValue(statusWith({ mode: 'managed', chosen: 'managed', modes: MODES }));
|
|
148
|
+
await proceed();
|
|
149
|
+
expect(await fullForm()).toBeInTheDocument();
|
|
150
|
+
expect(assign).not.toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
/** The choice is stored; the full form owns the failure and its retry. */
|
|
154
|
+
it('hands over to the full form when the knowledge base could not be initialized', async () => {
|
|
155
|
+
showGate();
|
|
156
|
+
await question();
|
|
157
|
+
api.saveSettings.mockRejectedValue(new KbInitFailed({ kind: 'unknown', cause: 'The disk is full.' }));
|
|
158
|
+
api.fetchSetupStatus.mockResolvedValue({
|
|
159
|
+
...statusWith({ mode: 'managed', chosen: 'managed', modes: MODES }),
|
|
160
|
+
kbInit: { kind: 'unknown', cause: 'The disk is full.' },
|
|
161
|
+
});
|
|
162
|
+
await proceed();
|
|
163
|
+
expect(await screen.findByTestId('kb-init-failure')).toHaveTextContent('The disk is full.');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('says when a restart is owed', async () => {
|
|
167
|
+
showGate();
|
|
168
|
+
await question();
|
|
169
|
+
api.saveSettings.mockResolvedValue({ restartRequired: true, complete: false, awaitingRestart: true, settings: SETTINGS });
|
|
170
|
+
await proceed();
|
|
171
|
+
expect(await screen.findByText(/needs a restart to pick the branch settings up/)).toBeInTheDocument();
|
|
172
|
+
expect(screen.getByRole('button', { name: 'Continue' })).toBeDisabled();
|
|
173
|
+
expect(assign).not.toHaveBeenCalled();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('says why a save failed and lets it be tried again', async () => {
|
|
177
|
+
showGate();
|
|
178
|
+
await question();
|
|
179
|
+
api.saveSettings.mockRejectedValue(new Error('The server could not be reached.'));
|
|
180
|
+
await proceed();
|
|
181
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('The server could not be reached.');
|
|
182
|
+
expect(screen.getByRole('button', { name: 'Continue' })).toBeEnabled();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('offers GitHub only where the deployment can connect through a GitHub App', async () => {
|
|
186
|
+
showGate({ mode: null, chosen: null, modes: ['managed', 'token'] });
|
|
187
|
+
await question();
|
|
188
|
+
expect(gitHubCard()).toBeNull();
|
|
189
|
+
expect(screen.getAllByRole('radio')).toHaveLength(1);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('moves the choice with the arrow keys, as a radiogroup promises', async () => {
|
|
193
|
+
showGate();
|
|
194
|
+
await question();
|
|
195
|
+
managedCard().focus();
|
|
196
|
+
await userEvent.keyboard('{ArrowRight}');
|
|
197
|
+
expect(gitHubCard()).toHaveAttribute('aria-checked', 'true');
|
|
198
|
+
expect(gitHubCard()).toHaveFocus();
|
|
199
|
+
expect(managedCard()).toHaveAttribute('tabindex', '-1');
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('connects GitHub, then saves the repository chosen there', async () => {
|
|
203
|
+
showGate();
|
|
204
|
+
await question();
|
|
205
|
+
await userEvent.click(gitHubCard()!);
|
|
206
|
+
await proceed();
|
|
207
|
+
expect(await screen.findByRole('heading', { name: 'Connect your GitHub' })).toBeInTheDocument();
|
|
208
|
+
expect(api.saveSettings).not.toHaveBeenCalled();
|
|
209
|
+
const save = screen.getByRole('button', { name: 'Save and continue' });
|
|
210
|
+
expect(save).toBeDisabled();
|
|
211
|
+
|
|
212
|
+
const picker = await screen.findByLabelText('Repository');
|
|
213
|
+
await waitFor(() => expect(picker).toBeEnabled());
|
|
214
|
+
await userEvent.selectOptions(picker, 'acme/kb');
|
|
215
|
+
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: true, settings: SETTINGS });
|
|
216
|
+
await userEvent.click(save);
|
|
217
|
+
expect(api.saveSettings).toHaveBeenCalledWith({ gitMode: 'github-app', githubRepository: 'acme/kb' });
|
|
218
|
+
await waitFor(() => expect(assign).toHaveBeenCalledWith('/workspace'));
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('shows a refusal about the repository beside it', async () => {
|
|
222
|
+
showGate();
|
|
223
|
+
await question();
|
|
224
|
+
await userEvent.click(gitHubCard()!);
|
|
225
|
+
await proceed();
|
|
226
|
+
const picker = await screen.findByLabelText('Repository');
|
|
227
|
+
await waitFor(() => expect(picker).toBeEnabled());
|
|
228
|
+
await userEvent.selectOptions(picker, 'acme/kb');
|
|
229
|
+
const refusal = 'The GitHub App cannot reach that repository.';
|
|
230
|
+
api.saveSettings.mockRejectedValue(new SettingsProblems({ githubRepository: refusal }));
|
|
231
|
+
await userEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
|
|
232
|
+
expect(await screen.findByText(refusal)).toHaveAttribute('id', 'github-repository-problem');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('goes back from GitHub to the question', async () => {
|
|
236
|
+
showGate();
|
|
237
|
+
await question();
|
|
238
|
+
await userEvent.click(gitHubCard()!);
|
|
239
|
+
await proceed();
|
|
240
|
+
await userEvent.click(await screen.findByRole('button', { name: 'Back' }));
|
|
241
|
+
expect(await question()).toBeInTheDocument();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
/** The trip to GitHub started here, so the return lands here, on the GitHub step. */
|
|
245
|
+
it('opens on the GitHub step on a return from GitHub', async () => {
|
|
246
|
+
standAt('?github=connected');
|
|
247
|
+
showGate();
|
|
248
|
+
expect(await screen.findByRole('heading', { name: 'Connect your GitHub' })).toBeInTheDocument();
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('returns to the full form when the trip to GitHub started there', async () => {
|
|
252
|
+
standAt('?github=connected');
|
|
253
|
+
sessionStorage.setItem(
|
|
254
|
+
'hexis_setup_draft',
|
|
255
|
+
JSON.stringify({ draft: { defaultBranch: 'trunk' }, dropped: [], at: Date.now() }),
|
|
256
|
+
);
|
|
257
|
+
showGate();
|
|
258
|
+
expect(await fullForm()).toBeInTheDocument();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
describe('an address and a token, on this screen', () => {
|
|
262
|
+
const openAddressStep = async () => {
|
|
263
|
+
showGate();
|
|
264
|
+
await question();
|
|
265
|
+
await userEvent.click(screen.getByRole('button', { name: 'Use an address and token' }));
|
|
266
|
+
await screen.findByRole('heading', { name: 'Connect your repository' });
|
|
267
|
+
};
|
|
268
|
+
const fill = async (url: string, token = 'glpat-secret') => {
|
|
269
|
+
await userEvent.type(screen.getByLabelText('Repository address'), url);
|
|
270
|
+
await userEvent.type(screen.getByLabelText('Access token'), token);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
it('opens as a step of this screen, not the full form, and goes back to the cards', async () => {
|
|
274
|
+
await openAddressStep();
|
|
275
|
+
expect(screen.queryByRole('heading', { name: 'Set up this deployment' })).toBeNull();
|
|
276
|
+
expect(screen.queryByRole('tab', { name: 'Hexis takes care of it' })).toBeNull();
|
|
277
|
+
expect(screen.getByRole('button', { name: 'Save and continue' })).toBeDisabled();
|
|
278
|
+
await userEvent.click(screen.getByRole('button', { name: 'Back' }));
|
|
279
|
+
expect(await question()).toBeInTheDocument();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('tests the connection and says what the host answered', async () => {
|
|
283
|
+
await openAddressStep();
|
|
284
|
+
await fill('https://gitlab.com/acme/kb.git');
|
|
285
|
+
api.testConnection.mockResolvedValue({ ok: true, outcome: 'connected', empty: true, branches: [] });
|
|
286
|
+
await userEvent.click(screen.getByRole('button', { name: 'Test connection' }));
|
|
287
|
+
expect(await screen.findByText('Connected. The repository is empty; it will be set up for you.')).toBeInTheDocument();
|
|
288
|
+
// The host's token username is known, so it is sent and not asked.
|
|
289
|
+
expect(api.testConnection).toHaveBeenCalledWith(
|
|
290
|
+
expect.objectContaining({ kbRepoUrl: 'https://gitlab.com/acme/kb.git', gitToken: 'glpat-secret' }),
|
|
291
|
+
);
|
|
292
|
+
expect(screen.queryByLabelText('Username for the token')).toBeNull();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('proves the connection before saving, then saves it with the branch the host named', async () => {
|
|
296
|
+
await openAddressStep();
|
|
297
|
+
await fill('https://gitlab.com/acme/kb.git');
|
|
298
|
+
api.testConnection.mockResolvedValue({ ok: true, outcome: 'connected', defaultBranch: 'trunk', branches: ['trunk'] });
|
|
299
|
+
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: true, settings: SETTINGS });
|
|
300
|
+
await userEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
|
|
301
|
+
await waitFor(() =>
|
|
302
|
+
expect(api.saveSettings).toHaveBeenCalledWith(
|
|
303
|
+
expect.objectContaining({
|
|
304
|
+
gitMode: 'token',
|
|
305
|
+
kbRepoUrl: 'https://gitlab.com/acme/kb.git',
|
|
306
|
+
gitToken: 'glpat-secret',
|
|
307
|
+
defaultBranch: 'trunk',
|
|
308
|
+
protectedBranches: 'trunk',
|
|
309
|
+
}),
|
|
310
|
+
),
|
|
311
|
+
);
|
|
312
|
+
await waitFor(() => expect(assign).toHaveBeenCalledWith('/workspace'));
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('does not save what the host turned down, and says why', async () => {
|
|
316
|
+
await openAddressStep();
|
|
317
|
+
await fill('https://gitlab.com/acme/kb.git', 'wrong');
|
|
318
|
+
api.testConnection.mockResolvedValue({ ok: false, outcome: 'rejected', field: 'gitToken', error: 'The token was refused.' });
|
|
319
|
+
await userEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
|
|
320
|
+
expect(await screen.findByText('The token was refused.')).toBeInTheDocument();
|
|
321
|
+
expect(screen.getByLabelText('Access token')).toHaveAttribute('aria-invalid', 'true');
|
|
322
|
+
expect(api.saveSettings).not.toHaveBeenCalled();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('drops a test answer about values edited while it was out, and tests what is typed before saving', async () => {
|
|
326
|
+
await openAddressStep();
|
|
327
|
+
await fill('https://gitlab.com/acme/old.git');
|
|
328
|
+
let answerOld!: (result: unknown) => void;
|
|
329
|
+
api.testConnection.mockImplementationOnce(() => new Promise((resolve) => (answerOld = resolve)));
|
|
330
|
+
await userEvent.click(screen.getByRole('button', { name: 'Test connection' }));
|
|
331
|
+
await waitFor(() => expect(api.testConnection).toHaveBeenCalledTimes(1));
|
|
332
|
+
|
|
333
|
+
const address = screen.getByLabelText('Repository address');
|
|
334
|
+
await userEvent.clear(address);
|
|
335
|
+
await userEvent.type(address, 'https://gitlab.com/acme/new.git');
|
|
336
|
+
answerOld({ ok: true, outcome: 'connected', defaultBranch: 'trunk', branches: ['trunk'] });
|
|
337
|
+
// The old repository's answer is not shown as if it were about the new one…
|
|
338
|
+
await waitFor(() => expect(screen.getByRole('button', { name: 'Test connection' })).toBeEnabled());
|
|
339
|
+
expect(screen.queryByText('Connected.')).toBeNull();
|
|
340
|
+
|
|
341
|
+
// …nor saved with: Save tests what is typed now, and takes the branch from that.
|
|
342
|
+
api.testConnection.mockResolvedValue({ ok: true, outcome: 'connected', defaultBranch: 'main', branches: ['main'] });
|
|
343
|
+
api.saveSettings.mockResolvedValue({ restartRequired: false, complete: true, settings: SETTINGS });
|
|
344
|
+
await userEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
|
|
345
|
+
await waitFor(() =>
|
|
346
|
+
expect(api.saveSettings).toHaveBeenCalledWith(
|
|
347
|
+
expect.objectContaining({
|
|
348
|
+
kbRepoUrl: 'https://gitlab.com/acme/new.git',
|
|
349
|
+
defaultBranch: 'main',
|
|
350
|
+
protectedBranches: 'main',
|
|
351
|
+
}),
|
|
352
|
+
),
|
|
353
|
+
);
|
|
354
|
+
expect(api.testConnection).toHaveBeenCalledTimes(2);
|
|
355
|
+
expect(api.testConnection).toHaveBeenLastCalledWith(
|
|
356
|
+
expect.objectContaining({ kbRepoUrl: 'https://gitlab.com/acme/new.git' }),
|
|
357
|
+
);
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
it('asks for the token username only on a host it does not know', async () => {
|
|
361
|
+
await openAddressStep();
|
|
362
|
+
await fill('https://git.acme.internal/kb.git');
|
|
363
|
+
expect(screen.getByLabelText('Username for the token')).toBeInTheDocument();
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it.each<[string, RepositoryStatus | null]>([
|
|
368
|
+
['a way is already chosen', { mode: null, chosen: 'token', modes: MODES }],
|
|
369
|
+
['a way is in effect on a server that does not report the choice', { mode: 'token', modes: MODES }],
|
|
370
|
+
['the environment pinned the way', { mode: null, chosen: null, pinned: 'GIT_MODE', modes: MODES }],
|
|
371
|
+
['the managed repository is not offered', { mode: null, chosen: null, modes: ['github-app', 'token'] }],
|
|
372
|
+
['the server knows one way only', null],
|
|
373
|
+
])('shows the full form as before when %s', async (_, repository) => {
|
|
374
|
+
showGate(repository);
|
|
375
|
+
expect(await fullForm()).toBeInTheDocument();
|
|
376
|
+
expect(screen.queryByRole('heading', { name: 'Where should your knowledge base live?' })).toBeNull();
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it('takes what the managed card says from the registry', async () => {
|
|
380
|
+
showGate(FRESH, {
|
|
381
|
+
...EMPTY_REGISTRY,
|
|
382
|
+
managedStorage: { title: 'Hexis keeps it', description: 'Hosted for you, ready now.' },
|
|
383
|
+
});
|
|
384
|
+
await question();
|
|
385
|
+
const card = screen.getByRole('radio', { name: 'Hexis keeps it' });
|
|
386
|
+
expect(card).toHaveAccessibleDescription(/Hosted for you, ready now\./);
|
|
387
|
+
expect(screen.queryByText('Hexis takes care of it')).toBeNull();
|
|
388
|
+
});
|
|
389
|
+
});
|
|
@@ -97,8 +97,8 @@ afterEach(() => {
|
|
|
97
97
|
describe('SetupScreen: the GitHub tab', () => {
|
|
98
98
|
it('is offered second, between the repository the deployment keeps and an address', () => {
|
|
99
99
|
show();
|
|
100
|
-
expect(screen.getAllByRole('tab').map((t) => t.textContent)).toEqual(['
|
|
101
|
-
expect(screen.getByRole('tab', { name: '
|
|
100
|
+
expect(screen.getAllByRole('tab').map((t) => t.textContent)).toEqual(['Hexis takes care of it', 'GitHub', 'Address and token']);
|
|
101
|
+
expect(screen.getByRole('tab', { name: 'Hexis takes care of it' })).toHaveAttribute('aria-selected', 'true');
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
it('is not drawn by a deployment that cannot connect to GitHub', () => {
|
|
@@ -342,7 +342,7 @@ describe('saving a repository on GitHub', () => {
|
|
|
342
342
|
const picker = await screen.findByRole('combobox', { name: 'Repository' });
|
|
343
343
|
await waitFor(() => expect(picker).toBeEnabled());
|
|
344
344
|
await userEvent.selectOptions(picker, 'acme/kb');
|
|
345
|
-
await userEvent.click(screen.getByRole('tab', { name: '
|
|
345
|
+
await userEvent.click(screen.getByRole('tab', { name: 'Hexis takes care of it' }));
|
|
346
346
|
await save();
|
|
347
347
|
await waitFor(() => expect(api.saveSettings).toHaveBeenCalledWith({ gitMode: 'managed' }));
|
|
348
348
|
});
|
|
@@ -352,7 +352,7 @@ describe('saving a repository on GitHub', () => {
|
|
|
352
352
|
api.saveSettings.mockRejectedValue(new SettingsProblems({ githubRepository: refusal }));
|
|
353
353
|
show({ mode: 'github-app', stored: 'acme/gone', variant: 'settings' });
|
|
354
354
|
await screen.findByRole('combobox', { name: 'Repository' });
|
|
355
|
-
await userEvent.click(screen.getByRole('tab', { name: '
|
|
355
|
+
await userEvent.click(screen.getByRole('tab', { name: 'Hexis takes care of it' }));
|
|
356
356
|
await userEvent.click(screen.getByRole('tab', { name: 'GitHub' }));
|
|
357
357
|
await save();
|
|
358
358
|
expect(await screen.findByText(refusal)).toBeInTheDocument();
|
|
@@ -411,6 +411,6 @@ describe('coming back from GitHub', () => {
|
|
|
411
411
|
it('opens where it always does on a deployment that does not offer GitHub', () => {
|
|
412
412
|
standAt('?github=connected');
|
|
413
413
|
show({ modes: ['managed', 'token'] });
|
|
414
|
-
expect(screen.getByRole('tab', { name: '
|
|
414
|
+
expect(screen.getByRole('tab', { name: 'Hexis takes care of it' })).toHaveAttribute('aria-selected', 'true');
|
|
415
415
|
});
|
|
416
416
|
});
|
|
@@ -163,7 +163,7 @@ describe('what was typed, across the trip to GitHub', () => {
|
|
|
163
163
|
show();
|
|
164
164
|
await typeThenLeave('Create the GitHub App');
|
|
165
165
|
comeBack();
|
|
166
|
-
await userEvent.click(screen.getByRole('tab', { name: '
|
|
166
|
+
await userEvent.click(screen.getByRole('tab', { name: 'Hexis takes care of it' }));
|
|
167
167
|
await userEvent.click(screen.getByRole('button', { name: 'Save and continue' }));
|
|
168
168
|
await waitFor(() => expect(api.saveSettings).toHaveBeenCalled());
|
|
169
169
|
expect(api.saveSettings.mock.calls[0]![0]).toEqual({
|
|
@@ -113,7 +113,7 @@ describe('a changed repository address, with change requests open', () => {
|
|
|
113
113
|
expect(confirm).toHaveTextContent(/stops being used and is cloned fresh/i);
|
|
114
114
|
// The warning has to name the cost, and name it truthfully: the copies are
|
|
115
115
|
// set aside on the server, so the work is out of the app but not destroyed.
|
|
116
|
-
expect(confirm).toHaveTextContent(/
|
|
116
|
+
expect(confirm).toHaveTextContent(/hasn’t reached your git host yet goes out of\s+the app/i);
|
|
117
117
|
expect(confirm).toHaveTextContent(/nothing is deleted/i);
|
|
118
118
|
expect(confirm).toHaveTextContent(/replaced-working-copies/);
|
|
119
119
|
expect(confirm).toHaveTextContent('There are 2 open change requests.');
|