test(scaffold): add skeleton test files for all 7 API endpoints

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Janpeter Visser 2026-04-25 18:24:25 +02:00
parent 0be3052f97
commit 46e795002f
7 changed files with 448 additions and 0 deletions

View file

@ -0,0 +1,62 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
vi.mock('@/lib/prisma', () => ({
prisma: {
sprint: {
findFirst: vi.fn(),
},
},
}))
vi.mock('@/lib/api-auth', () => ({
authenticateApiRequest: vi.fn(),
}))
import { prisma } from '@/lib/prisma'
import { authenticateApiRequest } from '@/lib/api-auth'
import { GET as getSprintTasks } from '@/app/api/sprints/[id]/tasks/route'
const mockPrisma = prisma as unknown as {
sprint: { findFirst: ReturnType<typeof vi.fn> }
}
const mockAuth = authenticateApiRequest as ReturnType<typeof vi.fn>
function makeRequest(sprintId = 'sprint-1', limit?: number): [Request, { params: Promise<{ id: string }> }] {
const url = limit
? `http://localhost/api/sprints/${sprintId}/tasks?limit=${limit}`
: `http://localhost/api/sprints/${sprintId}/tasks`
return [
new Request(url, {
method: 'GET',
headers: { Authorization: 'Bearer test-token' },
}),
{ params: Promise.resolve({ id: sprintId }) },
]
}
describe('GET /api/sprints/:id/tasks', () => {
beforeEach(() => {
vi.clearAllMocks()
})
// TC-ST-01
it.todo('returns 401 when no token provided')
// TC-ST-03
it.todo('returns 404 when sprint is not accessible')
// TC-ST-04
it.todo('returns 404 for another user\'s sprint')
// TC-ST-05
it.todo('applies default limit of 10 when no limit param given')
// TC-ST-06
it.todo('respects custom limit param')
// TC-ST-07
it.todo('handles limit=1 boundary')
// TC-ST-08
it.todo('returns empty array when sprint has no tasks')
})