aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-open.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 13:44:34 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 13:44:34 -0500
commitb081d62276378b3168c92c06153fd59db0589535 (patch)
tree9be7f7d22e0c9b4a73432fe744c09bb456c671a9 /tests/test-pearl-open.el
downloadpearl-b081d62276378b3168c92c06153fd59db0589535.tar.gz
pearl-b081d62276378b3168c92c06153fd59db0589535.zip
feat: pearl — manage Linear issues from org-mode
Pearl fetches Linear issues into an org file and syncs edits back. It covers list / custom views / saved queries, per-issue and bulk rendering with comments inline, conflict-aware sync of descriptions, titles, and comments, field commands for priority / state / assignee / labels, and a transient dispatch menu. The render folds to a scannable outline and nests issues under a sortable parent. Based on and inspired by Gael Blanchemain's linear-emacs.
Diffstat (limited to 'tests/test-pearl-open.el')
-rw-r--r--tests/test-pearl-open.el66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/test-pearl-open.el b/tests/test-pearl-open.el
new file mode 100644
index 0000000..1be6114
--- /dev/null
+++ b/tests/test-pearl-open.el
@@ -0,0 +1,66 @@
+;;; test-pearl-open.el --- Tests for open-issue-in-browser -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2026 Craig Jennings
+
+;; Author: Craig Jennings <c@cjennings.net>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Tests for `pearl-open-current-issue', which opens the issue at point
+;; in the browser from its LINEAR-URL property. `browse-url' is stubbed.
+
+;;; Code:
+
+(require 'test-bootstrap (expand-file-name "test-bootstrap.el"))
+(require 'cl-lib)
+
+(defmacro test-pearl--in-org (content &rest body)
+ "Run BODY in an org-mode temp buffer holding CONTENT at point-min."
+ (declare (indent 1))
+ `(with-temp-buffer
+ (insert ,content)
+ (org-mode)
+ (goto-char (point-min))
+ ,@body))
+
+(ert-deftest test-pearl-open-current-issue-visits-url ()
+ "The command passes the heading's LINEAR-URL to `browse-url'."
+ (let ((visited nil))
+ (test-pearl--in-org
+ "*** TODO Title\n:PROPERTIES:\n:LINEAR-ID: a\n:LINEAR-URL: https://linear.app/x/ENG-1\n:END:\nbody\n"
+ (cl-letf (((symbol-function 'browse-url)
+ (lambda (url &rest _) (setq visited url))))
+ (goto-char (point-max))
+ (pearl-open-current-issue)
+ (should (string= "https://linear.app/x/ENG-1" visited))))))
+
+(ert-deftest test-pearl-open-current-issue-no-url-errors ()
+ "An issue heading without a LINEAR-URL signals a user error, no browse."
+ (let ((visited nil))
+ (test-pearl--in-org
+ "*** TODO Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\n"
+ (cl-letf (((symbol-function 'browse-url)
+ (lambda (url &rest _) (setq visited url))))
+ (should-error (pearl-open-current-issue) :type 'user-error)
+ (should-not visited)))))
+
+(ert-deftest test-pearl-open-current-issue-not-on-issue-errors ()
+ "Running outside a heading signals a user error."
+ (test-pearl--in-org "plain text, no heading\n"
+ (should-error (pearl-open-current-issue) :type 'user-error)))
+
+(provide 'test-pearl-open)
+;;; test-pearl-open.el ends here