UserNotificationSettingValue,
UserNotificationType
} from '@shared/models'
-import { createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
+import {
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ setDefaultAccountAvatar,
+ setDefaultChannelAvatar,
+ setDefaultVideoChannel
+} from '@shared/server-commands'
import { MockSmtpServer } from './mock-servers'
type CheckerBaseParams = {
abuseStateChange: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
autoInstanceFollowing: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
newPeerTubeVersion: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
+ myVideoStudioEditionFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
newPluginVersion: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
}
}
await checkNotification({ ...options, notificationChecker, emailNotificationFinder })
}
+async function checkVideoStudioEditionIsFinished (options: CheckerBaseParams & {
+ videoName: string
+ shortUUID: string
+ checkType: CheckerType
+}) {
+ const { videoName, shortUUID } = options
+ const notificationType = UserNotificationType.MY_VIDEO_STUDIO_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
expect(notification).to.not.be.undefined
expect(notification.type).to.equal(notificationType)
- checkActor(notification.account)
+ checkActor(notification.account, { withAvatar: false })
expect(notification.account.name).to.equal(username)
} else {
expect(notification).to.satisfy(n => n.type !== notificationType || n.account.name !== username)
expect(notification).to.not.be.undefined
expect(notification.type).to.equal(notificationType)
- checkActor(notification.actorFollow.follower)
+ checkActor(notification.actorFollow.follower, { withAvatar: false })
expect(notification.actorFollow.follower.name).to.equal('peertube')
expect(notification.actorFollow.follower.host).to.equal(followerHost)
expect(notification.type).to.equal(notificationType)
const following = notification.actorFollow.following
- checkActor(following)
+
+ checkActor(following, { withAvatar: false })
expect(following.name).to.equal('peertube')
expect(following.host).to.equal(followingHost)
const servers = await createMultipleServers(serversCount, Object.assign(overrideConfig, overrideConfigArg))
await setAccessTokensToServers(servers)
+ await setDefaultVideoChannel(servers)
+ await setDefaultChannelAvatar(servers)
+ await setDefaultAccountAvatar(servers)
+
+ if (servers[1]) {
+ await servers[1].config.enableStudio()
+ await servers[1].config.enableLive({ allowReplay: true, transcoding: false })
+ }
if (serversCount > 1) {
await doubleFollow(servers[0], servers[1])
const userAccessToken = await servers[0].login.getAccessToken(user)
await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
+ await servers[0].users.updateMyAvatar({ token: userAccessToken, fixture: 'avatar.png' })
+ await servers[0].channels.updateImage({ channelName: 'user_1_channel', token: userAccessToken, fixture: 'avatar.png', type: 'avatar' })
+
await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() })
if (serversCount > 1) {
checkNewCommentAbuseForModerators,
checkNewAccountAbuseForModerators,
checkNewPeerTubeVersion,
- checkNewPluginVersion
+ checkNewPluginVersion,
+ checkVideoStudioEditionIsFinished
}
// ---------------------------------------------------------------------------
const check = options.check || { web: true, mail: true }
if (check.web) {
- const notification = await server.notifications.getLatest({ token: token })
+ const notification = await server.notifications.getLatest({ token })
if (notification || checkType !== 'absence') {
notificationChecker(notification, checkType)
expect(video.id).to.be.a('number')
}
-function checkActor (actor: any) {
+function checkActor (actor: any, options: { withAvatar?: boolean } = {}) {
+ const { withAvatar = true } = options
+
expect(actor.displayName).to.be.a('string')
expect(actor.displayName).to.not.be.empty
expect(actor.host).to.not.be.undefined
+
+ if (withAvatar) {
+ expect(actor.avatars).to.be.an('array')
+ expect(actor.avatars).to.have.lengthOf(2)
+ expect(actor.avatars[0].path).to.exist.and.not.empty
+ }
}
function checkComment (comment: any, commentId: number, threadId: number) {