mirror of
https://github.com/gotson/komga.git
synced 2026-05-08 12:35:30 +02:00
mock series support landscape poster
This commit is contained in:
parent
f5f85ffd5a
commit
f7f8a8bb04
1 changed files with 20 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { httpTyped } from '@/mocks/api/httpTyped'
|
||||
import { http, HttpResponse } from 'msw'
|
||||
import { HttpResponse } from 'msw'
|
||||
import mockThumbnailUrl from '@/assets/mock-thumbnail.jpg'
|
||||
import mockThumbnailLandscapeUrl from '@/assets/mock-thumbnail-landscape.jpg'
|
||||
import { PageRequest } from '@/types/PageRequest'
|
||||
import { mockPage } from '@/mocks/api/pageable'
|
||||
|
||||
|
|
@ -140,15 +141,25 @@ export const seriesHandlers = [
|
|||
Object.assign({}, mockSeries1, { metadata: { title: `Series ${params.seriesId}` } }),
|
||||
)
|
||||
}),
|
||||
http.get('*/api/v1/series/*/thumbnail', async () => {
|
||||
// Get an ArrayBuffer from reading the file from disk or fetching it.
|
||||
const buffer = await fetch(mockThumbnailUrl).then((response) => response.arrayBuffer())
|
||||
httpTyped.get('/api/v1/series/{seriesId}/thumbnail', async ({ params, response }) => {
|
||||
const seriesId = params.seriesId
|
||||
|
||||
return HttpResponse.arrayBuffer(buffer, {
|
||||
headers: {
|
||||
'content-type': 'image/jpg',
|
||||
},
|
||||
})
|
||||
// use landscape image for some images
|
||||
const landscape = seriesId.slice(-1) === 'L'
|
||||
|
||||
// Get an ArrayBuffer from reading the file from disk or fetching it.
|
||||
const buffer = await fetch(landscape ? mockThumbnailLandscapeUrl : mockThumbnailUrl).then(
|
||||
(response) => response.arrayBuffer(),
|
||||
)
|
||||
|
||||
return response.untyped(
|
||||
HttpResponse.arrayBuffer(buffer, {
|
||||
status: 200,
|
||||
headers: {
|
||||
'content-type': 'image/jpg',
|
||||
},
|
||||
}),
|
||||
)
|
||||
}),
|
||||
httpTyped.patch('/api/v1/series/{seriesId}/metadata', ({ response }) => response(204).empty()),
|
||||
httpTyped.post('/api/v1/series/{seriesId}/analyze', ({ response }) => response(202).empty()),
|
||||
|
|
|
|||
Loading…
Reference in a new issue