aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-comment-editing.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-26 12:48:22 -0500
committerCraig Jennings <c@cjennings.net>2026-05-26 12:48:22 -0500
commit052aef8689af897c20e02d069fcdb09490996d2d (patch)
treea5b3e4f823b76a344edc611ee95fa8148cbf452a /tests/test-pearl-comment-editing.el
parent914ab07da513daebd15c7bc65ac334cde5fbb769 (diff)
downloadpearl-052aef8689af897c20e02d069fcdb09490996d2d.tar.gz
pearl-052aef8689af897c20e02d069fcdb09490996d2d.zip
fix(comments): apply comment highlighting on the bulk render path
Comment headings only got their green (editable) / grey (read-only) coloring after `pearl-refresh-current-issue`, an add-comment, or a view merge (the three paths that call `pearl-highlight-comments`). A plain `pearl-list-issues` rendered through `pearl--update-org-from-issues`, which never called it, so a fresh fetch showed no coloring until I refreshed. I added the highlight call to branches A and B of `pearl--update-org-from-issues`, right after the content lands in the buffer. Branch C defers a dirty buffer without writing, so it stays uncolored. The regression test renders the comment fixture and asserts both headings carry the editability overlay (own to editable, other's to read-only) straight from the bulk render.
Diffstat (limited to 'tests/test-pearl-comment-editing.el')
-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")