aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-channels.ts')
-rw-r--r--server/tests/api/videos/video-channels.ts22
1 files changed, 17 insertions, 5 deletions
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 64bd4d9ae..c82ad6f16 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -3,7 +3,7 @@
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { basename } from 'path' 4import { basename } from 'path'
5import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants' 5import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
6import { testFileExistsOrNot, testImage } from '@server/tests/shared' 6import { SQLCommand, testFileExistsOrNot, testImage } from '@server/tests/shared'
7import { wait } from '@shared/core-utils' 7import { wait } from '@shared/core-utils'
8import { ActorImageType, User, VideoChannel } from '@shared/models' 8import { ActorImageType, User, VideoChannel } from '@shared/models'
9import { 9import {
@@ -25,6 +25,8 @@ async function findChannel (server: PeerTubeServer, channelId: number) {
25 25
26describe('Test video channels', function () { 26describe('Test video channels', function () {
27 let servers: PeerTubeServer[] 27 let servers: PeerTubeServer[]
28 let sqlCommands: SQLCommand[]
29
28 let userInfo: User 30 let userInfo: User
29 let secondVideoChannelId: number 31 let secondVideoChannelId: number
30 let totoChannel: number 32 let totoChannel: number
@@ -45,6 +47,8 @@ describe('Test video channels', function () {
45 await setDefaultAccountAvatar(servers) 47 await setDefaultAccountAvatar(servers)
46 48
47 await doubleFollow(servers[0], servers[1]) 49 await doubleFollow(servers[0], servers[1])
50
51 sqlCommands = servers.map(s => new SQLCommand(s))
48 }) 52 })
49 53
50 it('Should have one video channel (created with root)', async () => { 54 it('Should have one video channel (created with root)', async () => {
@@ -278,7 +282,9 @@ describe('Test video channels', function () {
278 282
279 await waitJobs(servers) 283 await waitJobs(servers)
280 284
281 for (const server of servers) { 285 for (let i = 0; i < servers.length; i++) {
286 const server = servers[i]
287
282 const videoChannel = await findChannel(server, secondVideoChannelId) 288 const videoChannel = await findChannel(server, secondVideoChannelId)
283 const expectedSizes = ACTOR_IMAGES_SIZE[ActorImageType.AVATAR] 289 const expectedSizes = ACTOR_IMAGES_SIZE[ActorImageType.AVATAR]
284 290
@@ -289,7 +295,7 @@ describe('Test video channels', function () {
289 await testImage(server.url, `avatar-resized-${avatar.width}x${avatar.width}`, avatarPaths[server.port], '.png') 295 await testImage(server.url, `avatar-resized-${avatar.width}x${avatar.width}`, avatarPaths[server.port], '.png')
290 await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true) 296 await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true)
291 297
292 const row = await server.sql.getActorImage(basename(avatarPaths[server.port])) 298 const row = await sqlCommands[i].getActorImage(basename(avatarPaths[server.port]))
293 299
294 expect(expectedSizes.some(({ height, width }) => row.height === height && row.width === width)).to.equal(true) 300 expect(expectedSizes.some(({ height, width }) => row.height === height && row.width === width)).to.equal(true)
295 } 301 }
@@ -309,14 +315,16 @@ describe('Test video channels', function () {
309 315
310 await waitJobs(servers) 316 await waitJobs(servers)
311 317
312 for (const server of servers) { 318 for (let i = 0; i < servers.length; i++) {
319 const server = servers[i]
320
313 const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host }) 321 const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host })
314 322
315 bannerPaths[server.port] = videoChannel.banners[0].path 323 bannerPaths[server.port] = videoChannel.banners[0].path
316 await testImage(server.url, 'banner-resized', bannerPaths[server.port]) 324 await testImage(server.url, 'banner-resized', bannerPaths[server.port])
317 await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true) 325 await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true)
318 326
319 const row = await server.sql.getActorImage(basename(bannerPaths[server.port])) 327 const row = await sqlCommands[i].getActorImage(basename(bannerPaths[server.port]))
320 expect(row.height).to.equal(ACTOR_IMAGES_SIZE[ActorImageType.BANNER][0].height) 328 expect(row.height).to.equal(ACTOR_IMAGES_SIZE[ActorImageType.BANNER][0].height)
321 expect(row.width).to.equal(ACTOR_IMAGES_SIZE[ActorImageType.BANNER][0].width) 329 expect(row.width).to.equal(ACTOR_IMAGES_SIZE[ActorImageType.BANNER][0].width)
322 } 330 }
@@ -546,6 +554,10 @@ describe('Test video channels', function () {
546 }) 554 })
547 555
548 after(async function () { 556 after(async function () {
557 for (const sqlCommand of sqlCommands) {
558 await sqlCommand.cleanup()
559 }
560
549 await cleanupTests(servers) 561 await cleanupTests(servers)
550 }) 562 })
551}) 563})