]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/comments-notifications.ts
Move AP request in requests file
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / comments-notifications.ts
index fd009e9d9b41dd17efaa5836c15e9368a5cff862..d2badf237403b542d282b3b52b30f8a6f9a68186 100644 (file)
@@ -2,20 +2,25 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { cleanupTests, getVideoCommentThreads, getVideoThreadComments, updateMyUser } from '../../../../shared/extra-utils'
-import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
-import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
-import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import { addAccountToAccountBlocklist, removeAccountFromAccountBlocklist } from '../../../../shared/extra-utils/users/blocklist'
 import {
+  addAccountToAccountBlocklist,
+  addVideoCommentReply,
+  addVideoCommentThread,
   checkCommentMention,
   CheckerBaseParams,
   checkNewCommentOnMyVideo,
-  prepareNotificationsTest
-} from '../../../../shared/extra-utils/users/user-notifications'
-import { addVideoCommentReply, addVideoCommentThread } from '../../../../shared/extra-utils/videos/video-comments'
-import { UserNotification } from '../../../../shared/models/users'
-import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
+  cleanupTests,
+  getVideoCommentThreads,
+  getVideoThreadComments,
+  MockSmtpServer,
+  prepareNotificationsTest,
+  removeAccountFromAccountBlocklist,
+  ServerInfo,
+  updateMyUser,
+  uploadVideo,
+  waitJobs
+} from '@shared/extra-utils'
+import { UserNotification, VideoCommentThreadTree } from '@shared/models'
 
 const expect = chai.expect
 
@@ -25,6 +30,11 @@ describe('Test comments notifications', function () {
   let userNotifications: UserNotification[] = []
   let emails: object[] = []
 
+  const commentText = '**hello** <a href="https://joinpeertube.org">world</a>, <h1>what do you think about peertube?</h1>'
+  const expectedHtml = '<strong style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">hello</strong> ' +
+  '<a href="https://joinpeertube.org" target="_blank" rel="noopener noreferrer" style="-ms-text-size-adjust: 100%; ' +
+  '-webkit-text-size-adjust: 100%; text-decoration: none; color: #f2690d;">world</a>, </p>what do you think about peertube?'
+
   before(async function () {
     this.timeout(120000)
 
@@ -48,7 +58,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should not send a new comment notification after a comment on another video', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
       const uuid = resVideo.body.video.uuid
@@ -61,7 +71,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should not send a new comment notification if I comment my own video', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
       const uuid = resVideo.body.video.uuid
@@ -74,7 +84,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should not send a new comment notification if the account is muted', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root')
 
@@ -91,7 +101,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should send a new comment notification after a local comment on my video', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
       const uuid = resVideo.body.video.uuid
@@ -104,7 +114,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should send a new comment notification after a remote comment on my video', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
       const uuid = resVideo.body.video.uuid
@@ -123,7 +133,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should send a new comment notification after a local reply on my video', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
       const uuid = resVideo.body.video.uuid
@@ -139,7 +149,7 @@ describe('Test comments notifications', function () {
     })
 
     it('Should send a new comment notification after a remote reply on my video', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' })
       const uuid = resVideo.body.video.uuid
@@ -167,25 +177,17 @@ describe('Test comments notifications', function () {
     })
 
     it('Should convert markdown in comment to html', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'cool video' })
       const uuid = resVideo.body.video.uuid
 
-      const commentText = '**hello** <a href="https://joinpeertube.org">world</a>, <h1>what do you think about peertube?</h1>'
-      const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, commentText)
-      const commentId = resComment.body.comment.id
+      await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, commentText)
 
       await waitJobs(servers)
-      await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
 
       const latestEmail = emails[emails.length - 1]
-
-      const expected = '<strong style="-ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;">hello</strong> ' +
-      '<a href="https://joinpeertube.org" target="_blank" rel="noopener noreferrer" style="-ms-text-size-adjust: 100%; ' +
-      '-webkit-text-size-adjust: 100%; text-decoration: none; color: #f2690d;">world</a>, </p>what do you think about peertube?'
-
-      expect(latestEmail['html']).to.contain(expected)
+      expect(latestEmail['html']).to.contain(expectedHtml)
     })
   })
 
@@ -321,6 +323,23 @@ describe('Test comments notifications', function () {
 
       await checkCommentMention(baseParams, uuid, commentId, server1ThreadId, 'super root 2 name', 'presence')
     })
+
+    it('Should convert markdown in comment to html', async function () {
+      this.timeout(10000)
+
+      const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' })
+      const uuid = resVideo.body.video.uuid
+
+      const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1')
+      const threadId = resThread.body.comment.id
+
+      await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, '@user_1 ' + commentText)
+
+      await waitJobs(servers)
+
+      const latestEmail = emails[emails.length - 1]
+      expect(latestEmail['html']).to.contain(expectedHtml)
+    })
   })
 
   after(async function () {