diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-pearl-saved-query-sync.el | 7 | ||||
| -rw-r--r-- | tests/test-pearl-views.el | 49 |
2 files changed, 53 insertions, 3 deletions
diff --git a/tests/test-pearl-saved-query-sync.el b/tests/test-pearl-saved-query-sync.el index 534993e..91a7061 100644 --- a/tests/test-pearl-saved-query-sync.el +++ b/tests/test-pearl-saved-query-sync.el @@ -199,6 +199,12 @@ label, plist team-id nil + team-name \"Personal\" + shared nil." ;;; pearl--customview-create-async +(ert-deftest test-pearl-customview-payload-fields-omit-url () + "The mutation payload selection must not request the unsupported `url' field. +Linear's `CustomView' has no `url'; selecting it 400s the create/update and +silently fails the publish (the 2026-06-02 regression)." + (should-not (string-match-p "\\burl\\b" pearl--customview-payload-fields))) + (ert-deftest test-pearl-customview-create-async-success () "A successful `customViewCreate' invokes the callback with `:success' t and the view." (testutil-linear-with-response @@ -459,6 +465,7 @@ erased on every re-sync." ((symbol-function 'pearl--progress) (lambda (&rest _) nil)) ((symbol-function 'message) (lambda (&rest _) nil)) ((symbol-function 'customize-save-variable) (lambda (_ _) nil)) + ((symbol-function 'pearl--org-url-key) (lambda (&optional _) "deepsat")) ((symbol-function 'pearl--customview-update-async) (lambda (_view-id input cb) (setq captured-input input) diff --git a/tests/test-pearl-views.el b/tests/test-pearl-views.el index a750ae0..e22a6d3 100644 --- a/tests/test-pearl-views.el +++ b/tests/test-pearl-views.el @@ -55,13 +55,52 @@ (cl-incf calls) (funcall (plist-get args :success) :data '((data (customViews - (nodes . [((id . "v1") (name . "My View") (url . "https://x"))]) + (nodes . [((id . "v1") (name . "My View"))]) (pageInfo (hasNextPage . :json-false))))))))) (let ((views (pearl--custom-views))) (should (= 1 (length views))) (pearl--custom-views) (should (= 1 calls)))))) +(ert-deftest test-pearl-custom-views-query-omits-url () + "The Custom Views list query must not select the unsupported `url' field. +Linear's `CustomView' type has no `url'; requesting it 400s the whole query +and leaves the run-view picker empty (the 2026-06-02 regression)." + (should-not (string-match-p "\\burl\\b" (pearl--custom-views-query)))) + +;;; --org-url-key (cached) and --view-url (reconstructed) + +(ert-deftest test-pearl-org-url-key-caches () + "The workspace url key is fetched once and served from cache." + (let ((pearl-api-key "test-key") + (pearl--cache-org-url-key nil) + (calls 0)) + (cl-letf (((symbol-function 'request) + (lambda (_url &rest args) + (cl-incf calls) + (funcall (plist-get args :success) :data + '((data (organization (urlKey . "deepsat")))))))) + (should (string= "deepsat" (pearl--org-url-key))) + (pearl--org-url-key) + (should (= 1 calls))))) + +(ert-deftest test-pearl-view-url-builds-from-urlkey () + "A view's web URL is reconstructed from the workspace url key and view id." + (cl-letf (((symbol-function 'pearl--org-url-key) (lambda (&optional _) "deepsat"))) + (should (string= "https://linear.app/deepsat/view/abc123" + (pearl--view-url "abc123"))))) + +(ert-deftest test-pearl-view-url-nil-when-no-urlkey () + "With no workspace url key, the view URL is nil so callers degrade gracefully." + (cl-letf (((symbol-function 'pearl--org-url-key) (lambda (&optional _) nil))) + (should-not (pearl--view-url "abc123")))) + +(ert-deftest test-pearl-view-url-nil-when-empty-view-id () + "A nil or empty view id yields no URL rather than a malformed link." + (cl-letf (((symbol-function 'pearl--org-url-key) (lambda (&optional _) "deepsat"))) + (should-not (pearl--view-url nil)) + (should-not (pearl--view-url "")))) + ;;; run-view (ert-deftest test-pearl-run-view-renders-with-view-source () @@ -69,7 +108,10 @@ (let ((ran-id nil) (rendered-source nil)) (cl-letf (((symbol-function 'pearl--custom-views) (lambda (&optional _force) - '(((id . "v1") (name . "My View") (url . "https://linear.app/view/v1"))))) + ;; Nodes carry no `url' -- Linear's CustomView has none; the + ;; source URL is reconstructed from the workspace url key. + '(((id . "v1") (name . "My View"))))) + ((symbol-function 'pearl--org-url-key) (lambda (&optional _) "deepsat")) ((symbol-function 'pearl--query-view-async) (lambda (id cb) (setq ran-id id) (funcall cb (pearl--make-query-result 'ok :issues nil)))) @@ -79,7 +121,8 @@ (should (string= "v1" ran-id)) (should (eq 'view (plist-get rendered-source :type))) (should (string= "v1" (plist-get rendered-source :id))) - (should (string= "https://linear.app/view/v1" (plist-get rendered-source :url)))))) + (should (string= "https://linear.app/deepsat/view/v1" + (plist-get rendered-source :url)))))) ;;; refresh-current-view, view branch |
