aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-org-write.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-26 19:28:05 -0500
committerCraig Jennings <c@cjennings.net>2026-05-26 19:28:05 -0500
commit899c55f230d96649bdd3a3f4a8a0302ecf2df994 (patch)
treed32e11d1a016fc2200f11fbb8beef39314d0982c /tests/test-pearl-org-write.el
parent269ed3c2b1a94ed8ebad5fdce110efb671aa70f6 (diff)
downloadpearl-899c55f230d96649bdd3a3f4a8a0302ecf2df994.tar.gz
pearl-899c55f230d96649bdd3a3f4a8a0302ecf2df994.zip
feat(refresh): prompt instead of silently deferring a dirty refresh
Running pearl-list-issues on a buffer with unsaved edits used to print a passive "refresh deferred" message and do nothing visible, so it read as a no-op. Now it prompts: (d)iscard and rebuild, (m)erge by LINEAR-ID keeping the edits, or (q) cancel. Branch C of pearl--update-org-from-issues dispatches on the choice: discard rebuilds in place, merge hands off to the same by-id merge that pearl-refresh-current-view uses, and cancel leaves the buffer untouched.
Diffstat (limited to 'tests/test-pearl-org-write.el')
-rw-r--r--tests/test-pearl-org-write.el10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/test-pearl-org-write.el b/tests/test-pearl-org-write.el
index 6c30380..e467436 100644
--- a/tests/test-pearl-org-write.el
+++ b/tests/test-pearl-org-write.el
@@ -69,19 +69,20 @@
(should-not (string-match-p "old content" (buffer-string)))))))
(ert-deftest test-pearl-update-org-dirty-buffer-not-overwritten ()
- "A buffer with unsaved edits is left untouched, not clobbered."
+ "Cancelling the dirty-refresh prompt leaves a buffer with unsaved edits untouched."
(test-pearl--with-org-file tmp
(let ((buf (find-file-noselect tmp)))
(with-current-buffer buf
(insert "unsaved edits"))
- (pearl--update-org-from-issues test-pearl--sample-issues)
+ (cl-letf (((symbol-function 'pearl--dirty-refresh-choice) (lambda (_p) ?q)))
+ (pearl--update-org-from-issues test-pearl--sample-issues))
(with-current-buffer buf
(should (buffer-modified-p))
(should (string-match-p "unsaved edits" (buffer-string)))
(should-not (string-match-p "ENG-1" (buffer-string)))))))
(ert-deftest test-pearl-update-org-dirty-buffer-preserves-disk-and-surfaces ()
- "A dirty buffer is left as-is, the on-disk file is untouched, and the buffer is surfaced."
+ "Cancelling the prompt leaves the dirty buffer and on-disk file as-is, and surfaces it."
(test-pearl--with-org-file tmp
(let ((buf (find-file-noselect tmp))
(surfaced nil))
@@ -92,7 +93,8 @@
(goto-char (point-max))
(insert "UNSAVED EDIT\n"))
(cl-letf (((symbol-function 'pearl--surface-buffer)
- (lambda (b) (setq surfaced b))))
+ (lambda (b) (setq surfaced b)))
+ ((symbol-function 'pearl--dirty-refresh-choice) (lambda (_p) ?q)))
(pearl--update-org-from-issues test-pearl--sample-issues))
;; buffer keeps the unsaved edit and stays modified
(with-current-buffer buf