Scrum4Me/__tests__/api/next-story.test.ts
Madhura68 46e795002f test(scaffold): add skeleton test files for all 7 API endpoints
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:24:25 +02:00

56 lines
1.4 KiB
TypeScript

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 getNextStory } from '@/app/api/products/[id]/next-story/route'
const mockPrisma = prisma as unknown as {
sprint: { findFirst: ReturnType<typeof vi.fn> }
}
const mockAuth = authenticateApiRequest as ReturnType<typeof vi.fn>
function makeRequest(productId = 'product-1'): [Request, { params: Promise<{ id: string }> }] {
return [
new Request(`http://localhost/api/products/${productId}/next-story`, {
method: 'GET',
headers: { Authorization: 'Bearer test-token' },
}),
{ params: Promise.resolve({ id: productId }) },
]
}
describe('GET /api/products/:id/next-story', () => {
beforeEach(() => {
vi.clearAllMocks()
})
// TC-NS-01
it.todo('returns 401 when no token provided')
// TC-NS-03
it.todo('returns 404 when product is not accessible')
// TC-NS-04
it.todo('returns 404 when product has no active sprint')
// TC-NS-05
it.todo('returns 404 when active sprint has no IN_SPRINT stories')
// TC-NS-06
it.todo('returns the highest-priority story with its tasks')
// TC-NS-07
it.todo('returns 404 for another user\'s product')
})