X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fnotifications%2Fuser-notifications.ts;h=ceadc21ffc61afee33724eb4751c66d7d1502a71;hb=b7faa8372ed598118305b760f7c1ddf537ca7f0d;hp=c87686cb5c64297e4fac0071b9012b095401683e;hpb=1808a1f8e4b7b102823492a2007a46929aebf189;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index c87686cb5..ceadc21ff 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -1,14 +1,13 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' +import { expect } from 'chai' import { CheckerBaseParams, checkMyVideoImportIsFinished, checkNewActorFollow, checkNewVideoFromSubscription, - checkVideoEditionIsFinished, checkVideoIsPublished, + checkVideoStudioEditionIsFinished, FIXTURE_URLS, MockSmtpServer, prepareNotificationsTest, @@ -16,10 +15,8 @@ import { } from '@server/tests/shared' import { wait } from '@shared/core-utils' import { buildUUID } from '@shared/extra-utils' -import { UserNotification, UserNotificationType, VideoEditorTask, VideoPrivacy } from '@shared/models' -import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' - -const expect = chai.expect +import { UserNotification, UserNotificationType, VideoPrivacy, VideoStudioTask } from '@shared/models' +import { cleanupTests, findExternalSavedVideo, PeerTubeServer, stopFfmpeg, waitJobs } from '@shared/server-commands' describe('Test user notifications', function () { let servers: PeerTubeServer[] = [] @@ -161,7 +158,7 @@ describe('Test user notifications', function () { }) it('Should send a new video notification when a remote video becomes public', async function () { - this.timeout(50000) + this.timeout(120000) const data = { privacy: VideoPrivacy.PRIVATE } const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) @@ -186,7 +183,7 @@ describe('Test user notifications', function () { }) it('Should not send a new video notification when a remote video becomes unlisted', async function () { - this.timeout(50000) + this.timeout(100000) const data = { privacy: VideoPrivacy.PRIVATE } const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 2, data) @@ -305,7 +302,7 @@ describe('Test user notifications', function () { }) it('Should not send a notification before the video is published', async function () { - this.timeout(50000) + this.timeout(150000) const updateAt = new Date(new Date().getTime() + 1000000) @@ -323,7 +320,77 @@ describe('Test user notifications', function () { }) }) - describe('Video editor', function () { + describe('My live replay is published', function () { + + let baseParams: CheckerBaseParams + + before(() => { + baseParams = { + server: servers[1], + emails, + socketNotifications: adminNotificationsServer2, + token: servers[1].accessToken + } + }) + + it('Should send a notification is a live replay of a non permanent live is published', async function () { + this.timeout(120000) + + const { shortUUID } = await servers[1].live.create({ + fields: { + name: 'non permanent live', + privacy: VideoPrivacy.PUBLIC, + channelId: servers[1].store.channel.id, + saveReplay: true, + permanentLive: false + } + }) + + const ffmpegCommand = await servers[1].live.sendRTMPStreamInVideo({ videoId: shortUUID }) + + await waitJobs(servers) + await servers[1].live.waitUntilPublished({ videoId: shortUUID }) + + await stopFfmpeg(ffmpegCommand) + await servers[1].live.waitUntilReplacedByReplay({ videoId: shortUUID }) + + await waitJobs(servers) + await checkVideoIsPublished({ ...baseParams, videoName: 'non permanent live', shortUUID, checkType: 'presence' }) + }) + + it('Should send a notification is a live replay of a permanent live is published', async function () { + this.timeout(120000) + + const { shortUUID } = await servers[1].live.create({ + fields: { + name: 'permanent live', + privacy: VideoPrivacy.PUBLIC, + channelId: servers[1].store.channel.id, + saveReplay: true, + permanentLive: true + } + }) + + const ffmpegCommand = await servers[1].live.sendRTMPStreamInVideo({ videoId: shortUUID }) + + await waitJobs(servers) + await servers[1].live.waitUntilPublished({ videoId: shortUUID }) + + const liveDetails = await servers[1].videos.get({ id: shortUUID }) + + await stopFfmpeg(ffmpegCommand) + + await servers[1].live.waitUntilWaiting({ videoId: shortUUID }) + await waitJobs(servers) + + const video = await findExternalSavedVideo(servers[1], liveDetails) + expect(video).to.exist + + await checkVideoIsPublished({ ...baseParams, videoName: video.name, shortUUID: video.shortUUID, checkType: 'presence' }) + }) + }) + + describe('Video studio', function () { let baseParams: CheckerBaseParams before(() => { @@ -335,7 +402,7 @@ describe('Test user notifications', function () { } }) - it('Should send a notification after editor edition', async function () { + it('Should send a notification after studio edition', async function () { this.timeout(240000) const { name, shortUUID, id } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }) @@ -343,7 +410,7 @@ describe('Test user notifications', function () { await waitJobs(servers) await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) - const tasks: VideoEditorTask[] = [ + const tasks: VideoStudioTask[] = [ { name: 'cut', options: { @@ -352,10 +419,10 @@ describe('Test user notifications', function () { } } ] - await servers[1].videoEditor.createEditionTasks({ videoId: id, tasks }) + await servers[1].videoStudio.createEditionTasks({ videoId: id, tasks }) await waitJobs(servers) - await checkVideoEditionIsFinished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + await checkVideoStudioEditionIsFinished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) }) }) @@ -475,7 +542,7 @@ describe('Test user notifications', function () { await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) }) - // PeerTube does not support accout -> account follows + // PeerTube does not support account -> account follows // it('Should notify when a local account is following one of our channel', async function () { // this.timeout(50000) //