aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-05 06:01:13 -0500
committerCraig Jennings <c@cjennings.net>2026-06-05 06:01:13 -0500
commitecfc66294e57788df715c98297ef425fd9dbd9ef (patch)
tree0142d54735b4a778bad0babc5d55dad18f624469 /tests
parent877c104bfa8497324de45b2fef96dd4520da07e4 (diff)
downloadpearl-ecfc66294e57788df715c98297ef425fd9dbd9ef.tar.gz
pearl-ecfc66294e57788df715c98297ef425fd9dbd9ef.zip
feat(render): save the buffer to disk after a fetch or refresh
The full-replace render saved the Org file, but the in-place paths didn't, so a refresh or a comment fetch left the buffer modified-but-unsaved and the file on disk stale. Five paths now save through pearl--save-if-visiting: refresh-current-view, refresh-current-issue, fetch-all-comments, create-comment, and the merge branch of a dirty source-switch. The helper saves only when the buffer visits a file, so it's a no-op in a test buffer. Saving the Org file never pushes to Linear, so an unpushed edit still waits for pearl-save-issue. This only keeps the disk copy in step with what's on screen. fetch-all-comments surfaced the gap first. An audit turned up the other four.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-pearl-fetch-all-comments.el25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test-pearl-fetch-all-comments.el b/tests/test-pearl-fetch-all-comments.el
index 04dfe31..4449314 100644
--- a/tests/test-pearl-fetch-all-comments.el
+++ b/tests/test-pearl-fetch-all-comments.el
@@ -124,5 +124,30 @@
(test-pearl-fac--goto-issue)
(should-not (pearl--unpushed-comment-edits-p))))
+;;; save-after-fetch helper
+
+(ert-deftest test-pearl-save-if-visiting-noop-without-file ()
+ "In a non-file buffer the save helper is a no-op, not an error."
+ (with-temp-buffer
+ (insert "x")
+ (should-not (pearl--save-if-visiting))))
+
+(ert-deftest test-pearl-save-if-visiting-saves-file-buffer ()
+ "In a file-visiting buffer the helper writes the buffer to disk."
+ (let ((f (make-temp-file "pearl-save-" nil ".org")))
+ (unwind-protect
+ (let ((buf (find-file-noselect f)))
+ (unwind-protect
+ (with-current-buffer buf
+ (insert "hello pearl")
+ (should (buffer-modified-p))
+ (pearl--save-if-visiting)
+ (should-not (buffer-modified-p))
+ (should (string-match-p
+ "hello pearl"
+ (with-temp-buffer (insert-file-contents f) (buffer-string)))))
+ (kill-buffer buf)))
+ (delete-file f))))
+
(provide 'test-pearl-fetch-all-comments)
;;; test-pearl-fetch-all-comments.el ends here