From a6a08fd6a418a5d404550478bde2883c440377a7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 3 Jun 2026 12:36:13 -0500 Subject: fix(render): nest comments under their issue in a grouped view In a grouped view, each issue's Comments subtree rendered at the issue's own level instead of one deeper, so the Comments heading sat as a sibling of its ticket rather than a child. The grouping feature gave pearl--format-issue-as-org-entry a level parameter (issues render at level 3 under a group heading) but left the comment subtree hardcoded: pearl--format-comments emitted "*** Comments" and pearl--format-comment "**** ". That nests right when the issue is at level 2 (flat) and breaks when it's at level 3 (grouped). I thread the issue's level through, so the Comments heading is level+1 and each comment body level+2: a flat issue stays 2/3/4, a grouped one becomes 3/4/5. --- tests/test-pearl-list-comments.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tests') diff --git a/tests/test-pearl-list-comments.el b/tests/test-pearl-list-comments.el index 751e220..71d3e73 100644 --- a/tests/test-pearl-list-comments.el +++ b/tests/test-pearl-list-comments.el @@ -112,6 +112,32 @@ (let ((out (pearl--format-comments (test-pearl--comments 2)))) (should (string-match-p "^\\*\\*\\* Comments$" out)))) +(ert-deftest test-pearl-format-comments-nests-under-issue-level () + "The Comments subtree nests one level under the issue: a flat issue (level 2, +the default) gets Comments at level 3 and bodies at level 4; a grouped issue at +level 3 gets Comments at level 4 and bodies at level 5. Regression guard for +the grouping bug where comments rendered as siblings of their issue." + (let ((comments (test-pearl--comments 1))) + ;; flat (default level 2) + (should (string-match-p "^\\*\\*\\* Comments$" (pearl--format-comments comments nil 2))) + (should (string-match-p "^\\*\\*\\*\\* " (pearl--format-comments comments nil 2))) + ;; grouped (issue at level 3) + (let ((out (pearl--format-comments comments nil 3))) + (should (string-match-p "^\\*\\*\\*\\* Comments$" out)) + (should (string-match-p "^\\*\\*\\*\\*\\* " out)) + (should-not (string-match-p "^\\*\\*\\* Comments$" out))))) + +(ert-deftest test-pearl-format-issue-grouped-nests-comments-under-issue () + "A level-3 issue with comments renders its Comments subtree at level 4 (a +child), not level 3 (a sibling) -- the grouped-view regression." + (let* ((issue (list :id "u" :identifier "ENG-1" :title "Fix it" + :priority 2 :state '(:name "Todo") + :comments (test-pearl--comments 1))) + (out (pearl--format-issue-as-org-entry issue 3))) + (should (string-match-p "^\\*\\*\\* TODO " out)) ; issue at level 3 + (should (string-match-p "^\\*\\*\\*\\* Comments$" out)) ; Comments nested at 4 + (should-not (string-match-p "^\\*\\*\\* Comments$" out)))) + ;;; the marked heading is still found by the append locator (ert-deftest test-pearl-append-finds-marked-comments-heading () -- cgit v1.2.3