fix: 明确提示超大 PNG 像素限制

This commit is contained in:
2026-08-13 19:01:44 +08:00
parent 6f22b03ed9
commit ed81f24892
4 changed files with 32 additions and 5 deletions

View File

@@ -0,0 +1,13 @@
import { describe, expect, it } from 'vitest'
import { MAX_IMAGE_PIXELS, isSharpPixelLimitError } from '../server/utils/image-validation'
describe('图片上传校验', () => {
it('识别 Sharp 像素上限错误', () => {
expect(isSharpPixelLimitError(new Error('Input image exceeds pixel limit'))).toBe(true)
})
it('不把普通解析错误误判为像素过大', () => {
expect(isSharpPixelLimitError(new Error('Input buffer contains unsupported image format'))).toBe(false)
expect(MAX_IMAGE_PIXELS).toBe(40_000_000)
})
})