Skip to content

test: add route tests for certificates verify endpoint - #1643

Open
hussnainahmedd wants to merge 2 commits into
rinafcode:mainfrom
hussnainahmedd:test/1416-certificates-verify-route-tests
Open

hussnainahmedd wants to merge 2 commits into
rinafcode:mainfrom
hussnainahmedd:test/1416-certificates-verify-route-tests

Conversation

@hussnainahmedd

Copy link
Copy Markdown

Summary

Adds the missing colocated test for the certificate verification route handler (src/app/api/certificates/verify/[id]/route.ts), following the same pattern as the merged email-verification route tests.

New file: src/app/api/certificates/verify/[id]/__tests__/route.test.ts

What the tests cover

  • 200 — valid certificate: asserts the validated verification payload is returned, the Cache-Control: public, max-age=3600 header is set, and verifyCertificate is called with the route param id.
  • 404 — certificate not found / revoked / invalid (verifyCertificate returns null): asserts valid: false and the expected error message.
  • 500 — service payload fails CertificateVerificationSchema validation: asserts the "Verification response validation failed" error.
  • 500 — verifyCertificate throws: asserts the "Failed to verify certificate" error.

The verifyCertificate service is mocked (vi.mock); the handler is driven with a plain Request plus a literal { params: { id } } context, matching the existing route-test style.

Testing notes

  • pnpm vitest run src/app/api/certificates/verify/[id]/__tests__/route.test.ts — 4/4 tests pass.
  • pnpm run type-check — no new errors (the only 2 errors are pre-existing in unrelated files SidebarNavigation.tsx / AccessibleModerationTools.tsx).
  • ESLint ignores __tests__ files per repo config.

Closes #1416

Copilot AI balanced review requested due to automatic review settings October 1, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Add tests for the API route src/app/api/certificates/verify/[id]/route.ts

2 participants