diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-14 01:12:21 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-14 01:12:21 -0500 |
| commit | a9736bcf1f1d683656d7222bdda26c1a7ef73986 (patch) | |
| tree | de366569e3922a036bddc040eda1d47b49940255 /archive/tests/test-signel-cancel-input.el | |
| parent | 42664cd1097a7bcea5de629bbddb3a58eadcdb57 (diff) | |
| download | dotemacs-a9736bcf1f1d683656d7222bdda26c1a7ef73986.tar.gz dotemacs-a9736bcf1f1d683656d7222bdda26c1a7ef73986.zip | |
refactor(signal): retire the in-Emacs signel client to the archive
Agents drive Signal via signal-cli and signal-mcp, so the interactive client earns no keep. I moved signal-config.el and its seven test files to archive/ per the pasture convention, dropped the require from init.el, removed the dashboard's Signal launcher (row sizes now 5 4 3 2, tests updated), and unregistered the C-; M prefix from the running daemon. The ~/code/signel fork repo is untouched. The spec record stays IMPLEMENTED with a retirement history line, and the messenger-unification draft carries a premise-shift note.
Diffstat (limited to 'archive/tests/test-signel-cancel-input.el')
| -rw-r--r-- | archive/tests/test-signel-cancel-input.el | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/archive/tests/test-signel-cancel-input.el b/archive/tests/test-signel-cancel-input.el new file mode 100644 index 00000000..b2a7ef89 --- /dev/null +++ b/archive/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 |
