aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-fields.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 21:22:27 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 21:22:27 -0500
commit60b51e1c996f1c8f152696946b9440f26ea9a956 (patch)
tree3154332cc2b7d5bb3e0eb71a812d9effc8c46633 /tests/test-pearl-fields.el
parentf9841539b3adb192d0c15470fa9c31d6cbbdf447 (diff)
downloadpearl-60b51e1c996f1c8f152696946b9440f26ea9a956.tar.gz
pearl-60b51e1c996f1c8f152696946b9440f26ea9a956.zip
refactor(save): retire the immediate-push field setters for buffer-editors
The structured fields now reconcile at save (the previous commits), so the immediate-push setters are the duplicate path that made the package feel like it had two save models. I retired them. pearl-set-priority is deleted outright — priority is edited org-natively through the heading cookie. pearl-set-state, pearl-set-assignee, and pearl-set-labels become pearl-edit-state / -assignee / -labels: the same completing-read picker, but it writes the buffer representation (keyword/name/id, the assignee drawer, the labels drawer plus the live LINEAR-LABEL-IDS set) and marks the field dirty instead of pushing. The change goes out at the next pearl-save-issue / pearl-save-all. pearl-compose-current-description is renamed pearl-edit-description (its compose-and-push behavior is unchanged — v2 doesn't touch the compose buffers). The transient, the C-; L e keymap, the affordance preamble, and the README follow the new names, and the priority slots are dropped (no command — it's the org cookie). Deleting the setters left pearl--push-issue-field and pearl--priority-choices with no callers, so both are gone, along with the killed-buffer test that only exercised the removed helper. I filed a follow-up: the atomic savers' async commit callbacks need the same killed-buffer guard that helper carried. The setter command tests are rewritten to assert the buffer-write-and-no-push contract. The reconcile-and-push path they used to cover is exercised in test-pearl-save.
Diffstat (limited to 'tests/test-pearl-fields.el')
-rw-r--r--tests/test-pearl-fields.el73
1 files changed, 14 insertions, 59 deletions
diff --git a/tests/test-pearl-fields.el b/tests/test-pearl-fields.el
index 3722486..2ad9679 100644
--- a/tests/test-pearl-fields.el
+++ b/tests/test-pearl-fields.el
@@ -86,38 +86,9 @@
(should (string-match-p "^\\*\\*\\* TODO Title" (thing-at-point 'line t)))
(should-not (string-match-p "\\[#" (thing-at-point 'line t)))))
-;;; pearl-set-priority
-
-(ert-deftest test-pearl-set-priority-pushes-and-updates-cookie ()
- "Setting priority pushes the numeric value and rewrites the cookie."
- (let ((pushed nil))
- (test-pearl--in-org "*** TODO [#C] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\n"
- (cl-letf (((symbol-function 'pearl--update-issue-async)
- (lambda (_id input cb) (setq pushed input) (funcall cb '(:success t)))))
- (re-search-forward "Title")
- (pearl-set-priority "High")
- (should (equal 2 (cdr (assoc "priority" pushed))))
- (goto-char (point-min))
- (should (string-match-p "\\[#B\\]" (thing-at-point 'line t)))))))
-
-(ert-deftest test-pearl-set-priority-not-on-issue-errors ()
- "Setting priority outside a Linear issue heading signals a user error."
- (test-pearl--in-org "* Plain heading\nno id\n"
- (should-error (pearl-set-priority "High") :type 'user-error)))
-
-(ert-deftest test-pearl-set-priority-failure-preserves-cookie ()
- "A failed priority push attempts the mutation but leaves the cookie unchanged."
- (let (pushed)
- (test-pearl--in-org "*** TODO [#C] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\n"
- (cl-letf (((symbol-function 'pearl--update-issue-async)
- (lambda (_id input cb) (setq pushed input) (funcall cb '(:success nil)))))
- (re-search-forward "Title")
- (pearl-set-priority "High")
- ;; the push was attempted with the intended value ...
- (should (equal 2 (cdr (assoc "priority" pushed))))
- ;; ... but the local cookie is still #C, not #B.
- (goto-char (point-min))
- (should (string-match-p "^\\*\\*\\* TODO \\[#C\\] Title" (thing-at-point 'line t)))))))
+;; pearl-set-priority is gone: priority is edited org-natively via the heading
+;; cookie and reconciled at save (see test-pearl-save). The cookie writer
+;; `pearl--set-priority-cookie' above is still exercised.
;;; --set-heading-state
@@ -140,10 +111,10 @@
(pearl--set-heading-state "Done" "s3")
(should-not fired)))))
-;;; pearl-set-state
+;;; pearl-edit-state (buffer-editor: writes the representation, no push)
-(ert-deftest test-pearl-set-state-pushes-id-and-updates-heading ()
- "Setting state resolves the name to an id, pushes it, and updates the heading."
+(ert-deftest test-pearl-edit-state-writes-heading-no-push ()
+ "edit-state resolves the name, writes keyword/name/id, and does not push."
(let ((pushed nil))
(test-pearl--in-org
"*** TODO [#B] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:LINEAR-TEAM-ID: team-1\n:END:\n"
@@ -151,34 +122,18 @@
(lambda (_team) '(((id . "s1") (name . "Todo"))
((id . "s2") (name . "In Progress")))))
((symbol-function 'pearl--update-issue-async)
- (lambda (_id input cb) (setq pushed input) (funcall cb '(:success t)))))
- (pearl-set-state "In Progress")
- (should (string= "s2" (cdr (assoc "stateId" pushed))))
+ (lambda (&rest _) (setq pushed t))))
+ (pearl-edit-state "In Progress")
+ (should-not pushed)
(goto-char (point-min))
(should (string-match-p "^\\*\\*\\* IN-PROGRESS " (thing-at-point 'line t)))
- (should (string= "In Progress" (org-entry-get nil "LINEAR-STATE-NAME")))))))
+ (should (string= "In Progress" (org-entry-get nil "LINEAR-STATE-NAME")))
+ (should (string= "s2" (org-entry-get nil "LINEAR-STATE-ID")))))))
-(ert-deftest test-pearl-set-state-not-on-issue-errors ()
- "Setting state outside a Linear issue heading signals a user error."
+(ert-deftest test-pearl-edit-state-not-on-issue-errors ()
+ "edit-state outside a Linear issue heading signals a user error."
(test-pearl--in-org "* Plain heading\nno id\n"
- (should-error (pearl-set-state "Done") :type 'user-error)))
-
-(ert-deftest test-pearl-set-state-failure-preserves-keyword-and-drawer ()
- "A failed state push attempts the mutation but leaves the keyword and drawer unchanged."
- (let (pushed)
- (test-pearl--in-org
- "*** TODO [#B] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:LINEAR-TEAM-ID: team-1\n:LINEAR-STATE-ID: s1\n:LINEAR-STATE-NAME: Todo\n:END:\n"
- (cl-letf (((symbol-function 'pearl--team-states)
- (lambda (_t) '(((id . "s1") (name . "Todo"))
- ((id . "s2") (name . "In Progress")))))
- ((symbol-function 'pearl--update-issue-async)
- (lambda (_id input cb) (setq pushed input) (funcall cb '(:success nil)))))
- (pearl-set-state "In Progress")
- (should (string= "s2" (cdr (assoc "stateId" pushed))))
- (goto-char (point-min))
- (should (string-match-p "^\\*\\*\\* TODO " (thing-at-point 'line t)))
- (should (string= "Todo" (org-entry-get nil "LINEAR-STATE-NAME")))
- (should (string= "s1" (org-entry-get nil "LINEAR-STATE-ID")))))))
+ (should-error (pearl-edit-state "Done") :type 'user-error)))
(provide 'test-pearl-fields)
;;; test-pearl-fields.el ends here