aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-format.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 19:39:11 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 19:39:11 -0500
commitc5ff668aa2666e70ce423cf382b9871ed069a527 (patch)
treeb8dc5be3d2affdb2667c967350bda0c471844825 /tests/test-pearl-format.el
parent2568f25d069ecf242d5288db8f3bda968d6f8868 (diff)
downloadpearl-c5ff668aa2666e70ce423cf382b9871ed069a527.tar.gz
pearl-c5ff668aa2666e70ce423cf382b9871ed069a527.zip
feat(save): write synced baselines for structured fields
Save-model v2 reconciles a field by diffing its live value against a baseline last synced from Linear, but the structured fields (priority, state, assignee, labels) only stored their current value — there was nothing to diff against. The renderer now writes a synced baseline beside each: LINEAR-PRIORITY (the numeric priority), LINEAR-STATE-ID-SYNCED, LINEAR-ASSIGNEE-ID-SYNCED, and LINEAR-LABEL-IDS / LINEAR-LABEL-IDS-SYNCED (the live and baseline id sets, with LINEAR-LABELS staying display-only names). At fetch, live equals baseline, so nothing reads dirty on a fresh issue. The merge refresh re-renders changed subtrees through the same renderer, so baselines advance there too, and a retained dirty subtree is left untouched.
Diffstat (limited to 'tests/test-pearl-format.el')
-rw-r--r--tests/test-pearl-format.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-pearl-format.el b/tests/test-pearl-format.el
index 1e9fa53..a642b53 100644
--- a/tests/test-pearl-format.el
+++ b/tests/test-pearl-format.el
@@ -68,6 +68,31 @@
(should (string-match-p "^:LINEAR-TITLE-SHA256: +[0-9a-f]\\{64\\}$" out))
(should (string-match-p "^:END:$" out)))))
+;;; synced baselines for structured fields (save-model v2)
+
+(ert-deftest test-pearl-format-issue-writes-synced-baselines ()
+ "The renderer writes a synced baseline per structured field, equal to its live value at fetch."
+ (test-pearl--with-default-mapping
+ (let ((out (pearl--format-issue-as-org-entry (test-pearl--norm-full))))
+ ;; priority: numeric baseline beside the cookie
+ (should (string-match-p "^:LINEAR-PRIORITY: +2$" out))
+ ;; state: live id and synced baseline both present and equal
+ (should (string-match-p "^:LINEAR-STATE-ID: +state-1$" out))
+ (should (string-match-p "^:LINEAR-STATE-ID-SYNCED: +state-1$" out))
+ ;; assignee: live id and synced baseline equal
+ (should (string-match-p "^:LINEAR-ASSIGNEE-ID: +user-1$" out))
+ (should (string-match-p "^:LINEAR-ASSIGNEE-ID-SYNCED: +user-1$" out))
+ ;; labels: live id set and synced baseline equal, in fetched order
+ (should (string-match-p "^:LINEAR-LABEL-IDS: +lbl-1 lbl-2$" out))
+ (should (string-match-p "^:LINEAR-LABEL-IDS-SYNCED: +lbl-1 lbl-2$" out)))))
+
+(ert-deftest test-pearl-format-issue-bare-empty-baselines ()
+ "Null/missing structured fields render empty id baselines without error."
+ (test-pearl--with-default-mapping
+ (let ((out (pearl--format-issue-as-org-entry (test-pearl--norm-bare))))
+ (should (string-match-p "^:LINEAR-LABEL-IDS: +$" out))
+ (should (string-match-p "^:LINEAR-LABEL-IDS-SYNCED: +$" out)))))
+
(ert-deftest test-pearl-format-issue-description-in-body-not-property ()
"The description renders as body text, not a :DESCRIPTION: property."
(test-pearl--with-default-mapping