Add webp avatar upload tests

pull/6788/head
Chocobozzz 2024-12-23 09:33:34 +01:00
parent 3fafcb15a1
commit 3aa15c44b0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
7 changed files with 6 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
packages/tests/fixtures/avatar.webp vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

View File

@ -272,8 +272,8 @@ describe('Test users', function () {
} }
}) })
it('Should be able to update my avatar with a gif, and then a png', async function () { it('Should be able to update my avatar with a gif, a webp and a png', async function () {
for (const extension of [ '.png', '.gif' ]) { for (const extension of [ '.png', '.gif', '.webp' ]) {
const fixture = 'avatar' + extension const fixture = 'avatar' + extension
await server.users.updateMyAvatar({ token: userToken, fixture }) await server.users.updateMyAvatar({ token: userToken, fixture })

View File

@ -62,12 +62,13 @@ async function testAvatarSize (options: {
// We don't test big GIF avatars // We don't test big GIF avatars
if (extension === '.gif' && avatar.width > 150) return if (extension === '.gif' && avatar.width > 150) return
const data = await readFile(buildAbsoluteFixturePath(imageName + extension)) const fixturePath = buildAbsoluteFixturePath(imageName + extension)
const data = await readFile(fixturePath)
const minLength = data.length - ((40 * data.length) / 100) const minLength = data.length - ((40 * data.length) / 100)
const maxLength = data.length + ((40 * data.length) / 100) const maxLength = data.length + ((40 * data.length) / 100)
expect(body.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture') expect(body.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture ' + fixturePath)
expect(body.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture') expect(body.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture ' + fixturePath)
} }
async function testImageGeneratedByFFmpeg (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') { async function testImageGeneratedByFFmpeg (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') {