]>
Commit | Line | Data |
---|---|---|
a1587156 | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
d525fc39 | 2 | |
d525fc39 | 3 | import 'mocha' |
1fd61899 | 4 | import * as chai from 'chai' |
d525fc39 | 5 | import { |
7243f84d | 6 | cleanupTests, |
254d3579 | 7 | createSingleServer, |
29837f88 | 8 | doubleFollow, |
254d3579 | 9 | PeerTubeServer, |
4c7e60bc | 10 | SearchCommand, |
d525fc39 | 11 | setAccessTokensToServers, |
1fd61899 C |
12 | setDefaultVideoChannel, |
13 | stopFfmpeg, | |
4f219914 C |
14 | wait |
15 | } from '@shared/extra-utils' | |
16 | import { VideoPrivacy } from '@shared/models' | |
d525fc39 C |
17 | |
18 | const expect = chai.expect | |
19 | ||
da3a3ab6 | 20 | describe('Test videos search', function () { |
29837f88 C |
21 | let server: PeerTubeServer |
22 | let remoteServer: PeerTubeServer | |
d525fc39 | 23 | let startDate: string |
3cf53828 | 24 | let videoUUID: string |
d525fc39 | 25 | |
af971e06 C |
26 | let command: SearchCommand |
27 | ||
d525fc39 | 28 | before(async function () { |
29837f88 | 29 | this.timeout(120000) |
d525fc39 | 30 | |
254d3579 | 31 | server = await createSingleServer(1) |
29837f88 | 32 | remoteServer = await createSingleServer(2) |
d525fc39 | 33 | |
29837f88 C |
34 | await setAccessTokensToServers([ server, remoteServer ]) |
35 | await setDefaultVideoChannel([ server, remoteServer ]) | |
d525fc39 C |
36 | |
37 | { | |
38 | const attributes1 = { | |
39 | name: '1111 2222 3333', | |
40 | fixture: '60fps_720p_small.mp4', // 2 seconds | |
41 | category: 1, | |
42 | licence: 1, | |
43 | nsfw: false, | |
44 | language: 'fr' | |
45 | } | |
89d241a7 | 46 | await server.videos.upload({ attributes: attributes1 }) |
d525fc39 | 47 | |
6c5065a0 | 48 | const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' } |
89d241a7 | 49 | await server.videos.upload({ attributes: attributes2 }) |
d525fc39 | 50 | |
3caf77d3 | 51 | { |
6c5065a0 | 52 | const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } |
89d241a7 | 53 | const { id, uuid } = await server.videos.upload({ attributes: attributes3 }) |
d23dd9fb | 54 | videoUUID = uuid |
3caf77d3 | 55 | |
c63830f1 | 56 | await server.captions.add({ |
3caf77d3 | 57 | language: 'en', |
d23dd9fb | 58 | videoId: id, |
3caf77d3 C |
59 | fixture: 'subtitle-good2.vtt', |
60 | mimeType: 'application/octet-stream' | |
61 | }) | |
62 | ||
c63830f1 | 63 | await server.captions.add({ |
3caf77d3 | 64 | language: 'aa', |
d23dd9fb | 65 | videoId: id, |
3caf77d3 C |
66 | fixture: 'subtitle-good2.vtt', |
67 | mimeType: 'application/octet-stream' | |
68 | }) | |
69 | } | |
d525fc39 | 70 | |
6c5065a0 | 71 | const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } |
89d241a7 | 72 | await server.videos.upload({ attributes: attributes4 }) |
d525fc39 C |
73 | |
74 | await wait(1000) | |
75 | ||
76 | startDate = new Date().toISOString() | |
77 | ||
6c5065a0 | 78 | const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined } |
89d241a7 | 79 | await server.videos.upload({ attributes: attributes5 }) |
d525fc39 | 80 | |
6c5065a0 | 81 | const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } |
89d241a7 | 82 | await server.videos.upload({ attributes: attributes6 }) |
d525fc39 | 83 | |
6c5065a0 | 84 | const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } |
89d241a7 | 85 | await server.videos.upload({ attributes: attributes7 }) |
d525fc39 | 86 | |
6c5065a0 | 87 | const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } |
89d241a7 | 88 | await server.videos.upload({ attributes: attributes8 }) |
d525fc39 C |
89 | } |
90 | ||
91 | { | |
92 | const attributes = { | |
93 | name: '3333 4444 5555', | |
94 | fixture: 'video_short.mp4', | |
95 | category: 2, | |
96 | licence: 2, | |
97 | language: 'en' | |
98 | } | |
89d241a7 | 99 | await server.videos.upload({ attributes: attributes }) |
d525fc39 | 100 | |
89d241a7 | 101 | await server.videos.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } }) |
d525fc39 C |
102 | } |
103 | ||
104 | { | |
105 | const attributes = { | |
106 | name: '6666 7777 8888', | |
107 | fixture: 'video_short.mp4', | |
108 | category: 3, | |
109 | licence: 3, | |
110 | language: 'pl' | |
111 | } | |
89d241a7 | 112 | await server.videos.upload({ attributes: attributes }) |
d525fc39 C |
113 | } |
114 | ||
115 | { | |
116 | const attributes1 = { | |
117 | name: '9999', | |
118 | tags: [ 'aaaa', 'bbbb', 'cccc' ], | |
119 | category: 1 | |
120 | } | |
89d241a7 C |
121 | await server.videos.upload({ attributes: attributes1 }) |
122 | await server.videos.upload({ attributes: { ...attributes1, category: 2 } }) | |
d525fc39 | 123 | |
89d241a7 C |
124 | await server.videos.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } }) |
125 | await server.videos.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } }) | |
d525fc39 | 126 | } |
d4112450 C |
127 | |
128 | { | |
129 | const attributes1 = { | |
130 | name: 'aaaa 2', | |
131 | category: 1 | |
132 | } | |
89d241a7 C |
133 | await server.videos.upload({ attributes: attributes1 }) |
134 | await server.videos.upload({ attributes: { ...attributes1, category: 2 } }) | |
d4112450 | 135 | } |
af971e06 | 136 | |
29837f88 C |
137 | { |
138 | await remoteServer.videos.upload({ attributes: { name: 'remote video 1' } }) | |
139 | await remoteServer.videos.upload({ attributes: { name: 'remote video 2' } }) | |
140 | } | |
141 | ||
142 | await doubleFollow(server, remoteServer) | |
143 | ||
89d241a7 | 144 | command = server.search |
d525fc39 C |
145 | }) |
146 | ||
147 | it('Should make a simple search and not have results', async function () { | |
af971e06 | 148 | const body = await command.searchVideos({ search: 'abc' }) |
d525fc39 | 149 | |
af971e06 C |
150 | expect(body.total).to.equal(0) |
151 | expect(body.data).to.have.lengthOf(0) | |
d525fc39 C |
152 | }) |
153 | ||
154 | it('Should make a simple search and have results', async function () { | |
af971e06 | 155 | const body = await command.searchVideos({ search: '4444 5555 duplicate' }) |
d525fc39 | 156 | |
af971e06 | 157 | expect(body.total).to.equal(2) |
d525fc39 | 158 | |
af971e06 | 159 | const videos = body.data |
d525fc39 C |
160 | expect(videos).to.have.lengthOf(2) |
161 | ||
162 | // bestmatch | |
163 | expect(videos[0].name).to.equal('3333 4444 5555 duplicate') | |
164 | expect(videos[1].name).to.equal('3333 4444 5555') | |
165 | }) | |
166 | ||
d4112450 | 167 | it('Should make a search on tags too, and have results', async function () { |
af971e06 | 168 | const search = { |
d4112450 C |
169 | search: 'aaaa', |
170 | categoryOneOf: [ 1 ] | |
171 | } | |
af971e06 | 172 | const body = await command.advancedVideoSearch({ search }) |
d4112450 | 173 | |
af971e06 | 174 | expect(body.total).to.equal(2) |
d4112450 | 175 | |
af971e06 | 176 | const videos = body.data |
d4112450 C |
177 | expect(videos).to.have.lengthOf(2) |
178 | ||
179 | // bestmatch | |
180 | expect(videos[0].name).to.equal('aaaa 2') | |
181 | expect(videos[1].name).to.equal('9999') | |
182 | }) | |
183 | ||
184 | it('Should filter on tags without a search', async function () { | |
af971e06 | 185 | const search = { |
d4112450 C |
186 | tagsAllOf: [ 'bbbb' ] |
187 | } | |
af971e06 | 188 | const body = await command.advancedVideoSearch({ search }) |
d4112450 | 189 | |
af971e06 | 190 | expect(body.total).to.equal(2) |
d4112450 | 191 | |
af971e06 | 192 | const videos = body.data |
d4112450 C |
193 | expect(videos).to.have.lengthOf(2) |
194 | ||
195 | expect(videos[0].name).to.equal('9999') | |
196 | expect(videos[1].name).to.equal('9999') | |
197 | }) | |
198 | ||
199 | it('Should filter on category without a search', async function () { | |
af971e06 | 200 | const search = { |
d4112450 C |
201 | categoryOneOf: [ 3 ] |
202 | } | |
af971e06 | 203 | const body = await command.advancedVideoSearch({ search: search }) |
d4112450 | 204 | |
af971e06 | 205 | expect(body.total).to.equal(1) |
d4112450 | 206 | |
af971e06 | 207 | const videos = body.data |
d4112450 C |
208 | expect(videos).to.have.lengthOf(1) |
209 | ||
210 | expect(videos[0].name).to.equal('6666 7777 8888') | |
211 | }) | |
212 | ||
d525fc39 C |
213 | it('Should search by tags (one of)', async function () { |
214 | const query = { | |
215 | search: '9999', | |
216 | categoryOneOf: [ 1 ], | |
4b1f1b81 | 217 | tagsOneOf: [ 'aAaa', 'ffff' ] |
d525fc39 | 218 | } |
d525fc39 | 219 | |
af971e06 C |
220 | { |
221 | const body = await command.advancedVideoSearch({ search: query }) | |
222 | expect(body.total).to.equal(2) | |
223 | } | |
224 | ||
225 | { | |
226 | const body = await command.advancedVideoSearch({ search: { ...query, tagsOneOf: [ 'blabla' ] } }) | |
227 | expect(body.total).to.equal(0) | |
228 | } | |
d525fc39 C |
229 | }) |
230 | ||
231 | it('Should search by tags (all of)', async function () { | |
232 | const query = { | |
233 | search: '9999', | |
234 | categoryOneOf: [ 1 ], | |
4b1f1b81 | 235 | tagsAllOf: [ 'CCcc' ] |
d525fc39 | 236 | } |
d525fc39 | 237 | |
af971e06 C |
238 | { |
239 | const body = await command.advancedVideoSearch({ search: query }) | |
240 | expect(body.total).to.equal(2) | |
241 | } | |
d525fc39 | 242 | |
af971e06 C |
243 | { |
244 | const body = await command.advancedVideoSearch({ search: { ...query, tagsAllOf: [ 'blAbla' ] } }) | |
245 | expect(body.total).to.equal(0) | |
246 | } | |
247 | ||
248 | { | |
249 | const body = await command.advancedVideoSearch({ search: { ...query, tagsAllOf: [ 'bbbb', 'CCCC' ] } }) | |
250 | expect(body.total).to.equal(1) | |
251 | } | |
d525fc39 C |
252 | }) |
253 | ||
254 | it('Should search by category', async function () { | |
255 | const query = { | |
256 | search: '6666', | |
257 | categoryOneOf: [ 3 ] | |
258 | } | |
d525fc39 | 259 | |
af971e06 C |
260 | { |
261 | const body = await command.advancedVideoSearch({ search: query }) | |
262 | expect(body.total).to.equal(1) | |
263 | expect(body.data[0].name).to.equal('6666 7777 8888') | |
264 | } | |
265 | ||
266 | { | |
267 | const body = await command.advancedVideoSearch({ search: { ...query, categoryOneOf: [ 2 ] } }) | |
268 | expect(body.total).to.equal(0) | |
269 | } | |
d525fc39 C |
270 | }) |
271 | ||
272 | it('Should search by licence', async function () { | |
273 | const query = { | |
274 | search: '4444 5555', | |
275 | licenceOneOf: [ 2 ] | |
276 | } | |
d525fc39 | 277 | |
af971e06 C |
278 | { |
279 | const body = await command.advancedVideoSearch({ search: query }) | |
280 | expect(body.total).to.equal(2) | |
281 | expect(body.data[0].name).to.equal('3333 4444 5555') | |
282 | expect(body.data[1].name).to.equal('3333 4444 5555 duplicate') | |
283 | } | |
284 | ||
285 | { | |
286 | const body = await command.advancedVideoSearch({ search: { ...query, licenceOneOf: [ 3 ] } }) | |
287 | expect(body.total).to.equal(0) | |
288 | } | |
d525fc39 C |
289 | }) |
290 | ||
291 | it('Should search by languages', async function () { | |
292 | const query = { | |
293 | search: '1111 2222 3333', | |
294 | languageOneOf: [ 'pl', 'en' ] | |
295 | } | |
d525fc39 | 296 | |
3caf77d3 | 297 | { |
af971e06 C |
298 | const body = await command.advancedVideoSearch({ search: query }) |
299 | expect(body.total).to.equal(2) | |
300 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') | |
301 | expect(body.data[1].name).to.equal('1111 2222 3333 - 4') | |
3caf77d3 C |
302 | } |
303 | ||
304 | { | |
af971e06 C |
305 | const body = await command.advancedVideoSearch({ search: { ...query, languageOneOf: [ 'pl', 'en', '_unknown' ] } }) |
306 | expect(body.total).to.equal(3) | |
307 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') | |
308 | expect(body.data[1].name).to.equal('1111 2222 3333 - 4') | |
309 | expect(body.data[2].name).to.equal('1111 2222 3333 - 5') | |
3caf77d3 C |
310 | } |
311 | ||
312 | { | |
af971e06 C |
313 | const body = await command.advancedVideoSearch({ search: { ...query, languageOneOf: [ 'eo' ] } }) |
314 | expect(body.total).to.equal(0) | |
3caf77d3 | 315 | } |
d525fc39 C |
316 | }) |
317 | ||
318 | it('Should search by start date', async function () { | |
319 | const query = { | |
320 | search: '1111 2222 3333', | |
321 | startDate | |
322 | } | |
323 | ||
af971e06 C |
324 | const body = await command.advancedVideoSearch({ search: query }) |
325 | expect(body.total).to.equal(4) | |
d525fc39 | 326 | |
af971e06 | 327 | const videos = body.data |
d525fc39 C |
328 | expect(videos[0].name).to.equal('1111 2222 3333 - 5') |
329 | expect(videos[1].name).to.equal('1111 2222 3333 - 6') | |
330 | expect(videos[2].name).to.equal('1111 2222 3333 - 7') | |
331 | expect(videos[3].name).to.equal('1111 2222 3333 - 8') | |
332 | }) | |
333 | ||
334 | it('Should make an advanced search', async function () { | |
335 | const query = { | |
336 | search: '1111 2222 3333', | |
337 | languageOneOf: [ 'pl', 'fr' ], | |
338 | durationMax: 4, | |
0b18f4aa | 339 | nsfw: 'false' as 'false', |
d525fc39 C |
340 | licenceOneOf: [ 1, 4 ] |
341 | } | |
342 | ||
af971e06 C |
343 | const body = await command.advancedVideoSearch({ search: query }) |
344 | expect(body.total).to.equal(4) | |
d525fc39 | 345 | |
af971e06 | 346 | const videos = body.data |
d525fc39 C |
347 | expect(videos[0].name).to.equal('1111 2222 3333') |
348 | expect(videos[1].name).to.equal('1111 2222 3333 - 6') | |
349 | expect(videos[2].name).to.equal('1111 2222 3333 - 7') | |
350 | expect(videos[3].name).to.equal('1111 2222 3333 - 8') | |
351 | }) | |
352 | ||
353 | it('Should make an advanced search and sort results', async function () { | |
354 | const query = { | |
355 | search: '1111 2222 3333', | |
356 | languageOneOf: [ 'pl', 'fr' ], | |
357 | durationMax: 4, | |
0b18f4aa | 358 | nsfw: 'false' as 'false', |
d525fc39 C |
359 | licenceOneOf: [ 1, 4 ], |
360 | sort: '-name' | |
361 | } | |
362 | ||
af971e06 C |
363 | const body = await command.advancedVideoSearch({ search: query }) |
364 | expect(body.total).to.equal(4) | |
d525fc39 | 365 | |
af971e06 | 366 | const videos = body.data |
d525fc39 C |
367 | expect(videos[0].name).to.equal('1111 2222 3333 - 8') |
368 | expect(videos[1].name).to.equal('1111 2222 3333 - 7') | |
369 | expect(videos[2].name).to.equal('1111 2222 3333 - 6') | |
370 | expect(videos[3].name).to.equal('1111 2222 3333') | |
371 | }) | |
372 | ||
373 | it('Should make an advanced search and only show the first result', async function () { | |
374 | const query = { | |
375 | search: '1111 2222 3333', | |
376 | languageOneOf: [ 'pl', 'fr' ], | |
377 | durationMax: 4, | |
0b18f4aa | 378 | nsfw: 'false' as 'false', |
d525fc39 C |
379 | licenceOneOf: [ 1, 4 ], |
380 | sort: '-name', | |
381 | start: 0, | |
382 | count: 1 | |
383 | } | |
384 | ||
af971e06 C |
385 | const body = await command.advancedVideoSearch({ search: query }) |
386 | expect(body.total).to.equal(4) | |
d525fc39 | 387 | |
af971e06 | 388 | const videos = body.data |
d525fc39 C |
389 | expect(videos[0].name).to.equal('1111 2222 3333 - 8') |
390 | }) | |
391 | ||
392 | it('Should make an advanced search and only show the last result', async function () { | |
393 | const query = { | |
394 | search: '1111 2222 3333', | |
395 | languageOneOf: [ 'pl', 'fr' ], | |
396 | durationMax: 4, | |
0b18f4aa | 397 | nsfw: 'false' as 'false', |
d525fc39 C |
398 | licenceOneOf: [ 1, 4 ], |
399 | sort: '-name', | |
400 | start: 3, | |
401 | count: 1 | |
402 | } | |
403 | ||
af971e06 C |
404 | const body = await command.advancedVideoSearch({ search: query }) |
405 | expect(body.total).to.equal(4) | |
d525fc39 | 406 | |
af971e06 | 407 | const videos = body.data |
d525fc39 C |
408 | expect(videos[0].name).to.equal('1111 2222 3333') |
409 | }) | |
410 | ||
31d065cc AM |
411 | it('Should search on originally published date', async function () { |
412 | const baseQuery = { | |
413 | search: '1111 2222 3333', | |
414 | languageOneOf: [ 'pl', 'fr' ], | |
415 | durationMax: 4, | |
416 | nsfw: 'false' as 'false', | |
417 | licenceOneOf: [ 1, 4 ] | |
418 | } | |
419 | ||
420 | { | |
6c5065a0 | 421 | const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' } |
af971e06 | 422 | const body = await command.advancedVideoSearch({ search: query }) |
31d065cc | 423 | |
af971e06 C |
424 | expect(body.total).to.equal(1) |
425 | expect(body.data[0].name).to.equal('1111 2222 3333 - 7') | |
31d065cc AM |
426 | } |
427 | ||
428 | { | |
6c5065a0 | 429 | const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' } |
af971e06 | 430 | const body = await command.advancedVideoSearch({ search: query }) |
31d065cc | 431 | |
af971e06 C |
432 | expect(body.total).to.equal(1) |
433 | expect(body.data[0].name).to.equal('1111 2222 3333 - 7') | |
31d065cc AM |
434 | } |
435 | ||
436 | { | |
6c5065a0 | 437 | const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' } |
af971e06 | 438 | const body = await command.advancedVideoSearch({ search: query }) |
31d065cc | 439 | |
af971e06 | 440 | expect(body.total).to.equal(0) |
31d065cc AM |
441 | } |
442 | ||
443 | { | |
6c5065a0 | 444 | const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' } |
af971e06 | 445 | const body = await command.advancedVideoSearch({ search: query }) |
31d065cc | 446 | |
af971e06 | 447 | expect(body.total).to.equal(0) |
31d065cc AM |
448 | } |
449 | ||
450 | { | |
6c5065a0 C |
451 | const query = { |
452 | ...baseQuery, | |
31d065cc AM |
453 | originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', |
454 | originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' | |
6c5065a0 | 455 | } |
af971e06 | 456 | const body = await command.advancedVideoSearch({ search: query }) |
31d065cc | 457 | |
af971e06 | 458 | expect(body.total).to.equal(0) |
31d065cc AM |
459 | } |
460 | ||
461 | { | |
6c5065a0 C |
462 | const query = { |
463 | ...baseQuery, | |
31d065cc AM |
464 | originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', |
465 | originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' | |
6c5065a0 | 466 | } |
af971e06 | 467 | const body = await command.advancedVideoSearch({ search: query }) |
31d065cc | 468 | |
af971e06 C |
469 | expect(body.total).to.equal(1) |
470 | expect(body.data[0].name).to.equal('1111 2222 3333 - 7') | |
31d065cc AM |
471 | } |
472 | }) | |
473 | ||
3cf53828 C |
474 | it('Should search by UUID', async function () { |
475 | const search = videoUUID | |
af971e06 | 476 | const body = await command.advancedVideoSearch({ search: { search } }) |
3cf53828 | 477 | |
af971e06 C |
478 | expect(body.total).to.equal(1) |
479 | expect(body.data[0].name).to.equal('1111 2222 3333 - 3') | |
3cf53828 C |
480 | }) |
481 | ||
29837f88 C |
482 | it('Should search by host', async function () { |
483 | { | |
484 | const body = await command.advancedVideoSearch({ search: { search: '6666 7777 8888', host: server.host } }) | |
485 | expect(body.total).to.equal(1) | |
486 | expect(body.data[0].name).to.equal('6666 7777 8888') | |
487 | } | |
488 | ||
489 | { | |
490 | const body = await command.advancedVideoSearch({ search: { search: '1111', host: 'example.com' } }) | |
491 | expect(body.total).to.equal(0) | |
492 | expect(body.data).to.have.lengthOf(0) | |
493 | } | |
494 | ||
495 | { | |
496 | const body = await command.advancedVideoSearch({ search: { search: 'remote', host: remoteServer.host } }) | |
497 | expect(body.total).to.equal(2) | |
498 | expect(body.data).to.have.lengthOf(2) | |
499 | expect(body.data[0].name).to.equal('remote video 1') | |
500 | expect(body.data[1].name).to.equal('remote video 2') | |
501 | } | |
502 | }) | |
503 | ||
1fd61899 | 504 | it('Should search by live', async function () { |
29837f88 | 505 | this.timeout(60000) |
1fd61899 C |
506 | |
507 | { | |
65e6e260 | 508 | const newConfig = { |
1fd61899 C |
509 | search: { |
510 | searchIndex: { enabled: false } | |
511 | }, | |
512 | live: { enabled: true } | |
513 | } | |
89d241a7 | 514 | await server.config.updateCustomSubConfig({ newConfig }) |
1fd61899 C |
515 | } |
516 | ||
517 | { | |
af971e06 | 518 | const body = await command.advancedVideoSearch({ search: { isLive: true } }) |
1fd61899 | 519 | |
af971e06 C |
520 | expect(body.total).to.equal(0) |
521 | expect(body.data).to.have.lengthOf(0) | |
1fd61899 C |
522 | } |
523 | ||
524 | { | |
89d241a7 | 525 | const liveCommand = server.live |
4f219914 | 526 | |
89d241a7 | 527 | const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.store.channel.id } |
04aed767 | 528 | const live = await liveCommand.create({ fields: liveAttributes }) |
1fd61899 | 529 | |
4f219914 | 530 | const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id }) |
04aed767 | 531 | await liveCommand.waitUntilPublished({ videoId: live.id }) |
1fd61899 | 532 | |
af971e06 | 533 | const body = await command.advancedVideoSearch({ search: { isLive: true } }) |
1fd61899 | 534 | |
af971e06 C |
535 | expect(body.total).to.equal(1) |
536 | expect(body.data[0].name).to.equal('live') | |
1fd61899 | 537 | |
af971e06 | 538 | await stopFfmpeg(ffmpegCommand) |
1fd61899 C |
539 | } |
540 | }) | |
541 | ||
7c3b7976 C |
542 | after(async function () { |
543 | await cleanupTests([ server ]) | |
d525fc39 C |
544 | }) |
545 | }) |