aboutsummaryrefslogtreecommitdiff
path: root/tests/test-org-webclipper-commands.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-25 17:51:17 -0500
committerCraig Jennings <c@cjennings.net>2026-05-25 17:51:17 -0500
commitd665582d6fc19c15a772c6ec24ff822e7e3c37f9 (patch)
tree40c44ed42cd4e4805de626221eae88a05ea484d1 /tests/test-org-webclipper-commands.el
parentc414a6346f970f0ac49f92222471efeaf7e922d0 (diff)
downloaddotemacs-d665582d6fc19c15a772c6ec24ff822e7e3c37f9.tar.gz
dotemacs-d665582d6fc19c15a772c6ec24ff822e7e3c37f9.zip
fix(org): guard external-tool assumptions in export and publishing commands
Four export/publishing commands shelled out to external tools without checking they exist, so a missing tool surfaced as an opaque process error — or, for reveal.js, a silently broken presentation. I added a command-time guard to each that names the tool and what's needed: - zathura, in the pandoc PDF export-and-open command - the hugo binary and the platform file-manager opener, in hugo-config - the local reveal.js checkout (run scripts/setup-reveal.sh), shared by the reveal export and preview commands - pandoc, in the web-clip protocol handler The checks run only when the command runs, so startup stays quiet. Each guard has a test asserting the user-error fires when the tool is absent, and the existing happy-path tests now stub the lookups so they exercise the real path rather than tripping the new guard.
Diffstat (limited to 'tests/test-org-webclipper-commands.el')
-rw-r--r--tests/test-org-webclipper-commands.el23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test-org-webclipper-commands.el b/tests/test-org-webclipper-commands.el
index 5ec5fbfe..be7fc38c 100644
--- a/tests/test-org-webclipper-commands.el
+++ b/tests/test-org-webclipper-commands.el
@@ -115,11 +115,34 @@ that registers the webclip entry. Providing `'org-protocol' fires the block."
(cl-letf (((symbol-function 'require) (lambda (&rest _) t)))
(should-error (cj/org-protocol-webclip-handler) :type 'error))))
+(ert-deftest test-webclipper-protocol-handler-errors-when-pandoc-missing ()
+ "Error: handler signals a user-error naming pandoc when it's not on PATH."
+ (let ((cj/--webclip-url "https://example.com")
+ (cj/--webclip-title "Title"))
+ (cl-letf (((symbol-function 'require) (lambda (&rest _) t))
+ ((symbol-function 'executable-find) (lambda (_) nil)))
+ (let ((err (should-error (cj/org-protocol-webclip-handler)
+ :type 'user-error)))
+ (should (string-match-p "pandoc" (cadr err)))))))
+
+(ert-deftest test-webclipper-protocol-handler-proceeds-when-pandoc-present ()
+ "Normal: with pandoc on PATH the guard passes through to conversion."
+ (let ((cj/--webclip-url "https://example.com")
+ (cj/--webclip-title "Title"))
+ (cl-letf (((symbol-function 'require) (lambda (&rest _) t))
+ ((symbol-function 'executable-find) (lambda (_) "/usr/bin/pandoc"))
+ ((symbol-function 'org-web-tools--url-as-readable-org)
+ (lambda (_) "* Page Title\n** Sub heading\nBody.\n"))
+ ((symbol-function 'message) #'ignore))
+ (should (string-match-p "Body"
+ (cj/org-protocol-webclip-handler))))))
+
(ert-deftest test-webclipper-protocol-handler-returns-processed-content ()
"Normal: handler converts the bound URL into processed org content."
(let ((cj/--webclip-url "https://example.com")
(cj/--webclip-title "Title"))
(cl-letf (((symbol-function 'require) (lambda (&rest _) t))
+ ((symbol-function 'executable-find) (lambda (_) "/usr/bin/pandoc"))
((symbol-function 'org-web-tools--url-as-readable-org)
(lambda (_) "* Page Title\n** Sub heading\nBody.\n"))
((symbol-function 'message) #'ignore))