diff options
author | Chocobozzz <me@florianbigard.com> | 2022-05-25 15:22:28 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-05-25 15:22:28 +0200 |
commit | ab623c0e0b4815bd69a94887241a69aaa857ed26 (patch) | |
tree | 9140675d0aa501d9ddbbcf14bbdb5c28b6ef0712 /server/tests | |
parent | c501cdef27e6769b7d2a13ac7b6deeb2e61eee46 (diff) | |
parent | c8fdfab0e36cc7324c61710009bf334e836485d9 (diff) | |
download | PeerTube-ab623c0e0b4815bd69a94887241a69aaa857ed26.tar.gz PeerTube-ab623c0e0b4815bd69a94887241a69aaa857ed26.tar.zst PeerTube-ab623c0e0b4815bd69a94887241a69aaa857ed26.zip |
Merge branch 'release/4.2.0' into develop
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/live/live-save-replay.ts | 34 | ||||
-rw-r--r-- | server/tests/api/live/live-socket-messages.ts | 2 | ||||
-rw-r--r-- | server/tests/shared/live.ts | 24 | ||||
-rw-r--r-- | server/tests/shared/notifications.ts | 20 |
4 files changed, 73 insertions, 7 deletions
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index 7ddcb04ef..007af51e9 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -441,6 +441,40 @@ describe('Save replay setting', function () { | |||
441 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) | 441 | await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404) |
442 | await checkLiveCleanup(servers[0], liveVideoUUID, []) | 442 | await checkLiveCleanup(servers[0], liveVideoUUID, []) |
443 | }) | 443 | }) |
444 | |||
445 | it('Should correctly save replays with multiple sessions', async function () { | ||
446 | this.timeout(120000) | ||
447 | |||
448 | liveVideoUUID = await createLiveWrapper({ permanent: true, replay: true }) | ||
449 | await waitJobs(servers) | ||
450 | |||
451 | // Streaming session #1 | ||
452 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | ||
453 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | ||
454 | await stopFfmpeg(ffmpegCommand) | ||
455 | await servers[0].live.waitUntilWaiting({ videoId: liveVideoUUID }) | ||
456 | |||
457 | // Streaming session #2 | ||
458 | ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) | ||
459 | await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) | ||
460 | await stopFfmpeg(ffmpegCommand) | ||
461 | await waitUntilLiveWaitingOnAllServers(servers, liveVideoUUID) | ||
462 | |||
463 | // Wait for replays | ||
464 | await waitJobs(servers) | ||
465 | |||
466 | const { total, data: sessions } = await servers[0].live.listSessions({ videoId: liveVideoUUID }) | ||
467 | |||
468 | expect(total).to.equal(2) | ||
469 | expect(sessions).to.have.lengthOf(2) | ||
470 | |||
471 | for (const session of sessions) { | ||
472 | expect(session.error).to.be.null | ||
473 | expect(session.replayVideo).to.exist | ||
474 | |||
475 | await servers[0].videos.get({ id: session.replayVideo.uuid }) | ||
476 | } | ||
477 | }) | ||
444 | }) | 478 | }) |
445 | 479 | ||
446 | after(async function () { | 480 | after(async function () { |
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts index 7668ed5b9..1669369c0 100644 --- a/server/tests/api/live/live-socket-messages.ts +++ b/server/tests/api/live/live-socket-messages.ts | |||
@@ -18,7 +18,7 @@ import { | |||
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
21 | describe('Test live', function () { | 21 | describe('Test live socket messages', function () { |
22 | let servers: PeerTubeServer[] = [] | 22 | let servers: PeerTubeServer[] = [] |
23 | 23 | ||
24 | before(async function () { | 24 | before(async function () { |
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 6ee4899b0..4bd4786fc 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts | |||
@@ -3,15 +3,35 @@ | |||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { LiveVideo } from '@shared/models' | ||
6 | import { PeerTubeServer } from '@shared/server-commands' | 7 | import { PeerTubeServer } from '@shared/server-commands' |
7 | 8 | ||
8 | async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { | 9 | async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { |
10 | let live: LiveVideo | ||
11 | |||
12 | try { | ||
13 | live = await server.live.get({ videoId: videoUUID }) | ||
14 | } catch {} | ||
15 | |||
9 | const basePath = server.servers.buildDirectory('streaming-playlists') | 16 | const basePath = server.servers.buildDirectory('streaming-playlists') |
10 | const hlsPath = join(basePath, 'hls', videoUUID) | 17 | const hlsPath = join(basePath, 'hls', videoUUID) |
11 | 18 | ||
12 | if (savedResolutions.length === 0) { | 19 | if (savedResolutions.length === 0) { |
13 | const result = await pathExists(hlsPath) | 20 | |
14 | expect(result).to.be.false | 21 | if (live?.permanentLive) { |
22 | expect(await pathExists(hlsPath)).to.be.true | ||
23 | |||
24 | const hlsFiles = await readdir(hlsPath) | ||
25 | expect(hlsFiles).to.have.lengthOf(1) // Only replays directory | ||
26 | |||
27 | const replayDir = join(hlsPath, 'replay') | ||
28 | expect(await pathExists(replayDir)).to.be.true | ||
29 | |||
30 | const replayFiles = await readdir(join(hlsPath, 'replay')) | ||
31 | expect(replayFiles).to.have.lengthOf(0) | ||
32 | } else { | ||
33 | expect(await pathExists(hlsPath)).to.be.false | ||
34 | } | ||
15 | 35 | ||
16 | return | 36 | return |
17 | } | 37 | } |
diff --git a/server/tests/shared/notifications.ts b/server/tests/shared/notifications.ts index a62410880..09bc8da03 100644 --- a/server/tests/shared/notifications.ts +++ b/server/tests/shared/notifications.ts | |||
@@ -185,7 +185,7 @@ async function checkUserRegistered (options: CheckerBaseParams & { | |||
185 | expect(notification).to.not.be.undefined | 185 | expect(notification).to.not.be.undefined |
186 | expect(notification.type).to.equal(notificationType) | 186 | expect(notification.type).to.equal(notificationType) |
187 | 187 | ||
188 | checkActor(notification.account) | 188 | checkActor(notification.account, { withAvatar: false }) |
189 | expect(notification.account.name).to.equal(username) | 189 | expect(notification.account.name).to.equal(username) |
190 | } else { | 190 | } else { |
191 | expect(notification).to.satisfy(n => n.type !== notificationType || n.account.name !== username) | 191 | expect(notification).to.satisfy(n => n.type !== notificationType || n.account.name !== username) |
@@ -253,7 +253,7 @@ async function checkNewInstanceFollower (options: CheckerBaseParams & { | |||
253 | expect(notification).to.not.be.undefined | 253 | expect(notification).to.not.be.undefined |
254 | expect(notification.type).to.equal(notificationType) | 254 | expect(notification.type).to.equal(notificationType) |
255 | 255 | ||
256 | checkActor(notification.actorFollow.follower) | 256 | checkActor(notification.actorFollow.follower, { withAvatar: false }) |
257 | expect(notification.actorFollow.follower.name).to.equal('peertube') | 257 | expect(notification.actorFollow.follower.name).to.equal('peertube') |
258 | expect(notification.actorFollow.follower.host).to.equal(followerHost) | 258 | expect(notification.actorFollow.follower.host).to.equal(followerHost) |
259 | 259 | ||
@@ -288,7 +288,8 @@ async function checkAutoInstanceFollowing (options: CheckerBaseParams & { | |||
288 | expect(notification.type).to.equal(notificationType) | 288 | expect(notification.type).to.equal(notificationType) |
289 | 289 | ||
290 | const following = notification.actorFollow.following | 290 | const following = notification.actorFollow.following |
291 | checkActor(following) | 291 | |
292 | checkActor(following, { withAvatar: false }) | ||
292 | expect(following.name).to.equal('peertube') | 293 | expect(following.name).to.equal('peertube') |
293 | expect(following.host).to.equal(followingHost) | 294 | expect(following.host).to.equal(followingHost) |
294 | 295 | ||
@@ -701,6 +702,9 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an | |||
701 | const userAccessToken = await servers[0].login.getAccessToken(user) | 702 | const userAccessToken = await servers[0].login.getAccessToken(user) |
702 | 703 | ||
703 | await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) | 704 | await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) |
705 | await servers[0].users.updateMyAvatar({ token: userAccessToken, fixture: 'avatar.png' }) | ||
706 | await servers[0].channels.updateImage({ channelName: 'user_1_channel', token: userAccessToken, fixture: 'avatar.png', type: 'avatar' }) | ||
707 | |||
704 | await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) | 708 | await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) |
705 | 709 | ||
706 | if (serversCount > 1) { | 710 | if (serversCount > 1) { |
@@ -832,10 +836,18 @@ function checkVideo (video: any, videoName?: string, shortUUID?: string) { | |||
832 | expect(video.id).to.be.a('number') | 836 | expect(video.id).to.be.a('number') |
833 | } | 837 | } |
834 | 838 | ||
835 | function checkActor (actor: any) { | 839 | function checkActor (actor: any, options: { withAvatar?: boolean } = {}) { |
840 | const { withAvatar = true } = options | ||
841 | |||
836 | expect(actor.displayName).to.be.a('string') | 842 | expect(actor.displayName).to.be.a('string') |
837 | expect(actor.displayName).to.not.be.empty | 843 | expect(actor.displayName).to.not.be.empty |
838 | expect(actor.host).to.not.be.undefined | 844 | expect(actor.host).to.not.be.undefined |
845 | |||
846 | if (withAvatar) { | ||
847 | expect(actor.avatars).to.be.an('array') | ||
848 | expect(actor.avatars).to.have.lengthOf(2) | ||
849 | expect(actor.avatars[0].path).to.exist.and.not.empty | ||
850 | } | ||
839 | } | 851 | } |
840 | 852 | ||
841 | function checkComment (comment: any, commentId: number, threadId: number) { | 853 | function checkComment (comment: any, commentId: number, threadId: number) { |