@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
|
@@ -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.');
|
|
@@ -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
|
|