Skip to content

Three API endpoints: add dedicated test coverage #101

@bradjin8

Description

@bradjin8

Problem

The baseline eval states: "All 14 HTTP route handlers — the primary user-facing interface — have no direct tests. The export route, PDF generation, workspace listing, workspace detail, composers, and logs endpoints are all unverified." While the project has ~80 test cases across 10 test files covering utility functions and CLI logic, no test exercises the Flask route handlers through the test client. The eval's "test-coverage" cluster finding specifically flags three API endpoints that lack any coverage, leaving the primary user-facing contract completely unverified against regressions.

Acceptance Criteria

  • At least three API endpoints have dedicated test files/functions using Flask's test client
  • Priority endpoints to cover: /api/search, /api/workspaces, and /api/export (or the three most complex handlers)
  • Each endpoint test covers: successful response (200), error response (400/404/500), and edge case (empty data, missing params)
  • Tests use fixtures or mocks for SQLite database access (do not require real Cursor data)
  • Tests verify response JSON structure matches the expected contract (key names, types)
  • Tests pass in CI (if applicable)
  • PR approved by at least 1 reviewer

Implementation Notes

Use Flask's built-in test client via app.test_client() from the create_app() factory. Create tests/test_api_search.py, tests/test_api_workspaces.py, and tests/test_api_export.py. For database mocking, create a temporary SQLite database with known test data mimicking Cursor's schema (ItemTable with key/value columns, cursorDiskKV patterns). Reference tests/ for existing fixture patterns. The search endpoint is the highest priority given its 450-line complexity and three data sources. For the workspace endpoint, verify that the response includes the expected workspace metadata structure. For export, verify that the correct content-type headers and file format are returned. Note: if item #99 (search decomposition) lands first, the extracted helper functions will be easier to test in isolation — coordinate ordering with Brad.

References

  • Eval finding: Test 30, cluster "test-coverage"
  • Related files: api/search.py, api/workspaces.py, api/export_api.py, app.py (create_app factory), tests/, requirements.txt

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions