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
70
__tests__/api/reorder.test.ts
Normal file
70
__tests__/api/reorder.test.ts
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
vi.mock('@/lib/prisma', () => ({
|
||||
prisma: {
|
||||
story: {
|
||||
findFirst: vi.fn(),
|
||||
},
|
||||
task: {
|
||||
findMany: vi.fn(),
|
||||
update: vi.fn(),
|
||||
},
|
||||
$transaction: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/lib/api-auth', () => ({
|
||||
authenticateApiRequest: vi.fn(),
|
||||
}))
|
||||
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { authenticateApiRequest } from '@/lib/api-auth'
|
||||
import { PATCH as patchReorder } from '@/app/api/stories/[id]/tasks/reorder/route'
|
||||
|
||||
const mockPrisma = prisma as unknown as {
|
||||
story: { findFirst: ReturnType<typeof vi.fn> }
|
||||
task: { findMany: ReturnType<typeof vi.fn>; update: ReturnType<typeof vi.fn> }
|
||||
$transaction: ReturnType<typeof vi.fn>
|
||||
}
|
||||
const mockAuth = authenticateApiRequest as ReturnType<typeof vi.fn>
|
||||
|
||||
function makeRequest(body: unknown, storyId = 'story-1'): [Request, { params: Promise<{ id: string }> }] {
|
||||
return [
|
||||
new Request(`http://localhost/api/stories/${storyId}/tasks/reorder`, {
|
||||
method: 'PATCH',
|
||||
headers: { Authorization: 'Bearer test-token', 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
}),
|
||||
{ params: Promise.resolve({ id: storyId }) },
|
||||
]
|
||||
}
|
||||
|
||||
describe('PATCH /api/stories/:id/tasks/reorder', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
// TC-RO-01
|
||||
it.todo('returns 401 when no token provided')
|
||||
|
||||
// TC-RO-03
|
||||
it.todo('returns 403 for demo users')
|
||||
|
||||
// TC-RO-04
|
||||
it.todo('returns 404 when story is not found')
|
||||
|
||||
// TC-RO-05
|
||||
it.todo('returns 404 for another user\'s story')
|
||||
|
||||
// TC-RO-06
|
||||
it.todo('returns 400 when task_ids is an empty array')
|
||||
|
||||
// TC-RO-07
|
||||
it.todo('returns 400 when task_ids is not an array')
|
||||
|
||||
// TC-RO-08
|
||||
it.todo('returns 400 when task_ids contains IDs from a different story')
|
||||
|
||||
// TC-RO-09
|
||||
it.todo('reorders tasks and returns 200')
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue