test(worktree): cover optimized creation call signatures

Preserve explicit branch adoption, WSL callback routing and sparse cleanup expectations.
This commit is contained in:
Neil
2026-09-04 22:35:42 -07:00
parent f2d3d0f620
commit f8ad8fb35f
4 changed files with 28 additions and 5 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ branch refs/heads/main
const calls = getGitCalls()
expect(calls).toEqual(
expect.arrayContaining([
'git worktree add --no-checkout --no-track -b feature/test /repo-feature',
'git -c checkout.workers=4 worktree add --no-checkout --no-track -b feature/test /repo-feature',
'git config --get push.autoSetupRemote',
'git config --local push.autoSetupRemote true',
'git sparse-checkout init --cone',
@@ -50,7 +50,13 @@ describe('OrcaRuntimeService', () => {
pushTarget: { remoteName: 'origin', branchName: 'feature/fix' }
})
expect(getBranchConflictKind).toHaveBeenCalledWith(TEST_REPO_PATH, 'feature/fix', 'abc123')
expect(getBranchConflictKind).toHaveBeenCalledWith(
TEST_REPO_PATH,
'feature/fix',
'abc123',
{},
undefined
)
expect(getPRForBranchMock).toHaveBeenCalledWith(TEST_REPO_PATH, 'feature/fix')
expect(addWorktree).toHaveBeenCalledWith(
TEST_REPO_PATH,
@@ -165,7 +171,9 @@ describe('OrcaRuntimeService', () => {
expect(getBranchConflictKind).toHaveBeenCalledWith(
TEST_REPO_PATH,
'feature/bitbucket',
'abc123'
'abc123',
{},
undefined
)
expect(getHostedReviewForBranchMock).toHaveBeenCalledWith(
expect.objectContaining({
@@ -533,10 +533,14 @@ describe('OrcaRuntimeService', () => {
branchNameOverride: 'feature/something'
})
// Why: an explicit branch override adopts the local branch before the conflict
// probe, so no lazy adoption callback is handed to getBranchConflictKind.
expect(getBranchConflictKind).toHaveBeenCalledWith(
TEST_REPO_PATH,
'feature/something',
'origin/feature/something'
'origin/feature/something',
{},
undefined
)
expect(addWorktree).toHaveBeenCalledWith(
TEST_REPO_PATH,
@@ -376,7 +376,18 @@ describe('OrcaRuntimeService', () => {
TEST_REPO_PATH,
'runtime-wsl',
'origin/main',
{ wslDistro: 'Ubuntu' }
{ wslDistro: 'Ubuntu' },
expect.any(Function)
)
// Why: the lazy adoption callback is only invoked when the conflict probe
// sees a local ref, so drive it here to prove adoption also routes via WSL.
const adoptLocalBranch = vi
.mocked(getBranchConflictKind)
.mock.calls.findLast((call) => call[1] === 'runtime-wsl')?.[4]
await expect(adoptLocalBranch?.()).resolves.toBe(false)
expect(gitSpy).toHaveBeenCalledWith(
['rev-parse', '--verify', '--quiet', 'refs/heads/runtime-wsl^{commit}'],
{ cwd: TEST_REPO_PATH, wslDistro: 'Ubuntu' }
)
expect(getPRForBranchMock).toHaveBeenCalledWith(
TEST_REPO_PATH,