diff options
Diffstat (limited to 'server/tests/api/notifications/comments-notifications.ts')
-rw-r--r-- | server/tests/api/notifications/comments-notifications.ts | 207 |
1 files changed, 84 insertions, 123 deletions
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index d2badf237..7cbb21397 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts | |||
@@ -3,30 +3,22 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addAccountToAccountBlocklist, | ||
7 | addVideoCommentReply, | ||
8 | addVideoCommentThread, | ||
9 | checkCommentMention, | 6 | checkCommentMention, |
10 | CheckerBaseParams, | 7 | CheckerBaseParams, |
11 | checkNewCommentOnMyVideo, | 8 | checkNewCommentOnMyVideo, |
12 | cleanupTests, | 9 | cleanupTests, |
13 | getVideoCommentThreads, | ||
14 | getVideoThreadComments, | ||
15 | MockSmtpServer, | 10 | MockSmtpServer, |
11 | PeerTubeServer, | ||
16 | prepareNotificationsTest, | 12 | prepareNotificationsTest, |
17 | removeAccountFromAccountBlocklist, | ||
18 | ServerInfo, | ||
19 | updateMyUser, | ||
20 | uploadVideo, | ||
21 | waitJobs | 13 | waitJobs |
22 | } from '@shared/extra-utils' | 14 | } from '@shared/extra-utils' |
23 | import { UserNotification, VideoCommentThreadTree } from '@shared/models' | 15 | import { UserNotification } from '@shared/models' |
24 | 16 | ||
25 | const expect = chai.expect | 17 | const expect = chai.expect |
26 | 18 | ||
27 | describe('Test comments notifications', function () { | 19 | describe('Test comments notifications', function () { |
28 | let servers: ServerInfo[] = [] | 20 | let servers: PeerTubeServer[] = [] |
29 | let userAccessToken: string | 21 | let userToken: string |
30 | let userNotifications: UserNotification[] = [] | 22 | let userNotifications: UserNotification[] = [] |
31 | let emails: object[] = [] | 23 | let emails: object[] = [] |
32 | 24 | ||
@@ -40,7 +32,7 @@ describe('Test comments notifications', function () { | |||
40 | 32 | ||
41 | const res = await prepareNotificationsTest(2) | 33 | const res = await prepareNotificationsTest(2) |
42 | emails = res.emails | 34 | emails = res.emails |
43 | userAccessToken = res.userAccessToken | 35 | userToken = res.userAccessToken |
44 | servers = res.servers | 36 | servers = res.servers |
45 | userNotifications = res.userNotifications | 37 | userNotifications = res.userNotifications |
46 | }) | 38 | }) |
@@ -53,136 +45,125 @@ describe('Test comments notifications', function () { | |||
53 | server: servers[0], | 45 | server: servers[0], |
54 | emails, | 46 | emails, |
55 | socketNotifications: userNotifications, | 47 | socketNotifications: userNotifications, |
56 | token: userAccessToken | 48 | token: userToken |
57 | } | 49 | } |
58 | }) | 50 | }) |
59 | 51 | ||
60 | it('Should not send a new comment notification after a comment on another video', async function () { | 52 | it('Should not send a new comment notification after a comment on another video', async function () { |
61 | this.timeout(20000) | 53 | this.timeout(20000) |
62 | 54 | ||
63 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 55 | const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
64 | const uuid = resVideo.body.video.uuid | ||
65 | 56 | ||
66 | const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') | 57 | const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) |
67 | const commentId = resComment.body.comment.id | 58 | const commentId = created.id |
68 | 59 | ||
69 | await waitJobs(servers) | 60 | await waitJobs(servers) |
70 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') | 61 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' }) |
71 | }) | 62 | }) |
72 | 63 | ||
73 | it('Should not send a new comment notification if I comment my own video', async function () { | 64 | it('Should not send a new comment notification if I comment my own video', async function () { |
74 | this.timeout(20000) | 65 | this.timeout(20000) |
75 | 66 | ||
76 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 67 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
77 | const uuid = resVideo.body.video.uuid | ||
78 | 68 | ||
79 | const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, 'comment') | 69 | const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' }) |
80 | const commentId = resComment.body.comment.id | 70 | const commentId = created.id |
81 | 71 | ||
82 | await waitJobs(servers) | 72 | await waitJobs(servers) |
83 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') | 73 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' }) |
84 | }) | 74 | }) |
85 | 75 | ||
86 | it('Should not send a new comment notification if the account is muted', async function () { | 76 | it('Should not send a new comment notification if the account is muted', async function () { |
87 | this.timeout(20000) | 77 | this.timeout(20000) |
88 | 78 | ||
89 | await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root') | 79 | await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }) |
90 | 80 | ||
91 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 81 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
92 | const uuid = resVideo.body.video.uuid | ||
93 | 82 | ||
94 | const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') | 83 | const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) |
95 | const commentId = resComment.body.comment.id | 84 | const commentId = created.id |
96 | 85 | ||
97 | await waitJobs(servers) | 86 | await waitJobs(servers) |
98 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') | 87 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'absence' }) |
99 | 88 | ||
100 | await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root') | 89 | await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }) |
101 | }) | 90 | }) |
102 | 91 | ||
103 | it('Should send a new comment notification after a local comment on my video', async function () { | 92 | it('Should send a new comment notification after a local comment on my video', async function () { |
104 | this.timeout(20000) | 93 | this.timeout(20000) |
105 | 94 | ||
106 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 95 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
107 | const uuid = resVideo.body.video.uuid | ||
108 | 96 | ||
109 | const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') | 97 | const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) |
110 | const commentId = resComment.body.comment.id | 98 | const commentId = created.id |
111 | 99 | ||
112 | await waitJobs(servers) | 100 | await waitJobs(servers) |
113 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') | 101 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'presence' }) |
114 | }) | 102 | }) |
115 | 103 | ||
116 | it('Should send a new comment notification after a remote comment on my video', async function () { | 104 | it('Should send a new comment notification after a remote comment on my video', async function () { |
117 | this.timeout(20000) | 105 | this.timeout(20000) |
118 | 106 | ||
119 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 107 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
120 | const uuid = resVideo.body.video.uuid | ||
121 | 108 | ||
122 | await waitJobs(servers) | 109 | await waitJobs(servers) |
123 | 110 | ||
124 | await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment') | 111 | await servers[1].comments.createThread({ videoId: uuid, text: 'comment' }) |
125 | 112 | ||
126 | await waitJobs(servers) | 113 | await waitJobs(servers) |
127 | 114 | ||
128 | const resComment = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) | 115 | const { data } = await servers[0].comments.listThreads({ videoId: uuid }) |
129 | expect(resComment.body.data).to.have.lengthOf(1) | 116 | expect(data).to.have.lengthOf(1) |
130 | const commentId = resComment.body.data[0].id | ||
131 | 117 | ||
132 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') | 118 | const commentId = data[0].id |
119 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId: commentId, commentId, checkType: 'presence' }) | ||
133 | }) | 120 | }) |
134 | 121 | ||
135 | it('Should send a new comment notification after a local reply on my video', async function () { | 122 | it('Should send a new comment notification after a local reply on my video', async function () { |
136 | this.timeout(20000) | 123 | this.timeout(20000) |
137 | 124 | ||
138 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 125 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
139 | const uuid = resVideo.body.video.uuid | ||
140 | 126 | ||
141 | const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') | 127 | const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) |
142 | const threadId = resThread.body.comment.id | ||
143 | 128 | ||
144 | const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'reply') | 129 | const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) |
145 | const commentId = resComment.body.comment.id | ||
146 | 130 | ||
147 | await waitJobs(servers) | 131 | await waitJobs(servers) |
148 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') | 132 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId, commentId, checkType: 'presence' }) |
149 | }) | 133 | }) |
150 | 134 | ||
151 | it('Should send a new comment notification after a remote reply on my video', async function () { | 135 | it('Should send a new comment notification after a remote reply on my video', async function () { |
152 | this.timeout(20000) | 136 | this.timeout(20000) |
153 | 137 | ||
154 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 138 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
155 | const uuid = resVideo.body.video.uuid | ||
156 | await waitJobs(servers) | 139 | await waitJobs(servers) |
157 | 140 | ||
158 | { | 141 | { |
159 | const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment') | 142 | const created = await servers[1].comments.createThread({ videoId: uuid, text: 'comment' }) |
160 | const threadId = resThread.body.comment.id | 143 | const threadId = created.id |
161 | await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, threadId, 'reply') | 144 | await servers[1].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) |
162 | } | 145 | } |
163 | 146 | ||
164 | await waitJobs(servers) | 147 | await waitJobs(servers) |
165 | 148 | ||
166 | const resThread = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) | 149 | const { data } = await servers[0].comments.listThreads({ videoId: uuid }) |
167 | expect(resThread.body.data).to.have.lengthOf(1) | 150 | expect(data).to.have.lengthOf(1) |
168 | const threadId = resThread.body.data[0].id | ||
169 | 151 | ||
170 | const resComments = await getVideoThreadComments(servers[0].url, uuid, threadId) | 152 | const threadId = data[0].id |
171 | const tree = resComments.body as VideoCommentThreadTree | 153 | const tree = await servers[0].comments.getThread({ videoId: uuid, threadId }) |
172 | 154 | ||
173 | expect(tree.children).to.have.lengthOf(1) | 155 | expect(tree.children).to.have.lengthOf(1) |
174 | const commentId = tree.children[0].comment.id | 156 | const commentId = tree.children[0].comment.id |
175 | 157 | ||
176 | await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') | 158 | await checkNewCommentOnMyVideo({ ...baseParams, shortUUID, threadId, commentId, checkType: 'presence' }) |
177 | }) | 159 | }) |
178 | 160 | ||
179 | it('Should convert markdown in comment to html', async function () { | 161 | it('Should convert markdown in comment to html', async function () { |
180 | this.timeout(20000) | 162 | this.timeout(20000) |
181 | 163 | ||
182 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'cool video' }) | 164 | const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'cool video' } }) |
183 | const uuid = resVideo.body.video.uuid | ||
184 | 165 | ||
185 | await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, commentText) | 166 | await servers[0].comments.createThread({ videoId: uuid, text: commentText }) |
186 | 167 | ||
187 | await waitJobs(servers) | 168 | await waitJobs(servers) |
188 | 169 | ||
@@ -193,147 +174,127 @@ describe('Test comments notifications', function () { | |||
193 | 174 | ||
194 | describe('Mention notifications', function () { | 175 | describe('Mention notifications', function () { |
195 | let baseParams: CheckerBaseParams | 176 | let baseParams: CheckerBaseParams |
177 | const byAccountDisplayName = 'super root name' | ||
196 | 178 | ||
197 | before(async () => { | 179 | before(async () => { |
198 | baseParams = { | 180 | baseParams = { |
199 | server: servers[0], | 181 | server: servers[0], |
200 | emails, | 182 | emails, |
201 | socketNotifications: userNotifications, | 183 | socketNotifications: userNotifications, |
202 | token: userAccessToken | 184 | token: userToken |
203 | } | 185 | } |
204 | 186 | ||
205 | await updateMyUser({ | 187 | await servers[0].users.updateMe({ displayName: 'super root name' }) |
206 | url: servers[0].url, | 188 | await servers[1].users.updateMe({ displayName: 'super root 2 name' }) |
207 | accessToken: servers[0].accessToken, | ||
208 | displayName: 'super root name' | ||
209 | }) | ||
210 | |||
211 | await updateMyUser({ | ||
212 | url: servers[1].url, | ||
213 | accessToken: servers[1].accessToken, | ||
214 | displayName: 'super root 2 name' | ||
215 | }) | ||
216 | }) | 189 | }) |
217 | 190 | ||
218 | it('Should not send a new mention comment notification if I mention the video owner', async function () { | 191 | it('Should not send a new mention comment notification if I mention the video owner', async function () { |
219 | this.timeout(10000) | 192 | this.timeout(10000) |
220 | 193 | ||
221 | const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) | 194 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } }) |
222 | const uuid = resVideo.body.video.uuid | ||
223 | 195 | ||
224 | const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello') | 196 | const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) |
225 | const commentId = resComment.body.comment.id | ||
226 | 197 | ||
227 | await waitJobs(servers) | 198 | await waitJobs(servers) |
228 | await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') | 199 | await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' }) |
229 | }) | 200 | }) |
230 | 201 | ||
231 | it('Should not send a new mention comment notification if I mention myself', async function () { | 202 | it('Should not send a new mention comment notification if I mention myself', async function () { |
232 | this.timeout(10000) | 203 | this.timeout(10000) |
233 | 204 | ||
234 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 205 | const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
235 | const uuid = resVideo.body.video.uuid | ||
236 | 206 | ||
237 | const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, '@user_1 hello') | 207 | const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) |
238 | const commentId = resComment.body.comment.id | ||
239 | 208 | ||
240 | await waitJobs(servers) | 209 | await waitJobs(servers) |
241 | await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') | 210 | await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' }) |
242 | }) | 211 | }) |
243 | 212 | ||
244 | it('Should not send a new mention notification if the account is muted', async function () { | 213 | it('Should not send a new mention notification if the account is muted', async function () { |
245 | this.timeout(10000) | 214 | this.timeout(10000) |
246 | 215 | ||
247 | await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root') | 216 | await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' }) |
248 | 217 | ||
249 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 218 | const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
250 | const uuid = resVideo.body.video.uuid | ||
251 | 219 | ||
252 | const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello') | 220 | const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) |
253 | const commentId = resComment.body.comment.id | ||
254 | 221 | ||
255 | await waitJobs(servers) | 222 | await waitJobs(servers) |
256 | await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') | 223 | await checkCommentMention({ ...baseParams, shortUUID, threadId: commentId, commentId, byAccountDisplayName, checkType: 'absence' }) |
257 | 224 | ||
258 | await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root') | 225 | await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' }) |
259 | }) | 226 | }) |
260 | 227 | ||
261 | it('Should not send a new mention notification if the remote account mention a local account', async function () { | 228 | it('Should not send a new mention notification if the remote account mention a local account', async function () { |
262 | this.timeout(20000) | 229 | this.timeout(20000) |
263 | 230 | ||
264 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 231 | const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
265 | const uuid = resVideo.body.video.uuid | ||
266 | 232 | ||
267 | await waitJobs(servers) | 233 | await waitJobs(servers) |
268 | const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, '@user_1 hello') | 234 | const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' }) |
269 | const threadId = resThread.body.comment.id | ||
270 | 235 | ||
271 | await waitJobs(servers) | 236 | await waitJobs(servers) |
272 | await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') | 237 | |
238 | const byAccountDisplayName = 'super root 2 name' | ||
239 | await checkCommentMention({ ...baseParams, shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'absence' }) | ||
273 | }) | 240 | }) |
274 | 241 | ||
275 | it('Should send a new mention notification after local comments', async function () { | 242 | it('Should send a new mention notification after local comments', async function () { |
276 | this.timeout(10000) | 243 | this.timeout(10000) |
277 | 244 | ||
278 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 245 | const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
279 | const uuid = resVideo.body.video.uuid | ||
280 | 246 | ||
281 | const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1') | 247 | const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) |
282 | const threadId = resThread.body.comment.id | ||
283 | 248 | ||
284 | await waitJobs(servers) | 249 | await waitJobs(servers) |
285 | await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') | 250 | await checkCommentMention({ ...baseParams, shortUUID, threadId, commentId: threadId, byAccountDisplayName, checkType: 'presence' }) |
286 | 251 | ||
287 | const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'hello 2 @user_1') | 252 | const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }) |
288 | const commentId = resComment.body.comment.id | ||
289 | 253 | ||
290 | await waitJobs(servers) | 254 | await waitJobs(servers) |
291 | await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') | 255 | await checkCommentMention({ ...baseParams, shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' }) |
292 | }) | 256 | }) |
293 | 257 | ||
294 | it('Should send a new mention notification after remote comments', async function () { | 258 | it('Should send a new mention notification after remote comments', async function () { |
295 | this.timeout(20000) | 259 | this.timeout(20000) |
296 | 260 | ||
297 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 261 | const { uuid, shortUUID } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
298 | const uuid = resVideo.body.video.uuid | ||
299 | 262 | ||
300 | await waitJobs(servers) | 263 | await waitJobs(servers) |
301 | 264 | ||
302 | const text1 = `hello @user_1@localhost:${servers[0].port} 1` | 265 | const text1 = `hello @user_1@localhost:${servers[0].port} 1` |
303 | const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1) | 266 | const { id: server2ThreadId } = await servers[1].comments.createThread({ videoId: uuid, text: text1 }) |
304 | const server2ThreadId = resThread.body.comment.id | ||
305 | 267 | ||
306 | await waitJobs(servers) | 268 | await waitJobs(servers) |
307 | 269 | ||
308 | const resThread2 = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) | 270 | const { data } = await servers[0].comments.listThreads({ videoId: uuid }) |
309 | expect(resThread2.body.data).to.have.lengthOf(1) | 271 | expect(data).to.have.lengthOf(1) |
310 | const server1ThreadId = resThread2.body.data[0].id | 272 | |
311 | await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') | 273 | const byAccountDisplayName = 'super root 2 name' |
274 | const threadId = data[0].id | ||
275 | await checkCommentMention({ ...baseParams, shortUUID, commentId: threadId, threadId, byAccountDisplayName, checkType: 'presence' }) | ||
312 | 276 | ||
313 | const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` | 277 | const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` |
314 | await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2) | 278 | await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) |
315 | 279 | ||
316 | await waitJobs(servers) | 280 | await waitJobs(servers) |
317 | 281 | ||
318 | const resComments = await getVideoThreadComments(servers[0].url, uuid, server1ThreadId) | 282 | const tree = await servers[0].comments.getThread({ videoId: uuid, threadId }) |
319 | const tree = resComments.body as VideoCommentThreadTree | ||
320 | 283 | ||
321 | expect(tree.children).to.have.lengthOf(1) | 284 | expect(tree.children).to.have.lengthOf(1) |
322 | const commentId = tree.children[0].comment.id | 285 | const commentId = tree.children[0].comment.id |
323 | 286 | ||
324 | await checkCommentMention(baseParams, uuid, commentId, server1ThreadId, 'super root 2 name', 'presence') | 287 | await checkCommentMention({ ...baseParams, shortUUID, commentId, threadId, byAccountDisplayName, checkType: 'presence' }) |
325 | }) | 288 | }) |
326 | 289 | ||
327 | it('Should convert markdown in comment to html', async function () { | 290 | it('Should convert markdown in comment to html', async function () { |
328 | this.timeout(10000) | 291 | this.timeout(10000) |
329 | 292 | ||
330 | const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) | 293 | const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } }) |
331 | const uuid = resVideo.body.video.uuid | ||
332 | 294 | ||
333 | const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1') | 295 | const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello 1' }) |
334 | const threadId = resThread.body.comment.id | ||
335 | 296 | ||
336 | await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, '@user_1 ' + commentText) | 297 | await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText }) |
337 | 298 | ||
338 | await waitJobs(servers) | 299 | await waitJobs(servers) |
339 | 300 | ||