|
| 1 | +# Running the Trunk Branch Bug Test |
| 2 | + |
| 3 | +This document describes how to run the test that demonstrates the trunk branch bug in `createWorkspace`. |
| 4 | + |
| 5 | +## Bug Description |
| 6 | + |
| 7 | +When creating a new workspace, the `trunkBranch` parameter should specify which branch to create the new branch from. However, in SSHRuntime, this parameter is being ignored and new branches are created from HEAD instead. |
| 8 | + |
| 9 | +**Location of bug:** `src/runtime/SSHRuntime.ts:592` and `618` |
| 10 | +- Line 592: `trunkBranch` is destructured as `_trunkBranch` (underscore indicates unused) |
| 11 | +- Line 618: Branch is created from `HEAD` instead of using `trunkBranch` |
| 12 | + |
| 13 | +## Test Location |
| 14 | + |
| 15 | +The test is located in `tests/ipcMain/createWorkspace.test.ts` in the "Branch handling" describe block within the runtime matrix. |
| 16 | + |
| 17 | +Test name: `"creates new branch from specified trunk branch, not from default branch"` |
| 18 | + |
| 19 | +## Running the Test |
| 20 | + |
| 21 | +### Prerequisites |
| 22 | + |
| 23 | +1. Set the `TEST_INTEGRATION` environment variable to enable integration tests: |
| 24 | + ```bash |
| 25 | + export TEST_INTEGRATION=1 |
| 26 | + ``` |
| 27 | + |
| 28 | +2. Ensure Docker is installed and running (required for SSH runtime tests) |
| 29 | + |
| 30 | +### Run the specific test |
| 31 | + |
| 32 | +```bash |
| 33 | +# Run just this test for both runtimes |
| 34 | +./node_modules/.bin/jest tests/ipcMain/createWorkspace.test.ts -t "creates new branch from specified trunk branch" |
| 35 | +``` |
| 36 | + |
| 37 | +Or using make: |
| 38 | +```bash |
| 39 | +TEST_INTEGRATION=1 make test |
| 40 | +``` |
| 41 | + |
| 42 | +## Expected Results |
| 43 | + |
| 44 | +### LocalRuntime (PASS ✓) |
| 45 | +The test should **PASS** for LocalRuntime because it correctly uses the `trunkBranch` parameter when creating a new branch via `git worktree add -b`. |
| 46 | + |
| 47 | +### SSHRuntime (FAIL ✗) |
| 48 | +The test should **FAIL** for SSHRuntime because it ignores the `trunkBranch` parameter and creates branches from `HEAD` instead. |
| 49 | + |
| 50 | +The failure will manifest as: |
| 51 | +- `trunk-file.txt` will NOT exist (it should exist if branch was created from custom-trunk) |
| 52 | +- The test assertion `expect(checkOutput.trim()).toBe("exists")` will fail |
| 53 | + |
| 54 | +## Test Scenario |
| 55 | + |
| 56 | +The test creates the following git structure: |
| 57 | + |
| 58 | +``` |
| 59 | +main (initial) ← custom-trunk (+ trunk-file.txt) |
| 60 | + ↑ |
| 61 | + Should branch from here |
| 62 | + |
| 63 | +main (initial) ← other-branch (+ other-file.txt) |
| 64 | + ↑ |
| 65 | + HEAD might be here (bug) |
| 66 | +``` |
| 67 | + |
| 68 | +When creating a workspace with `trunkBranch: "custom-trunk"`: |
| 69 | +- **Expected:** New branch contains `trunk-file.txt` (from custom-trunk) |
| 70 | +- **Actual (bug):** New branch might be from HEAD/default, missing `trunk-file.txt` |
| 71 | + |
| 72 | +## Test Coverage |
| 73 | + |
| 74 | +This test is part of the runtime matrix and runs for both: |
| 75 | +- `{ type: "local" }` - LocalRuntime |
| 76 | +- `{ type: "ssh" }` - SSHRuntime |
| 77 | + |
| 78 | +This ensures parity between runtime implementations. |
| 79 | + |
0 commit comments