aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/search')
-rw-r--r--server/tests/api/search/search-activitypub-video-channels.ts37
-rw-r--r--server/tests/api/search/search-activitypub-video-playlists.ts9
-rw-r--r--server/tests/api/search/search-activitypub-videos.ts32
-rw-r--r--server/tests/api/search/search-index.ts4
-rw-r--r--server/tests/api/search/search-playlists.ts9
-rw-r--r--server/tests/api/search/search-videos.ts42
6 files changed, 64 insertions, 69 deletions
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index bcc21381c..75794402d 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -5,12 +5,9 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunMultipleServers, 7 flushAndRunMultipleServers,
8 getVideoChannelVideos,
9 SearchCommand, 8 SearchCommand,
10 ServerInfo, 9 ServerInfo,
11 setAccessTokensToServers, 10 setAccessTokensToServers,
12 updateVideo,
13 uploadVideo,
14 wait, 11 wait,
15 waitJobs 12 waitJobs
16} from '@shared/extra-utils' 13} from '@shared/extra-utils'
@@ -53,8 +50,9 @@ describe('Test ActivityPub video channels search', function () {
53 const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel }) 50 const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel })
54 channelIdServer2 = created.id 51 channelIdServer2 = created.id
55 52
56 const res = await uploadVideo(servers[1].url, userServer2Token, { name: 'video 1 server 2', channelId: channelIdServer2 }) 53 const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 }
57 videoServer2UUID = res.body.video.uuid 54 const { uuid } = await servers[1].videosCommand.upload({ token: userServer2Token, attributes })
55 videoServer2UUID = uuid
58 } 56 }
59 57
60 await waitJobs(servers) 58 await waitJobs(servers)
@@ -149,16 +147,21 @@ describe('Test ActivityPub video channels search', function () {
149 147
150 await waitJobs(servers) 148 await waitJobs(servers)
151 149
152 const res = await getVideoChannelVideos(servers[0].url, null, 'channel1_server2@localhost:' + servers[1].port, 0, 5) 150 const { total, data } = await servers[0].videosCommand.listByChannel({
153 expect(res.body.total).to.equal(0) 151 token: null,
154 expect(res.body.data).to.have.lengthOf(0) 152 videoChannelName: 'channel1_server2@localhost:' + servers[1].port
153 })
154 expect(total).to.equal(0)
155 expect(data).to.have.lengthOf(0)
155 }) 156 })
156 157
157 it('Should list video channel videos of server 2 with token', async function () { 158 it('Should list video channel videos of server 2 with token', async function () {
158 const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, 'channel1_server2@localhost:' + servers[1].port, 0, 5) 159 const { total, data } = await servers[0].videosCommand.listByChannel({
160 videoChannelName: 'channel1_server2@localhost:' + servers[1].port
161 })
159 162
160 expect(res.body.total).to.equal(1) 163 expect(total).to.equal(1)
161 expect(res.body.data[0].name).to.equal('video 1 server 2') 164 expect(data[0].name).to.equal('video 1 server 2')
162 }) 165 })
163 166
164 it('Should update video channel of server 2, and refresh it on server 1', async function () { 167 it('Should update video channel of server 2, and refresh it on server 1', async function () {
@@ -190,8 +193,8 @@ describe('Test ActivityPub video channels search', function () {
190 it('Should update and add a video on server 2, and update it on server 1 after a search', async function () { 193 it('Should update and add a video on server 2, and update it on server 1 after a search', async function () {
191 this.timeout(60000) 194 this.timeout(60000)
192 195
193 await updateVideo(servers[1].url, userServer2Token, videoServer2UUID, { name: 'video 1 updated' }) 196 await servers[1].videosCommand.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } })
194 await uploadVideo(servers[1].url, userServer2Token, { name: 'video 2 server 2', channelId: channelIdServer2 }) 197 await servers[1].videosCommand.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } })
195 198
196 await waitJobs(servers) 199 await waitJobs(servers)
197 200
@@ -204,11 +207,11 @@ describe('Test ActivityPub video channels search', function () {
204 await waitJobs(servers) 207 await waitJobs(servers)
205 208
206 const videoChannelName = 'channel1_server2@localhost:' + servers[1].port 209 const videoChannelName = 'channel1_server2@localhost:' + servers[1].port
207 const res = await getVideoChannelVideos(servers[0].url, servers[0].accessToken, videoChannelName, 0, 5, '-createdAt') 210 const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName, sort: '-createdAt' })
208 211
209 expect(res.body.total).to.equal(2) 212 expect(total).to.equal(2)
210 expect(res.body.data[0].name).to.equal('video 2 server 2') 213 expect(data[0].name).to.equal('video 2 server 2')
211 expect(res.body.data[1].name).to.equal('video 1 updated') 214 expect(data[1].name).to.equal('video 1 updated')
212 }) 215 })
213 216
214 it('Should delete video channel of server 2, and delete it on server 1', async function () { 217 it('Should delete video channel of server 2, and delete it on server 1', async function () {
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts
index cb7582d29..46105c12c 100644
--- a/server/tests/api/search/search-activitypub-video-playlists.ts
+++ b/server/tests/api/search/search-activitypub-video-playlists.ts
@@ -9,7 +9,6 @@ import {
9 ServerInfo, 9 ServerInfo,
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 setDefaultVideoChannel, 11 setDefaultVideoChannel,
12 uploadVideoAndGetId,
13 wait, 12 wait,
14 waitJobs 13 waitJobs
15} from '@shared/extra-utils' 14} from '@shared/extra-utils'
@@ -34,8 +33,8 @@ describe('Test ActivityPub playlists search', function () {
34 await setDefaultVideoChannel(servers) 33 await setDefaultVideoChannel(servers)
35 34
36 { 35 {
37 const video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid 36 const video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
38 const video2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid 37 const video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
39 38
40 const attributes = { 39 const attributes = {
41 displayName: 'playlist 1 on server 1', 40 displayName: 'playlist 1 on server 1',
@@ -51,8 +50,8 @@ describe('Test ActivityPub playlists search', function () {
51 } 50 }
52 51
53 { 52 {
54 const videoId = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 1' })).uuid 53 const videoId = (await servers[1].videosCommand.quickUpload({ name: 'video 1' })).uuid
55 video2Server2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 2' })).uuid 54 video2Server2 = (await servers[1].videosCommand.quickUpload({ name: 'video 2' })).uuid
56 55
57 const attributes = { 56 const attributes = {
58 displayName: 'playlist 1 on server 2', 57 displayName: 'playlist 1 on server 2',
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts
index 403c84010..19b4d5ed8 100644
--- a/server/tests/api/search/search-activitypub-videos.ts
+++ b/server/tests/api/search/search-activitypub-videos.ts
@@ -5,17 +5,13 @@ import * as chai from 'chai'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 flushAndRunMultipleServers, 7 flushAndRunMultipleServers,
8 getVideosList,
9 removeVideo,
10 SearchCommand, 8 SearchCommand,
11 ServerInfo, 9 ServerInfo,
12 setAccessTokensToServers, 10 setAccessTokensToServers,
13 updateVideo, 11 wait,
14 uploadVideo, 12 waitJobs
15 wait 13} from '@shared/extra-utils'
16} from '../../../../shared/extra-utils' 14import { VideoPrivacy } from '@shared/models'
17import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
18import { VideoPrivacy } from '../../../../shared/models/videos'
19 15
20const expect = chai.expect 16const expect = chai.expect
21 17
@@ -34,13 +30,13 @@ describe('Test ActivityPub videos search', function () {
34 await setAccessTokensToServers(servers) 30 await setAccessTokensToServers(servers)
35 31
36 { 32 {
37 const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video 1 on server 1' }) 33 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1 on server 1' } })
38 videoServer1UUID = res.body.video.uuid 34 videoServer1UUID = uuid
39 } 35 }
40 36
41 { 37 {
42 const res = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video 1 on server 2' }) 38 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 on server 2' } })
43 videoServer2UUID = res.body.video.uuid 39 videoServer2UUID = uuid
44 } 40 }
45 41
46 await waitJobs(servers) 42 await waitJobs(servers)
@@ -109,10 +105,10 @@ describe('Test ActivityPub videos search', function () {
109 }) 105 })
110 106
111 it('Should not list this remote video', async function () { 107 it('Should not list this remote video', async function () {
112 const res = await getVideosList(servers[0].url) 108 const { total, data } = await servers[0].videosCommand.list()
113 expect(res.body.total).to.equal(1) 109 expect(total).to.equal(1)
114 expect(res.body.data).to.have.lengthOf(1) 110 expect(data).to.have.lengthOf(1)
115 expect(res.body.data[0].name).to.equal('video 1 on server 1') 111 expect(data[0].name).to.equal('video 1 on server 1')
116 }) 112 })
117 113
118 it('Should update video of server 2, and refresh it on server 1', async function () { 114 it('Should update video of server 2, and refresh it on server 1', async function () {
@@ -131,7 +127,7 @@ describe('Test ActivityPub videos search', function () {
131 privacy: VideoPrivacy.UNLISTED, 127 privacy: VideoPrivacy.UNLISTED,
132 channelId: videoChannelId 128 channelId: videoChannelId
133 } 129 }
134 await updateVideo(servers[1].url, servers[1].accessToken, videoServer2UUID, attributes) 130 await servers[1].videosCommand.update({ id: videoServer2UUID, attributes })
135 131
136 await waitJobs(servers) 132 await waitJobs(servers)
137 // Expire video 133 // Expire video
@@ -157,7 +153,7 @@ describe('Test ActivityPub videos search', function () {
157 it('Should delete video of server 2, and delete it on server 1', async function () { 153 it('Should delete video of server 2, and delete it on server 1', async function () {
158 this.timeout(120000) 154 this.timeout(120000)
159 155
160 await removeVideo(servers[1].url, servers[1].accessToken, videoServer2UUID) 156 await servers[1].videosCommand.remove({ id: videoServer2UUID })
161 157
162 await waitJobs(servers) 158 await waitJobs(servers)
163 // Expire video 159 // Expire video
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts
index 306f84c3a..d5dc40f60 100644
--- a/server/tests/api/search/search-index.ts
+++ b/server/tests/api/search/search-index.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' 5import { cleanupTests, flushAndRunServer, SearchCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils'
6import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models' 6import { BooleanBothQuery, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
7 7
8const expect = chai.expect 8const expect = chai.expect
@@ -20,7 +20,7 @@ describe('Test videos search', function () {
20 20
21 await setAccessTokensToServers([ server ]) 21 await setAccessTokensToServers([ server ])
22 22
23 await uploadVideo(server.url, server.accessToken, { name: localVideoName }) 23 await server.videosCommand.upload({ attributes: { name: localVideoName } })
24 24
25 command = server.searchCommand 25 command = server.searchCommand
26 }) 26 })
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts
index 517884503..2e4773ed6 100644
--- a/server/tests/api/search/search-playlists.ts
+++ b/server/tests/api/search/search-playlists.ts
@@ -2,16 +2,15 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoPlaylistPrivacy } from '@shared/models'
6import { 5import {
7 cleanupTests, 6 cleanupTests,
8 flushAndRunServer, 7 flushAndRunServer,
9 SearchCommand, 8 SearchCommand,
10 ServerInfo, 9 ServerInfo,
11 setAccessTokensToServers, 10 setAccessTokensToServers,
12 setDefaultVideoChannel, 11 setDefaultVideoChannel
13 uploadVideoAndGetId 12} from '@shared/extra-utils'
14} from '../../../../shared/extra-utils' 13import { VideoPlaylistPrivacy } from '@shared/models'
15 14
16const expect = chai.expect 15const expect = chai.expect
17 16
@@ -27,7 +26,7 @@ describe('Test playlists search', function () {
27 await setAccessTokensToServers([ server ]) 26 await setAccessTokensToServers([ server ])
28 await setDefaultVideoChannel([ server ]) 27 await setDefaultVideoChannel([ server ])
29 28
30 const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid 29 const videoId = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
31 30
32 { 31 {
33 const attributes = { 32 const attributes = {
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 66f5f3182..148499d5f 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -10,7 +10,6 @@ import {
10 setAccessTokensToServers, 10 setAccessTokensToServers,
11 setDefaultVideoChannel, 11 setDefaultVideoChannel,
12 stopFfmpeg, 12 stopFfmpeg,
13 uploadVideo,
14 wait 13 wait
15} from '@shared/extra-utils' 14} from '@shared/extra-utils'
16import { VideoPrivacy } from '@shared/models' 15import { VideoPrivacy } from '@shared/models'
@@ -41,50 +40,49 @@ describe('Test videos search', function () {
41 nsfw: false, 40 nsfw: false,
42 language: 'fr' 41 language: 'fr'
43 } 42 }
44 await uploadVideo(server.url, server.accessToken, attributes1) 43 await server.videosCommand.upload({ attributes: attributes1 })
45 44
46 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' } 45 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
47 await uploadVideo(server.url, server.accessToken, attributes2) 46 await server.videosCommand.upload({ attributes: attributes2 })
48 47
49 { 48 {
50 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } 49 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
51 const res = await uploadVideo(server.url, server.accessToken, attributes3) 50 const { id, uuid } = await server.videosCommand.upload({ attributes: attributes3 })
52 const videoId = res.body.video.id 51 videoUUID = uuid
53 videoUUID = res.body.video.uuid
54 52
55 await server.captionsCommand.createVideoCaption({ 53 await server.captionsCommand.createVideoCaption({
56 language: 'en', 54 language: 'en',
57 videoId, 55 videoId: id,
58 fixture: 'subtitle-good2.vtt', 56 fixture: 'subtitle-good2.vtt',
59 mimeType: 'application/octet-stream' 57 mimeType: 'application/octet-stream'
60 }) 58 })
61 59
62 await server.captionsCommand.createVideoCaption({ 60 await server.captionsCommand.createVideoCaption({
63 language: 'aa', 61 language: 'aa',
64 videoId, 62 videoId: id,
65 fixture: 'subtitle-good2.vtt', 63 fixture: 'subtitle-good2.vtt',
66 mimeType: 'application/octet-stream' 64 mimeType: 'application/octet-stream'
67 }) 65 })
68 } 66 }
69 67
70 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } 68 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
71 await uploadVideo(server.url, server.accessToken, attributes4) 69 await server.videosCommand.upload({ attributes: attributes4 })
72 70
73 await wait(1000) 71 await wait(1000)
74 72
75 startDate = new Date().toISOString() 73 startDate = new Date().toISOString()
76 74
77 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined } 75 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
78 await uploadVideo(server.url, server.accessToken, attributes5) 76 await server.videosCommand.upload({ attributes: attributes5 })
79 77
80 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } 78 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
81 await uploadVideo(server.url, server.accessToken, attributes6) 79 await server.videosCommand.upload({ attributes: attributes6 })
82 80
83 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } 81 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
84 await uploadVideo(server.url, server.accessToken, attributes7) 82 await server.videosCommand.upload({ attributes: attributes7 })
85 83
86 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } 84 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
87 await uploadVideo(server.url, server.accessToken, attributes8) 85 await server.videosCommand.upload({ attributes: attributes8 })
88 } 86 }
89 87
90 { 88 {
@@ -95,9 +93,9 @@ describe('Test videos search', function () {
95 licence: 2, 93 licence: 2,
96 language: 'en' 94 language: 'en'
97 } 95 }
98 await uploadVideo(server.url, server.accessToken, attributes) 96 await server.videosCommand.upload({ attributes: attributes })
99 97
100 await uploadVideo(server.url, server.accessToken, { ...attributes, name: attributes.name + ' duplicate' }) 98 await server.videosCommand.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
101 } 99 }
102 100
103 { 101 {
@@ -108,7 +106,7 @@ describe('Test videos search', function () {
108 licence: 3, 106 licence: 3,
109 language: 'pl' 107 language: 'pl'
110 } 108 }
111 await uploadVideo(server.url, server.accessToken, attributes) 109 await server.videosCommand.upload({ attributes: attributes })
112 } 110 }
113 111
114 { 112 {
@@ -117,11 +115,11 @@ describe('Test videos search', function () {
117 tags: [ 'aaaa', 'bbbb', 'cccc' ], 115 tags: [ 'aaaa', 'bbbb', 'cccc' ],
118 category: 1 116 category: 1
119 } 117 }
120 await uploadVideo(server.url, server.accessToken, attributes1) 118 await server.videosCommand.upload({ attributes: attributes1 })
121 await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) 119 await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } })
122 120
123 await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'cccc', 'dddd' ] }) 121 await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
124 await uploadVideo(server.url, server.accessToken, { ...attributes1, tags: [ 'eeee', 'ffff' ] }) 122 await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
125 } 123 }
126 124
127 { 125 {
@@ -129,8 +127,8 @@ describe('Test videos search', function () {
129 name: 'aaaa 2', 127 name: 'aaaa 2',
130 category: 1 128 category: 1
131 } 129 }
132 await uploadVideo(server.url, server.accessToken, attributes1) 130 await server.videosCommand.upload({ attributes: attributes1 })
133 await uploadVideo(server.url, server.accessToken, { ...attributes1, category: 2 }) 131 await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } })
134 } 132 }
135 133
136 command = server.searchCommand 134 command = server.searchCommand