aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-pearl-comment-editing.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test-pearl-comment-editing.el b/tests/test-pearl-comment-editing.el
index ff1dff5..29a5236 100644
--- a/tests/test-pearl-comment-editing.el
+++ b/tests/test-pearl-comment-editing.el
@@ -29,6 +29,7 @@
(require 'test-bootstrap (expand-file-name "test-bootstrap.el"))
(require 'testutil-request (expand-file-name "testutil-request.el"))
+(require 'testutil-fixtures (expand-file-name "testutil-fixtures.el"))
(require 'cl-lib)
(defmacro test-pearl--in-org (content &rest body)
@@ -256,6 +257,43 @@
(should (eq 'pearl-editable-comment (face-on "^\\*\\*\\*\\*\\* Me")))
(should (eq 'pearl-readonly-comment (face-on "^\\*\\*\\*\\*\\* Them"))))))
+(ert-deftest test-pearl-update-org-highlights-comments-on-bulk-render ()
+ "The bulk render colors comment headings, so a list-issues fetch shows
+editability without a follow-up refresh. Regression: highlighting ran only on
+the refresh / add-comment / view-merge paths, never on the initial render."
+ (let* ((tmp (make-temp-file "pearl-hl" nil ".org"))
+ (pearl-org-file-path tmp)
+ (pearl--cache-viewer '(:id "user-1" :name "Craig"))
+ (issue (pearl--normalize-issue (testutil-linear-fixture-issue-with-comments))))
+ (unwind-protect
+ (progn
+ (when (find-buffer-visiting tmp) (kill-buffer (find-buffer-visiting tmp)))
+ (cl-letf (((symbol-function 'pearl--surface-buffer) (lambda (_b) nil)))
+ (pearl--update-org-from-issues
+ (list issue) '(:type filter :name "X" :filter nil) nil))
+ (let ((buf (find-buffer-visiting tmp)))
+ (should buf)
+ (with-current-buffer buf
+ (let (faces)
+ (save-excursion
+ (goto-char (point-min))
+ (while (re-search-forward "^\\*+ " nil t)
+ (let ((cid (org-entry-get nil "LINEAR-COMMENT-ID")))
+ (when cid
+ (let ((ov (cl-find-if
+ (lambda (o) (overlay-get o 'pearl-comment))
+ (overlays-at (line-beginning-position)))))
+ (push (cons cid (and ov (overlay-get ov 'face))) faces))))))
+ ;; both comment headings carry the editability overlay after a
+ ;; plain bulk render — no refresh needed
+ (should (= 2 (length faces)))
+ ;; cm-2 is Craig's own (user-1) -> editable; cm-1 is Alice's
+ ;; (user-2) -> read-only
+ (should (eq 'pearl-editable-comment (cdr (assoc "cm-2" faces))))
+ (should (eq 'pearl-readonly-comment (cdr (assoc "cm-1" faces))))))))
+ (when (find-buffer-visiting tmp) (kill-buffer (find-buffer-visiting tmp)))
+ (ignore-errors (delete-file tmp)))))
+
(ert-deftest test-pearl-add-comment-from-inside-comment-refuses ()
"Running add-comment from inside a comment subtree refuses — no issue id there."
(test-pearl--in-org (test-pearl--comment-doc "u-me" "stored" "uniquecommentline")