Skip to content

test(web): achieve 80% API route coverage with CI enforcement#418

Open
pauljacobb wants to merge 1 commit into
AnnabelJoe:mainfrom
pauljacobb:test/325-api-coverage-80
Open

test(web): achieve 80% API route coverage with CI enforcement#418
pauljacobb wants to merge 1 commit into
AnnabelJoe:mainfrom
pauljacobb:test/325-api-coverage-80

Conversation

@pauljacobb
Copy link
Copy Markdown

Adds missing API route tests and enforces an 80% coverage threshold in CI with Codecov upload.

Changes

  • certificates/route.test.ts — new: happy path, DB error, pagination, cursor, field normalization
  • meters/route.test.ts — added GET tests (list + DB error path)
  • ready/route.test.ts — new: healthy and degraded states
  • vitest.config.ts — added lcov reporter + 80% thresholds on lines/functions/branches/statements
  • ci.yml — run vitest --coverage and upload lcov.info to Codecov

Acceptance criteria

  • Coverage measured with vitest --coverage
  • All API routes have at least one happy-path test
  • Error paths (DB failure, invalid input) tested
  • Coverage threshold enforced in CI (minimum 80%)
  • Coverage report uploaded to Codecov

Closes #325

…nabelJoe#325)

- certificates/route.test.ts: happy path, DB error, pagination, cursor,
  field normalization (readings join flattened to meter_id)
- meters/route.test.ts: add GET tests (list + DB error)
- ready/route.test.ts: healthy and degraded states
- vitest.config.ts: add lcov reporter + 80% threshold on lines/functions/
  branches/statements
- ci.yml: run vitest --coverage and upload lcov to Codecov

Closes AnnabelJoe#325
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 31, 2026

@pauljacobb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

readings: { meter_id: 'meter-1' },
}

function mockDb(data: unknown[], error: unknown = null, count = 1) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Achieve 80% test coverage across the Next.js API routes

2 participants