aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-comment-editing.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-pearl-comment-editing.el')
-rw-r--r--tests/test-pearl-comment-editing.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test-pearl-comment-editing.el b/tests/test-pearl-comment-editing.el
index 05a3a76..866366f 100644
--- a/tests/test-pearl-comment-editing.el
+++ b/tests/test-pearl-comment-editing.el
@@ -214,6 +214,26 @@
(pearl-edit-current-comment)
(should-not updated)))))
+(ert-deftest test-pearl-edit-comment-push-failure-keeps-hash ()
+ "A failed comment push keeps the stored hash and the edited body for retry."
+ (test-pearl--in-org (test-pearl--comment-doc "u-me" "old body" "new body")
+ (let ((pearl--cache-viewer '(:id "u-me" :name "Me"))
+ (pushed-body nil)
+ (stored (secure-hash 'sha256 "old body")))
+ (cl-letf (((symbol-function 'pearl--fetch-comment-body-async)
+ (lambda (_id cb) (funcall cb "old body")))
+ ((symbol-function 'pearl--update-comment-async)
+ (lambda (_id body cb) (setq pushed-body body) (funcall cb '(:success nil)))))
+ (re-search-forward "new body")
+ (pearl-edit-current-comment)
+ ;; push attempted with the edited body ...
+ (should (string= "new body" pushed-body))
+ ;; ... but the stored hash is not advanced and the edit stays.
+ (goto-char (point-min))
+ (re-search-forward "^\\*\\*\\*\\*\\* Craig")
+ (should (string= stored (org-entry-get nil "LINEAR-COMMENT-SHA256")))
+ (should (string= "new body" (pearl--issue-body-at-point)))))))
+
;;; editability highlighting
(ert-deftest test-pearl-highlight-comments-colors-by-editability ()