From 29c6448843f50ba211be7f5ba9c1abd77d6c942c Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Fri, 13 Mar 2026 23:08:01 +0100 Subject: [PATCH 1/2] Add test of interactive calls to existing hyrolo tests * test/hyrolo-tests.el (hyrolo-add-items-interactive): (hyrolo-tests--hyrolo-grep-interactive): Add new separate test for interactive call. (hyrolo-sort-test, hyrolo-fgrep-find-all-types-of-files): Modify test to do both interactive and non-interactive call. --- ChangeLog | 8 ++++ test/hyrolo-tests.el | 107 ++++++++++++++++++++++++++++++++----------- 2 files changed, 87 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f492a00..b379bccd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2026-03-13 Mats Lidell + +* test/hyrolo-tests.el (hyrolo-add-items-interactive): + (hyrolo-tests--hyrolo-grep-interactive): Add new separate test for + interactive call. + (hyrolo-sort-test, hyrolo-fgrep-find-all-types-of-files): Modify test to + do both interactive and non-interactive call. + 2026-03-11 Bob Weiner * hsys-org.el (hsys-org-link-at-p): Clarify doc string with regard to diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 82dd45cd..9d6dc6fd 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -19,6 +19,7 @@ ;;; Code: (require 'ert) +(require 'ert-x) (require 'hact) (require 'hyrolo) (require 'hyrolo-demo) @@ -45,6 +46,28 @@ (should (looking-at-p "\\*\\*\\* c"))) (hy-delete-file-and-buffer hyrolo-file)))) +(ert-deftest hyrolo-add-items-interactive () + "`hyrolo-add` can add items when called interactively." + (let ((hyrolo-file (make-temp-file "hypb" nil ".otl"))) + (unwind-protect + (let ((hyrolo-file-list (list hyrolo-file))) + (find-file (car (hyrolo-get-file-list))) + (insert "===\nHdr\n===\n") + (goto-char (point-min)) + (should (looking-at "===")) + (ert-simulate-keys "item\n" + (call-interactively #'hyrolo-add)) + (beginning-of-line) + (should (looking-at-p "\\* item\n")) + ;; hyrolo-add in mail buffer + (with-mock + (mock (hyrolo-name-and-email) => (list "first, last" "email")) + (ert-simulate-keys "\n" ;; Confirm proposed name + (call-interactively #'hyrolo-add)) + (beginning-of-line) + (should (looking-at-p "\\* first, last\t\t\n")))) + (hy-delete-file-and-buffer hyrolo-file)))) + (ert-deftest hyrolo-demo-search-work () "Use demo example and search for work should match work." (unwind-protect @@ -195,29 +218,34 @@ and {b} the previous same level cell." (let ((hyrolo-file-list (list hyrolo-file)) (hyrolo-date-format "%m/%d/%Y")) (hyrolo-find-file (car (hyrolo-get-file-list))) - (insert "===\nHdr\n===\n") - (goto-char (point-min)) - (should (looking-at "===")) - (hyrolo-add "c") - (hyrolo-add "b") - (hyrolo-add "a") - (hyrolo-add "b/d") - - ;; Verify insertion order and following date on separate line - (goto-char (point-min)) - (should (looking-at "===")) - (dolist (insertion-order '("a" "b" "d" "c")) - (goto-char (1+ (should (search-forward insertion-order)))) - (should (looking-at-p "^\t[0-9/]+$"))) - - (hyrolo-sort) - - ;; Verify sorted order and following date on separate line - (goto-char (point-min)) - (should (looking-at "===")) - (dolist (sorted-order '("a" "b" "d" "c")) - (goto-char (1+ (should (search-forward sorted-order)))) - (should (looking-at-p "^\t[0-9/]+$")))) + (dolist (v '(:interactive nil)) + (erase-buffer) + (insert "===\nHdr\n===\n") + (goto-char (point-min)) + (should (looking-at "===")) + (hyrolo-add "c") + (hyrolo-add "b") + (hyrolo-add "a") + (hyrolo-add "b/d") + + ;; Verify insertion order and following date on separate line + (goto-char (point-min)) + (should (looking-at "===")) + (dolist (insertion-order '("a" "b" "d" "c")) + (goto-char (1+ (should (search-forward insertion-order)))) + (should (looking-at-p "^\t[0-9/]+$"))) + + (if (eq v :interactive) + (ert-simulate-keys "\n" ;; Confirm proposed name + (call-interactively #'hyrolo-sort)) + (hyrolo-sort)) + + ;; Verify sorted order and following date on separate line + (goto-char (point-min)) + (should (looking-at "===")) + (dolist (sorted-order '("a" "b" "d" "c")) + (goto-char (1+ (should (search-forward sorted-order)))) + (should (looking-at-p "^\t[0-9/]+$"))))) (hy-delete-file-and-buffer hyrolo-file)))) (ert-deftest hyrolo-sort-records-at-different-levels () @@ -269,11 +297,15 @@ and {b} the previous same level cell." (hyrolo-file-list (list folder))) (unwind-protect (progn - (hyrolo-fgrep "string") - (should (string= (buffer-name) hyrolo-display-buffer)) - (should (= (how-many "@loc>") 4)) - (dolist (f (list org-file kotl-file md-file outl-file)) - (should (= (how-many (concat "@loc> \"" f "\"")) 1)))) + (dolist (v '(:interactive nil)) + (if (eq v :interactive) + (ert-simulate-keys "string\n" + (call-interactively #'hyrolo-fgrep)) + (hyrolo-fgrep "string")) + (should (string= (buffer-name) hyrolo-display-buffer)) + (should (= (how-many "@loc>") 4)) + (dolist (f (list org-file kotl-file md-file outl-file)) + (should (= (how-many (concat "@loc> \"" f "\"")) 1))))) (dolist (f (list org-file kotl-file md-file outl-file)) (hy-delete-file-and-buffer f)) (kill-buffer hyrolo-display-buffer) @@ -523,6 +555,25 @@ Example: heading-prefix-char heading (1+ section) body depth)))) result)) +(ert-deftest hyrolo-tests--hyrolo-grep-interactive () + "Verify `hyrolo-grep' works when called interactively. +This just verifies it looks good when called interactively. Other tests +below verifies all the details." + (let* ((org-file (make-temp-file "hypb" nil ".org" + (hyrolo-tests--gen-outline ?* "heading" 2 "body" 2))) + (hyrolo-file-list (list org-file))) + (unwind-protect + (progn + (ert-simulate-keys "body\n" + (call-interactively #'hyrolo-grep)) + (should (string= hyrolo-display-buffer (buffer-name))) + + (should (looking-at-p "===")) + (execute-kbd-macro (kbd "n")) + (should (looking-at-p "^\\* heading 1"))) + (kill-buffer hyrolo-display-buffer) + (hy-delete-files-and-buffers hyrolo-file-list)))) + (ert-deftest hyrolo-tests--outline-next-visible-heading () "Verify movement to next visible heading." (let* ((org-file (make-temp-file "hypb" nil ".org" From 424f2150e268d610922615b0ec3e270a56ee7d6a Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Sat, 14 Mar 2026 00:14:58 +0100 Subject: [PATCH 2/2] Use hy-test-helpers:ert-simulate-keys --- test/hyrolo-tests.el | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 9d6dc6fd..92004761 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -55,14 +55,14 @@ (insert "===\nHdr\n===\n") (goto-char (point-min)) (should (looking-at "===")) - (ert-simulate-keys "item\n" + (hy-test-helpers:ert-simulate-keys "item\n" (call-interactively #'hyrolo-add)) (beginning-of-line) (should (looking-at-p "\\* item\n")) ;; hyrolo-add in mail buffer (with-mock (mock (hyrolo-name-and-email) => (list "first, last" "email")) - (ert-simulate-keys "\n" ;; Confirm proposed name + (hy-test-helpers:ert-simulate-keys "\n" ;; Confirm proposed name (call-interactively #'hyrolo-add)) (beginning-of-line) (should (looking-at-p "\\* first, last\t\t\n")))) @@ -236,7 +236,7 @@ and {b} the previous same level cell." (should (looking-at-p "^\t[0-9/]+$"))) (if (eq v :interactive) - (ert-simulate-keys "\n" ;; Confirm proposed name + (hy-test-helpers:ert-simulate-keys "\n" ;; Confirm proposed name (call-interactively #'hyrolo-sort)) (hyrolo-sort)) @@ -299,7 +299,7 @@ and {b} the previous same level cell." (progn (dolist (v '(:interactive nil)) (if (eq v :interactive) - (ert-simulate-keys "string\n" + (hy-test-helpers:ert-simulate-keys "string\n" (call-interactively #'hyrolo-fgrep)) (hyrolo-fgrep "string")) (should (string= (buffer-name) hyrolo-display-buffer)) @@ -564,7 +564,7 @@ below verifies all the details." (hyrolo-file-list (list org-file))) (unwind-protect (progn - (ert-simulate-keys "body\n" + (hy-test-helpers:ert-simulate-keys "body\n" (call-interactively #'hyrolo-grep)) (should (string= hyrolo-display-buffer (buffer-name)))