Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 37x 3x 18x 3x 1x 1x | import { http, HttpResponse } from 'msw'
import { mockPipelines } from '@/msw/mock-data'
import { createMockPipeline } from '@/msw/data'
export const pipelineHandlers = [
http.get('/api/v1/projects/:projectId/pipelines', ({ params }) => {
const projectId = params.projectId as string
const pipelines = mockPipelines.filter((p) => p.project_id === projectId)
return HttpResponse.json({
data: pipelines.length > 0 ? pipelines : [createMockPipeline({ project_id: projectId })],
meta: { limit: 50, returned: Math.max(pipelines.length, 1), has_more: false },
})
}),
http.get('/api/v1/pipelines/:id', ({ params }) => {
const pipeline = mockPipelines.find((p) => p.id === params.id)
return HttpResponse.json(pipeline ?? createMockPipeline({ id: params.id as string }))
}),
http.post('/api/v1/projects/:projectId/pipelines', ({ params }) =>
HttpResponse.json(createMockPipeline({ project_id: params.projectId as string }), { status: 201 }),
),
http.put('/api/v1/pipelines/:id', ({ params }) => {
const existing = mockPipelines.find((p) => p.id === params.id)
return HttpResponse.json(existing ?? createMockPipeline({ id: params.id as string }))
}),
http.delete('/api/v1/pipelines/:id', () => new HttpResponse(null, { status: 204 })),
]
|