56 lines
1.4 KiB
TypeScript
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')
|
|
})
|