aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 09:43:59 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit6c5065a011b099618681a37bd77eaa7bd3db752e (patch)
tree352252a00b25013c4b1902f6bcd9668aba295c7b /server/tests/api/search/search-videos.ts
parent0d8ecb7592577f54012413a2b5a9b159cfc90399 (diff)
downloadPeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.gz
PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.tar.zst
PeerTube-6c5065a011b099618681a37bd77eaa7bd3db752e.zip
Introduce server commands
Diffstat (limited to 'server/tests/api/search/search-videos.ts')
-rw-r--r--server/tests/api/search/search-videos.ts46
1 files changed, 22 insertions, 24 deletions
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 513538917..66f5f3182 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -5,7 +5,6 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunServer, 7 flushAndRunServer,
8 immutableAssign,
9 SearchCommand, 8 SearchCommand,
10 ServerInfo, 9 ServerInfo,
11 setAccessTokensToServers, 10 setAccessTokensToServers,
@@ -44,11 +43,11 @@ describe('Test videos search', function () {
44 } 43 }
45 await uploadVideo(server.url, server.accessToken, attributes1) 44 await uploadVideo(server.url, server.accessToken, attributes1)
46 45
47 const attributes2 = immutableAssign(attributes1, { name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }) 46 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
48 await uploadVideo(server.url, server.accessToken, attributes2) 47 await uploadVideo(server.url, server.accessToken, attributes2)
49 48
50 { 49 {
51 const attributes3 = immutableAssign(attributes1, { name: attributes1.name + ' - 3', language: undefined }) 50 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
52 const res = await uploadVideo(server.url, server.accessToken, attributes3) 51 const res = await uploadVideo(server.url, server.accessToken, attributes3)
53 const videoId = res.body.video.id 52 const videoId = res.body.video.id
54 videoUUID = res.body.video.uuid 53 videoUUID = res.body.video.uuid
@@ -68,26 +67,23 @@ describe('Test videos search', function () {
68 }) 67 })
69 } 68 }
70 69
71 const attributes4 = immutableAssign(attributes1, { name: attributes1.name + ' - 4', language: 'pl', nsfw: true }) 70 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
72 await uploadVideo(server.url, server.accessToken, attributes4) 71 await uploadVideo(server.url, server.accessToken, attributes4)
73 72
74 await wait(1000) 73 await wait(1000)
75 74
76 startDate = new Date().toISOString() 75 startDate = new Date().toISOString()
77 76
78 const attributes5 = immutableAssign(attributes1, { name: attributes1.name + ' - 5', licence: 2, language: undefined }) 77 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
79 await uploadVideo(server.url, server.accessToken, attributes5) 78 await uploadVideo(server.url, server.accessToken, attributes5)
80 79
81 const attributes6 = immutableAssign(attributes1, { name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }) 80 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
82 await uploadVideo(server.url, server.accessToken, attributes6) 81 await uploadVideo(server.url, server.accessToken, attributes6)
83 82
84 const attributes7 = immutableAssign(attributes1, { 83 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
85 name: attributes1.name + ' - 7',
86 originallyPublishedAt: '2019-02-12T09:58:08.286Z'
87 })
88 await uploadVideo(server.url, server.accessToken, attributes7) 84 await uploadVideo(server.url, server.accessToken, attributes7)
89 85
90 const attributes8 = immutableAssign(attributes1, { name: attributes1.name + ' - 8', licence: 4 }) 86 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
91 await uploadVideo(server.url, server.accessToken, attributes8) 87 await uploadVideo(server.url, server.accessToken, attributes8)
92 } 88 }
93 89
@@ -101,7 +97,7 @@ describe('Test videos search', function () {
101 } 97 }
102 await uploadVideo(server.url, server.accessToken, attributes) 98 await uploadVideo(server.url, server.accessToken, attributes)
103 99
104 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes, { name: attributes.name + ' duplicate' })) 100 await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' })
105 } 101 }
106 102
107 { 103 {
@@ -122,10 +118,10 @@ describe('Test videos search', function () {
122 category: 1 118 category: 1
123 } 119 }
124 await uploadVideo(server.url, server.accessToken, attributes1) 120 await uploadVideo(server.url, server.accessToken, attributes1)
125 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) 121 await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 })
126 122
127 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'cccc', 'dddd' ] })) 123 await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] })
128 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { tags: [ 'eeee', 'ffff' ] })) 124 await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] })
129 } 125 }
130 126
131 { 127 {
@@ -134,7 +130,7 @@ describe('Test videos search', function () {
134 category: 1 130 category: 1
135 } 131 }
136 await uploadVideo(server.url, server.accessToken, attributes1) 132 await uploadVideo(server.url, server.accessToken, attributes1)
137 await uploadVideo(server.url, server.accessToken, immutableAssign(attributes1, { category: 2 })) 133 await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 })
138 } 134 }
139 135
140 command = server.searchCommand 136 command = server.searchCommand
@@ -414,7 +410,7 @@ describe('Test videos search', function () {
414 } 410 }
415 411
416 { 412 {
417 const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }) 413 const query = { ...baseQuery, originallyPublishedStartDate: '2019-02-11T09:58:08.286Z' }
418 const body = await command.advancedVideoSearch({ search: query }) 414 const body = await command.advancedVideoSearch({ search: query })
419 415
420 expect(body.total).to.equal(1) 416 expect(body.total).to.equal(1)
@@ -422,7 +418,7 @@ describe('Test videos search', function () {
422 } 418 }
423 419
424 { 420 {
425 const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }) 421 const query = { ...baseQuery, originallyPublishedEndDate: '2019-03-11T09:58:08.286Z' }
426 const body = await command.advancedVideoSearch({ search: query }) 422 const body = await command.advancedVideoSearch({ search: query })
427 423
428 expect(body.total).to.equal(1) 424 expect(body.total).to.equal(1)
@@ -430,34 +426,36 @@ describe('Test videos search', function () {
430 } 426 }
431 427
432 { 428 {
433 const query = immutableAssign(baseQuery, { originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }) 429 const query = { ...baseQuery, originallyPublishedEndDate: '2019-01-11T09:58:08.286Z' }
434 const body = await command.advancedVideoSearch({ search: query }) 430 const body = await command.advancedVideoSearch({ search: query })
435 431
436 expect(body.total).to.equal(0) 432 expect(body.total).to.equal(0)
437 } 433 }
438 434
439 { 435 {
440 const query = immutableAssign(baseQuery, { originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }) 436 const query = { ...baseQuery, originallyPublishedStartDate: '2019-03-11T09:58:08.286Z' }
441 const body = await command.advancedVideoSearch({ search: query }) 437 const body = await command.advancedVideoSearch({ search: query })
442 438
443 expect(body.total).to.equal(0) 439 expect(body.total).to.equal(0)
444 } 440 }
445 441
446 { 442 {
447 const query = immutableAssign(baseQuery, { 443 const query = {
444 ...baseQuery,
448 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', 445 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
449 originallyPublishedEndDate: '2019-01-10T09:58:08.286Z' 446 originallyPublishedEndDate: '2019-01-10T09:58:08.286Z'
450 }) 447 }
451 const body = await command.advancedVideoSearch({ search: query }) 448 const body = await command.advancedVideoSearch({ search: query })
452 449
453 expect(body.total).to.equal(0) 450 expect(body.total).to.equal(0)
454 } 451 }
455 452
456 { 453 {
457 const query = immutableAssign(baseQuery, { 454 const query = {
455 ...baseQuery,
458 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z', 456 originallyPublishedStartDate: '2019-01-11T09:58:08.286Z',
459 originallyPublishedEndDate: '2019-04-11T09:58:08.286Z' 457 originallyPublishedEndDate: '2019-04-11T09:58:08.286Z'
460 }) 458 }
461 const body = await command.advancedVideoSearch({ search: query }) 459 const body = await command.advancedVideoSearch({ search: query })
462 460
463 expect(body.total).to.equal(1) 461 expect(body.total).to.equal(1)