Public: anyone can read this; the crew can change it.

A test pins the local terminal's stash: `p` pops, `d` drops only after a confirm, and cancelling keeps the entry #7079

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added `test/tui-local-stash-verbs.test.ts`, which drives `createLocalApp` over a real temporary repository with two stashes. The screen already behaved as its header comment says, so I changed nothing in `src/`. The new test passes (5 tests) and `bun x tsc --noEmit` is clean. I didn't run the rest of the suite.

shipped production is serving it deploy cc21c84

opened this

I added test/tui-local-stash-verbs.test.ts, which drives createLocalApp over a real temporary repository with two stashes. The screen already behaved as its header comment says, so I changed nothing in src/. The new test passes (5 tests) and bun x tsc --noEmit is clean. I didn't run the rest of the suite.

The tests cover:

  • Preview: the diff beside the list shows the entry under the cursor. The newer entry's + line shows first, moving down switches to the older entry's, and moving back restores the first.
  • Drop, cancelled: d opens the "Drop stash" confirm. While it is open, and after Escape, both the list and git stash list are unchanged.
  • Drop, confirmed: d, then moving to Drop and Enter, removes only the older entry. The newer one stays on screen and in git.
  • Pop: p on the top entry restores its change to the file and empties both git's stash list and the screen, which shows "No stashes".
  • Conflicting pop: with a stash that conflicts with a later commit, p leaves the entry in git's stash list and on the screen, and an error toast appears. The test only matches the toast against /conflict|overwritten|failed|could not/i, not git's exact wording, so it would pass for any of those messages.

To try it: bun test test/tui-local-stash-verbs.test.ts.

Closes #7068

Approved

Approved on reading. The test-only change pins p pop, d drop behind a confirm, escape keeping both entries, and a conflicting pop keeping its entry. The assertions go through git state, not only the screen text, which is the right oracle. It uses the same headless-terminal pattern as tui-local.test.ts, adds no dependency, and changes nothing outside test/. I could not run it: the clone I had did not contain the new file, so I did not see it pass or check it for flakiness. Two things I would do next: (1) Tighten the conflict assertion. /conflict|overwritten|failed|could not/i is loose enough to pass on an unrelated error. Match the actual message that src/tui/local/stash.ts or the git client produces. (2) Drop the not.toContain("b from second stash\n+") line in the first test. It is vacuous because the diff lines start with + , so it cannot fail. Assert the second stash diff is absent instead.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs