Skip to content

Add API tests for the alerts endpoint #111

Description

@alimaandev

Summary

desktop/api_server.py has an alerts endpoint (\GET /api/v1/alerts, line ~444) that returns recent proactive alerts, but ests/test_api_server.py has no coverage for it. The TestMetrics, TestHealth, and other classes cover other endpoints.

Goal

Add a TestAlerts class in ests/test_api_server.py covering:

  • \GET /api/v1/alerts\ returns 200 with an alerts list
  • Requires auth (401 without a valid token)
  • Works when the alerts store is empty (returns empty list, not an error)

Tasks

  • Inspect the alert handler to confirm response shape (data/status/error envelope)
  • Add the new test class following the existing patterns (app fixture, headers fixture)
  • Run the suite: \python -m pytest tests/test_api_server.py --cov=desktop --cov-fail-under=40\

Acceptance criteria

  • All three behaviors tested and passing
  • No regressions in the rest of the suite
  • CI coverage gate still passes (>=40% for api_server)

Labels

good first issue, help wanted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions