Browse Source

Add webp avatar upload tests

pull/6548/merge
Chocobozzz 2 weeks ago
parent
commit
3aa15c44b0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
  1. BIN
      packages/tests/fixtures/avatar-resized-120x120.webp
  2. BIN
      packages/tests/fixtures/avatar-resized-1500x1500.webp
  3. BIN
      packages/tests/fixtures/avatar-resized-48x48.webp
  4. BIN
      packages/tests/fixtures/avatar-resized-600x600.webp
  5. BIN
      packages/tests/fixtures/avatar.webp
  6. 4
      packages/tests/src/api/users/users.ts
  7. 7
      packages/tests/src/shared/checks.ts

BIN
packages/tests/fixtures/avatar-resized-120x120.webp vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
packages/tests/fixtures/avatar-resized-1500x1500.webp vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
packages/tests/fixtures/avatar-resized-48x48.webp vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

BIN
packages/tests/fixtures/avatar-resized-600x600.webp vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
packages/tests/fixtures/avatar.webp vendored

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

4
packages/tests/src/api/users/users.ts

@ -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 () {
for (const extension of [ '.png', '.gif' ]) {
it('Should be able to update my avatar with a gif, a webp and a png', async function () {
for (const extension of [ '.png', '.gif', '.webp' ]) {
const fixture = 'avatar' + extension
await server.users.updateMyAvatar({ token: userToken, fixture })

7
packages/tests/src/shared/checks.ts

@ -62,12 +62,13 @@ async function testAvatarSize (options: {
// We don't test big GIF avatars
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 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.below(maxLength, 'the generated image is way larger 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 ' + fixturePath)
}
async function testImageGeneratedByFFmpeg (url: string, imageName: string, imageHTTPPath: string, extension = '.jpg') {

Loading…
Cancel
Save