diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-11 05:17:44 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-11 05:17:44 -0500 |
| commit | 364d69dc6f9be5d310c0ac1f0c69c31b08d82821 (patch) | |
| tree | b77fec1c9c5ade2c527b6ecaa55b2c2bec4426e5 /tests | |
| parent | 54a2567c58dd3a456219c17c44e89233f7176b0d (diff) | |
| download | dotemacs-364d69dc6f9be5d310c0ac1f0c69c31b08d82821.tar.gz dotemacs-364d69dc6f9be5d310c0ac1f0c69c31b08d82821.zip | |
test(vterm): cover AI-vterm inheritance of the vterm copy path
I added three ERT cases around `cj/vterm--current-tmux-pane-id` and `cj/vterm-copy-mode-cancel`: the pane-id lookup rejects a non-`vterm-mode` buffer, it still resolves a `claude [...]`-named buffer by process TTY, and the copy-mode cancel command errors outside copy mode. The pane-id-by-TTY case pins the contract that AI-vterm buffers get the copy commands because they're `vterm-mode` buffers, not because of any buffer-name check.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-vterm-tmux-history.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/test-vterm-tmux-history.el b/tests/test-vterm-tmux-history.el index f5263df5..db82176f 100644 --- a/tests/test-vterm-tmux-history.el +++ b/tests/test-vterm-tmux-history.el @@ -150,5 +150,37 @@ modern keyboards and was redundant." (should (eq (keymap-lookup vterm-copy-mode-map "M-w") #'vterm-copy-mode-done))) +(ert-deftest test-vterm-copy-mode-cancel-errors-outside-copy-mode () + "Error: `cj/vterm-copy-mode-cancel' refuses to run when not in copy mode." + (with-temp-buffer + (should-error (cj/vterm-copy-mode-cancel) :type 'user-error))) + +(ert-deftest test-vterm-current-tmux-pane-id-rejects-non-vterm-buffer () + "Error: pane-id lookup refuses a buffer that is not in `vterm-mode'." + (with-temp-buffer + (should-error (cj/vterm--current-tmux-pane-id) :type 'user-error))) + +(ert-deftest test-vterm-current-tmux-pane-id-accepts-ai-vterm-named-buffer () + "Normal: an AI-vterm-named buffer still resolves by process TTY. + +The copy path belongs to `vterm-mode', not to `*vterm*'-named buffers. +A buffer named like `claude [repo]' (ai-vterm.el's naming) is a +`vterm-mode' buffer and must inherit tmux history copy. The pane lookup +keys off the live process TTY, never the buffer name -- so the +AI-vterm name neither helps nor blocks resolution." + (let ((claude (cj/test--make-fake-vterm-buffer "claude [emacs.d]"))) + (unwind-protect + (with-current-buffer claude + (cl-letf (((symbol-function 'get-buffer-process) + (lambda (_buffer) 'fake-process)) + ((symbol-function 'process-tty-name) + (lambda (_process) "/dev/pts/8"))) + (test-vterm-tmux-history--with-tmux-mock + '((("list-clients" "-F" "#{client_tty}\t#{pane_id}") 0 + "/dev/pts/1\t%1\n/dev/pts/8\t%8\n")) + (should (equal (cj/vterm--current-tmux-pane-id) "%8"))))) + (when (buffer-live-p claude) + (kill-buffer claude))))) + (provide 'test-vterm-tmux-history) ;;; test-vterm-tmux-history.el ends here |
