Tidy up WebP download filename fix #297

This commit is contained in:
Alan Grainger
2026-10-05 09:12:10 +13:00
parent 2a99258278
commit 0ae17abdc0
8 changed files with 33 additions and 38 deletions
+1 -3
View File
@@ -198,9 +198,7 @@ describe('assetBuffer streaming', () => {
expect(res.headers['content-length']).toBe(String(4 * CHUNK))
})
it('names a preview-clamped download after the served bytes, not .jpg (WebP preview generation)', async () => {
// maxDownloadQuality=preview with Immich generating WebP previews: the
// Content-Disposition extension must follow the response content-type.
it('names a WebP preview download .webp', async () => {
setConfig({ ipp: { maxDownloadQuality: 'preview' } })
vi.stubGlobal('fetch', vi.fn(async () => new globalThis.Response(
new ReadableStream({
+1 -3
View File
@@ -285,9 +285,7 @@ describe('downloadAssets', () => {
expect(signals.every(s => s.aborted)).toBe(true)
}, 10_000)
it('names a preview-clamped entry after the served bytes, not .jpg (WebP preview generation)', async () => {
// Immich generates previews in an operator-chosen format; with WebP
// selected and maxDownloadQuality=preview, the zip entry must be .webp.
it('names a WebP preview zip entry .webp', async () => {
setConfig({ ipp: { maxDownloadQuality: 'preview' } })
const fetchMock = vi.fn(async () => new globalThis.Response(new Uint8Array(2048), {
status: 200,
+5 -1
View File
@@ -56,11 +56,15 @@ describe('getFilename servedMime override (playback-fallback downloads)', () =>
})
})
describe('getFilename converted-byte previews (e.g. WebP preview generation)', () => {
describe('getFilename WebP previews', () => {
it('swaps the extension to match the served preview bytes', () => {
expect(getFilename(imageAsset('holiday.heic'), ImageSize.preview, 'image/webp')).toBe('holiday.webp')
})
it('matches the served MIME type case-insensitively', () => {
expect(getFilename(imageAsset('holiday.heic'), ImageSize.preview, 'image/WebP')).toBe('holiday.webp')
})
it('keeps a JPEG extension when the preview is JPEG', () => {
expect(getFilename(imageAsset('holiday.heic'), ImageSize.preview, 'image/jpeg')).toBe('holiday.jpg')
})