Skip to content

Commit d5c70e9

Browse files
authored
fix: use explicit main branch in e2e test git init (Refs: beans-iv91) (#137)
## Summary - Fix all 13 workspace e2e tests that have been failing on CI since March 12 - The e2e fixtures called `git init` without specifying a branch name; on CI (Ubuntu), git defaults to `master`, but the app's worktree base ref defaults to `main` - `git worktree add ... main` failed because the `main` ref didn't exist, causing the `createWorktree` mutation to error silently and navigation to never happen ## Test plan - [x] All 52 e2e tests pass locally - [ ] CI passes on this PR (the whole point of this fix)
1 parent 09b6a47 commit d5c70e9

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
# beans-iv91
3+
title: Fix e2e tests failing on CI due to git default branch name
4+
status: completed
5+
type: bug
6+
priority: normal
7+
created_at: 2026-03-17T16:16:44Z
8+
updated_at: 2026-03-17T16:18:01Z
9+
---
10+
11+
E2e tests fail on CI because git init creates 'master' branch on Ubuntu while the app expects 'main'. The fix is to use git init -b main in the e2e fixtures.
12+
13+
## Summary of Changes
14+
15+
The e2e test fixtures in `frontend/e2e/fixtures.ts` used `git init` without specifying a branch name. On macOS, git defaults to `main`, but on CI (Ubuntu), git defaults to `master`. Since the app's worktree base ref defaults to `main`, the `git worktree add ... main` command failed silently, causing the `createWorktree` mutation to error and navigation to never happen.
16+
17+
Fixed by adding `-b main` to both `git init` calls in the fixtures (template creation and per-test repo creation).

frontend/e2e/fixtures.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function getBinaries() {
3434
*/
3535
function createBeansTemplate(beansBin: string): string {
3636
const templateDir = mkdtempSync(join(tmpdir(), 'beans-e2e-template-'));
37-
execFileSync('git', ['init'], { cwd: templateDir, timeout: 10_000 });
37+
execFileSync('git', ['init', '-b', 'main'], { cwd: templateDir, timeout: 10_000 });
3838
execFileSync('git', ['commit', '--allow-empty', '-m', 'init'], {
3939
cwd: templateDir,
4040
timeout: 10_000,
@@ -187,7 +187,7 @@ export const test = base.extend<Fixtures, WorkerFixtures>({
187187

188188
// Fresh git repo per test (needed for worktree operations)
189189
const projectDir = mkdtempSync(join(tmpdir(), 'beans-e2e-'));
190-
execFileSync('git', ['init'], { cwd: projectDir, timeout: 10_000 });
190+
execFileSync('git', ['init', '-b', 'main'], { cwd: projectDir, timeout: 10_000 });
191191
execFileSync('git', ['commit', '--allow-empty', '-m', 'init'], {
192192
cwd: projectDir,
193193
timeout: 10_000,

frontend/e2e/workspace-create.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ test.describe('Workspace creation', () => {
6060
// Wait for a second workspace to appear
6161
await expect(workspaceLabels).toHaveCount(3, { timeout: 10_000 }); // main + 2 new
6262

63-
const secondName = await workspaceLabels.nth(2).textContent();
64-
65-
expect(firstName).toBeTruthy();
66-
expect(secondName).toBeTruthy();
67-
expect(firstName).not.toBe(secondName);
63+
// Collect all non-main workspace names (order may vary due to LastActiveAt sorting)
64+
const allNames: string[] = [];
65+
for (let i = 0; i < 3; i++) {
66+
const name = await workspaceLabels.nth(i).textContent();
67+
if (name && name !== 'main') allNames.push(name);
68+
}
69+
70+
expect(allNames).toHaveLength(2);
71+
expect(allNames[0]).not.toBe(allNames[1]);
6872
});
6973

7074
test('destroy worktree removes it from sidebar', async ({ beans, page }) => {

internal/gitutil/status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func initBranchedTestRepo(t *testing.T) string {
254254

255255
// Create the "remote" bare repo
256256
bare := t.TempDir()
257-
cmd := exec.Command("git", "init", "--bare")
257+
cmd := exec.Command("git", "init", "--bare", "-b", "main")
258258
cmd.Dir = bare
259259
if out, err := cmd.CombinedOutput(); err != nil {
260260
t.Fatalf("git init --bare failed: %s: %v", out, err)

internal/gitutil/worktree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func initTestRepo(t *testing.T) string {
1212
dir := t.TempDir()
1313

1414
commands := [][]string{
15-
{"git", "init"},
15+
{"git", "init", "-b", "main"},
1616
{"git", "config", "user.email", "test@test.com"},
1717
{"git", "config", "user.name", "Test"},
1818
{"git", "commit", "--allow-empty", "-m", "initial"},

0 commit comments

Comments
 (0)