diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-28 03:08:05 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-28 03:08:05 -0500 |
| commit | 998e9c7a08a57f343a3ac2423597ec7e5556f329 (patch) | |
| tree | ef17e79f411fc100ce1bed144c33c03d69e12bcf /tests | |
| parent | 1c93820893a3aa831684e2322c606e54b0bba40c (diff) | |
| download | dotemacs-998e9c7a08a57f343a3ac2423597ec7e5556f329.tar.gz dotemacs-998e9c7a08a57f343a3ac2423597ec7e5556f329.zip | |
feat(signal): dock chat buffer to bottom 30% and add cancel binding
I added a display-buffer-alist entry matching "*Signel:" chat buffers and routing them through display-buffer-at-bottom with window-height 0.3. The signel fork's signel-chat now uses pop-to-buffer instead of switch-to-buffer, which is what makes the rule apply. Without that switch the buffer replaces the current window and skips display-buffer entirely.
Two new tests in test-signal-config.el lock the entry shape and the regex's buffer-name match set. A new test-signel-cancel-input.el covers the fork's C-c C-k handler. It clears the editable region between signel--input-marker and point-max, then quit-windows so the buffer survives the dismiss.
Closes the "Chat buffer placement + exit keys" task filed during the 2026-05-28 manual-verify walk.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-signal-config.el | 25 | ||||
| -rw-r--r-- | tests/test-signel-cancel-input.el | 74 |
2 files changed, 99 insertions, 0 deletions
diff --git a/tests/test-signal-config.el b/tests/test-signal-config.el index b362e03b..3be63362 100644 --- a/tests/test-signal-config.el +++ b/tests/test-signal-config.el @@ -368,5 +368,30 @@ commands the workflow spec names." (should (eq (keymap-lookup cj/signel-prefix-map "SPC") #'cj/signel-connect))) +;;; display-buffer-alist entry for *Signel: ...* chat buffers + +(ert-deftest test-signal-config-chat-buffer-display-rule-uses-bottom-30 () + "Normal: signal-config registers a `display-buffer-alist' entry that +matches `*Signel: <id>*' buffers, routes them through +`display-buffer-at-bottom', and sets `window-height' to 0.3 so the +chat docks to the bottom 30% of the frame." + (let ((entry (seq-find (lambda (e) (equal (car e) "\\`\\*Signel: ")) + display-buffer-alist))) + (should entry) + (should (memq 'display-buffer-at-bottom (cadr entry))) + (should (equal 0.3 (cdr (assq 'window-height (cddr entry))))))) + +(ert-deftest test-signal-config-chat-buffer-display-rule-matches-buffer-name () + "Boundary: the registered regex matches a realistic chat buffer name +\(phone-number id and group-id) and does not match unrelated buffers." + (let* ((entry (seq-find (lambda (e) (equal (car e) "\\`\\*Signel: ")) + display-buffer-alist)) + (regex (car entry))) + (should regex) + (should (string-match-p regex "*Signel: +15555550100*")) + (should (string-match-p regex "*Signel: groupid-abc*")) + (should-not (string-match-p regex "*signel-log*")) + (should-not (string-match-p regex "scratch")))) + (provide 'test-signal-config) ;;; test-signal-config.el ends here diff --git a/tests/test-signel-cancel-input.el b/tests/test-signel-cancel-input.el new file mode 100644 index 00000000..b2a7ef89 --- /dev/null +++ b/tests/test-signel-cancel-input.el @@ -0,0 +1,74 @@ +;;; test-signel-cancel-input.el --- Cancel-input contract for the signel fork -*- lexical-binding: t; -*- + +;;; Commentary: +;; `signel--cancel-input' is the C-c C-k handler in `signel-chat-mode'. +;; Its contract: clear any in-progress input between `signel--input-marker' +;; and `point-max' (so the prompt is fresh on next visit), then dismiss +;; the window via `quit-window' (the buffer stays alive so chat history +;; survives revisits). These tests lock the contract; the binding test +;; locks the keymap entry. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(eval-and-compile + (add-to-list 'load-path (expand-file-name "~/code/signel"))) +(require 'signel) + +(defmacro test-signel-cancel--with-chat-buffer (&rest body) + "Set up a temp signel-chat-mode buffer with prompt drawn and run BODY." + (declare (indent 0)) + `(with-temp-buffer + (signel-chat-mode) + (setq signel--chat-id "+15555550100") + (signel--draw-prompt) + ,@body)) + +(ert-deftest test-signel-cancel-input-clears-pending-text () + "Normal: pending input from input-marker to point-max is cleared." + (test-signel-cancel--with-chat-buffer + (insert "abandoned-draft") + (cl-letf (((symbol-function 'quit-window) (lambda (&rest _) nil))) + (signel--cancel-input)) + (should-not (signel--pending-input)))) + +(ert-deftest test-signel-cancel-input-empty-input-area-is-a-noop () + "Boundary: cancelling with no in-progress input is harmless." + (test-signel-cancel--with-chat-buffer + (cl-letf (((symbol-function 'quit-window) (lambda (&rest _) nil))) + (signel--cancel-input)) + (should-not (signel--pending-input)))) + +(ert-deftest test-signel-cancel-input-calls-quit-window () + "Normal: cancel dismisses the window via `quit-window'." + (test-signel-cancel--with-chat-buffer + (insert "abandoned-draft") + (let ((called nil)) + (cl-letf (((symbol-function 'quit-window) + (lambda (&rest _) (setq called t)))) + (signel--cancel-input)) + (should called)))) + +(ert-deftest test-signel-cancel-input-preserves-buffer () + "Normal: cancel does not kill the buffer; chat history (prompt + prior +content above the input marker) survives so reopening the contact lands +in the same buffer." + (test-signel-cancel--with-chat-buffer + (insert "abandoned-draft") + (let ((buf (current-buffer))) + (cl-letf (((symbol-function 'quit-window) (lambda (&rest _) nil))) + (signel--cancel-input)) + (should (buffer-live-p buf))))) + +(ert-deftest test-signel-chat-mode-binds-c-c-c-k-to-cancel () + "Normal: `signel-chat-mode' binds C-c C-k to `signel--cancel-input' so +the documented cancel gesture reaches the handler." + (with-temp-buffer + (signel-chat-mode) + (should (eq (lookup-key (current-local-map) (kbd "C-c C-k")) + #'signel--cancel-input)))) + +(provide 'test-signel-cancel-input) +;;; test-signel-cancel-input.el ends here |
