aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-comments.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-28 10:32:25 -0500
committerCraig Jennings <c@cjennings.net>2026-05-28 10:32:25 -0500
commitb1df299c164bd688ce4d0887603e6b71ea51bd22 (patch)
treed27347e44893260602f7ba1f1cb4c0037413bc40 /tests/test-pearl-comments.el
parente5a07739c5b58b041bcb7192eae35a2c4d98bce3 (diff)
downloadpearl-b1df299c164bd688ce4d0887603e6b71ea51bd22.tar.gz
pearl-b1df299c164bd688ce4d0887603e6b71ea51bd22.zip
refactor(render): drop the leading 💬 glyph from the Comments heading
Pearl was rendering the Comments subtree heading as `*** 💬 Comments [N/M]`. Craig flagged that it looks strange, and the renderer should work cleanly before it gets glyphed. I dropped the emoji prefix so the heading reads `*** Comments [N/M]`. Partly reverts 41a3396. The overlay-glyph idea (a content-aware display overlay on the leading stars) stays tracked as a separate task. I touched pearl--format-comments (the new-subtree literal) and pearl--append-comment-to-issue (both the new-subtree insert and a couple of stale docstring references). The append-locator regex stays tolerant of the legacy `💬 Comments` heading and of the older pre-2026-05 `Comments 💬 N/N` trailing-glyph layout. Buffers rendered in any of the three states still locate their Comments heading on append. I added one regression test (test-pearl-append-comment-locates-legacy-emoji-prefixed-heading) that seeds a `*** 💬 Comments 1/1` heading and asserts append still finds it, bumps the count to 2/2, and doesn't add a second Comments heading. I updated assertions in test-pearl-comments.el, test-pearl-list-comments.el, and test-integration-acceptance.el to expect the no-emoji form. I also updated docstrings on pearl-fetch-comments-in-list, pearl-list-comments-count-cap, pearl--format-comments, pearl--bump-comments-count-marker, and pearl--comment-count-marker. The README's sample buffer block now matches what the renderer emits. All 669 ert tests pass. make compile and make lint are clean.
Diffstat (limited to 'tests/test-pearl-comments.el')
-rw-r--r--tests/test-pearl-comments.el28
1 files changed, 22 insertions, 6 deletions
diff --git a/tests/test-pearl-comments.el b/tests/test-pearl-comments.el
index 323d7b7..0a0cb45 100644
--- a/tests/test-pearl-comments.el
+++ b/tests/test-pearl-comments.el
@@ -71,7 +71,7 @@
"With newest-first order, the most recent comment renders on top."
(let* ((pearl-comment-sort-order 'newest-first)
(out (pearl--format-comments test-pearl--two-comments)))
- (should (string-match-p "^\\*\\*\\* 💬 Comments$" out))
+ (should (string-match-p "^\\*\\*\\* Comments$" out))
(should (< (string-match "second" out) (string-match "first" out)))))
(ert-deftest test-pearl-format-comments-oldest-first ()
@@ -90,7 +90,7 @@
:state (:name "Todo") :description "Body text."
:comments ((:id "c1" :author "A" :created-at "2026-05-23T09:00:00.000Z"
:body "a comment"))))))
- (should (string-match-p "^\\*\\*\\* 💬 Comments$" out))
+ (should (string-match-p "^\\*\\*\\* Comments$" out))
(should (< (string-match "Body text." out) (string-match "a comment" out))))))
;;; --create-comment-async
@@ -120,23 +120,39 @@
;;; --append-comment-to-issue
(ert-deftest test-pearl-append-comment-creates-subtree ()
- "Appending to an issue with no Comments subtree creates one, glyphed and 1/1."
+ "Appending to an issue with no Comments subtree creates one with the 1/1 marker."
(test-pearl--in-org
"*** TODO [#B] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody.\n"
(pearl--append-comment-to-issue
'(:id "c1" :author "A" :created-at "2026-05-23T09:00:00.000Z" :body "first comment"))
(goto-char (point-min))
- (should (re-search-forward "^\\*\\*\\* 💬 Comments 1/1$" nil t))
+ (should (re-search-forward "^\\*\\*\\* Comments 1/1$" nil t))
(should (re-search-forward "first comment" nil t))))
(ert-deftest test-pearl-append-comment-bumps-count-marker ()
"Appending increments the shown/total count on an existing Comments heading."
(test-pearl--in-org
+ "** TODO [#B] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody.\n*** Comments 1/1\n**** A — 2026-05-23T09:00:00.000Z\nfirst\n"
+ (pearl--append-comment-to-issue
+ '(:id "c2" :author "B" :created-at "2026-05-23T12:00:00.000Z" :body "second"))
+ (goto-char (point-min))
+ (should (re-search-forward "^\\*\\*\\* Comments 2/2$" nil t))))
+
+(ert-deftest test-pearl-append-comment-locates-legacy-emoji-prefixed-heading ()
+ "The locator regex still finds a pre-existing `💬 Comments' heading.
+Buffers rendered between 2026-05-26 and the 💬-emoji revert carry the
+leading glyph; pearl--append-comment-to-issue should still find and
+extend them without re-rendering the file."
+ (test-pearl--in-org
"** TODO [#B] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody.\n*** 💬 Comments 1/1\n**** A — 2026-05-23T09:00:00.000Z\nfirst\n"
(pearl--append-comment-to-issue
'(:id "c2" :author "B" :created-at "2026-05-23T12:00:00.000Z" :body "second"))
(goto-char (point-min))
- (should (re-search-forward "^\\*\\*\\* 💬 Comments 2/2$" nil t))))
+ ;; The bump-count operates on the legacy heading; the new comment appears
+ ;; under it without a second Comments heading being added.
+ (should (re-search-forward "^\\*\\*\\* 💬 Comments 2/2$" nil t))
+ (goto-char (point-min))
+ (should-not (re-search-forward "^\\*\\*\\* Comments " nil t))))
(ert-deftest test-pearl-append-comment-newest-first-inserts-at-top ()
"With newest-first order, a new comment lands above the existing ones."
@@ -178,7 +194,7 @@
(re-search-forward "Body.")
(pearl-create-comment "my new comment")
(goto-char (point-min))
- (should (re-search-forward "^\\*\\*\\* 💬 Comments 1/1$" nil t))
+ (should (re-search-forward "^\\*\\*\\* Comments 1/1$" nil t))
(should (re-search-forward "my new comment" nil t)))))
(ert-deftest test-pearl-create-comment-reports-failure ()