diff options
Diffstat (limited to 'tests/test-pearl-local-views.el')
| -rw-r--r-- | tests/test-pearl-local-views.el | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test-pearl-local-views.el b/tests/test-pearl-local-views.el index 71fb173..b474e74 100644 --- a/tests/test-pearl-local-views.el +++ b/tests/test-pearl-local-views.el @@ -167,5 +167,38 @@ (should (equal (plist-get spec :filter) '(:open t))) (should (equal (plist-get spec :linear-view-id) "v-1"))))))) +;;; account guard on publish and delete -- no Linear call on mismatch (Phase 5) + +(ert-deftest test-pearl-publish-local-view-refuses-cross-account () + "Publishing a cross-account local view errors before any customViewCreate/Update." + (let ((pearl-local-views '(("v" :filter (:open t) :account "acct-b"))) + (pearl-accounts '(("acct-a" . x) ("acct-b" . y))) + (created nil)) + (cl-letf (((symbol-function 'pearl--current-account-context) + (lambda () '(:name "acct-a"))) + ((symbol-function 'pearl--require-account-context) (lambda (&rest _) nil)) + ((symbol-function 'pearl--customview-create-async) + (lambda (&rest _) (setq created t))) + ((symbol-function 'pearl--customview-update-async) + (lambda (&rest _) (setq created t)))) + (should-error (pearl-publish-local-view "v") :type 'user-error) + (should-not created)))) + +(ert-deftest test-pearl-delete-local-view-refuses-cross-account-no-linear-call () + "Deleting a cross-account local view errors before the confirm or customViewDelete." + (let ((pearl-local-views '(("v" :filter (:open t) + :linear-view-id "vid" :account "acct-b"))) + (pearl-accounts '(("acct-a" . x))) + (deleted nil) (confirmed nil)) + (cl-letf (((symbol-function 'pearl--current-account-context) + (lambda () '(:name "acct-a"))) + ((symbol-function 'pearl--customview-delete-async) + (lambda (&rest _) (setq deleted t))) + ((symbol-function 'yes-or-no-p) + (lambda (&rest _) (setq confirmed t) t))) + (should-error (pearl-delete-local-view "v") :type 'user-error) + (should-not deleted) + (should-not confirmed)))) + (provide 'test-pearl-local-views) ;;; test-pearl-local-views.el ends here |
