Require Immich 3.x; code cleanup

This commit is contained in:
Alan Grainger
2026-10-06 09:23:57 +13:00
parent d03a77f691
commit 255260ccb3
33 changed files with 347 additions and 800 deletions
+12 -1
View File
@@ -2,7 +2,8 @@ import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'
import express from 'express'
import type { Server } from 'http'
import type { AddressInfo } from 'net'
import { asyncHandler, errorHandler } from '../src/http'
import { asyncHandler } from '../src/http'
import { errorHandler } from '../src/invalidRequest'
/*
Regression tests for the per-request crash class: under Express 4 a rejected
@@ -26,6 +27,10 @@ describe('asyncHandler + errorHandler', () => {
app.get('/boom', asyncHandler(async () => {
throw new TypeError("Cannot read properties of undefined (reading 'headers')")
}))
app.get('/public-boom', asyncHandler(async (_req, res) => {
res.set('Cache-Control', 'public, max-age=2592000')
throw new Error('failed after the operator headers were applied')
}))
app.get('/mid-stream', asyncHandler(async (_req, res) => {
res.status(200)
res.write('partial')
@@ -50,6 +55,12 @@ describe('asyncHandler + errorHandler', () => {
expect(await res.text()).toBe('')
})
it('sends the 404 no-store, replacing the public TTL a route set first', async () => {
const res = await fetch(base + '/public-boom')
expect(res.status).toBe(404)
expect(res.headers.get('cache-control')).toContain('no-store')
})
it('keeps serving other requests after a route has thrown', async () => {
await fetch(base + '/boom')
const res = await fetch(base + '/ok')
+5 -5
View File
@@ -2,8 +2,7 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
import { getImmichVersion, isImmichVersionSupported, MIN_IMMICH_VERSION } from '../src/immich/client'
// The startup guard that refuses to run against an Immich server older than
// IPP supports. The floor is 2.0.0 - the columnar timeline API IPP relies on
// to enumerate album shares landed in Immich 2.0.
// IPP supports (3.0.0).
function jsonResponse (body: unknown, status = 200) {
return {
@@ -20,13 +19,14 @@ describe('isImmichVersionSupported', () => {
expect(isImmichVersionSupported(MIN_IMMICH_VERSION)).toBe(true)
})
it('accepts newer major/minor/patch across the 2.x and 3.x lines', () => {
expect(isImmichVersionSupported({ major: 2, minor: 7, patch: 5 })).toBe(true)
it('accepts newer major/minor/patch', () => {
expect(isImmichVersionSupported({ major: 3, minor: 0, patch: 2 })).toBe(true)
expect(isImmichVersionSupported({ major: 3, minor: 4, patch: 0 })).toBe(true)
expect(isImmichVersionSupported({ major: 4, minor: 0, patch: 0 })).toBe(true)
})
it('rejects 1.x, which predates the columnar timeline API', () => {
it('rejects 2.x and 1.x', () => {
expect(isImmichVersionSupported({ major: 2, minor: 7, patch: 5 })).toBe(false)
expect(isImmichVersionSupported({ major: 1, minor: 137, patch: 3 })).toBe(false)
expect(isImmichVersionSupported({ major: 1, minor: 125, patch: 7 })).toBe(false)
})