]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/notifications/comments-notifications.ts
Fix tests timeout
[github/Chocobozzz/PeerTube.git] / server / tests / api / notifications / comments-notifications.ts
index cd3ed2f70639e4a192ec035c38a5d9080af336dd..3da828b6aa4b26ef9562b36ecffa97213ba9549c 100644 (file)
@@ -2,7 +2,7 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { cleanupTests, getVideoCommentThreads, getVideoThreadComments, updateMyUser, wait } from '../../../../shared/extra-utils'
+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'
@@ -25,6 +25,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)
 
@@ -56,7 +61,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
     })
 
@@ -69,7 +74,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, 'comment')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
     })
 
@@ -84,7 +89,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
 
       await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
@@ -99,7 +104,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence')
     })
 
@@ -134,7 +139,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'reply')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
     })
 
@@ -165,6 +170,20 @@ describe('Test comments notifications', function () {
 
       await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
     })
+
+    it('Should convert markdown in comment to html', async function () {
+      this.timeout(10000)
+
+      const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'cool video' })
+      const uuid = resVideo.body.video.uuid
+
+      await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, commentText)
+
+      await waitJobs(servers)
+
+      const latestEmail = emails[emails.length - 1]
+      expect(latestEmail['html']).to.contain(expectedHtml)
+    })
   })
 
   describe('Mention notifications', function () {
@@ -200,7 +219,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
     })
 
@@ -213,7 +232,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, '@user_1 hello')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
     })
 
@@ -228,7 +247,7 @@ describe('Test comments notifications', function () {
       const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
 
       await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root')
@@ -257,13 +276,13 @@ describe('Test comments notifications', function () {
       const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1')
       const threadId = resThread.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
 
       const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'hello 2 @user_1')
       const commentId = resComment.body.comment.id
 
-      await wait(500)
+      await waitJobs(servers)
       await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
     })
 
@@ -299,6 +318,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 () {