aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
committerChocobozzz <me@florianbigard.com>2021-07-21 15:51:30 +0200
commita24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch)
treea54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/search/search-videos.ts
parent5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff)
parentc63830f15403ac4e750829f27d8bbbdc9a59282c (diff)
downloadPeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst
PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/search/search-videos.ts')
-rw-r--r--server/tests/api/search/search-videos.ts331
1 files changed, 172 insertions, 159 deletions
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 5b8907961..965766742 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -2,37 +2,31 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoPrivacy } from '@shared/models'
6import { 5import {
7 advancedVideosSearch,
8 cleanupTests, 6 cleanupTests,
9 createLive, 7 createSingleServer,
10 flushAndRunServer, 8 PeerTubeServer,
11 immutableAssign, 9 SearchCommand,
12 searchVideo,
13 sendRTMPStreamInVideo,
14 ServerInfo,
15 setAccessTokensToServers, 10 setAccessTokensToServers,
16 setDefaultVideoChannel, 11 setDefaultVideoChannel,
17 stopFfmpeg, 12 stopFfmpeg,
18 updateCustomSubConfig, 13 wait
19 uploadVideo, 14} from '@shared/extra-utils'
20 wait, 15import { VideoPrivacy } from '@shared/models'
21 waitUntilLivePublished
22} from '../../../../shared/extra-utils'
23import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions'
24 16
25const expect = chai.expect 17const expect = chai.expect
26 18
27describe('Test videos search', function () { 19describe('Test videos search', function () {
28 let server: ServerInfo = null 20 let server: PeerTubeServer = null
29 let startDate: string 21 let startDate: string
30 let videoUUID: string 22 let videoUUID: string
31 23
24 let command: SearchCommand
25
32 before(async function () { 26 before(async function () {
33 this.timeout(60000) 27 this.timeout(60000)
34 28
35 server = await flushAndRunServer(1) 29 server = await createSingleServer(1)
36 30
37 await setAccessTokensToServers([ server ]) 31 await setAccessTokensToServers([ server ])
38 await setDefaultVideoChannel([ server ]) 32 await setDefaultVideoChannel([ server ])
@@ -46,57 +40,49 @@ describe('Test videos search', function () {
46 nsfw: false, 40 nsfw: false,
47 language: 'fr' 41 language: 'fr'
48 } 42 }
49 await uploadVideo(server.url, server.accessToken, attributes1) 43 await server.videos.upload({ attributes: attributes1 })
50 44
51 const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) 45 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
52 await uploadVideo(server.url, server.accessToken, attributes2) 46 await server.videos.upload({ attributes: attributes2 })
53 47
54 { 48 {
55 const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined }) 49 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
56 const res = await uploadVideo(server.url, server.accessToken, attributes3) 50 const { id, uuid } = await server.videos.upload({ attributes: attributes3 })
57 const videoId = res.body.video.id 51 videoUUID = uuid
58 videoUUID = res.body.video.uuid 52
59 53 await server.captions.add({
60 await createVideoCaption({
61 url: server.url,
62 accessToken: server.accessToken,
63 language: 'en', 54 language: 'en',
64 videoId, 55 videoId: id,
65 fixture: 'subtitle-good2.vtt', 56 fixture: 'subtitle-good2.vtt',
66 mimeType: 'application/octet-stream' 57 mimeType: 'application/octet-stream'
67 }) 58 })
68 59
69 await createVideoCaption({ 60 await server.captions.add({
70 url: server.url,
71 accessToken: server.accessToken,
72 language: 'aa', 61 language: 'aa',
73 videoId, 62 videoId: id,
74 fixture: 'subtitle-good2.vtt', 63 fixture: 'subtitle-good2.vtt',
75 mimeType: 'application/octet-stream' 64 mimeType: 'application/octet-stream'
76 }) 65 })
77 } 66 }
78 67
79 const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) 68 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
80 await uploadVideo(server.url, server.accessToken, attributes4) 69 await server.videos.upload({ attributes: attributes4 })
81 70
82 await wait(1000) 71 await wait(1000)
83 72
84 startDate = new Date().toISOString() 73 startDate = new Date().toISOString()
85 74
86 const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) 75 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
87 await uploadVideo(server.url, server.accessToken, attributes5) 76 await server.videos.upload({ attributes: attributes5 })
88 77
89 const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }) 78 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
90 await uploadVideo(server.url, server.accessToken, attributes6) 79 await server.videos.upload({ attributes: attributes6 })
91 80
92 const attributes7 = immutableAssign(attributes1, { 81 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
93 name: attributes1.name + ' - 7', 82 await server.videos.upload({ attributes: attributes7 })
94 originallyPublishedAt: '2019-02-12T09:58:08.286Z'
95 })
96 await uploadVideo(server.url, server.accessToken, attributes7)
97 83
98 const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) 84 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
99 await uploadVideo(server.url, server.accessToken, attributes8) 85 await server.videos.upload({ attributes: attributes8 })
100 } 86 }
101 87
102 { 88 {
@@ -107,9 +93,9 @@ describe('Test videos search', function () {
107 licence: 2, 93 licence: 2,
108 language: 'en' 94 language: 'en'
109 } 95 }
110 await uploadVideo(server.url, server.accessToken, attributes) 96 await server.videos.upload({ attributes: attributes })
111 97
112 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes, { name: attributes.name + ' duplicate' })) 98 await server.videos.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
113 } 99 }
114 100
115 { 101 {
@@ -120,7 +106,7 @@ describe('Test videos search', function () {
120 licence: 3, 106 licence: 3,
121 language: 'pl' 107 language: 'pl'
122 } 108 }
123 await uploadVideo(server.url, server.accessToken, attributes) 109 await server.videos.upload({ attributes: attributes })
124 } 110 }
125 111
126 { 112 {
@@ -129,11 +115,11 @@ describe('Test videos search', function () {
129 tags: [ 'aaaa', 'bbbb', 'cccc' ], 115 tags: [ 'aaaa', 'bbbb', 'cccc' ],
130 category: 1 116 category: 1
131 } 117 }
132 await uploadVideo(server.url, server.accessToken, attributes1) 118 await server.videos.upload({ attributes: attributes1 })
133 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) 119 await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
134 120
135 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] })) 121 await server.videos.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
136 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] })) 122 await server.videos.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
137 } 123 }
138 124
139 { 125 {
@@ -141,24 +127,26 @@ describe('Test videos search', function () {
141 name: 'aaaa 2', 127 name: 'aaaa 2',
142 category: 1 128 category: 1
143 } 129 }
144 await uploadVideo(server.url, server.accessToken, attributes1) 130 await server.videos.upload({ attributes: attributes1 })
145 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) 131 await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
146 } 132 }
133
134 command = server.search
147 }) 135 })
148 136
149 it('Should make a simple search and not have results', async function () { 137 it('Should make a simple search and not have results', async function () {
150 const res = await searchVideo(server.url, 'abc') 138 const body = await command.searchVideos({ search: 'abc' })
151 139
152 expect(res.body.total).to.equal(0) 140 expect(body.total).to.equal(0)
153 expect(res.body.data).to.have.lengthOf(0) 141 expect(body.data).to.have.lengthOf(0)
154 }) 142 })
155 143
156 it('Should make a simple search and have results', async function () { 144 it('Should make a simple search and have results', async function () {
157 const res = await searchVideo(server.url, '4444 5555 duplicate') 145 const body = await command.searchVideos({ search: '4444 5555 duplicate' })
158 146
159 expect(res.body.total).to.equal(2) 147 expect(body.total).to.equal(2)
160 148
161 const videos = res.body.data 149 const videos = body.data
162 expect(videos).to.have.lengthOf(2) 150 expect(videos).to.have.lengthOf(2)
163 151
164 // bestmatch 152 // bestmatch
@@ -167,15 +155,15 @@ describe('Test videos search', function () {
167 }) 155 })
168 156
169 it('Should make a search on tags too, and have results', async function () { 157 it('Should make a search on tags too, and have results', async function () {
170 const query = { 158 const search = {
171 search: 'aaaa', 159 search: 'aaaa',
172 categoryOneOf: [ 1 ] 160 categoryOneOf: [ 1 ]
173 } 161 }
174 const res = await advancedVideosSearch(server.url, query) 162 const body = await command.advancedVideoSearch({ search })
175 163
176 expect(res.body.total).to.equal(2) 164 expect(body.total).to.equal(2)
177 165
178 const videos = res.body.data 166 const videos = body.data
179 expect(videos).to.have.lengthOf(2) 167 expect(videos).to.have.lengthOf(2)
180 168
181 // bestmatch 169 // bestmatch
@@ -184,14 +172,14 @@ describe('Test videos search', function () {
184 }) 172 })
185 173
186 it('Should filter on tags without a search', async function () { 174 it('Should filter on tags without a search', async function () {
187 const query = { 175 const search = {
188 tagsAllOf: [ 'bbbb' ] 176 tagsAllOf: [ 'bbbb' ]
189 } 177 }
190 const res = await advancedVideosSearch(server.url, query) 178 const body = await command.advancedVideoSearch({ search })
191 179
192 expect(res.body.total).to.equal(2) 180 expect(body.total).to.equal(2)
193 181
194 const videos = res.body.data 182 const videos = body.data
195 expect(videos).to.have.lengthOf(2) 183 expect(videos).to.have.lengthOf(2)
196 184
197 expect(videos[0].name).to.equal('9999') 185 expect(videos[0].name).to.equal('9999')
@@ -199,14 +187,14 @@ describe('Test videos search', function () {
199 }) 187 })
200 188
201 it('Should filter on category without a search', async function () { 189 it('Should filter on category without a search', async function () {
202 const query = { 190 const search = {
203 categoryOneOf: [ 3 ] 191 categoryOneOf: [ 3 ]
204 } 192 }
205 const res = await advancedVideosSearch(server.url, query) 193 const body = await command.advancedVideoSearch({ search: search })
206 194
207 expect(res.body.total).to.equal(1) 195 expect(body.total).to.equal(1)
208 196
209 const videos = res.body.data 197 const videos = body.data
210 expect(videos).to.have.lengthOf(1) 198 expect(videos).to.have.lengthOf(1)
211 199
212 expect(videos[0].name).to.equal('6666 7777 8888') 200 expect(videos[0].name).to.equal('6666 7777 8888')
@@ -218,11 +206,16 @@ describe('Test videos search', function () {
218 categoryOneOf: [ 1 ], 206 categoryOneOf: [ 1 ],
219 tagsOneOf: [ 'aAaa', 'ffff' ] 207 tagsOneOf: [ 'aAaa', 'ffff' ]
220 } 208 }
221 const res1 = await advancedVideosSearch(server.url, query)
222 expect(res1.body.total).to.equal(2)
223 209
224 const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsOneOf: [ 'blabla' ] })) 210 {
225 expect(res2.body.total).to.equal(0) 211 const body = await command.advancedVideoSearch({ search: query })
212 expect(body.total).to.equal(2)
213 }
214
215 {
216 const body = await command.advancedVideoSearch({ search: { ...query, tagsOneOf: [ 'blabla' ] } })
217 expect(body.total).to.equal(0)
218 }
226 }) 219 })
227 220
228 it('Should search by tags (all of)', async function () { 221 it('Should search by tags (all of)', async function () {
@@ -231,14 +224,21 @@ describe('Test videos search', function () {
231 categoryOneOf: [ 1 ], 224 categoryOneOf: [ 1 ],
232 tagsAllOf: [ 'CCcc' ] 225 tagsAllOf: [ 'CCcc' ]
233 } 226 }
234 const res1 = await advancedVideosSearch(server.url, query)
235 expect(res1.body.total).to.equal(2)
236 227
237 const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'blAbla' ] })) 228 {
238 expect(res2.body.total).to.equal(0) 229 const body = await command.advancedVideoSearch({ search: query })
230 expect(body.total).to.equal(2)
231 }
239 232
240 const res3 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'bbbb', 'CCCC' ] })) 233 {
241 expect(res3.body.total).to.equal(1) 234 const body = await command.advancedVideoSearch({ search: { ...query, tagsAllOf: [ 'blAbla' ] } })
235 expect(body.total).to.equal(0)
236 }
237
238 {
239 const body = await command.advancedVideoSearch({ search: { ...query, tagsAllOf: [ 'bbbb', 'CCCC' ] } })
240 expect(body.total).to.equal(1)
241 }
242 }) 242 })
243 243
244 it('Should search by category', async function () { 244 it('Should search by category', async function () {
@@ -246,12 +246,17 @@ describe('Test videos search', function () {
246 search: '6666', 246 search: '6666',
247 categoryOneOf: [ 3 ] 247 categoryOneOf: [ 3 ]
248 } 248 }
249 const res1 = await advancedVideosSearch(server.url, query)
250 expect(res1.body.total).to.equal(1)
251 expect(res1.body.data[0].name).to.equal('6666 7777 8888')
252 249
253 const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { categoryOneOf: [ 2 ] })) 250 {
254 expect(res2.body.total).to.equal(0) 251 const body = await command.advancedVideoSearch({ search: query })
252 expect(body.total).to.equal(1)
253 expect(body.data[0].name).to.equal('6666 7777 8888')
254 }
255
256 {
257 const body = await command.advancedVideoSearch({ search: { ...query, categoryOneOf: [ 2 ] } })
258 expect(body.total).to.equal(0)
259 }
255 }) 260 })
256 261
257 it('Should search by licence', async function () { 262 it('Should search by licence', async function () {
@@ -259,13 +264,18 @@ describe('Test videos search', function () {
259 search: '4444 5555', 264 search: '4444 5555',
260 licenceOneOf: [ 2 ] 265 licenceOneOf: [ 2 ]
261 } 266 }
262 const res1 = await advancedVideosSearch(server.url, query)
263 expect(res1.body.total).to.equal(2)
264 expect(res1.body.data[0].name).to.equal('3333 4444 5555')
265 expect(res1.body.data[1].name).to.equal('3333 4444 5555 duplicate')
266 267
267 const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { licenceOneOf: [ 3 ] })) 268 {
268 expect(res2.body.total).to.equal(0) 269 const body = await command.advancedVideoSearch({ search: query })
270 expect(body.total).to.equal(2)
271 expect(body.data[0].name).to.equal('3333 4444 5555')
272 expect(body.data[1].name).to.equal('3333 4444 5555 duplicate')
273 }
274
275 {
276 const body = await command.advancedVideoSearch({ search: { ...query, licenceOneOf: [ 3 ] } })
277 expect(body.total).to.equal(0)
278 }
269 }) 279 })
270 280
271 it('Should search by languages', async function () { 281 it('Should search by languages', async function () {
@@ -275,23 +285,23 @@ describe('Test videos search', function () {
275 } 285 }
276 286
277 { 287 {
278 const res = await advancedVideosSearch(server.url, query) 288 const body = await command.advancedVideoSearch({ search: query })
279 expect(res.body.total).to.equal(2) 289 expect(body.total).to.equal(2)
280 expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') 290 expect(body.data[0].name).to.equal('1111 2222 3333 - 3')
281 expect(res.body.data[1].name).to.equal('1111 2222 3333 - 4') 291 expect(body.data[1].name).to.equal('1111 2222 3333 - 4')
282 } 292 }
283 293
284 { 294 {
285 const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'pl', 'en', '_unknown' ] })) 295 const body = await command.advancedVideoSearch({ search: { ...query, languageOneOf: [ 'pl', 'en', '_unknown' ] } })
286 expect(res.body.total).to.equal(3) 296 expect(body.total).to.equal(3)
287 expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') 297 expect(body.data[0].name).to.equal('1111 2222 3333 - 3')
288 expect(res.body.data[1].name).to.equal('1111 2222 3333 - 4') 298 expect(body.data[1].name).to.equal('1111 2222 3333 - 4')
289 expect(res.body.data[2].name).to.equal('1111 2222 3333 - 5') 299 expect(body.data[2].name).to.equal('1111 2222 3333 - 5')
290 } 300 }
291 301
292 { 302 {
293 const res = await advancedVideosSearch(server.url, immutableAssign(query, { languageOneOf: [ 'eo' ] })) 303 const body = await command.advancedVideoSearch({ search: { ...query, languageOneOf: [ 'eo' ] } })
294 expect(res.body.total).to.equal(0) 304 expect(body.total).to.equal(0)
295 } 305 }
296 }) 306 })
297 307
@@ -301,10 +311,10 @@ describe('Test videos search', function () {
301 startDate 311 startDate
302 } 312 }
303 313
304 const res = await advancedVideosSearch(server.url, query) 314 const body = await command.advancedVideoSearch({ search: query })
305 expect(res.body.total).to.equal(4) 315 expect(body.total).to.equal(4)
306 316
307 const videos = res.body.data 317 const videos = body.data
308 expect(videos[0].name).to.equal('1111 2222 3333 - 5') 318 expect(videos[0].name).to.equal('1111 2222 3333 - 5')
309 expect(videos[1].name).to.equal('1111 2222 3333 - 6') 319 expect(videos[1].name).to.equal('1111 2222 3333 - 6')
310 expect(videos[2].name).to.equal('1111 2222 3333 - 7') 320 expect(videos[2].name).to.equal('1111 2222 3333 - 7')
@@ -320,10 +330,10 @@ describe('Test videos search', function () {
320 licenceOneOf: [ 1, 4 ] 330 licenceOneOf: [ 1, 4 ]
321 } 331 }
322 332
323 const res = await advancedVideosSearch(server.url, query) 333 const body = await command.advancedVideoSearch({ search: query })
324 expect(res.body.total).to.equal(4) 334 expect(body.total).to.equal(4)
325 335
326 const videos = res.body.data 336 const videos = body.data
327 expect(videos[0].name).to.equal('1111 2222 3333') 337 expect(videos[0].name).to.equal('1111 2222 3333')
328 expect(videos[1].name).to.equal('1111 2222 3333 - 6') 338 expect(videos[1].name).to.equal('1111 2222 3333 - 6')
329 expect(videos[2].name).to.equal('1111 2222 3333 - 7') 339 expect(videos[2].name).to.equal('1111 2222 3333 - 7')
@@ -340,10 +350,10 @@ describe('Test videos search', function () {
340 sort: '-name' 350 sort: '-name'
341 } 351 }
342 352
343 const res = await advancedVideosSearch(server.url, query) 353 const body = await command.advancedVideoSearch({ search: query })
344 expect(res.body.total).to.equal(4) 354 expect(body.total).to.equal(4)
345 355
346 const videos = res.body.data 356 const videos = body.data
347 expect(videos[0].name).to.equal('1111 2222 3333 - 8') 357 expect(videos[0].name).to.equal('1111 2222 3333 - 8')
348 expect(videos[1].name).to.equal('1111 2222 3333 - 7') 358 expect(videos[1].name).to.equal('1111 2222 3333 - 7')
349 expect(videos[2].name).to.equal('1111 2222 3333 - 6') 359 expect(videos[2].name).to.equal('1111 2222 3333 - 6')
@@ -362,10 +372,10 @@ describe('Test videos search', function () {
362 count: 1 372 count: 1
363 } 373 }
364 374
365 const res = await advancedVideosSearch(server.url, query) 375 const body = await command.advancedVideoSearch({ search: query })
366 expect(res.body.total).to.equal(4) 376 expect(body.total).to.equal(4)
367 377
368 const videos = res.body.data 378 const videos = body.data
369 expect(videos[0].name).to.equal('1111 2222 3333 - 8') 379 expect(videos[0].name).to.equal('1111 2222 3333 - 8')
370 }) 380 })
371 381
@@ -381,10 +391,10 @@ describe('Test videos search', function () {
381 count: 1 391 count: 1
382 } 392 }
383 393
384 const res = await advancedVideosSearch(server.url, query) 394 const body = await command.advancedVideoSearch({ search: query })
385 expect(res.body.total).to.equal(4) 395 expect(body.total).to.equal(4)
386 396
387 const videos = res.body.data 397 const videos = body.data
388 expect(videos[0].name).to.equal('1111 2222 3333') 398 expect(videos[0].name).to.equal('1111 2222 3333')
389 }) 399 })
390 400
@@ -398,99 +408,102 @@ describe('Test videos search', function () {
398 } 408 }
399 409
400 { 410 {
401 const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) 411 const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }
402 const res = await advancedVideosSearch(server.url, query) 412 const body = await command.advancedVideoSearch({ search: query })
403 413
404 expect(res.body.total).to.equal(1) 414 expect(body.total).to.equal(1)
405 expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') 415 expect(body.data[0].name).to.equal('1111 2222 3333 - 7')
406 } 416 }
407 417
408 { 418 {
409 const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) 419 const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }
410 const res = await advancedVideosSearch(server.url, query) 420 const body = await command.advancedVideoSearch({ search: query })
411 421
412 expect(res.body.total).to.equal(1) 422 expect(body.total).to.equal(1)
413 expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') 423 expect(body.data[0].name).to.equal('1111 2222 3333 - 7')
414 } 424 }
415 425
416 { 426 {
417 const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) 427 const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }
418 const res = await advancedVideosSearch(server.url, query) 428 const body = await command.advancedVideoSearch({ search: query })
419 429
420 expect(res.body.total).to.equal(0) 430 expect(body.total).to.equal(0)
421 } 431 }
422 432
423 { 433 {
424 const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) 434 const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }
425 const res = await advancedVideosSearch(server.url, query) 435 const body = await command.advancedVideoSearch({ search: query })
426 436
427 expect(res.body.total).to.equal(0) 437 expect(body.total).to.equal(0)
428 } 438 }
429 439
430 { 440 {
431 const query = immutableAssign(baseQuery, { 441 const query = {
442 ...baseQuery,
432 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', 443 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
433 originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' 444 originallyPublishedEndDate: '2019-01-10T09:58:08.286Z'
434 }) 445 }
435 const res = await advancedVideosSearch(server.url, query) 446 const body = await command.advancedVideoSearch({ search: query })
436 447
437 expect(res.body.total).to.equal(0) 448 expect(body.total).to.equal(0)
438 } 449 }
439 450
440 { 451 {
441 const query = immutableAssign(baseQuery, { 452 const query = {
453 ...baseQuery,
442 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', 454 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
443 originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' 455 originallyPublishedEndDate: '2019-04-11T09:58:08.286Z'
444 }) 456 }
445 const res = await advancedVideosSearch(server.url, query) 457 const body = await command.advancedVideoSearch({ search: query })
446 458
447 expect(res.body.total).to.equal(1) 459 expect(body.total).to.equal(1)
448 expect(res.body.data[0].name).to.equal('1111 2222 3333 - 7') 460 expect(body.data[0].name).to.equal('1111 2222 3333 - 7')
449 } 461 }
450 }) 462 })
451 463
452 it('Should search by UUID', async function () { 464 it('Should search by UUID', async function () {
453 const search = videoUUID 465 const search = videoUUID
454 const res = await advancedVideosSearch(server.url, { search }) 466 const body = await command.advancedVideoSearch({ search: { search } })
455 467
456 expect(res.body.total).to.equal(1) 468 expect(body.total).to.equal(1)
457 expect(res.body.data[0].name).to.equal('1111 2222 3333 - 3') 469 expect(body.data[0].name).to.equal('1111 2222 3333 - 3')
458 }) 470 })
459 471
460 it('Should search by live', async function () { 472 it('Should search by live', async function () {
461 this.timeout(30000) 473 this.timeout(30000)
462 474
463 { 475 {
464 const options = { 476 const newConfig = {
465 search: { 477 search: {
466 searchIndex: { enabled: false } 478 searchIndex: { enabled: false }
467 }, 479 },
468 live: { enabled: true } 480 live: { enabled: true }
469 } 481 }
470 await updateCustomSubConfig(server.url, server.accessToken, options) 482 await server.config.updateCustomSubConfig({ newConfig })
471 } 483 }
472 484
473 { 485 {
474 const res = await advancedVideosSearch(server.url, { isLive: true }) 486 const body = await command.advancedVideoSearch({ search: { isLive: true } })
475 487
476 expect(res.body.total).to.equal(0) 488 expect(body.total).to.equal(0)
477 expect(res.body.data).to.have.lengthOf(0) 489 expect(body.data).to.have.lengthOf(0)
478 } 490 }
479 491
480 { 492 {
481 const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } 493 const liveCommand = server.live
482 const resLive = await createLive(server.url, server.accessToken, liveOptions) 494
483 const liveVideoId = resLive.body.video.uuid 495 const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.store.channel.id }
496 const live = await liveCommand.create({ fields: liveAttributes })
484 497
485 const command = await sendRTMPStreamInVideo(server.url, server.accessToken, liveVideoId) 498 const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id })
486 await waitUntilLivePublished(server.url, server.accessToken, liveVideoId) 499 await liveCommand.waitUntilPublished({ videoId: live.id })
487 500
488 const res = await advancedVideosSearch(server.url, { isLive: true }) 501 const body = await command.advancedVideoSearch({ search: { isLive: true } })
489 502
490 expect(res.body.total).to.equal(1) 503 expect(body.total).to.equal(1)
491 expect(res.body.data[0].name).to.equal('live') 504 expect(body.data[0].name).to.equal('live')
492 505
493 await stopFfmpeg(command) 506 await stopFfmpeg(ffmpegCommand)
494 } 507 }
495 }) 508 })
496 509