@bevel-software/platform-core-frontend 0.1.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/LICENSE +202 -0
- package/package.json +70 -0
- package/src/core/CoreAppShell.tsx +444 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +95 -0
- package/src/core/events.ts +29 -0
- package/src/core/registry.ts +336 -0
- package/src/css-side-effect-imports.d.ts +7 -0
- package/src/html-extensions.ts +12 -0
- package/src/index.css +49 -0
- package/src/index.ts +23 -0
- package/src/lib/api.ts +57 -0
- package/src/lib/utils.ts +138 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +130 -0
- package/src/modules/access/__tests__/useFileAccess.test.tsx +253 -0
- package/src/modules/access/api.ts +205 -0
- package/src/modules/access/components/AccessRestrictedBanner.tsx +31 -0
- package/src/modules/access/components/ManageAccessDialog.tsx +1232 -0
- package/src/modules/access/components/NodeOwnersBanner.tsx +30 -0
- package/src/modules/access/hooks/useFileAccess.ts +151 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +943 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +74 -0
- package/src/modules/admin/services/admin.api.ts +92 -0
- package/src/modules/admin/services/roles.api.ts +136 -0
- package/src/modules/admin/state/admin.context.tsx +223 -0
- package/src/modules/auth/components/LoginScreen.tsx +135 -0
- package/src/modules/auth/hooks/useAuthState.ts +59 -0
- package/src/modules/auth/services/auth.api.ts +24 -0
- package/src/modules/auth/services/microsoft-oauth.ts +57 -0
- package/src/modules/auth/state/auth.context.ts +18 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +347 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +201 -0
- package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +82 -0
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +441 -0
- package/src/modules/git/__tests__/git.api.test.ts +113 -0
- package/src/modules/git/__tests__/pr.api.test.ts +44 -0
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +212 -0
- package/src/modules/git/components/BranchSwitcher.tsx +527 -0
- package/src/modules/git/components/DiffView.tsx +30 -0
- package/src/modules/git/components/FileComparisonPanel.tsx +377 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +320 -0
- package/src/modules/git/components/ProtectedBranchBanner.tsx +42 -0
- package/src/modules/git/components/PullNeededBanner.tsx +204 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +244 -0
- package/src/modules/git/components/UnifiedDiffView.tsx +37 -0
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +99 -0
- package/src/modules/git/hooks/useAutoPullUpdates.ts +121 -0
- package/src/modules/git/hooks/useGitState.ts +335 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +134 -0
- package/src/modules/git/services/error-messages.ts +257 -0
- package/src/modules/git/services/git.api.ts +163 -0
- package/src/modules/git/services/pr-prompts.ts +159 -0
- package/src/modules/git/services/pr.api.ts +39 -0
- package/src/modules/git/state/auto-update.context.ts +21 -0
- package/src/modules/git/state/git.context.ts +82 -0
- package/src/modules/layout/components/AppLayout.tsx +40 -0
- package/src/modules/layout/components/DemoBanner.tsx +57 -0
- package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +153 -0
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +203 -0
- package/src/modules/layout/components/SlideOverlay.tsx +224 -0
- package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +77 -0
- package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +57 -0
- package/src/modules/layout/hooks/useMediaQuery.ts +23 -0
- package/src/modules/layout/state/__tests__/layout.context.test.tsx +39 -0
- package/src/modules/layout/state/layout.context.ts +46 -0
- package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -0
- package/src/modules/library/__tests__/diff.test.ts +62 -0
- package/src/modules/library/__tests__/loadout.test.tsx +72 -0
- package/src/modules/library/__tests__/status.test.ts +117 -0
- package/src/modules/library/components/ChangeRequestDock.tsx +47 -0
- package/src/modules/library/components/CompareView.tsx +357 -0
- package/src/modules/library/components/DetailDialog.tsx +566 -0
- package/src/modules/library/components/GearIcon.tsx +12 -0
- package/src/modules/library/components/LibraryCard.tsx +132 -0
- package/src/modules/library/components/LibraryPage.tsx +254 -0
- package/src/modules/library/components/LoadoutSidebar.tsx +156 -0
- package/src/modules/library/components/StatusGem.tsx +21 -0
- package/src/modules/library/components/SuggestChange.tsx +171 -0
- package/src/modules/library/components/particles.ts +50 -0
- package/src/modules/library/hooks/useLibraryData.ts +119 -0
- package/src/modules/library/hooks/useSkillDetail.ts +74 -0
- package/src/modules/library/library.css +320 -0
- package/src/modules/library/services/library.api.ts +164 -0
- package/src/modules/library/state/loadout.tsx +129 -0
- package/src/modules/library/state/toast.tsx +42 -0
- package/src/modules/library/utils/diff.ts +102 -0
- package/src/modules/library/utils/status.ts +116 -0
- package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +93 -0
- package/src/modules/pr/__tests__/PrCancelButton.test.tsx +158 -0
- package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +44 -0
- package/src/modules/pr/__tests__/PrMergeButton.test.tsx +360 -0
- package/src/modules/pr/__tests__/bucketize-comments.test.ts +85 -0
- package/src/modules/pr/__tests__/parsePatch.test.ts +104 -0
- package/src/modules/pr/__tests__/usePrViewerState.test.ts +72 -0
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +193 -0
- package/src/modules/pr/components/PrApprovalBadge.tsx +80 -0
- package/src/modules/pr/components/PrCancelButton.tsx +99 -0
- package/src/modules/pr/components/PrCancelConfirmDialog.tsx +119 -0
- package/src/modules/pr/components/PrCommentComposer.tsx +92 -0
- package/src/modules/pr/components/PrCommentThread.tsx +168 -0
- package/src/modules/pr/components/PrCommentsPanel.tsx +143 -0
- package/src/modules/pr/components/PrDiffPane.tsx +425 -0
- package/src/modules/pr/components/PrFileRow.tsx +164 -0
- package/src/modules/pr/components/PrFilesList.tsx +53 -0
- package/src/modules/pr/components/PrHeader.tsx +45 -0
- package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +58 -0
- package/src/modules/pr/components/PrMergeButton.tsx +268 -0
- package/src/modules/pr/components/PrMergeConfirmDialog.tsx +112 -0
- package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +110 -0
- package/src/modules/pr/components/PrViewer.tsx +364 -0
- package/src/modules/pr/hooks/usePrViewerState.ts +150 -0
- package/src/modules/pr/services/pr-approvals.api.ts +31 -0
- package/src/modules/pr/services/pr-cancel.api.ts +19 -0
- package/src/modules/pr/services/pr-comments.api.ts +45 -0
- package/src/modules/pr/services/pr-detail.api.ts +17 -0
- package/src/modules/pr/services/pr-merge.api.ts +53 -0
- package/src/modules/pr/services/pr-open.api.ts +30 -0
- package/src/modules/pr/state/pr-viewer.context.ts +34 -0
- package/src/modules/pr/utils/bucketize-comments.ts +55 -0
- package/src/modules/pr/utils/parsePatch.ts +57 -0
- package/src/modules/review/__tests__/review.api.test.ts +121 -0
- package/src/modules/review/components/BinaryChangePlaceholder.tsx +15 -0
- package/src/modules/review/components/DiffViewer.tsx +78 -0
- package/src/modules/review/components/MarkdownDiffViewer.tsx +263 -0
- package/src/modules/review/components/ReviewFileRow.tsx +114 -0
- package/src/modules/review/components/ReviewPanel.tsx +260 -0
- package/src/modules/review/components/ReviewPanelSurface.tsx +52 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +106 -0
- package/src/modules/review/hooks/__tests__/useReviewState.test.ts +88 -0
- package/src/modules/review/hooks/useReviewState.ts +256 -0
- package/src/modules/review/services/review.api.ts +72 -0
- package/src/modules/review/state/ReviewProvider.tsx +28 -0
- package/src/modules/review/state/review.context.ts +29 -0
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +488 -0
- package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -0
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +362 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -0
- package/src/modules/secrets-vault/services/connect.api.ts +113 -0
- package/src/modules/secrets-vault/services/secrets.api.ts +82 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +116 -0
- package/src/modules/toolbar/components/AdminMenu.tsx +250 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +108 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -0
- package/src/modules/toolbar/components/Toolbar.tsx +123 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +122 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +353 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +65 -0
- package/src/modules/tools/ToolsExplorerPage.tsx +380 -0
- package/src/modules/workflow/hooks/useEventBusSubscription.ts +24 -0
- package/src/modules/workflow/hooks/useFileLock.ts +430 -0
- package/src/modules/workflow/services/lock.api.ts +139 -0
- package/src/modules/workflow/state/EventBusFocusBinder.tsx +25 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +232 -0
- package/src/modules/workflow/state/event-bus.context.ts +75 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +54 -0
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +91 -0
- package/src/modules/workspace/components/EditorTabs.tsx +384 -0
- package/src/modules/workspace/components/FileExplorer.tsx +1068 -0
- package/src/modules/workspace/components/FileRoute.tsx +392 -0
- package/src/modules/workspace/components/FileViewer.tsx +906 -0
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +241 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +666 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +330 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +492 -0
- package/src/modules/workspace/components/renderers/CsvRenderer.tsx +174 -0
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +87 -0
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +231 -0
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +50 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +287 -0
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +252 -0
- package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +268 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +81 -0
- package/src/modules/workspace/components/renderers/TextRenderer.tsx +86 -0
- package/src/modules/workspace/components/renderers/ToolForm.tsx +404 -0
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +417 -0
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +157 -0
- package/src/modules/workspace/components/renderers/__tests__/CsvRenderer.test.ts +57 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +95 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +328 -0
- package/src/modules/workspace/components/renderers/__tests__/PdfRenderer.test.tsx +167 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +318 -0
- package/src/modules/workspace/components/renderers/csvUtils.ts +76 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +332 -0
- package/src/modules/workspace/components/renderers/index.ts +39 -0
- package/src/modules/workspace/components/renderers/types.ts +27 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +298 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +1315 -0
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +99 -0
- package/src/modules/workspace/routing/kb-routes.ts +266 -0
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +72 -0
- package/src/modules/workspace/services/workspace.api.ts +185 -0
- package/src/modules/workspace/state/workspace.context.ts +235 -0
- package/src/modules/workspace/utils/__tests__/frontmatter.test.ts +107 -0
- package/src/modules/workspace/utils/diff.ts +53 -0
- package/src/modules/workspace/utils/fileTree.ts +179 -0
- package/src/modules/workspace/utils/frontmatter.ts +80 -0
- package/src/modules/workspace/utils/readDroppedEntries.ts +119 -0
- package/src/modules/workspace/utils/tab-persistence.ts +23 -0
- package/src/shared/components/Dialog.tsx +198 -0
- package/src/shared/components/PageShell.tsx +51 -0
- package/src/shared/components/useModalLayer.ts +35 -0
- package/src/shared/markdown/Markdown.tsx +62 -0
- package/src/test-setup.ts +59 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
2
|
+
import { renderHook, waitFor } from '@testing-library/react';
|
|
3
|
+
import type { BranchInfo, CommitAttribution, FileTreeEntry, WorkingTreeStatus } from '@bevel-software/platform-shared';
|
|
4
|
+
import { useAutoPullUpdates } from '../hooks/useAutoPullUpdates';
|
|
5
|
+
import type { GitContextValue } from '../state/git.context';
|
|
6
|
+
import type { WorkspaceContextValue } from '../../workspace/state/workspace.context';
|
|
7
|
+
import { makeWorkspaceFixture } from '../../workspace/__tests__/testFixtures';
|
|
8
|
+
|
|
9
|
+
function makeStatus(overrides: Partial<WorkingTreeStatus> = {}): WorkingTreeStatus {
|
|
10
|
+
return {
|
|
11
|
+
branch: 'current-company-state',
|
|
12
|
+
hasUpstream: true,
|
|
13
|
+
unmergedFromUpstream: true,
|
|
14
|
+
...overrides,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function makeTree(paths: string[] = ['Knowledge/Foo.md']): FileTreeEntry {
|
|
19
|
+
return {
|
|
20
|
+
name: '',
|
|
21
|
+
relativePath: '',
|
|
22
|
+
type: 'directory',
|
|
23
|
+
children: paths.map((p) => ({
|
|
24
|
+
name: p.split('/').pop() ?? p,
|
|
25
|
+
relativePath: p,
|
|
26
|
+
type: 'file' as const,
|
|
27
|
+
})),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function makeGit(
|
|
32
|
+
overrides: Partial<GitContextValue> & { status?: WorkingTreeStatus | null } = {},
|
|
33
|
+
): GitContextValue {
|
|
34
|
+
const status: WorkingTreeStatus | null =
|
|
35
|
+
overrides.status === undefined ? makeStatus() : overrides.status;
|
|
36
|
+
const branches: BranchInfo[] = [];
|
|
37
|
+
return {
|
|
38
|
+
status,
|
|
39
|
+
branches,
|
|
40
|
+
availability: 'ready',
|
|
41
|
+
lastError: null,
|
|
42
|
+
refreshStatus: async () => null,
|
|
43
|
+
refreshBranches: async () => {},
|
|
44
|
+
createBranch: async () => {},
|
|
45
|
+
deleteBranch: async () => {},
|
|
46
|
+
pull: async () => {},
|
|
47
|
+
fetchForkBase: async () => null,
|
|
48
|
+
revert: async (): Promise<CommitAttribution> => ({
|
|
49
|
+
authorName: '',
|
|
50
|
+
authorEmail: '',
|
|
51
|
+
sha: '',
|
|
52
|
+
subject: '',
|
|
53
|
+
committedAt: '',
|
|
54
|
+
}),
|
|
55
|
+
fetchFileHistory: async () => [],
|
|
56
|
+
fetchFileDiff: async () => '',
|
|
57
|
+
fetchFileComparison: async () => '',
|
|
58
|
+
...overrides,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface WorkspaceFixture extends WorkspaceContextValue {
|
|
63
|
+
refreshFileTree: ReturnType<typeof vi.fn>;
|
|
64
|
+
bumpFsRevision: ReturnType<typeof vi.fn>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function makeWorkspace(
|
|
68
|
+
overrides: Partial<WorkspaceContextValue> & {
|
|
69
|
+
refreshFileTreeResult?: FileTreeEntry | null;
|
|
70
|
+
} = {},
|
|
71
|
+
): WorkspaceFixture {
|
|
72
|
+
const refreshFileTree = vi.fn(
|
|
73
|
+
async (): Promise<FileTreeEntry | null> =>
|
|
74
|
+
overrides.refreshFileTreeResult === undefined
|
|
75
|
+
? makeTree()
|
|
76
|
+
: overrides.refreshFileTreeResult,
|
|
77
|
+
);
|
|
78
|
+
const bumpFsRevision = vi.fn(() => {});
|
|
79
|
+
return makeWorkspaceFixture({
|
|
80
|
+
...overrides,
|
|
81
|
+
refreshFileTree,
|
|
82
|
+
bumpFsRevision,
|
|
83
|
+
}) as WorkspaceFixture;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
afterEach(() => {
|
|
87
|
+
vi.restoreAllMocks();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('useAutoPullUpdates', () => {
|
|
91
|
+
it('pulls clean protected branches automatically and bumps fsRevision after refresh', async () => {
|
|
92
|
+
// Under the multi-tab model the hook signals open tabs to re-read disk
|
|
93
|
+
// via `bumpFsRevision()` instead of the legacy single-file openFile /
|
|
94
|
+
// closeFile dance. Active tab refetches eagerly; any tab whose file
|
|
95
|
+
// vanished gets dropped by the eager refetch's 404 handler in
|
|
96
|
+
// useWorkspaceState (covered by its own tests).
|
|
97
|
+
const pull = vi.fn(async () => {});
|
|
98
|
+
const workspace = makeWorkspace({
|
|
99
|
+
refreshFileTreeResult: makeTree(['Knowledge/Foo.md', 'Knowledge/New.md']),
|
|
100
|
+
});
|
|
101
|
+
const git = makeGit({ status: makeStatus({ branch: 'current-company-state' }), pull });
|
|
102
|
+
const onPrStale = vi.fn();
|
|
103
|
+
window.addEventListener('bevel:pr-stale', onPrStale);
|
|
104
|
+
|
|
105
|
+
renderHook(() => useAutoPullUpdates(git, workspace));
|
|
106
|
+
|
|
107
|
+
await waitFor(() => expect(pull).toHaveBeenCalledTimes(1));
|
|
108
|
+
await waitFor(() => expect(workspace.refreshFileTree).toHaveBeenCalledTimes(1));
|
|
109
|
+
await waitFor(() => expect(workspace.bumpFsRevision).toHaveBeenCalledTimes(1));
|
|
110
|
+
expect(onPrStale).toHaveBeenCalledTimes(1);
|
|
111
|
+
|
|
112
|
+
window.removeEventListener('bevel:pr-stale', onPrStale);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('exposes updating state while the automatic pull is in flight', async () => {
|
|
116
|
+
let resolvePull: () => void = () => {};
|
|
117
|
+
const pull = vi.fn(
|
|
118
|
+
() =>
|
|
119
|
+
new Promise<void>((resolve) => {
|
|
120
|
+
resolvePull = resolve;
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const workspace = makeWorkspace();
|
|
125
|
+
const git = makeGit({ status: makeStatus({ branch: 'current-company-state' }), pull });
|
|
126
|
+
const { result } = renderHook(() => useAutoPullUpdates(git, workspace));
|
|
127
|
+
|
|
128
|
+
await waitFor(() => expect(result.current).toMatchObject({
|
|
129
|
+
status: 'updating',
|
|
130
|
+
branch: 'current-company-state',
|
|
131
|
+
reason: null,
|
|
132
|
+
}));
|
|
133
|
+
|
|
134
|
+
resolvePull();
|
|
135
|
+
await waitFor(() => expect(result.current.status).toBe('idle'));
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('exposes failed state with sanitized reason when automatic pull fails', async () => {
|
|
139
|
+
const pull = vi.fn(async () => {
|
|
140
|
+
throw new Error(
|
|
141
|
+
'fatal: could not resolve host https://ghp_supersecrettoken1234567890abcdef@example.com/org/repo in /Users/alice/work/bevel token=ghp_supersecrettoken1234567890abcdef',
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const workspace = makeWorkspace();
|
|
146
|
+
const git = makeGit({ status: makeStatus({ branch: 'current-company-state' }), pull });
|
|
147
|
+
const { result } = renderHook(() => useAutoPullUpdates(git, workspace));
|
|
148
|
+
|
|
149
|
+
await waitFor(() => expect(result.current.status).toBe('failed'));
|
|
150
|
+
expect(result.current.branch).toBe('current-company-state');
|
|
151
|
+
expect(result.current.reason).toContain('[url]');
|
|
152
|
+
expect(result.current.reason).not.toContain('https://');
|
|
153
|
+
expect(result.current.reason).not.toContain('/Users/alice/work/bevel');
|
|
154
|
+
expect(result.current.reason).not.toContain('ghp_supersecrettoken');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('resets state after the branch is no longer behind', async () => {
|
|
158
|
+
const pull = vi.fn(async () => {
|
|
159
|
+
throw new Error('boom');
|
|
160
|
+
});
|
|
161
|
+
const workspace = makeWorkspace();
|
|
162
|
+
|
|
163
|
+
const { result, rerender } = renderHook(
|
|
164
|
+
({ status }: { status: WorkingTreeStatus }) =>
|
|
165
|
+
useAutoPullUpdates(makeGit({ status, pull }), workspace),
|
|
166
|
+
{ initialProps: { status: makeStatus({ branch: 'current-company-state' }) } },
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
await waitFor(() => expect(result.current.status).toBe('failed'));
|
|
170
|
+
|
|
171
|
+
rerender({
|
|
172
|
+
status: makeStatus({
|
|
173
|
+
branch: 'current-company-state',
|
|
174
|
+
unmergedFromUpstream: false,
|
|
175
|
+
}),
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
await waitFor(() => expect(result.current.status).toBe('idle'));
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('auto-pulls feature branches that are behind upstream', async () => {
|
|
182
|
+
// Under save=share, the on-disk clone is shared across all users on
|
|
183
|
+
// a given branch (feature OR protected). A feature branch silently
|
|
184
|
+
// falling behind upstream causes non-fast-forward push failures on
|
|
185
|
+
// the next save, surfacing as confusing "draft is missing teammate
|
|
186
|
+
// updates" banners. The hook must auto-pull these too.
|
|
187
|
+
const pull = vi.fn(async () => {});
|
|
188
|
+
|
|
189
|
+
renderHook(() =>
|
|
190
|
+
useAutoPullUpdates(
|
|
191
|
+
makeGit({ status: makeStatus({ branch: 'alice/draft' }), pull }),
|
|
192
|
+
makeWorkspace(),
|
|
193
|
+
),
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
await waitFor(() => expect(pull).toHaveBeenCalledTimes(1));
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('does not auto-pull while the open editor has unsaved in-memory changes', async () => {
|
|
200
|
+
const pull = vi.fn(async () => {});
|
|
201
|
+
|
|
202
|
+
renderHook(() =>
|
|
203
|
+
useAutoPullUpdates(
|
|
204
|
+
makeGit({ status: makeStatus(), pull }),
|
|
205
|
+
makeWorkspace({ hasUnsavedFileChanges: true }),
|
|
206
|
+
),
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
210
|
+
expect(pull).not.toHaveBeenCalled();
|
|
211
|
+
});
|
|
212
|
+
});
|