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:
parent
0be3052f97
commit
46e795002f
7 changed files with 448 additions and 0 deletions
58
__tests__/api/tasks.test.ts
Normal file
58
__tests__/api/tasks.test.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
vi.mock('@/lib/prisma', () => ({
|
||||
prisma: {
|
||||
task: {
|
||||
findFirst: vi.fn(),
|
||||
update: vi.fn(),
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/api-auth', () => ({
|
||||
authenticateApiRequest: vi.fn(),
|
||||
}))
|
||||
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { authenticateApiRequest } from '@/lib/api-auth'
|
||||
import { PATCH as patchTask } from '@/app/api/tasks/[id]/route'
|
||||
|
||||
const mockPrisma = prisma as unknown as {
|
||||
task: { findFirst: ReturnType<typeof vi.fn>; update: ReturnType<typeof vi.fn> }
|
||||
}
|
||||
const mockAuth = authenticateApiRequest as ReturnType<typeof vi.fn>
|
||||
|
||||
function makeRequest(body: unknown, taskId = 'task-1'): [Request, { params: Promise<{ id: string }> }] {
|
||||
return [
|
||||
new Request(`http://localhost/api/tasks/${taskId}`, {
|
||||
method: 'PATCH',
|
||||
headers: { Authorization: 'Bearer test-token', 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
{ params: Promise.resolve({ id: taskId }) },
|
||||
]
|
||||
}
|
||||
|
||||
describe('PATCH /api/tasks/:id', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
// TC-T-06
|
||||
it.todo('returns 400 for invalid status value')
|
||||
|
||||
// TC-T-07
|
||||
it.todo('returns 400 when body has no recognized fields')
|
||||
|
||||
// TC-T-08
|
||||
it.todo('updates status only and returns 200')
|
||||
|
||||
// TC-T-09
|
||||
it.todo('updates implementation_plan only and returns 200')
|
||||
|
||||
// TC-T-10
|
||||
it.todo('updates both status and implementation_plan and returns 200')
|
||||
|
||||
// TC-T-11
|
||||
it.todo('allows update when user is a team member of the product')
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue