Skip to content

Improve test coverage in low-coverage controllers, notifications, and JavaScript #6833

@compwron

Description

@compwron

Summary

An audit of test coverage identified several areas with significantly lower coverage than the project average (~91% Ruby line coverage). Every Ruby app file has a corresponding spec file, so the gaps are about depth of coverage, not missing files entirely.

Ruby Coverage Gaps

Controllers (target: match project average of 91%+)

File Current Coverage
app/controllers/learning_hour_topics_controller.rb 41.7%
app/controllers/learning_hour_types_controller.rb 41.7%
app/controllers/mileage_reports_controller.rb 44.4%
app/controllers/followup_reports_controller.rb 50.0%

Notifications

File Current Coverage
app/notifications/delivery_methods/sms.rb 43.8%

Policies

File Current Coverage
app/policies/custom_org_link_policy.rb 50.0%

JavaScript Coverage Gaps (46.75% overall)

File Line Coverage
app/javascript/src/case_emancipation.js 17.3%
app/javascript/src/case_contact.js 20%
app/javascript/src/casa_case.js 21%
app/javascript/src/dashboard.js 22.7%
app/javascript/src/session_timeout_poller.js 43.8%
app/javascript/src/require_communication_preference.js 50%

There are also 2 failing Jest tests in validated_form.test.js (color format mismatch: rgb() vs hex).

Suggested approach

  • Controllers: Add request specs or system tests covering untested actions (per ADR 0006, system tests are preferred)
  • Notifications/Policies: Add unit specs for uncovered branches
  • JavaScript: Add Jest tests for the 4 files under 25% coverage as the highest-value targets
  • Jest failures: Fix the 2 failing assertions in validated_form.test.js

How to reproduce

# Ruby coverage report
RUN_SIMPLECOV=true bundle exec rspec
open coverage/index.html

# JavaScript coverage
npx jest --coverage

# Check for missing spec files
bundle exec rake test_checker

Notes

  • lib/tasks directory is at 49.7% but most of those are one-time deployment rake tasks — lower priority
  • Coverage data is from the last SimpleCov run; re-run to get current numbers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions