From fac5c2973b4d6e028c203a4bad0ba104178e1349 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 2 Jun 2026 20:27:38 -0500 Subject: fix(priority): error on an out-of-range cookie instead of silent None pearl--priority-number-at-point matched only [#A-D], so a cookie outside that range (a hand-typed [#E], say) didn't match and fell through to 0 (None). On save that silently pushed None to Linear and cleared the issue's priority, with no error and no sign anything was wrong. It now matches any [#A-Z] and, when the letter isn't A-D, signals a user-error naming the valid range (A=Urgent, B=High, C=Medium, D=Low, or no cookie for None), so a stray cookie surfaces before any push rather than quietly wiping the priority. Linear has exactly five priorities, so A-D plus no-cookie is the whole range. --- tests/test-pearl-bugfixes.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/test-pearl-bugfixes.el b/tests/test-pearl-bugfixes.el index c1348f1..3d8d53e 100644 --- a/tests/test-pearl-bugfixes.el +++ b/tests/test-pearl-bugfixes.el @@ -150,5 +150,28 @@ (should-error (pearl-run-local-view "bad") :type 'user-error) (should-not fetched)))) +;;; Bug: an out-of-range priority cookie ([#E]) silently downgraded to None + +(ert-deftest test-pearl-priority-number-in-range () + "A/B/C/D cookies map to Linear 1-4; a heading with no cookie is 0 (None)." + (test-pearl-bug--in-org "* TODO [#A] Urgent issue\n" + (should (= 1 (pearl--priority-number-at-point)))) + (test-pearl-bug--in-org "* TODO [#C] Medium issue\n" + (should (= 3 (pearl--priority-number-at-point)))) + (test-pearl-bug--in-org "* TODO [#D] Low issue\n" + (should (= 4 (pearl--priority-number-at-point)))) + (test-pearl-bug--in-org "* TODO No cookie issue\n" + (should (= 0 (pearl--priority-number-at-point))))) + +(ert-deftest test-pearl-priority-number-out-of-range-errors () + "An out-of-range cookie ([#E]) signals a user-error, not a silent None. +The old reader matched only [#A-D], so [#E] fell through to 0 and a save +silently pushed None, clearing the issue's Linear priority. Now it refuses +at read time so the bad cookie surfaces before any push." + (test-pearl-bug--in-org "* TODO [#E] Bogus priority\n" + (should-error (pearl--priority-number-at-point) :type 'user-error)) + (test-pearl-bug--in-org "* TODO [#Z] Also bogus\n" + (should-error (pearl--priority-number-at-point) :type 'user-error))) + (provide 'test-pearl-bugfixes) ;;; test-pearl-bugfixes.el ends here -- cgit v1.2.3