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
+51
View File
@@ -105,6 +105,57 @@ describe('album timeline enumeration (Immich 3.0)', () => {
expect(assets[0].width!).toBeGreaterThan(assets[0].height!)
})
it('withholds assets Immich has not finished generating thumbnails for', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
const pending = {
...bucketResponse,
id: bucketResponse.id.map(id => id.replace(/^a/, 'e')),
thumbhash: [null, null, 'hashC'],
isTrashed: [false, true, false]
}
vi.stubGlobal('fetch', vi.fn(async (url: string) => {
if (url.includes('/shared-links/me')) return jsonResponse(sharedLinkResponse())
if (url.includes('/timeline/buckets')) return jsonResponse(bucketsResponse)
if (url.includes('/timeline/bucket')) return jsonResponse(pending)
throw new Error('Unexpected fetch to ' + url)
}))
const first = await getShareByKey(uniqueKey(), undefined, KeyType.key)
// A second share key stands in for the next cache refresh.
await getShareByKey(uniqueKey(), undefined, KeyType.key)
expect(first.valid).toBe(true)
expect(first.link!.assets.map(a => a.id)).toEqual(['cccccccc-cccc-cccc-cccc-cccccccccccc'])
const warnings = warn.mock.calls.filter(c => String(c[0]).includes('eaaaaaaa-'))
expect(warnings).toHaveLength(1)
warn.mockRestore()
})
it('withholds unprocessed assets on an individual share too', async () => {
// Individual shares carry their assets inline on /shared-links/me rather
// than via the timeline, so the filter has to sit downstream of both.
vi.spyOn(console, 'warn').mockImplementation(() => {})
const individual = {
type: 'INDIVIDUAL',
key: 'real-key',
allowDownload: true,
expiresAt: null,
showMetadata: true,
assets: [
{ id: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', type: 'IMAGE', isTrashed: false, thumbhash: 'hashA' },
{ id: 'ffffffff-ffff-ffff-ffff-ffffffffffff', type: 'IMAGE', isTrashed: false, thumbhash: null }
]
}
vi.stubGlobal('fetch', vi.fn(async (url: string) => {
if (url.includes('/shared-links/me')) return jsonResponse(individual)
throw new Error('Unexpected fetch to ' + url)
}))
const result = await getShareByKey(uniqueKey(), undefined, KeyType.key)
expect(result.valid).toBe(true)
expect(result.link!.assets.map(a => a.id)).toEqual(['aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'])
vi.mocked(console.warn).mockRestore()
})
it('requests each bucket with an explicit UTC key so non-UTC databases match (#260)', async () => {
const fetchMock = routeFetch(sharedLinkResponse())
vi.stubGlobal('fetch', fetchMock)