From 1808a1f8e4b7b102823492a2007a46929aebf189 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 22 Mar 2022 14:35:04 +0100 Subject: Add video edition finished notification --- .../tests/api/check-params/user-notifications.ts | 1 + .../tests/api/notifications/user-notifications.ts | 41 +++++++++++++++++++++- server/tests/api/transcoding/video-editor.ts | 8 +---- server/tests/shared/notifications.ts | 34 +++++++++++++++++- 4 files changed, 75 insertions(+), 9 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 4bc8084a1..93355e8b3 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts @@ -171,6 +171,7 @@ describe('Test user notifications API validators', function () { abuseNewMessage: UserNotificationSettingValue.WEB, abuseStateChange: UserNotificationSettingValue.WEB, newPeerTubeVersion: UserNotificationSettingValue.WEB, + myVideoEditionFinished: UserNotificationSettingValue.WEB, newPluginVersion: UserNotificationSettingValue.WEB } diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index f9f3e0e0e..c87686cb5 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -7,6 +7,7 @@ import { checkMyVideoImportIsFinished, checkNewActorFollow, checkNewVideoFromSubscription, + checkVideoEditionIsFinished, checkVideoIsPublished, FIXTURE_URLS, MockSmtpServer, @@ -15,7 +16,7 @@ import { } from '@server/tests/shared' import { wait } from '@shared/core-utils' import { buildUUID } from '@shared/extra-utils' -import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' +import { UserNotification, UserNotificationType, VideoEditorTask, VideoPrivacy } from '@shared/models' import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands' const expect = chai.expect @@ -23,10 +24,12 @@ const expect = chai.expect describe('Test user notifications', function () { let servers: PeerTubeServer[] = [] let userAccessToken: string + let userNotifications: UserNotification[] = [] let adminNotifications: UserNotification[] = [] let adminNotificationsServer2: UserNotification[] = [] let emails: object[] = [] + let channelId: number before(async function () { @@ -320,6 +323,42 @@ describe('Test user notifications', function () { }) }) + describe('Video editor', function () { + let baseParams: CheckerBaseParams + + before(() => { + baseParams = { + server: servers[1], + emails, + socketNotifications: adminNotificationsServer2, + token: servers[1].accessToken + } + }) + + it('Should send a notification after editor edition', async function () { + this.timeout(240000) + + const { name, shortUUID, id } = await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: true }) + + await waitJobs(servers) + await checkVideoIsPublished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + + const tasks: VideoEditorTask[] = [ + { + name: 'cut', + options: { + start: 0, + end: 1 + } + } + ] + await servers[1].videoEditor.createEditionTasks({ videoId: id, tasks }) + await waitJobs(servers) + + await checkVideoEditionIsFinished({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + }) + }) + describe('My video is imported', function () { let baseParams: CheckerBaseParams diff --git a/server/tests/api/transcoding/video-editor.ts b/server/tests/api/transcoding/video-editor.ts index a9b6950cc..f70bd49e6 100644 --- a/server/tests/api/transcoding/video-editor.ts +++ b/server/tests/api/transcoding/video-editor.ts @@ -56,13 +56,7 @@ describe('Test video editor', function () { await servers[0].config.enableMinimumTranscoding() - await servers[0].config.updateExistingSubConfig({ - newConfig: { - videoEditor: { - enabled: true - } - } - }) + await servers[0].config.enableEditor() }) describe('Cutting', function () { diff --git a/server/tests/shared/notifications.ts b/server/tests/shared/notifications.ts index 78d3787f0..f1ddbbbf7 100644 --- a/server/tests/shared/notifications.ts +++ b/server/tests/shared/notifications.ts @@ -47,6 +47,7 @@ function getAllNotificationsSettings (): UserNotificationSetting { abuseStateChange: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, autoInstanceFollowing: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, newPeerTubeVersion: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, + myVideoEditionFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL, newPluginVersion: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL } } @@ -109,6 +110,34 @@ async function checkVideoIsPublished (options: CheckerBaseParams & { await checkNotification({ ...options, notificationChecker, emailNotificationFinder }) } +async function checkVideoEditionIsFinished (options: CheckerBaseParams & { + videoName: string + shortUUID: string + checkType: CheckerType +}) { + const { videoName, shortUUID } = options + const notificationType = UserNotificationType.MY_VIDEO_EDITION_FINISHED + + function notificationChecker (notification: UserNotification, checkType: CheckerType) { + if (checkType === 'presence') { + expect(notification).to.not.be.undefined + expect(notification.type).to.equal(notificationType) + + checkVideo(notification.video, videoName, shortUUID) + checkActor(notification.video.channel) + } else { + expect(notification.video).to.satisfy(v => v === undefined || v.name !== videoName) + } + } + + function emailNotificationFinder (email: object) { + const text: string = email['text'] + return text.includes(shortUUID) && text.includes('Edition of your video') + } + + await checkNotification({ ...options, notificationChecker, emailNotificationFinder }) +} + async function checkMyVideoImportIsFinished (options: CheckerBaseParams & { videoName: string shortUUID: string @@ -656,6 +685,8 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an await setDefaultChannelAvatar(servers) await setDefaultAccountAvatar(servers) + await servers[1].config.enableEditor() + if (serversCount > 1) { await doubleFollow(servers[0], servers[1]) } @@ -724,7 +755,8 @@ export { checkNewCommentAbuseForModerators, checkNewAccountAbuseForModerators, checkNewPeerTubeVersion, - checkNewPluginVersion + checkNewPluginVersion, + checkVideoEditionIsFinished } // --------------------------------------------------------------------------- -- cgit v1.2.3