summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2025-11-08refactor: core: lazy-load xterm-color dependencyCraig Jennings
Move xterm-color from top-level require to on-demand loading within functions that actually use it. This simplifies user configuration by eliminating the need for separate xterm-color use-package declarations. Changes: - Replace top-level (require 'xterm-color) with declare-function - Add (require 'xterm-color) in wttrin--process-weather-content - Add (require 'xterm-color) in wttrin--display-weather - Update smoke test to check loadability vs. feature presence Benefits: - Simpler use-package config (no :after xterm-color needed) - xterm-color still auto-installed via Package-Requires on MELPA - Load time optimization (loads only when displaying weather)
2025-11-08test: smoke: reorganize test suite following quality-engineer.org naming ↵Craig Jennings
conventions - Create test-wttrin-smoke.el with 15 smoke tests for package sanity checks - Delete test-wttrin-integration.el (misnamed, contained smoke tests not integration tests) - Remove redundant functional tests already covered in dedicated unit test files - URL building: covered by test-wttrin--build-url.el (12 tests) - Cache operations: covered by test-wttrin--get-cached-or-fetch.el (11 tests) - Mode-line display: covered by test-wttrin--mode-line-map.el Smoke tests verify: - Package loads without errors - Dependencies available (xterm-color, url) - Public API exists and is interactive - Configuration variables defined - Keymaps exist and are valid - Package metadata correct (version, autoload cookies) Final test organization: 18 files, 162 tests (15 smoke + 142 unit + 5 integration)
2025-11-08refactor: Improve cache cleanup clarity and add input validationCraig Jennings
Cache Refactorings: - Extract wttrin--get-cache-entries-by-age helper function - Refactor wttrin--cleanup-cache-if-needed to use helper - Improves code clarity with descriptive variable names - Makes cache logic independently testable - Add 15 new tests (8 for helper, 7 for refactored cleanup) Input Validation: - Add range validation to wttrin-mode-line-startup-delay (1-10 seconds) - Prevents invalid values (0, negative, or excessive delays) - Uses restricted-sexp type for enforcement Test Fixes: - Fix debug function naming (use public wttrin-debug-clear-log) - Ensure wttrin-debug module loads in test setup - Make mocks synchronous for batch mode compatibility - Update test expectations to match actual debug messages - Fix startup delay test to check defcustom default value Linter/Compiler Fixes: - Add declare-function for wttrin--debug-log - Add defvar/declare-function in wttrin-debug.el - Fix docstring line lengths (wrap at 80 chars) - Fix checkdoc warnings (imperative mood, escaping) - Disambiguate temporary-file-directory reference All 165 tests passing. Clean byte-compile, package-lint, checkdoc.
2025-11-08refactor: make debug functions public (single hyphen naming)Craig Jennings
Renamed private debug functions to public API: - wttrin--debug-show-log → wttrin-debug-show-log - wttrin--debug-clear-log → wttrin-debug-clear-log Added ;;;###autoload to both functions for proper autoloading. Updated all references: - README.org (2 occurrences) - tests/README-DEBUG-TESTS.md (4 occurrences) - tests/test-wttrin-integration-with-debug.el (8 occurrences) These are user-facing commands that should be discoverable via M-x, so they follow the public API naming convention (single hyphen). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08feat: debug: add comprehensive debug logging and integration testsCraig Jennings
Enhanced wttrin-debug.el: - Added wttrin--debug-log() function for timestamped logging - Added wttrin--debug-clear-log() to clear log - Added wttrin--debug-show-log() to display log in buffer - Debug log structure: list of (timestamp . message) pairs Added debug logging to key functions in wttrin.el: - wttrin--fetch-url: Logs start, success (bytes), and errors - wttrin--mode-line-fetch-weather: Logs start, URL, data received - wttrin--mode-line-update-display: Logs display update, emoji extraction Created comprehensive integration tests: - test-wttrin-integration-with-debug.el (5 tests, 3 passing) - Tests fetch, mode-line display, error handling with debug logging - Includes mocked network calls to avoid external dependencies - Example debug output shows complete flow: [wttrin-debug 11:51:46.490] mode-line-fetch: Starting fetch for Berkeley, CA [wttrin-debug 11:51:46.490] mode-line-fetch: Received data = "Berkeley, CA: ☀️ +62°F Clear" [wttrin-debug 11:51:46.490] mode-line-display: Extracted emoji = "☀", font = Noto Color Emoji [wttrin-debug 11:51:46.490] mode-line-display: Complete. mode-line-string set = YES Added test fixtures: - tests/fixtures/test-init.el: Minimal config with debug enabled - tests/README-DEBUG-TESTS.md: Documentation for using debug features Usage: (setq wttrin-debug t) ; Before loading wttrin (require 'wttrin) M-x wttrin--debug-show-log ; View all logged events This provides complete visibility into wttrin's operation for troubleshooting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08test: add comprehensive integration tests for package loadingCraig Jennings
Add 18 integration tests to verify wttrin loads correctly: Package Loading: - Package loads without errors - Feature is properly provided - Dependencies available (xterm-color, url) Function Availability: - Main commands defined and interactive (wttrin, wttrin-clear-cache) - Modes defined (wttrin-mode, wttrin-mode-line-mode) Configuration: - All defcustom variables exist - Internal variables defined - Keymaps exist and valid Package Metadata: - Version information present - Autoload cookies in place Smoke Tests: - URL building works - Cache operations function - Mode-line display works All 18 tests passing - package loads correctly when dependencies available. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08refactor: mode-line: extract inline keymap to shared defvarCraig Jennings
Replace inline keymap construction with shared wttrin--mode-line-map defvar. Before (line 474-479): Keymap recreated on every mode-line update - (let ((map (make-sparse-keymap))) ...) - Allocates new keymap object each time - 6 lines of repetitive code After (line 183-190 + line 483): Shared keymap created once - (defvar wttrin--mode-line-map ...) - Reference: 'local-map wttrin--mode-line-map - Single allocation, no repeated construction Added comprehensive tests (8 tests, all passing): - Keymap existence and structure verification - Keybinding tests (mouse-1, mouse-3, no mouse-2) - Integration test verifying mode-line uses shared map Benefits: - More efficient (no allocation on every update) - Clearer code structure - Easier to add new keybindings - Self-documenting with inline documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08refactor: config: replace magic numbers with named constantsCraig Jennings
Replace two magic numbers with self-documenting constants: 1. Cache cleanup percentage (line 395): - Before: (dotimes (_ (/ (length entries) 5)) - After: (dotimes (_ (floor (* (length entries) wttrin--cache-cleanup-percentage))) - Added: wttrin--cache-cleanup-percentage constant (0.20 = 20%) - Explains WHY 20%: provides buffer before next cleanup cycle 2. Mode-line startup delay (line 508): - Before: (run-at-time 3 nil #'wttrin--mode-line-fetch-weather) - After: (run-at-time wttrin-mode-line-startup-delay nil ...) - Added: wttrin-mode-line-startup-delay defcustom (default 3 seconds) - Now user-customizable, range 1-5 seconds recommended Added comprehensive tests (8 tests, all passing): - 5 tests verify cache cleanup behavior (removes ~20% of oldest entries) - 3 tests verify startup delay defcustom exists and has reasonable value Benefits: - Self-documenting code (explains WHY these values exist) - Startup delay is now user-customizable - Easier for future maintainers to understand rationale 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08test: render: add comprehensive ERT tests for display helper functionsCraig Jennings
Add 34 new tests covering the three helper functions extracted from wttrin--display-weather: - test-wttrin--validate-weather-data.el (12 tests) - test-wttrin--process-weather-content.el (12 tests) - test-wttrin--add-buffer-instructions.el (10 tests) Tests follow Normal/Boundary/Error pattern and all pass. Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08test: core: enhance ERT tests for pure functionsCraig Jennings
- Enhanced test-wttrin-additional-url-params with clearer test organization - Enhanced test-wttrin--build-url with comprehensive boundary and error cases - Added tests for Unicode, special characters, GPS coordinates, domains - Fixed domain name test to check for URL-encoded @ symbol (%40) - Enhanced test-wttrin--make-cache-key with extensive boundary tests - Critical test: same location with different units produces different keys - Added tests for special chars, Unicode, empty strings, pipe characters All 29 tests for these three pure functions now pass (6 + 12 + 11) Combined with wttrin--fetch-url tests: 38 total tests passing
2025-11-08refactor: fetch: extract duplicate URL fetching logic into wttrin--fetch-urlCraig Jennings
- Created wttrin--fetch-url helper to eliminate code duplication - Refactored wttrin-fetch-raw-string to use helper (27 lines -> 3 lines) - Refactored wttrin--mode-line-fetch-weather to use helper (~30 lines -> ~10 lines) - Added comprehensive ERT test suite with 9 tests covering normal, boundary, and error cases - All tests passing This refactoring provides a single point of truth for async URL fetching, making the code more maintainable and reducing duplication by ~40 lines.
2025-11-04fix(wttrin): Fix ANSI color rendering on fresh Emacs launchCraig Jennings
Critical bug fix: On fresh Emacs launch, weather displayed with only double quotes colored blue, all other text white. Pressing 'g' to refresh brought colors back. Root cause: wttrin-mode (derived mode) calls kill-all-local-variables internally. The code was setting xterm-color--state buffer-local BEFORE calling wttrin-mode, so the state was immediately wiped out. On refresh, the mode was already active (no-op), so the state survived. Fix: Call wttrin-mode FIRST, then set buffer-local variables after. This ensures kill-all-local-variables runs before we set any state. Changes: - Reorder initialization in wttrin--display-weather (wttrin.el:277-285) - Add regression tests for mode initialization order (2 new tests) Test results: 65 tests, all passing
2025-11-04feat(emacs): Add asynchronous weather fetching to wttrinCraig Jennings
Introduce asynchronous data fetching to the wttrin.el Emacs package. This enhancement avoids blocking Emacs during data retrieval by using `url-retrieve` for async calls. The behavior is controlled via a new customizable variable `wttrin-use-async`. Tests have been added for the new async behavior to ensure proper functionality.feat:makefile): Add package initialization for Emacs batch Enhance Makefile with package support by loading and initializing MELPA archive before validating and compiling, ensuring required packages are available during these operations. feat(tests): Add unit tests for `wttrin--display-weather` Introduce comprehensive tests for `wttrin--display-weather` function to validate buffer creation, content, keybindings, and error handling.
2025-11-04Add comprehensive ERT test suite and fix critical bugsCraig Jennings
Session 1: Testing infrastructure and initial test coverage Bug fixes in wttrin.el: - Fix wttrin-additional-url-params to handle nil unit system - Remove incorrect callback parameter to url-retrieve-synchronously - Add nil buffer check for network failures - Strip HTTP headers before decoding response - Kill buffer after fetch to prevent memory leaks - Fix double concatenation of URL params in cache function - Add proper URL encoding via new wttrin--build-url function Refactoring: - Extract wttrin--build-url as pure, testable function - Separate URL building logic from network I/O Test infrastructure (33 tests, 100% passing): - tests/testutil-wttrin.el: Shared test utilities - tests/test-wttrin-additional-url-params.el: 7 tests - tests/test-wttrin--make-cache-key.el: 9 tests - tests/test-wttrin--build-url.el: 10 tests - tests/test-wttrin--cleanup-cache-if-needed.el: 7 tests Documentation: - docs/testing-plan.org: Comprehensive testing roadmap - docs/bugs.org: Bug analysis from code review - docs/NOTES.org: Session tracking and guidelines - docs/session-1-summary.org: Detailed session summary Next session: Cache workflow tests, parsing logic extraction, integration tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>