Scrum4Me/__tests__/api
Madhura68 eeed5d7506 feat(ST-1107): add Vercel cron expire-questions (+ M10 pairing cleanup)
POST /api/cron/expire-questions:
- Auth via Authorization: Bearer ${CRON_SECRET} (Vercel injecteert dit
  automatisch wanneer de env-var op de project-omgeving staat); 401 als secret
  niet matcht of niet is gezet (faal-veilig — geen open endpoint in dev)
- updateMany op claude_questions WHERE status='open' AND expires_at<now →
  'expired'
- Bonus: zelfde route ruimt M10 login_pairings op (status='pending' AND
  expires_at<now → 'cancelled'). Eén cron-job is goedkoper qua Vercel-budget
  en houdt cleanup-strategie centraal — opvolg-actie uit M10 dat geparkeerd was.

Config:
- vercel.json: crons-entry { path: '/api/cron/expire-questions', schedule: '0 */6 * * *' } (4x/dag)
- lib/env.ts: CRON_SECRET als optional in Zod-schema
- .env.example: documentatie + openssl rand-tip

Tests __tests__/api/cron-expire-questions.test.ts (4 cases):
- 401 zonder Authorization-header
- 401 met verkeerde secret
- 401 als CRON_SECRET niet is gezet (faal-veilig)
- 200 met juiste secret: response { expired_questions, expired_pairings, ran_at }
  + beide updateMany WHERE/data correct

Quality gates: lint 0 errors, tsc clean, vitest 151/151.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 01:51:48 +02:00
..
cron-expire-questions.test.ts feat(ST-1107): add Vercel cron expire-questions (+ M10 pairing cleanup) 2026-04-28 01:51:48 +02:00
next-story.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
notifications-stream.test.ts test(ST-1106): add cross-product access-isolation test for notifications SSE 2026-04-28 01:47:38 +02:00
pair-claim.test.ts M10: Password-loze inlog via QR-pairing (ST-1001..ST-1008) (#12) 2026-04-28 00:01:04 +02:00
pair-start.test.ts M10: Password-loze inlog via QR-pairing (ST-1001..ST-1008) (#12) 2026-04-28 00:01:04 +02:00
pair-stream.test.ts M10: Password-loze inlog via QR-pairing (ST-1001..ST-1008) (#12) 2026-04-28 00:01:04 +02:00
products.test.ts test(products): add unit tests for GET /api/products 2026-04-25 18:31:35 +02:00
reorder.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
security.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
sprint-tasks.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
story-log.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
tasks.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00
todos.test.ts Todo description, entity codes, REST API extensions and Claude Code hardening (ST-509/511/512/513) (#2) 2026-04-26 23:40:54 +02:00