Back to Source Monitor

Test Suite Updates

.vbw-planning/milestones/ui-fixes-and-smart-scraping/phases/05-simplify-source-status/05-SUMMARY.md

0.13.04.2 KB
Original Source

What Was Built

Updated the entire test suite (13 test files, 25+ source/view files) to use the simplified 4-status health model: working, declining, improving, failing. Removed all references to the old 6-status values (healthy, warning, critical, auto_paused, unknown). Also updated the corresponding source code since plans 01-04 had not yet been merged into this worktree.

Commits

HashMessage
a3ffe9ctest(health): update SourceHealthMonitor tests for 4-status model
0d1faaatest(health): update reset tests for working status
7c58f18test: update model, controller, and helper tests for 4-status health
dc85857test(health): update remaining test files for 4-status health model
10c4259fix(test): resolve remaining test failures from status migration

Tasks Completed

  1. SourceHealthMonitor tests - Updated all assertions: "healthy" -> "working", "auto_paused" -> "failing", removed warning_threshold references. Fixed declining/improving test scenarios to use correct log distributions (rate must be between auto_pause and healthy thresholds).
  2. SourceHealthReset and controller tests - Changed "auto_paused" -> "failing", "healthy" -> "working" in reset tests and controller tests.
  3. Source model, controller, and helper tests - Updated default health_status assertions, filter tests, badge mapping tests. Added tests for "failing" and "working" interactive_health_status. Restored full helper test file with all original tests intact.
  4. Remaining test files - Updated stats_query_test (4-status distribution), consecutive_failures_test ("auto_paused" -> "failing"), source_health_check_job_test ("critical"/"warning" -> "failing", "healthy" -> "working"), import_sessions_controller_test ("healthy" -> "working"), system test ("auto_paused"/"critical" -> "failing").
  5. Quality gates - Full test suite: 1416 runs, 0 failures (2 gemspec failures and 9 integration errors are pre-existing worktree issues). RuboCop: 0 offenses in changed files. Brakeman: pre-existing warning only.

Source Code Updates (required because other plans not yet merged)

Updated source files to match the 4-status model alongside tests:

  • lib/source_monitor/health/source_health_monitor.rb - New decision tree, removed warning_threshold
  • lib/source_monitor/health/source_health_reset.rb - Reset to "working"
  • lib/source_monitor/configuration/health_settings.rb - Removed warning_threshold
  • app/models/source_monitor/source.rb - Default "working"
  • app/helpers/source_monitor/health_badge_helper.rb - 4-status mapping
  • app/jobs/source_monitor/source_health_check_job.rb - DEGRADED_STATUSES updated
  • lib/source_monitor/fetching/feed_fetcher/source_updater.rb - Auto-pause sets "failing"
  • lib/source_monitor/health/import_source_health_check.rb - Returns "working" not "healthy"
  • lib/source_monitor/dashboard/queries/stats_query.rb - 4-status distribution
  • Views: dashboard stats, sources index, import health check row
  • test/dummy/db/schema.rb - Default "working"

Files Modified (tests)

  • test/lib/source_monitor/health/source_health_monitor_test.rb
  • test/lib/source_monitor/health/source_health_reset_test.rb
  • test/controllers/source_monitor/source_health_resets_controller_test.rb
  • test/models/source_monitor/source_test.rb
  • test/controllers/source_monitor/sources_controller_test.rb
  • test/helpers/source_monitor/application_helper_test.rb
  • test/lib/source_monitor/dashboard/stats_query_test.rb
  • test/lib/source_monitor/fetching/consecutive_failures_test.rb
  • test/jobs/source_monitor/source_health_check_job_test.rb
  • test/jobs/source_monitor/import_session_health_check_job_test.rb
  • test/controllers/source_monitor/import_sessions_controller_test.rb
  • test/system/sources_test.rb
  • test/lib/source_monitor/configuration/settings_test.rb

Deviations

  • Had to update source code in addition to tests because plans 01-04 were not merged into the worktree yet
  • Adjusted declining/improving test scenarios: original tests had < window_size logs, making rate fall below auto_pause_threshold. Fixed by adding enough logs to hit the intermediate range (above auto_pause, below healthy threshold)
  • Helper test file was accidentally truncated during Write; restored fully from git history with health-status updates applied