diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-integration-acceptance.el | 18 | ||||
| -rw-r--r-- | tests/test-pearl-accounts.el | 16 | ||||
| -rw-r--r-- | tests/test-pearl-adhoc.el | 54 | ||||
| -rw-r--r-- | tests/test-pearl-bugfixes.el | 12 | ||||
| -rw-r--r-- | tests/test-pearl-favorites.el | 8 | ||||
| -rw-r--r-- | tests/test-pearl-keymap.el | 10 | ||||
| -rw-r--r-- | tests/test-pearl-menu.el | 8 | ||||
| -rw-r--r-- | tests/test-pearl-naming.el | 74 | ||||
| -rw-r--r-- | tests/test-pearl-resolve.el | 2 | ||||
| -rw-r--r-- | tests/test-pearl-saved-query-sync.el | 110 | ||||
| -rw-r--r-- | tests/test-pearl-saved.el | 16 | ||||
| -rw-r--r-- | tests/test-pearl-views.el | 4 |
12 files changed, 203 insertions, 129 deletions
diff --git a/tests/test-integration-acceptance.el b/tests/test-integration-acceptance.el index 523d1b3..0e1c64d 100644 --- a/tests/test-integration-acceptance.el +++ b/tests/test-integration-acceptance.el @@ -29,7 +29,7 @@ ;; and a field-setter command — runs for real against a temp active file. ;; ;; Components integrated (all real unless noted): -;; - pearl-run-saved-query -> --build-issue-filter -> --query-issues-async +;; - pearl-run-local-view -> --build-issue-filter -> --query-issues-async ;; - --query-issues-async -> --graphql-request-async (MOCKED at the wire) ;; - --render-query-result -> --normalize-issue -> --sort-issues ;; - --update-org-from-issues (real disk write + buffer surface, surface MOCKED) @@ -102,7 +102,7 @@ because the description-update mutation contains both `IssueDescription' and (pearl-org-file-path tmp) (pearl-api-key "test-key") (pearl-fold-after-update nil) - (pearl-saved-queries + (pearl-local-views '(("Open" :filter (:open t) :sort priority :order asc) ("Bugs" :filter (:labels ("bug") :open t)))) (test-integration--ops nil)) @@ -124,9 +124,9 @@ because the description-update mutation contains both `IssueDescription' and (ignore-errors (delete-file tmp)))))) (ert-deftest test-integration-run-saved-query-renders-active-file () - "A saved query fetches, renders to the active file with a source header, and surfaces a buffer." + "A local view fetches, renders to the active file with a source header, and surfaces a buffer." (test-integration--with-env - (pearl-run-saved-query "Open") + (pearl-run-local-view "Open") (let ((buf (find-buffer-visiting pearl-org-file-path))) (should (buffer-live-p buf)) (with-current-buffer buf @@ -146,7 +146,7 @@ because the description-update mutation contains both `IssueDescription' and (ert-deftest test-integration-refresh-reruns-recorded-source () "Refresh reads the recorded source from the buffer and merges a re-fetch in place." (test-integration--with-env - (pearl-run-saved-query "Open") + (pearl-run-local-view "Open") (with-current-buffer (find-buffer-visiting pearl-org-file-path) (setq test-integration--ops nil) (pearl-refresh-current-view) @@ -159,22 +159,22 @@ because the description-update mutation contains both `IssueDescription' and (should (re-search-forward "Second issue" nil t))))) (ert-deftest test-integration-switch-source-protects-dirty-buffer () - "Switching to a different saved query with unsaved edits does not overwrite them." + "Switching to a different local view with unsaved edits does not overwrite them." (test-integration--with-env - (pearl-run-saved-query "Open") + (pearl-run-local-view "Open") (with-current-buffer (find-buffer-visiting pearl-org-file-path) (goto-char (point-max)) (insert "\nUNSAVED LOCAL EDIT\n") (should (buffer-modified-p)) ;; the switch must defer rather than clobber the dirty buffer - (pearl-run-saved-query "Bugs") + (pearl-run-local-view "Bugs") (goto-char (point-min)) (should (re-search-forward "UNSAVED LOCAL EDIT" nil t))))) (ert-deftest test-integration-issue-commands-from-subtree () "From inside a rendered issue subtree: syncing an edited body pushes, adding a comment inserts it, and setting priority drives a field update — all through the real request path." (test-integration--with-env - (pearl-run-saved-query "Open") + (pearl-run-local-view "Open") (with-current-buffer (find-buffer-visiting pearl-org-file-path) ;; --- sync a description edit (remote unchanged -> clean push) --- (goto-char (point-min)) diff --git a/tests/test-pearl-accounts.el b/tests/test-pearl-accounts.el index f8bc06b..2a4cb69 100644 --- a/tests/test-pearl-accounts.el +++ b/tests/test-pearl-accounts.el @@ -403,35 +403,35 @@ fetching the active account's issues into it would cross workspaces." ;;; Saved-query :account guard (ert-deftest test-pearl-run-saved-query-refuses-other-account-before-network () - "A saved query tagged for another account refuses before any compilation or fetch." + "A local view tagged for another account refuses before any compilation or fetch." (let ((pearl-accounts '(("work" :api-key-source (:literal "kw") :org-file "/tmp/w.org") ("home" :api-key-source (:literal "kh") :org-file "/tmp/h.org"))) (pearl-active-account "home") (pearl-default-account "home") - (pearl-saved-queries '(("Work bugs" :account "work" :filter (:assignee :me)))) + (pearl-local-views '(("Work bugs" :account "work" :filter (:assignee :me)))) (api-called nil)) (cl-letf (((symbol-function 'request) (lambda (&rest _) (setq api-called t)))) - (let ((err (should-error (pearl-run-saved-query "Work bugs") :type 'error))) + (let ((err (should-error (pearl-run-local-view "Work bugs") :type 'error))) (should (string-match-p "work" (error-message-string err)))) (should-not api-called)))) (ert-deftest test-pearl-run-saved-query-account-match-proceeds-to-fetch () - "A saved query tagged for the active account compiles and dispatches." + "A local view tagged for the active account compiles and dispatches." (let ((pearl-accounts '(("work" :api-key-source (:literal "kw") :org-file "/tmp/w.org"))) (pearl-active-account "work") (pearl-default-account "work") - (pearl-saved-queries '(("Work bugs" :account "work" :filter (:assignee :me)))) + (pearl-local-views '(("Work bugs" :account "work" :filter (:assignee :me)))) (api-called nil)) (cl-letf (((symbol-function 'request) (lambda (&rest _) (setq api-called t)))) - (pearl-run-saved-query "Work bugs") + (pearl-run-local-view "Work bugs") (should api-called)))) (ert-deftest test-pearl-run-saved-query-account-tag-ignored-in-legacy () "With no accounts configured, an `:account' tag is inert (shared query)." (let ((pearl-accounts nil) (pearl-active-account nil) (pearl-default-account nil) (pearl-api-key "lin_legacy") - (pearl-saved-queries '(("Work bugs" :account "work" :filter (:assignee :me)))) + (pearl-local-views '(("Work bugs" :account "work" :filter (:assignee :me)))) (api-called nil)) (cl-letf (((symbol-function 'request) (lambda (&rest _) (setq api-called t)))) - (pearl-run-saved-query "Work bugs") + (pearl-run-local-view "Work bugs") (should api-called)))) ;;; pearl-load-api-key-from-env legacy-only diff --git a/tests/test-pearl-adhoc.el b/tests/test-pearl-adhoc.el index 558578a..4959840 100644 --- a/tests/test-pearl-adhoc.el +++ b/tests/test-pearl-adhoc.el @@ -159,82 +159,82 @@ candidate list, so completion still works the way the framework expects." (ert-deftest test-pearl-save-query-adds-entry () "Saving a query adds it to the saved-queries variable." - (let ((pearl-saved-queries nil)) + (let ((pearl-local-views nil)) (cl-letf (((symbol-function 'customize-save-variable) (lambda (&rest _) nil))) (pearl--save-query "My filter" '(:open t :labels ("bug"))) - (let ((entry (assoc "My filter" pearl-saved-queries))) + (let ((entry (assoc "My filter" pearl-local-views))) (should entry) (should (equal '(:open t :labels ("bug")) (plist-get (cdr entry) :filter))))))) (ert-deftest test-pearl-save-query-replaces-same-name () "Saving under an existing name replaces that entry rather than duplicating." - (let ((pearl-saved-queries '(("Dup" :filter (:open t))))) + (let ((pearl-local-views '(("Dup" :filter (:open t))))) (cl-letf (((symbol-function 'customize-save-variable) (lambda (&rest _) nil))) (pearl--save-query "Dup" '(:priority 1)) - (should (= 1 (cl-count "Dup" pearl-saved-queries + (should (= 1 (cl-count "Dup" pearl-local-views :key #'car :test #'string=))) (should (equal '(:priority 1) - (plist-get (cdr (assoc "Dup" pearl-saved-queries)) :filter)))))) + (plist-get (cdr (assoc "Dup" pearl-local-views)) :filter)))))) -;;; pearl-delete-saved-query +;;; pearl-delete-local-view (ert-deftest test-pearl-delete-saved-query-removes-entry-on-yes () "Confirming the prompt removes the named entry and persists." - (let ((pearl-saved-queries '(("Keep" :filter (:open t)) + (let ((pearl-local-views '(("Keep" :filter (:open t)) ("Drop" :filter (:priority 1)))) (persisted nil)) (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) t)) ((symbol-function 'customize-save-variable) (lambda (&rest _) (setq persisted t)))) - (pearl-delete-saved-query "Drop") - (should-not (assoc "Drop" pearl-saved-queries)) - (should (assoc "Keep" pearl-saved-queries)) + (pearl-delete-local-view "Drop") + (should-not (assoc "Drop" pearl-local-views)) + (should (assoc "Keep" pearl-local-views)) (should persisted)))) (ert-deftest test-pearl-delete-saved-query-no-at-confirm-keeps-entry () "Declining the confirm prompt leaves the entry in place and does not persist." - (let ((pearl-saved-queries '(("Keep" :filter (:open t)))) + (let ((pearl-local-views '(("Keep" :filter (:open t)))) (persisted nil)) (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) nil)) ((symbol-function 'customize-save-variable) (lambda (&rest _) (setq persisted t)))) - (pearl-delete-saved-query "Keep") - (should (assoc "Keep" pearl-saved-queries)) + (pearl-delete-local-view "Keep") + (should (assoc "Keep" pearl-local-views)) (should-not persisted)))) (ert-deftest test-pearl-delete-saved-query-sentinel-cancels () "Picking the `pearl--filter-cancel' sentinel cancels without touching anything." - (let ((pearl-saved-queries '(("Keep" :filter (:open t)))) + (let ((pearl-local-views '(("Keep" :filter (:open t)))) (confirmed nil)) (cl-letf (((symbol-function 'yes-or-no-p) (lambda (&rest _) (setq confirmed t) t)) ((symbol-function 'customize-save-variable) (lambda (&rest _) nil))) - (pearl-delete-saved-query pearl--filter-cancel) - (should (assoc "Keep" pearl-saved-queries)) + (pearl-delete-local-view pearl--filter-cancel) + (should (assoc "Keep" pearl-local-views)) (should-not confirmed)))) (ert-deftest test-pearl-delete-saved-query-unknown-name-errors () "An unknown name (e.g. typed past completion) signals a user-error." - (let ((pearl-saved-queries '(("Keep" :filter (:open t))))) - (should-error (pearl-delete-saved-query "Nope") :type 'user-error))) + (let ((pearl-local-views '(("Keep" :filter (:open t))))) + (should-error (pearl-delete-local-view "Nope") :type 'user-error))) (ert-deftest test-pearl-delete-saved-query-empty-list-errors-on-interactive () - "Called interactively with no saved queries, the command errors cleanly + "Called interactively with no local views, the command errors cleanly rather than offering an empty picker." - (let ((pearl-saved-queries nil)) - (should-error (call-interactively #'pearl-delete-saved-query) + (let ((pearl-local-views nil)) + (should-error (call-interactively #'pearl-delete-local-view) :type 'user-error))) -;;; pearl-run-saved-query sentinel cancel +;;; pearl-run-local-view sentinel cancel (ert-deftest test-pearl-run-saved-query-sentinel-cancels () "Picking the `pearl--filter-cancel' sentinel cancels the run without fetching." (let ((fetched nil) - (pearl-saved-queries '(("Open" :filter (:open t))))) + (pearl-local-views '(("Open" :filter (:open t))))) (cl-letf (((symbol-function 'pearl--query-issues-async) (lambda (&rest _) (setq fetched t)))) - (should-error (pearl-run-saved-query pearl--filter-cancel) :type 'user-error) + (should-error (pearl-run-local-view pearl--filter-cancel) :type 'user-error) (should-not fetched)))) ;;; pearl-list-issues-filtered @@ -255,8 +255,8 @@ rather than offering an empty picker." (should (equal '(:assignee :me :open t) (plist-get rendered-source :filter)))))) (ert-deftest test-pearl-list-issues-filtered-saves-when-named () - "Passing a save name persists the ad-hoc filter as a saved query." - (let ((pearl-saved-queries nil)) + "Passing a save name persists the ad-hoc filter as a local view." + (let ((pearl-local-views nil)) (cl-letf (((symbol-function 'pearl--build-issue-filter) (lambda (_p) nil)) ((symbol-function 'pearl--query-issues-async) (lambda (_f cb &optional _o) @@ -264,7 +264,7 @@ rather than offering an empty picker." ((symbol-function 'pearl--render-query-result) (lambda (&rest _) nil)) ((symbol-function 'customize-save-variable) (lambda (&rest _) nil))) (pearl-list-issues-filtered '(:open t) "Saved adhoc") - (should (assoc "Saved adhoc" pearl-saved-queries))))) + (should (assoc "Saved adhoc" pearl-local-views))))) (provide 'test-pearl-adhoc) ;;; test-pearl-adhoc.el ends here diff --git a/tests/test-pearl-bugfixes.el b/tests/test-pearl-bugfixes.el index 9fe2518..c1348f1 100644 --- a/tests/test-pearl-bugfixes.el +++ b/tests/test-pearl-bugfixes.el @@ -133,21 +133,21 @@ ;;; Bug: saved/ad-hoc query filters bypass validation (ert-deftest test-pearl-run-saved-query-validates-before-fetch () - "A saved query with an unknown filter key errors before any fetch." - (let ((pearl-saved-queries '(("bad" :filter (:bogus-key "x")))) + "A local view with an unknown filter key errors before any fetch." + (let ((pearl-local-views '(("bad" :filter (:bogus-key "x")))) (fetched nil)) (cl-letf (((symbol-function 'pearl--query-issues-async) (lambda (&rest _) (setq fetched t)))) - (should-error (pearl-run-saved-query "bad") :type 'user-error) + (should-error (pearl-run-local-view "bad") :type 'user-error) (should-not fetched)))) (ert-deftest test-pearl-run-saved-query-validates-bad-priority () - "A saved query with an out-of-range priority errors before any fetch." - (let ((pearl-saved-queries '(("bad" :filter (:priority 9)))) + "A local view with an out-of-range priority errors before any fetch." + (let ((pearl-local-views '(("bad" :filter (:priority 9)))) (fetched nil)) (cl-letf (((symbol-function 'pearl--query-issues-async) (lambda (&rest _) (setq fetched t)))) - (should-error (pearl-run-saved-query "bad") :type 'user-error) + (should-error (pearl-run-local-view "bad") :type 'user-error) (should-not fetched)))) (provide 'test-pearl-bugfixes) diff --git a/tests/test-pearl-favorites.el b/tests/test-pearl-favorites.el index 70507d7..b6235c7 100644 --- a/tests/test-pearl-favorites.el +++ b/tests/test-pearl-favorites.el @@ -177,7 +177,7 @@ For an issue node, IDENTIFIER fills the issue's user-facing key." ;;; pick-source candidate builder (ert-deftest test-pearl-pick-source-candidates-orders-favorites-by-sort-order () - "Favorites are listed first in ascending :sort-order, then saved queries alphabetically." + "Favorites are listed first in ascending :sort-order, then local views alphabetically." (let* ((favs (list (test-pearl-fav--norm 'project "p1" "Bravo") ; sort-order 0.0 (let ((f (test-pearl-fav--norm 'view "v1" "Alpha"))) (plist-put f :sort-order -1.0)))) ; lower, comes first @@ -210,10 +210,10 @@ For an issue node, IDENTIFIER fills the issue's user-facing key." (should (= 2 (length (delete-dups (copy-sequence labels))))))) (ert-deftest test-pearl-pick-source-candidates-empty () - "No favorites and no saved queries yields no candidates." + "No favorites and no local views yields no candidates." (should (null (pearl--pick-source-candidates nil nil)))) -;;; pick-source candidate builder -- synced saved queries (view-sync Phase 4) +;;; pick-source candidate builder -- synced local views (view-sync Phase 4) (ert-deftest test-pearl-pick-source-candidates-synced-saved-query-team-scope () "A team-scoped synced entry renders as `[saved \\u2192 <TeamName>] <Name>'." @@ -285,7 +285,7 @@ source plist; the open-in-Linear command errors cleanly until the user re-syncs. (should-not (plist-get source :url)))) (ert-deftest test-pearl-pick-source-candidates-local-only-saved-query-keeps-saved-label () - "A saved query without :linear-view-id still renders as `[saved] <Name>' and dispatches as filter." + "A local view without :linear-view-id still renders as `[saved] <Name>' and dispatches as filter." (let* ((saved '(("Local" :filter (:open t)))) (cands (pearl--pick-source-candidates nil saved '())) (source (cdr (assoc "[saved] Local" cands)))) diff --git a/tests/test-pearl-keymap.el b/tests/test-pearl-keymap.el index 1ae0d3d..f80a002 100644 --- a/tests/test-pearl-keymap.el +++ b/tests/test-pearl-keymap.el @@ -71,11 +71,11 @@ The lowercase `c' is no longer a direct command -- it is the create prefix." (should (eq 'pearl-list-issues (lookup-key pearl-prefix-map (kbd "f o")))) (should (eq 'pearl-list-issues-by-project (lookup-key pearl-prefix-map (kbd "f p")))) (should (eq 'pearl-list-issues-filtered (lookup-key pearl-prefix-map (kbd "f f")))) - (should (eq 'pearl-run-view (lookup-key pearl-prefix-map (kbd "f v")))) - (should (eq 'pearl-run-saved-query (lookup-key pearl-prefix-map (kbd "f q")))) - (should (eq 'pearl-sync-saved-query-to-linear + (should (eq 'pearl-run-linear-view (lookup-key pearl-prefix-map (kbd "f v")))) + (should (eq 'pearl-run-local-view (lookup-key pearl-prefix-map (kbd "f q")))) + (should (eq 'pearl-publish-local-view (lookup-key pearl-prefix-map (kbd "f S")))) - (should (eq 'pearl-publish-current-source + (should (eq 'pearl-publish-current-view (lookup-key pearl-prefix-map (kbd "f P"))))) (ert-deftest test-pearl-prefix-map-edit-group () @@ -94,7 +94,7 @@ The lowercase `c' is no longer a direct command -- it is the create prefix." (should (eq 'pearl-create-comment (lookup-key pearl-prefix-map (kbd "c c")))) (should (eq 'pearl-delete-current-issue (lookup-key pearl-prefix-map (kbd "k t")))) (should (eq 'pearl-delete-current-comment (lookup-key pearl-prefix-map (kbd "k c")))) - (should (eq 'pearl-delete-saved-query (lookup-key pearl-prefix-map (kbd "k q"))))) + (should (eq 'pearl-delete-local-view (lookup-key pearl-prefix-map (kbd "k q"))))) (ert-deftest test-pearl-prefix-map-open-and-copy-groups () "The open group resolves the two open actions; copy resolves copy-url." diff --git a/tests/test-pearl-menu.el b/tests/test-pearl-menu.el index e2ea550..9c97384 100644 --- a/tests/test-pearl-menu.el +++ b/tests/test-pearl-menu.el @@ -60,10 +60,10 @@ menu entry that still points at it fails here." "A representative slice of the command surface is reachable from the menu." (let ((cmds (mapcar #'cdr (test-pearl-menu--pairs)))) (dolist (expected '(pearl-list-issues - pearl-run-view - pearl-run-saved-query - pearl-sync-saved-query-to-linear - pearl-publish-current-source + pearl-run-linear-view + pearl-run-local-view + pearl-publish-local-view + pearl-publish-current-view pearl-save-issue pearl-save-all pearl-edit-state diff --git a/tests/test-pearl-naming.el b/tests/test-pearl-naming.el new file mode 100644 index 0000000..41077e9 --- /dev/null +++ b/tests/test-pearl-naming.el @@ -0,0 +1,74 @@ +;;; test-pearl-naming.el --- Naming-regression tests for local/Linear views -*- 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: + +;; The local/Linear views spec renames Pearl's "saved query" surface to +;; local-view vocabulary with NO obsolete aliases (Pearl has no users). +;; These tests enforce the contract: the new public symbols exist, the old +;; ones are gone (not aliased), and no user-facing command exposes "query". + +;;; Code: + +(require 'test-bootstrap (expand-file-name "test-bootstrap.el")) + +(defconst test-pearl-naming--new-commands + '(pearl-run-local-view + pearl-delete-local-view + pearl-publish-local-view + pearl-publish-current-view + pearl-run-linear-view) + "Public commands the rename introduces.") + +(defconst test-pearl-naming--old-symbols + '(pearl-saved-queries + pearl-run-saved-query + pearl-delete-saved-query + pearl-sync-saved-query-to-linear + pearl-run-view + pearl-publish-current-source) + "Old user-facing symbols that must be gone (renamed, not aliased).") + +(ert-deftest test-pearl-naming-new-defcustom-bound () + "`pearl-local-views' is the renamed local-view store." + (should (boundp 'pearl-local-views))) + +(ert-deftest test-pearl-naming-new-commands-exist () + "Every renamed public command is defined and interactive." + (dolist (cmd test-pearl-naming--new-commands) + (should (fboundp cmd)) + (should (commandp cmd)))) + +(ert-deftest test-pearl-naming-old-symbols-gone () + "The old saved-query symbols are not bound -- direct rename, no aliases." + (dolist (sym test-pearl-naming--old-symbols) + (should-not (fboundp sym)) + (should-not (boundp sym)))) + +(ert-deftest test-pearl-naming-no-user-facing-query-in-docstrings () + "Public local-view commands and the defcustom carry no \"saved query\" text. +\"query\" alone survives only in internal GraphQL helpers, not here." + (dolist (sym (cons 'pearl-local-views test-pearl-naming--new-commands)) + (let ((doc (or (documentation-property sym 'variable-documentation) + (ignore-errors (documentation sym)) + ""))) + (should-not (string-match-p "saved quer" doc))))) + +(provide 'test-pearl-naming) +;;; test-pearl-naming.el ends here diff --git a/tests/test-pearl-resolve.el b/tests/test-pearl-resolve.el index 0812f94..aefe27a 100644 --- a/tests/test-pearl-resolve.el +++ b/tests/test-pearl-resolve.el @@ -21,7 +21,7 @@ ;; Tests for the per-team cached collection fetch (`--team-collection') and ;; the name->id resolver (`--resolve-team-id'), which back the field commands, -;; the ad-hoc filter, and saved queries. The HTTP boundary is stubbed; the +;; the ad-hoc filter, and local views. The HTTP boundary is stubbed; the ;; cache is reset around each test. ;;; Code: diff --git a/tests/test-pearl-saved-query-sync.el b/tests/test-pearl-saved-query-sync.el index e237108..534993e 100644 --- a/tests/test-pearl-saved-query-sync.el +++ b/tests/test-pearl-saved-query-sync.el @@ -1,4 +1,4 @@ -;;; test-pearl-saved-query-sync.el --- Tests for syncing saved queries to Linear views -*- lexical-binding: t; -*- +;;; test-pearl-saved-query-sync.el --- Tests for syncing local views to Linear views -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Craig Jennings @@ -19,7 +19,7 @@ ;;; Commentary: -;; Tests for `pearl-sync-saved-query-to-linear' and its helpers +;; Tests for `pearl-publish-local-view' and its helpers ;; (`pearl--sync-scope-candidates', `pearl--find-view-by-name-in-scope', ;; `pearl--customview-create-async', `pearl--customview-update-async', ;; `pearl--save-query-mark-synced', `pearl--sync-record-or-orphan-error'). @@ -254,11 +254,11 @@ label, plist team-id nil + team-name \"Personal\" + shared nil." (ert-deftest test-pearl-save-query-mark-synced-adds-the-four-keys () "After mark-synced, the entry carries `:linear-view-id', `-team-id', `-shared', `-synced-at'." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t)))))) (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil))) (pearl--save-query-mark-synced "Q" "team-uuid" t "view-uuid")) - (let ((spec (cdr (assoc "Q" pearl-saved-queries)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) (should (equal "view-uuid" (plist-get spec :linear-view-id))) (should (equal "team-uuid" (plist-get spec :linear-view-team-id))) (should (eq t (plist-get spec :linear-view-shared))) @@ -268,39 +268,39 @@ label, plist team-id nil + team-name \"Personal\" + shared nil." (ert-deftest test-pearl-save-query-mark-synced-preserves-sort-and-order () "Mark-synced doesn't drop `:sort' or `:order' from the entry." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :sort updated :order desc))))) (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil))) (pearl--save-query-mark-synced "Q" nil nil "view-uuid")) - (let ((spec (cdr (assoc "Q" pearl-saved-queries)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) (should (eq 'updated (plist-get spec :sort))) (should (eq 'desc (plist-get spec :order)))))) (ert-deftest test-pearl-save-query-mark-synced-personal-nil-team () "Personal scope persists `:linear-view-team-id' as nil and `:linear-view-shared' nil." - (let ((pearl-saved-queries + (let ((pearl-local-views (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")) - (let ((spec (cdr (assoc "Q" pearl-saved-queries)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) (should (null (plist-get spec :linear-view-team-id))) (should (null (plist-get spec :linear-view-shared)))))) (ert-deftest test-pearl-save-query-mark-synced-unknown-name-signals-user-error () "Mark-synced on a name that doesn't exist signals a `user-error'." - (let ((pearl-saved-queries '())) + (let ((pearl-local-views '())) (should-error (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 + (let ((pearl-local-views (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)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) (should (equal "https://linear.app/ws/view/abc" (plist-get spec :linear-view-url)))))) @@ -308,7 +308,7 @@ label, plist team-id nil + team-name \"Personal\" + shared nil." "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 + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "old-id" :linear-view-team-id nil @@ -317,7 +317,7 @@ URL the create path already wrote." (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)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) (should (equal "https://linear.app/ws/view/old" (plist-get spec :linear-view-url)))))) @@ -327,7 +327,7 @@ The earlier implementation rebuilt the spec from a fixed key set and silently dropped anything outside it. Copy-then-plist-put preserves arbitrary keys so a future schema field or user annotation isn't erased on every re-sync." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :sort updated :order desc @@ -335,7 +335,7 @@ erased on every re-sync." :user-tag "experimental"))))) (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil))) (pearl--save-query-mark-synced "Q" "team-uuid" t "view-uuid" "https://x")) - (let ((spec (cdr (assoc "Q" pearl-saved-queries)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) ;; Original keys survive. (should (equal '(:open t) (plist-get spec :filter))) (should (eq 'updated (plist-get spec :sort))) @@ -351,7 +351,7 @@ erased on every re-sync." (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 + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "OLD-id" :linear-view-team-id "OLD-team" @@ -359,7 +359,7 @@ erased on every re-sync." :linear-view-synced-at "1970-01-01T00:00:00Z"))))) (cl-letf (((symbol-function 'customize-save-variable) (lambda (_ _) nil))) (pearl--save-query-mark-synced "Q" "NEW-team" t "NEW-id")) - (let ((spec (cdr (assoc "Q" pearl-saved-queries)))) + (let ((spec (cdr (assoc "Q" pearl-local-views)))) (should (equal "NEW-id" (plist-get spec :linear-view-id))) (should (equal "NEW-team" (plist-get spec :linear-view-team-id))) (should (eq t (plist-get spec :linear-view-shared))) @@ -445,7 +445,7 @@ erased on every re-sync." "Re-sync of an entry with `:linear-view-shared :json-false' must NOT flip it shared. `:json-false' is truthy in Elisp, so a stored `:json-false' would slip past `(if shared t :json-false)' in the encoder and silently make the view team-shared." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "view-id" :linear-view-team-id nil @@ -465,18 +465,18 @@ erased on every re-sync." (funcall cb (list :success t :view '((id . "view-id") (shared . :json-false))))))) - (pearl-sync-saved-query-to-linear "Q") + (pearl-publish-local-view "Q") (let ((shared-value (cdr (assoc "shared" captured-input)))) (should (eq :json-false shared-value)))))) -;;; pearl-sync-saved-query-to-linear — empty filter refusal +;;; pearl-publish-local-view — empty filter refusal (ert-deftest test-pearl-sync-empty-filter-refuses-before-scope-prompt () - "A first-time-sync saved query whose filter compiles to nil signals a clear + "A first-time-sync local view whose filter compiles to nil signals a clear user-error before any scope prompt fires. Without the guard, the sync would pass filterData=null to Linear, which rejects with an opaque error after the user has already clicked through the scope picker." - (let ((pearl-saved-queries (copy-tree '(("EmptyFilter" :filter nil)))) + (let ((pearl-local-views (copy-tree '(("EmptyFilter" :filter nil)))) (scope-prompt-fired nil) (api-called nil)) (cl-letf (((symbol-function 'pearl--sync-saved-query-pick-scope) @@ -488,7 +488,7 @@ user has already clicked through the scope picker." (list :team-id nil :team-name "Personal" :shared nil)))) ((symbol-function 'pearl--customview-create-async) (lambda (&rest _) (setq api-called t)))) - (should-error (pearl-sync-saved-query-to-linear "EmptyFilter") + (should-error (pearl-publish-local-view "EmptyFilter") :type 'user-error) (should-not scope-prompt-fired) (should-not api-called)))) @@ -498,7 +498,7 @@ user has already clicked through the scope picker." edited down to nil takes the same empty-filter guard, refusing without calling customViewUpdate. Guards against a future refactor accidentally hoisting the guard into the create-only branch." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("EmptyFilter" :filter nil :linear-view-id "existing-view-uuid" :linear-view-team-id nil @@ -506,11 +506,11 @@ hoisting the guard into the create-only branch." (update-called nil)) (cl-letf (((symbol-function 'pearl--customview-update-async) (lambda (&rest _) (setq update-called t)))) - (should-error (pearl-sync-saved-query-to-linear "EmptyFilter") + (should-error (pearl-publish-local-view "EmptyFilter") :type 'user-error) (should-not update-called)))) -;;; pearl-publish-current-source +;;; pearl-publish-current-view (defmacro test-pearl-publish--in-buffer (source-form &rest body) "Run BODY in an org-mode temp buffer carrying SOURCE-FORM as #+LINEAR-SOURCE. @@ -526,50 +526,50 @@ SOURCE-FORM is the source plist (or nil for no source header)." (ert-deftest test-pearl-publish-current-source-no-source-header-errors () "A buffer with no #+LINEAR-SOURCE signals a clear user-error." (test-pearl-publish--in-buffer nil - (should-error (pearl-publish-current-source) :type 'user-error))) + (should-error (pearl-publish-current-view) :type 'user-error))) (ert-deftest test-pearl-publish-current-source-view-source-errors () "A view source signals user-error -- views are already on Linear." (test-pearl-publish--in-buffer '(:type view :name "Eng dashboard" :id "v1") - (should-error (pearl-publish-current-source) :type 'user-error))) + (should-error (pearl-publish-current-view) :type 'user-error))) (ert-deftest test-pearl-publish-current-source-transient-filter-no-name-errors () "A :type filter with no :name (transient ad-hoc) signals user-error." (test-pearl-publish--in-buffer '(:type filter :filter (:open t)) - (should-error (pearl-publish-current-source) :type 'user-error))) + (should-error (pearl-publish-current-view) :type 'user-error))) (ert-deftest test-pearl-publish-current-source-no-matching-saved-query-errors () - "A :type filter source whose name doesn't match any pearl-saved-queries entry errors." - (let ((pearl-saved-queries '(("Other" :filter (:open t))))) + "A :type filter source whose name doesn't match any pearl-local-views entry errors." + (let ((pearl-local-views '(("Other" :filter (:open t))))) (test-pearl-publish--in-buffer '(:type filter :name "Gone" :filter (:open t)) - (should-error (pearl-publish-current-source) :type 'user-error)))) + (should-error (pearl-publish-current-view) :type 'user-error)))) (ert-deftest test-pearl-publish-current-source-dispatches-to-sync-with-name () - "A :type filter source whose name matches dispatches to pearl-sync-saved-query-to-linear." - (let ((pearl-saved-queries '(("Mine" :filter (:open t)))) + "A :type filter source whose name matches dispatches to pearl-publish-local-view." + (let ((pearl-local-views '(("Mine" :filter (:open t)))) (sync-called-with nil)) - (cl-letf (((symbol-function 'pearl-sync-saved-query-to-linear) + (cl-letf (((symbol-function 'pearl-publish-local-view) (lambda (n) (setq sync-called-with n)))) (test-pearl-publish--in-buffer '(:type filter :name "Mine" :filter (:open t)) - (pearl-publish-current-source)) + (pearl-publish-current-view)) (should (equal "Mine" sync-called-with))))) (ert-deftest test-pearl-publish-current-source-empty-name-errors () "A :type filter source with an empty-string :name (degenerate) errors cleanly." (test-pearl-publish--in-buffer '(:type filter :name "" :filter (:open t)) - (should-error (pearl-publish-current-source) :type 'user-error))) + (should-error (pearl-publish-current-view) :type 'user-error))) (ert-deftest test-pearl-publish-current-source-whitespace-name-errors () "A :type filter source with a whitespace-only :name takes the no-name branch rather than falling through to the no-matching-saved-query branch with a visibly-blank name in the error message." - (let ((pearl-saved-queries '())) + (let ((pearl-local-views '())) (test-pearl-publish--in-buffer '(:type filter :name " " :filter (:open t)) - (let ((err (should-error (pearl-publish-current-source) + (let ((err (should-error (pearl-publish-current-view) :type 'user-error))) ;; The message should name the source-has-no-name reason, not the ;; no-matching-query reason. @@ -609,7 +609,7 @@ team-key lookups." (pearl--customview-delete-async "view-uuid" (lambda (r) (setq result r))) (should-not (plist-get result :success))))) -;;; pearl-delete-saved-query — synced-entry second-stage prompt +;;; pearl-delete-local-view — synced-entry second-stage prompt (defun test-pearl--make-yes-no-stub (answers) "Return a `yes-or-no-p' replacement that returns each ANSWERS in order. @@ -623,7 +623,7 @@ more prompts fire than answers were prepared for." (ert-deftest test-pearl-delete-saved-query-synced-yes-yes-calls-customview-delete () "Synced entry, both prompts yes: customViewDelete fires and the local entry is removed." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "view-uuid" :linear-view-team-id nil @@ -638,13 +638,13 @@ more prompts fire than answers were prepared for." (lambda (vid cb) (setq delete-called-with vid) (funcall cb (list :success t))))) - (pearl-delete-saved-query "Q") + (pearl-delete-local-view "Q") (should (equal "view-uuid" delete-called-with)) - (should-not (assoc "Q" pearl-saved-queries))))) + (should-not (assoc "Q" pearl-local-views))))) (ert-deftest test-pearl-delete-saved-query-synced-yes-no-unlinks-only () "Synced entry, first prompt yes second prompt no: local entry removed, customViewDelete not called." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "view-uuid")))) (delete-called nil)) @@ -655,13 +655,13 @@ more prompts fire than answers were prepared for." ((symbol-function 'message) (lambda (&rest _) nil)) ((symbol-function 'pearl--customview-delete-async) (lambda (_ _) (setq delete-called t)))) - (pearl-delete-saved-query "Q") + (pearl-delete-local-view "Q") (should-not delete-called) - (should-not (assoc "Q" pearl-saved-queries))))) + (should-not (assoc "Q" pearl-local-views))))) (ert-deftest test-pearl-delete-saved-query-synced-api-failure-then-delete-anyway () "Synced entry, customViewDelete fails, user accepts delete-anyway prompt: local removed, message names the orphan id." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "ORPHAN-UUID")))) (last-message nil)) @@ -675,8 +675,8 @@ more prompts fire than answers were prepared for." ((symbol-function 'pearl--customview-delete-async) (lambda (_ cb) (funcall cb (list :success nil :error "permission denied"))))) - (pearl-delete-saved-query "Q") - (should-not (assoc "Q" pearl-saved-queries)) + (pearl-delete-local-view "Q") + (should-not (assoc "Q" pearl-local-views)) (should (string-match-p "ORPHAN-UUID" last-message)) (should (string-match-p "orphan" last-message))))) @@ -685,7 +685,7 @@ more prompts fire than answers were prepared for." Verifies the API call actually fires (so the keep branch only runs when the delete-anyway prompt explicitly declines), guarding against a future refactor that silently routes to the unlink branch and skips the API call." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t) :linear-view-id "view-uuid")))) (delete-called-with nil)) @@ -698,13 +698,13 @@ that silently routes to the unlink branch and skips the API call." (lambda (vid cb) (setq delete-called-with vid) (funcall cb (list :success nil :error "permission denied"))))) - (pearl-delete-saved-query "Q") + (pearl-delete-local-view "Q") (should (equal "view-uuid" delete-called-with)) - (should (assoc "Q" pearl-saved-queries))))) + (should (assoc "Q" pearl-local-views))))) (ert-deftest test-pearl-delete-saved-query-local-only-entry-unchanged-behavior () "Local-only entry (no `:linear-view-id'): one yes-or-no-p, no second prompt, no API call." - (let ((pearl-saved-queries + (let ((pearl-local-views (copy-tree '(("Q" :filter (:open t))))) (delete-called nil) (prompt-count 0)) @@ -714,10 +714,10 @@ that silently routes to the unlink branch and skips the API call." ((symbol-function 'message) (lambda (&rest _) nil)) ((symbol-function 'pearl--customview-delete-async) (lambda (_ _) (setq delete-called t)))) - (pearl-delete-saved-query "Q") + (pearl-delete-local-view "Q") (should (= 1 prompt-count)) (should-not delete-called) - (should-not (assoc "Q" pearl-saved-queries))))) + (should-not (assoc "Q" pearl-local-views))))) (provide 'test-pearl-saved-query-sync) ;;; test-pearl-saved-query-sync.el ends here diff --git a/tests/test-pearl-saved.el b/tests/test-pearl-saved.el index 88bf468..d5f14e0 100644 --- a/tests/test-pearl-saved.el +++ b/tests/test-pearl-saved.el @@ -1,4 +1,4 @@ -;;; test-pearl-saved.el --- Tests for saved queries + sort -*- lexical-binding: t; -*- +;;; test-pearl-saved.el --- Tests for local views + sort -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Craig Jennings @@ -19,8 +19,8 @@ ;;; Commentary: -;; Tests for local saved queries and the sort layer: the client-side -;; `--sort-issues', the sort->orderBy mapping, and `pearl-run-saved-query' +;; Tests for local views and the sort layer: the client-side +;; `--sort-issues', the sort->orderBy mapping, and `pearl-run-local-view' ;; threading the filter, source, and order through. ;;; Code: @@ -69,8 +69,8 @@ ;;; run-saved-query (ert-deftest test-pearl-run-saved-query-threads-filter-and-source () - "Running a saved query compiles its filter and renders with a sorted source." - (let ((pearl-saved-queries + "Running a local view compiles its filter and renders with a sorted source." + (let ((pearl-local-views '(("My bugs" :filter (:labels ("bug") :open t) :sort priority :order asc))) (built nil) (rendered-source nil) (order nil)) (cl-letf (((symbol-function 'pearl--build-issue-filter) @@ -80,7 +80,7 @@ (funcall cb (pearl--make-query-result 'ok :issues nil)))) ((symbol-function 'pearl--render-query-result) (lambda (_result source) (setq rendered-source source)))) - (pearl-run-saved-query "My bugs") + (pearl-run-local-view "My bugs") (should (equal '(:labels ("bug") :open t) built)) (should (eq 'priority (plist-get rendered-source :sort))) (should (eq 'asc (plist-get rendered-source :order))) @@ -89,8 +89,8 @@ (ert-deftest test-pearl-run-saved-query-unknown-errors () "An unknown saved-query name signals a user error." - (let ((pearl-saved-queries '(("Known" :filter (:open t))))) - (should-error (pearl-run-saved-query "Missing") :type 'user-error))) + (let ((pearl-local-views '(("Known" :filter (:open t))))) + (should-error (pearl-run-local-view "Missing") :type 'user-error))) ;;; render applies the source sort diff --git a/tests/test-pearl-views.el b/tests/test-pearl-views.el index 2f2adfd..a750ae0 100644 --- a/tests/test-pearl-views.el +++ b/tests/test-pearl-views.el @@ -20,7 +20,7 @@ ;;; Commentary: ;; Tests for reading and running Linear Custom Views: the cached views list, -;; the server-side `--query-view-async' run, `pearl-run-view', the view +;; the server-side `--query-view-async' run, `pearl-run-linear-view', the view ;; branch of refresh, and opening the active view in the browser. HTTP is ;; stubbed. @@ -75,7 +75,7 @@ (funcall cb (pearl--make-query-result 'ok :issues nil)))) ((symbol-function 'pearl--render-query-result) (lambda (_result source) (setq rendered-source source)))) - (pearl-run-view "My View") + (pearl-run-linear-view "My View") (should (string= "v1" ran-id)) (should (eq 'view (plist-get rendered-source :type))) (should (string= "v1" (plist-get rendered-source :id))) |
