From ffc9707790a3dff195bd827c17039faf0dcf44b0 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 4 Apr 2026 14:11:48 -0500 Subject: Show modeline icon immediately on chime-mode enable Previously chime-modeline-string was nil until the first async check completed (~10-15 seconds after startup). Now the icon appears instantly with a "waiting for first event check" tooltip. On validation or async failure, the icon stays visible and the tooltip updates to show the error state instead of going blank. --- tests/test-integration-chime-mode.el | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'tests') diff --git a/tests/test-integration-chime-mode.el b/tests/test-integration-chime-mode.el index 0f19330..69ad176 100644 --- a/tests/test-integration-chime-mode.el +++ b/tests/test-integration-chime-mode.el @@ -65,5 +65,50 @@ and set it to nil." ;; Timer should be nil after disable (should (null chime--timer)))) +(ert-deftest test-integration-chime-mode-enable-sets-modeline-string-immediately () + "Enabling chime-mode should set chime-modeline-string to a non-nil value +immediately, before the first async check completes." + (let ((chime-enable-modeline t) + (chime-modeline-lookahead-minutes 120) + (chime-modeline-no-events-text " ⏰")) + (unwind-protect + (progn + (chime-mode 1) + ;; Should be non-nil right away, not after startup delay + (should chime-modeline-string) + (should (stringp chime-modeline-string))) + (chime-mode -1)))) + +(ert-deftest test-integration-chime-mode-enable-immediate-string-has-tooltip () + "The immediate modeline string should have a help-echo tooltip." + (let ((chime-enable-modeline t) + (chime-modeline-lookahead-minutes 120) + (chime-modeline-no-events-text " ⏰")) + (unwind-protect + (progn + (chime-mode 1) + (should (get-text-property 0 'help-echo chime-modeline-string))) + (chime-mode -1)))) + +(ert-deftest test-integration-chime-mode-validation-failure-keeps-icon-visible () + "When validation fails, modeline should still show the icon with error info +in the tooltip, not go blank." + (let ((chime-enable-modeline t) + (chime-modeline-lookahead-minutes 120) + (chime-modeline-no-events-text " ⏰") + (org-agenda-files nil) + (chime--validation-done nil) + (chime--validation-retry-count 0) + (chime-validation-max-retries 0)) + (unwind-protect + (progn + (chime-mode 1) + ;; Force a check that will fail validation + (chime-check) + ;; Icon should still be visible, not nil + (should chime-modeline-string) + (should (stringp chime-modeline-string))) + (chime-mode -1)))) + (provide 'test-integration-chime-mode) ;;; test-integration-chime-mode.el ends here -- cgit v1.2.3