branch: elpa/git-commit commit 703410039cf28e6bba4949853d010e897d972356 Author: Paul Pogonyshev <pogonys...@gmail.com> Commit: Jonas Bernoulli <jo...@bernoul.li>
test: Assert that certain text is visible Basic UI tests; would catch the bug in commit 1ab107a7. --- test/magit-tests.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/magit-tests.el b/test/magit-tests.el index 57797f338a..f2d67f87b3 100644 --- a/test/magit-tests.el +++ b/test/magit-tests.el @@ -59,6 +59,20 @@ (declare (indent 1) (debug t)) `(magit-with-test-directory (magit-test-init-repo "." "--bare") ,@body)) +(defun magit-test-visible-text (&optional raw) + (save-excursion + (let (chunks) + (goto-char (point-min)) + (while (let ((to (next-single-char-property-change (point) 'invisible))) + (unless (invisible-p (point)) + (push (buffer-substring-no-properties (point) to) chunks)) + (goto-char to) + (< (point) (point-max)))) + (let ((result (mapconcat #'identity (nreverse chunks) nil))) + (unless raw + (setq result (string-trim result))) + result)))) + ;;; Git (ert-deftest magit--with-safe-default-directory () @@ -401,6 +415,26 @@ Enter passphrase for key '/home/user/.ssh/id_rsa': " '(unpushed . "@{upstream}..") (magit-rev-parse "--short" "master"))))) +(ert-deftest magit-status:section-commands () + (magit-with-test-repository + (magit-git "commit" "-m" "dummy" "--allow-empty") + (with-current-buffer (magit-status-setup-buffer) + (magit-section-show-level-1-all) + (should (string-match-p + "\\`Head:[[:space:]]+master dummy\n\nRecent commits\\'" + (magit-test-visible-text))) + (magit-section-show-level-2-all) + (should (string-match-p + "\\`Head:[[:space:]]+master dummy\n +Recent commits\n[[:xdigit:]]\\{7,\\} master dummy\\'" + (magit-test-visible-text))) + (goto-char (point-min)) + (search-forward "Recent") + (magit-section-show-level-1) + (should (string-match-p + "\\`Head:[[:space:]]+master dummy\n\nRecent commits\\'" + (magit-test-visible-text)))))) + ;;; libgit (ert-deftest magit-in-bare-repo ()