summaryrefslogtreecommitdiff
path: root/tests/test-ai-vterm--sort-candidates.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-ai-vterm--sort-candidates.el')
-rw-r--r--tests/test-ai-vterm--sort-candidates.el27
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/test-ai-vterm--sort-candidates.el b/tests/test-ai-vterm--sort-candidates.el
index 5e3d760a..26953604 100644
--- a/tests/test-ai-vterm--sort-candidates.el
+++ b/tests/test-ai-vterm--sort-candidates.el
@@ -3,8 +3,10 @@
;;; Commentary:
;; The project picker lists candidates with a live tmux session first
;; (so an agent that survived an Emacs crash is easy to get back to),
-;; then everything else. Within each group the order is alphabetical
-;; by abbreviated path.
+;; then everything else. Within the active group, projects opened this
+;; session (`cj/--ai-vterm-mru') lead, most-recent first; the rest of the
+;; active group, and the whole no-session group, sort alphabetically by
+;; abbreviated path. With an empty MRU it's just active-first-then-alpha.
;;; Code:
@@ -40,6 +42,27 @@
"Boundary: no candidates -> nil."
(should (null (cj/--ai-vterm-sort-candidates nil '("aiv-foo")))))
+(ert-deftest test-ai-vterm--sort-candidates-active-group-mru-first ()
+ "Normal: within the active group, recently-opened projects lead in MRU
+order; active dirs not opened this session fall after them alpha; the
+no-session group trails, alpha."
+ (let ((cj/ai-vterm-tmux-session-prefix "aiv-")
+ (cj/--ai-vterm-mru '("/c/baz" "/c/foo")))
+ (should (equal (cj/--ai-vterm-sort-candidates
+ '("/c/foo" "/c/bar" "/c/baz" "/c/qux")
+ '("aiv-foo" "aiv-bar" "aiv-baz"))
+ '("/c/baz" "/c/foo" "/c/bar" "/c/qux")))))
+
+(ert-deftest test-ai-vterm--sort-candidates-mru-does-not-bump-inactive ()
+ "Boundary: an MRU dir whose tmux session has died sorts alpha in the
+no-session group, not at the top."
+ (let ((cj/ai-vterm-tmux-session-prefix "aiv-")
+ (cj/--ai-vterm-mru '("/c/zed")))
+ (should (equal (cj/--ai-vterm-sort-candidates
+ '("/c/foo" "/c/zed" "/c/bar")
+ '("aiv-foo"))
+ '("/c/foo" "/c/bar" "/c/zed")))))
+
(ert-deftest test-ai-vterm--session-active-p-matches-by-derived-name ()
"Normal: a dir is active when its derived session name is in the set."
(let ((cj/ai-vterm-tmux-session-prefix "aiv-"))