mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-12 22:13:05 +00:00
Derivada AVIF 720px q60 armazenada como objeto-irmão determinístico de cada foto aprovada (flickr-<id>-grade.avif), servida direto quando o cliente negocia Accept: image/avif; fallback JPEG on-the-fly em ausência/falha, heal preguiçoso via after(), warm no afterChange da aprovação e backfill pnpm archive:thumbnails idempotente com recibo e guardas *_CONFIRM. Sem migration, sem UI, sem mudança de URL pública ou pull-down. Closes #1424
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
ARCHIVE_PHOTO_GRADE_EXTENSION,
|
|
ARCHIVE_PHOTO_GRADE_MIME_TYPE,
|
|
ARCHIVE_PHOTO_GRADE_QUALITY,
|
|
archivePhotoGradeFilename,
|
|
} from '@/lib/archivePhotoThumbnail'
|
|
|
|
// C248 — the pure naming rules of the stored grade: the deterministic sibling
|
|
// key the route, the generation utility and the backfill CLI share. The
|
|
// extension swap is the whole contract; a collision with the original key or a
|
|
// nondeterministic name would silently break the discovery by exact key.
|
|
|
|
describe('archive photo grade naming (C248)', () => {
|
|
it('derives the sibling key by replacing the original extension', () => {
|
|
expect(archivePhotoGradeFilename('flickr-123.jpg')).toBe('flickr-123-grade.avif')
|
|
expect(archivePhotoGradeFilename('flickr-123.jpeg')).toBe('flickr-123-grade.avif')
|
|
expect(archivePhotoGradeFilename('flickr-123.png')).toBe('flickr-123-grade.avif')
|
|
expect(archivePhotoGradeFilename('flickr-abc_def-9.JPG')).toBe('flickr-abc_def-9-grade.avif')
|
|
})
|
|
|
|
it('keeps the whole name as the base when there is no usable extension', () => {
|
|
expect(archivePhotoGradeFilename('flickr-123')).toBe('flickr-123-grade.avif')
|
|
expect(archivePhotoGradeFilename('.hidden')).toBe('.hidden-grade.avif')
|
|
expect(archivePhotoGradeFilename('flickr-1.2.jpg')).toBe('flickr-1.2-grade.avif')
|
|
})
|
|
|
|
it('never derives the original key itself', () => {
|
|
const original = 'flickr-999.jpg'
|
|
expect(archivePhotoGradeFilename(original)).not.toBe(original)
|
|
})
|
|
|
|
it('pins the AVIF container and the repo quality ruler', () => {
|
|
expect(ARCHIVE_PHOTO_GRADE_MIME_TYPE).toBe('image/avif')
|
|
expect(ARCHIVE_PHOTO_GRADE_EXTENSION).toBe('.avif')
|
|
expect(ARCHIVE_PHOTO_GRADE_QUALITY).toBe(60)
|
|
})
|
|
})
|