aboutsummaryrefslogtreecommitdiff
path: root/tests/test-pearl-saved-query-sync.el
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-pearl-saved-query-sync.el')
-rw-r--r--tests/test-pearl-saved-query-sync.el28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test-pearl-saved-query-sync.el b/tests/test-pearl-saved-query-sync.el
index ebf4622..830f738 100644
--- a/tests/test-pearl-saved-query-sync.el
+++ b/tests/test-pearl-saved-query-sync.el
@@ -239,6 +239,34 @@
(pearl--save-query-mark-synced "Q" nil nil "view-uuid")
:type 'user-error)))
+(ert-deftest test-pearl-save-query-mark-synced-stores-view-url-when-given ()
+ "The optional VIEW-URL arg lands in the entry as :linear-view-url."
+ (let ((pearl-saved-queries
+ (copy-tree '(("Q" :filter (:open t))))))
+ (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil)))
+ (pearl--save-query-mark-synced
+ "Q" nil nil "view-uuid" "https://linear.app/ws/view/abc"))
+ (let ((spec (cdr (assoc "Q" pearl-saved-queries))))
+ (should (equal "https://linear.app/ws/view/abc"
+ (plist-get spec :linear-view-url))))))
+
+(ert-deftest test-pearl-save-query-mark-synced-keeps-prior-url-when-omitted ()
+ "Omitting VIEW-URL on a re-sync preserves any previously stored URL.
+Re-sync paths whose API response doesn't carry a URL shouldn't erase a
+URL the create path already wrote."
+ (let ((pearl-saved-queries
+ (copy-tree '(("Q" :filter (:open t)
+ :linear-view-id "old-id"
+ :linear-view-team-id nil
+ :linear-view-shared :json-false
+ :linear-view-url "https://linear.app/ws/view/old")))))
+ (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil)))
+ ;; No VIEW-URL passed -- the prior URL should survive.
+ (pearl--save-query-mark-synced "Q" nil nil "new-id"))
+ (let ((spec (cdr (assoc "Q" pearl-saved-queries))))
+ (should (equal "https://linear.app/ws/view/old"
+ (plist-get spec :linear-view-url))))))
+
(ert-deftest test-pearl-save-query-mark-synced-overwrites-prior-sync-metadata ()
"Re-syncing an already-synced entry overwrites the four `:linear-view-*' keys."
(let ((pearl-saved-queries