From 11109b45094eaecc1dc87a2e99afab4040732c8f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 15:24:12 -0500 Subject: test: cover comment insertion and extraction boundary cases Added ERT tests: append targets the current issue's Comments subtree even when a later issue already has its own Comments; add-comment from inside a comment subtree refuses (no issue id at that heading); edit-current-comment refuses a comment missing LINEAR-COMMENT-ID with no network call; and a comment body containing drawer-looking (:note:) text reads back intact. 380 tests green. --- tests/test-pearl-comments.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/test-pearl-comments.el') diff --git a/tests/test-pearl-comments.el b/tests/test-pearl-comments.el index 7fa4482..d335132 100644 --- a/tests/test-pearl-comments.el +++ b/tests/test-pearl-comments.el @@ -166,5 +166,26 @@ (test-pearl--in-org "* Plain heading\nno id\n" (should-error (pearl-add-comment "x") :type 'user-error))) +(ert-deftest test-pearl-append-comment-targets-current-issue-not-sibling () + "Appending adds under the current issue's Comments, not a later issue's subtree." + (test-pearl--in-org + (concat "** TODO Issue A\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody A.\n" + "*** Comments\n**** X — t\n:PROPERTIES:\n:LINEAR-COMMENT-ID: cx\n:END:\nfirst A\n" + "** TODO Issue B\n:PROPERTIES:\n:LINEAR-ID: b\n:END:\nBody B.\n" + "*** Comments\n**** Y — t\n:PROPERTIES:\n:LINEAR-COMMENT-ID: cy\n:END:\nfirst B\n") + (goto-char (point-min)) + (re-search-forward "Body A\\.") + (pearl--append-comment-to-issue + '(:id "cnew" :author "Z" :created-at "2026-05-24T12:00:00.000Z" :body "new on A")) + ;; the new comment landed under issue A, before issue B + (goto-char (point-min)) + (let ((new-pos (progn (re-search-forward "new on A") (point))) + (b-pos (progn (goto-char (point-min)) (re-search-forward "Issue B") (point)))) + (should (< new-pos b-pos))) + ;; issue B still has exactly one Comments heading (not a second one) + (goto-char (point-min)) + (re-search-forward "Issue B") + (should (re-search-forward "^\\*\\*\\* Comments$" nil t)))) + (provide 'test-pearl-comments) ;;; test-pearl-comments.el ends here -- cgit v1.2.3