aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-pearl-grouping.el58
-rw-r--r--tests/test-pearl-output.el18
2 files changed, 68 insertions, 8 deletions
diff --git a/tests/test-pearl-grouping.el b/tests/test-pearl-grouping.el
index a30bcc1..5bcae1d 100644
--- a/tests/test-pearl-grouping.el
+++ b/tests/test-pearl-grouping.el
@@ -354,5 +354,63 @@ SE-1 has a comment subtree; SE-2 has no assignee.")
(should (string-match-p "^\\*\\* Apollo$" out))
(should-not (string-match-p "^\\*\\* In Progress$" out))))
+;;; group ordering (board order, not first-appearance)
+
+(ert-deftest test-pearl-order-groups-workflowstate-by-type-then-position ()
+ "workflowState groups order by state type rank, then position within a type."
+ (let ((groups (list (cons "In Progress" (list '(:state (:type "started" :position 3.0))))
+ (cons "Icebox" (list '(:state (:type "backlog" :position 1.0))))
+ (cons "Done" (list '(:state (:type "completed" :position 5.0))))
+ (cons "Inbox" (list '(:state (:type "backlog" :position 2.0)))))))
+ (should (equal (mapcar #'car (pearl--order-groups "workflowState" groups))
+ '("Icebox" "Inbox" "In Progress" "Done")))))
+
+(ert-deftest test-pearl-order-groups-priority-urgent-first-none-last ()
+ "priority groups order Urgent..Low, then None last."
+ (let ((groups (list (cons "None" (list '(:priority 0)))
+ (cons "High" (list '(:priority 2)))
+ (cons "Urgent" (list '(:priority 1)))
+ (cons "Low" (list '(:priority 4))))))
+ (should (equal (mapcar #'car (pearl--order-groups "priority" groups))
+ '("Urgent" "High" "Low" "None")))))
+
+(ert-deftest test-pearl-order-groups-other-dimension-alphabetical ()
+ "A dimension with no board order (project) sorts alphabetically by label."
+ (let ((groups (list (cons "Zeta" (list '(:project (:name "Zeta"))))
+ (cons "alpha" (list '(:project (:name "alpha")))))))
+ (should (equal (mapcar #'car (pearl--order-groups "project" groups))
+ '("alpha" "Zeta")))))
+
+(ert-deftest test-pearl-group-issues-orders-by-board-order ()
+ "pearl--group-issues sections by board order even when input order differs."
+ (let ((issues (list '(:id "a" :state (:name "In Progress" :type "started" :position 3.0))
+ '(:id "b" :state (:name "Icebox" :type "backlog" :position 1.0)))))
+ (should (equal (mapcar #'car (pearl--group-issues issues "workflowState"))
+ '("Icebox" "In Progress")))))
+
+(defconst test-pearl-grouping--positioned
+ (concat
+ "#+LINEAR-SOURCE: (:type filter :name \"F\" :filter (:open t))\n\n"
+ "* F\n"
+ "** TODO SE-1: Alpha\n:PROPERTIES:\n:LINEAR-ID: i1\n"
+ ":LINEAR-STATE-NAME: In Progress\n:LINEAR-STATE-TYPE: started\n:LINEAR-STATE-POSITION: 3.0\n:END:\nBody.\n"
+ "** TODO SE-2: Beta\n:PROPERTIES:\n:LINEAR-ID: i2\n"
+ ":LINEAR-STATE-NAME: Icebox\n:LINEAR-STATE-TYPE: backlog\n:LINEAR-STATE-POSITION: 1.0\n:END:\nBody.\n")
+ "Flat buffer where first-appearance (In Progress, Icebox) differs from board
+order (Icebox before In Progress).")
+
+(ert-deftest test-pearl-regroup-orders-sections-by-board-order ()
+ "Regrouping by status orders the sections by Linear's board order, not arrival."
+ (test-pearl-grouping--in-org test-pearl-grouping--positioned
+ (should (eq (pearl--regroup-issue-subtrees "workflowState") t))
+ (should (equal (test-pearl-grouping--group-headings) '("Icebox" "In Progress")))))
+
+(ert-deftest test-pearl-format-issue-renders-state-position ()
+ "The issue drawer carries LINEAR-STATE-POSITION so an offline regroup can order."
+ (let ((out (pearl--format-issue-as-org-entry
+ '(:id "x" :identifier "SE-9" :title "T"
+ :state (:name "S" :type "started" :position 2.5)))))
+ (should (string-match-p "LINEAR-STATE-POSITION:[[:space:]]+2\\.5" out))))
+
(provide 'test-pearl-grouping)
;;; test-pearl-grouping.el ends here
diff --git a/tests/test-pearl-output.el b/tests/test-pearl-output.el
index 55f7886..1035ff2 100644
--- a/tests/test-pearl-output.el
+++ b/tests/test-pearl-output.el
@@ -90,7 +90,7 @@ cookie cycling reaches Low regardless of the user's global `org-priority-lowest'
(ert-deftest test-pearl-build-org-content-grouped-sections-and-startup ()
"A grouped view folds to show3levels, emits a level-2 group heading per group
-in first-appearance order, and renders issues at level 3 under them."
+in Linear board order (state type rank), and renders issues at level 3 under them."
(let* ((issues '((:id "1" :identifier "SE-1" :title "One"
:state (:name "Started" :type "started") :priority 0)
(:id "2" :identifier "SE-2" :title "Two"
@@ -104,14 +104,16 @@ in first-appearance order, and renders issues at level 3 under them."
(should (string-match-p "^\\*\\* Backlog$" out))
;; Issues live at level 3 under the group headings.
(should (string-match-p "^\\*\\*\\* STARTED " out))
- ;; First-appearance order: SE-1 (Started) before SE-2 (Backlog).
- (should (< (string-match "^\\*\\* Started$" out)
- (string-match "^\\*\\* Backlog$" out)))
- ;; The group heading carries no LINEAR-ID, so save/merge skip it.
- (let ((started (string-match "^\\*\\* Started$" out))
+ ;; Board order: Backlog (backlog-type) sorts before Started (started-type),
+ ;; regardless of which appeared first in the input.
+ (should (< (string-match "^\\*\\* Backlog$" out)
+ (string-match "^\\*\\* Started$" out)))
+ ;; The first group heading carries no LINEAR-ID, so save/merge skip it: it
+ ;; sits ahead of the first issue drawer.
+ (let ((first-group (string-match "^\\*\\* Backlog$" out))
(next-id (string-match "LINEAR-ID:" out)))
- (should started)
- (should (< started next-id)))))
+ (should first-group)
+ (should (< first-group next-id)))))
(ert-deftest test-pearl-build-org-content-grouped-source-roundtrips ()
"A grouped view's source (with :group) reads back from the rendered header."