aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-09-10 07:46:17 -0500
committerCraig Jennings <c@cjennings.net>2026-09-10 07:46:17 -0500
commit36409a3b5d27d64358a3e06b5a93d74d6ef9eca6 (patch)
tree4c8c7e772934594763488aef3a0d5b118862db4d
parentfb46b78003132d4281db2db1482118034e2424d8 (diff)
downloadpearl-36409a3b5d27d64358a3e06b5a93d74d6ef9eca6.tar.gz
pearl-36409a3b5d27d64358a3e06b5a93d74d6ef9eca6.zip
test(menu): read transient suffixes in the 0.13 layout shape
Transient 0.13 (the version Emacs 31 bundles) stores each suffix as (transient-suffix :key ... :command ...) rather than a bare plist. The layout walker in test-pearl-menu.el found no pairs, so two tests failed. The helper now reads both shapes, and synthetic layouts in each shape pin that.
-rw-r--r--tests/test-pearl-menu.el50
1 files changed, 45 insertions, 5 deletions
diff --git a/tests/test-pearl-menu.el b/tests/test-pearl-menu.el
index 1795a41..6294da2 100644
--- a/tests/test-pearl-menu.el
+++ b/tests/test-pearl-menu.el
@@ -15,15 +15,23 @@
(defun test-pearl-menu--suffixes (node)
"Collect (KEY . COMMAND) pairs from a transient layout NODE.
-Walks vectors and lists recursively; whenever it reaches a plist
-\(a list whose car is a keyword) it reads :key and :command from it."
+Walks vectors and lists recursively; whenever it reaches a suffix plist it
+reads :key and :command from it. Transient has stored a suffix two ways:
+inside a (LEVEL CLASS (:key ... :command ...)) list, where the bare plist is
+reached by recursion, and, since transient 0.13 (the version Emacs 31
+bundles), as a list headed by the class symbol (transient-suffix :key ...).
+Both shapes are read here so the test survives the library's own layout
+changes."
(cond
((vectorp node)
(apply #'append (mapcar #'test-pearl-menu--suffixes
(append node nil))))
- ((and (consp node) (keywordp (car node)))
- (let ((cmd (plist-get node :command))
- (key (plist-get node :key)))
+ ((and (consp node)
+ (or (keywordp (car node))
+ (and (symbolp (car node)) (keywordp (cadr node)))))
+ (let* ((plist (if (keywordp (car node)) node (cdr node)))
+ (cmd (plist-get plist :command))
+ (key (plist-get plist :key)))
(when cmd (list (cons key cmd)))))
((consp node)
(apply #'append (mapcar #'test-pearl-menu--suffixes node)))
@@ -87,5 +95,37 @@ menu entry that still points at it fails here."
pearl-toggle-sort-order))
(should (memq expected cmds)))))
+;; Synthetic layouts pin both suffix shapes the walker must read, so the
+;; branch for whichever transient version isn't installed can't rot unseen.
+
+(defconst test-pearl-menu--old-layout
+ '([1 transient-columns nil
+ ([1 transient-column (:description "Save")
+ ((1 transient-suffix (:key "s" :command pearl-save-issue))
+ (1 transient-suffix (:key "S" :command pearl-save-all)))])])
+ "A menu layout in the pre-0.13 transient shape: (LEVEL CLASS PLIST) suffixes.")
+
+(defconst test-pearl-menu--new-layout
+ '([transient-columns nil
+ ([transient-column (:description "Save")
+ ((transient-suffix :key "s" :command pearl-save-issue)
+ (transient-suffix :key "S" :command pearl-save-all))])])
+ "The same menu in the transient 0.13 shape: (CLASS :key ...) suffixes.")
+
+(ert-deftest test-pearl-menu-suffixes-reads-old-layout-shape ()
+ "The walker finds every suffix in the pre-0.13 (LEVEL CLASS PLIST) layout."
+ (should (equal (test-pearl-menu--suffixes test-pearl-menu--old-layout)
+ '(("s" . pearl-save-issue) ("S" . pearl-save-all)))))
+
+(ert-deftest test-pearl-menu-suffixes-reads-new-layout-shape ()
+ "The walker finds every suffix in the transient 0.13 (CLASS :key ...) layout."
+ (should (equal (test-pearl-menu--suffixes test-pearl-menu--new-layout)
+ '(("s" . pearl-save-issue) ("S" . pearl-save-all)))))
+
+(ert-deftest test-pearl-menu-suffixes-empty-layout-is-nil ()
+ "An empty layout and a group with no suffixes both yield no pairs."
+ (should (null (test-pearl-menu--suffixes nil)))
+ (should (null (test-pearl-menu--suffixes '([transient-column (:description "x") ()])))))
+
(provide 'test-pearl-menu)
;;; test-pearl-menu.el ends here