diff options
author | kontrollanten <6680299+kontrollanten@users.noreply.github.com> | 2022-02-28 08:34:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 08:34:43 +0100 |
commit | d0800f7661f13fabe7bb6f4aa0ea50764f106405 (patch) | |
tree | d43e6b0b6f4a5a32e03487e6464edbcaf288be2a /server/tests/api/videos/video-channels.ts | |
parent | 5cad2ca9db9b9d138f8a33058d10b94a9fd50c69 (diff) | |
download | PeerTube-d0800f7661f13fabe7bb6f4aa0ea50764f106405.tar.gz PeerTube-d0800f7661f13fabe7bb6f4aa0ea50764f106405.tar.zst PeerTube-d0800f7661f13fabe7bb6f4aa0ea50764f106405.zip |
Implement avatar miniatures (#4639)
* client: remove unused file
* refactor(client/my-actor-avatar): size from input
Read size from component input instead of scss, to make it possible to
use smaller avatar images when implemented.
* implement avatar miniatures
close #4560
* fix(test): max file size
* fix(search-index): normalize res acc to avatarMini
* refactor avatars to an array
* client/search: resize channel avatar to 120
* refactor(client/videos): remove unused function
* client(actor-avatar): set default size
* fix tests and avatars full result
When findOne is used only an array containting one avatar is returned.
* update migration version and version notations
* server/search: harmonize normalizing
* Cleanup avatar miniature PR
Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'server/tests/api/videos/video-channels.ts')
-rw-r--r-- | server/tests/api/videos/video-channels.ts | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index d435f3682..0f8227fd3 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -6,13 +6,14 @@ import { basename } from 'path' | |||
6 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' | 6 | import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' |
7 | import { testFileExistsOrNot, testImage } from '@server/tests/shared' | 7 | import { testFileExistsOrNot, testImage } from '@server/tests/shared' |
8 | import { wait } from '@shared/core-utils' | 8 | import { wait } from '@shared/core-utils' |
9 | import { User, VideoChannel } from '@shared/models' | 9 | import { ActorImageType, User, VideoChannel } from '@shared/models' |
10 | import { | 10 | import { |
11 | cleanupTests, | 11 | cleanupTests, |
12 | createMultipleServers, | 12 | createMultipleServers, |
13 | doubleFollow, | 13 | doubleFollow, |
14 | PeerTubeServer, | 14 | PeerTubeServer, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | setDefaultAccountAvatar, | ||
16 | setDefaultVideoChannel, | 17 | setDefaultVideoChannel, |
17 | waitJobs | 18 | waitJobs |
18 | } from '@shared/server-commands' | 19 | } from '@shared/server-commands' |
@@ -44,6 +45,7 @@ describe('Test video channels', function () { | |||
44 | 45 | ||
45 | await setAccessTokensToServers(servers) | 46 | await setAccessTokensToServers(servers) |
46 | await setDefaultVideoChannel(servers) | 47 | await setDefaultVideoChannel(servers) |
48 | await setDefaultAccountAvatar(servers) | ||
47 | 49 | ||
48 | await doubleFollow(servers[0], servers[1]) | 50 | await doubleFollow(servers[0], servers[1]) |
49 | }) | 51 | }) |
@@ -281,14 +283,19 @@ describe('Test video channels', function () { | |||
281 | 283 | ||
282 | for (const server of servers) { | 284 | for (const server of servers) { |
283 | const videoChannel = await findChannel(server, secondVideoChannelId) | 285 | const videoChannel = await findChannel(server, secondVideoChannelId) |
286 | const expectedSizes = ACTOR_IMAGES_SIZE[ActorImageType.AVATAR] | ||
284 | 287 | ||
285 | avatarPaths[server.port] = videoChannel.avatar.path | 288 | expect(videoChannel.avatars.length).to.equal(expectedSizes.length, 'Expected avatars to be generated in all sizes') |
286 | await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png') | ||
287 | await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true) | ||
288 | 289 | ||
289 | const row = await server.sql.getActorImage(basename(avatarPaths[server.port])) | 290 | for (const avatar of videoChannel.avatars) { |
290 | expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height) | 291 | avatarPaths[server.port] = avatar.path |
291 | expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width) | 292 | await testImage(server.url, `avatar-resized-${avatar.width}x${avatar.width}`, avatarPaths[server.port], '.png') |
293 | await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true) | ||
294 | |||
295 | const row = await server.sql.getActorImage(basename(avatarPaths[server.port])) | ||
296 | |||
297 | expect(expectedSizes.some(({ height, width }) => row.height === height && row.width === width)).to.equal(true) | ||
298 | } | ||
292 | } | 299 | } |
293 | }) | 300 | }) |
294 | 301 | ||
@@ -308,19 +315,18 @@ describe('Test video channels', function () { | |||
308 | for (const server of servers) { | 315 | for (const server of servers) { |
309 | const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host }) | 316 | const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host }) |
310 | 317 | ||
311 | bannerPaths[server.port] = videoChannel.banner.path | 318 | bannerPaths[server.port] = videoChannel.banners[0].path |
312 | await testImage(server.url, 'banner-resized', bannerPaths[server.port]) | 319 | await testImage(server.url, 'banner-resized', bannerPaths[server.port]) |
313 | await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true) | 320 | await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true) |
314 | 321 | ||
315 | const row = await server.sql.getActorImage(basename(bannerPaths[server.port])) | 322 | const row = await server.sql.getActorImage(basename(bannerPaths[server.port])) |
316 | expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height) | 323 | expect(row.height).to.equal(ACTOR_IMAGES_SIZE[ActorImageType.BANNER][0].height) |
317 | expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width) | 324 | expect(row.width).to.equal(ACTOR_IMAGES_SIZE[ActorImageType.BANNER][0].width) |
318 | } | 325 | } |
319 | }) | 326 | }) |
320 | 327 | ||
321 | it('Should delete the video channel avatar', async function () { | 328 | it('Should delete the video channel avatar', async function () { |
322 | this.timeout(15000) | 329 | this.timeout(15000) |
323 | |||
324 | await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) | 330 | await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) |
325 | 331 | ||
326 | await waitJobs(servers) | 332 | await waitJobs(servers) |
@@ -329,7 +335,7 @@ describe('Test video channels', function () { | |||
329 | const videoChannel = await findChannel(server, secondVideoChannelId) | 335 | const videoChannel = await findChannel(server, secondVideoChannelId) |
330 | await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), false) | 336 | await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), false) |
331 | 337 | ||
332 | expect(videoChannel.avatar).to.be.null | 338 | expect(videoChannel.avatars).to.be.empty |
333 | } | 339 | } |
334 | }) | 340 | }) |
335 | 341 | ||
@@ -344,7 +350,7 @@ describe('Test video channels', function () { | |||
344 | const videoChannel = await findChannel(server, secondVideoChannelId) | 350 | const videoChannel = await findChannel(server, secondVideoChannelId) |
345 | await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), false) | 351 | await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), false) |
346 | 352 | ||
347 | expect(videoChannel.banner).to.be.null | 353 | expect(videoChannel.banners).to.be.empty |
348 | } | 354 | } |
349 | }) | 355 | }) |
350 | 356 | ||