diff options
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/index.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 6 | ||||
-rw-r--r-- | server/tests/api/videos/single-server.ts | 13 | ||||
-rw-r--r-- | server/tests/api/videos/videos-common-filters.ts | 403 | ||||
-rw-r--r-- | server/tests/api/videos/videos-filter.ts | 122 |
5 files changed, 407 insertions, 139 deletions
diff --git a/server/tests/api/videos/index.ts b/server/tests/api/videos/index.ts index 5c07f8926..c9c678e9d 100644 --- a/server/tests/api/videos/index.ts +++ b/server/tests/api/videos/index.ts | |||
@@ -15,7 +15,7 @@ import './video-playlist-thumbnails' | |||
15 | import './video-privacy' | 15 | import './video-privacy' |
16 | import './video-schedule-update' | 16 | import './video-schedule-update' |
17 | import './video-transcoder' | 17 | import './video-transcoder' |
18 | import './videos-filter' | 18 | import './videos-common-filters' |
19 | import './videos-history' | 19 | import './videos-history' |
20 | import './videos-overview' | 20 | import './videos-overview' |
21 | import './videos-views-cleaner' | 21 | import './videos-views-cleaner' |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index df9deb1e1..9c255c1c5 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -349,7 +349,7 @@ describe('Test multiple servers', function () { | |||
349 | 349 | ||
350 | describe('It should list local videos', function () { | 350 | describe('It should list local videos', function () { |
351 | it('Should list only local videos on server 1', async function () { | 351 | it('Should list only local videos on server 1', async function () { |
352 | const { data, total } = await servers[0].videos.list({ filter: 'local' }) | 352 | const { data, total } = await servers[0].videos.list({ isLocal: true }) |
353 | 353 | ||
354 | expect(total).to.equal(1) | 354 | expect(total).to.equal(1) |
355 | expect(data).to.be.an('array') | 355 | expect(data).to.be.an('array') |
@@ -358,7 +358,7 @@ describe('Test multiple servers', function () { | |||
358 | }) | 358 | }) |
359 | 359 | ||
360 | it('Should list only local videos on server 2', async function () { | 360 | it('Should list only local videos on server 2', async function () { |
361 | const { data, total } = await servers[1].videos.list({ filter: 'local' }) | 361 | const { data, total } = await servers[1].videos.list({ isLocal: true }) |
362 | 362 | ||
363 | expect(total).to.equal(1) | 363 | expect(total).to.equal(1) |
364 | expect(data).to.be.an('array') | 364 | expect(data).to.be.an('array') |
@@ -367,7 +367,7 @@ describe('Test multiple servers', function () { | |||
367 | }) | 367 | }) |
368 | 368 | ||
369 | it('Should list only local videos on server 3', async function () { | 369 | it('Should list only local videos on server 3', async function () { |
370 | const { data, total } = await servers[2].videos.list({ filter: 'local' }) | 370 | const { data, total } = await servers[2].videos.list({ isLocal: true }) |
371 | 371 | ||
372 | expect(total).to.equal(2) | 372 | expect(total).to.equal(2) |
373 | expect(data).to.be.an('array') | 373 | expect(data).to.be.an('array') |
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 29dac6ec1..a0e4a156c 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts | |||
@@ -354,19 +354,6 @@ describe('Test a single server', function () { | |||
354 | await server.videos.update({ id: videoId, attributes }) | 354 | await server.videos.update({ id: videoId, attributes }) |
355 | }) | 355 | }) |
356 | 356 | ||
357 | it('Should filter by tags and category', async function () { | ||
358 | { | ||
359 | const { data, total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) | ||
360 | expect(total).to.equal(1) | ||
361 | expect(data[0].name).to.equal('my super video updated') | ||
362 | } | ||
363 | |||
364 | { | ||
365 | const { total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) | ||
366 | expect(total).to.equal(0) | ||
367 | } | ||
368 | }) | ||
369 | |||
370 | it('Should have the video updated', async function () { | 357 | it('Should have the video updated', async function () { |
371 | this.timeout(60000) | 358 | this.timeout(60000) |
372 | 359 | ||
diff --git a/server/tests/api/videos/videos-common-filters.ts b/server/tests/api/videos/videos-common-filters.ts new file mode 100644 index 000000000..eb2d2ab50 --- /dev/null +++ b/server/tests/api/videos/videos-common-filters.ts | |||
@@ -0,0 +1,403 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import { expect } from 'chai' | ||
5 | import { pick } from '@shared/core-utils' | ||
6 | import { | ||
7 | cleanupTests, | ||
8 | createMultipleServers, | ||
9 | doubleFollow, | ||
10 | makeGetRequest, | ||
11 | PeerTubeServer, | ||
12 | setAccessTokensToServers, | ||
13 | setDefaultVideoChannel, | ||
14 | waitJobs | ||
15 | } from '@shared/extra-utils' | ||
16 | import { HttpStatusCode, UserRole, Video, VideoInclude, VideoPrivacy } from '@shared/models' | ||
17 | |||
18 | describe('Test videos filter', function () { | ||
19 | let servers: PeerTubeServer[] | ||
20 | let paths: string[] | ||
21 | let remotePaths: string[] | ||
22 | |||
23 | // --------------------------------------------------------------- | ||
24 | |||
25 | before(async function () { | ||
26 | this.timeout(160000) | ||
27 | |||
28 | servers = await createMultipleServers(2) | ||
29 | |||
30 | await setAccessTokensToServers(servers) | ||
31 | await setDefaultVideoChannel(servers) | ||
32 | |||
33 | for (const server of servers) { | ||
34 | const moderator = { username: 'moderator', password: 'my super password' } | ||
35 | await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) | ||
36 | server['moderatorAccessToken'] = await server.login.getAccessToken(moderator) | ||
37 | |||
38 | await server.videos.upload({ attributes: { name: 'public ' + server.serverNumber } }) | ||
39 | |||
40 | { | ||
41 | const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED } | ||
42 | await server.videos.upload({ attributes }) | ||
43 | } | ||
44 | |||
45 | { | ||
46 | const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE } | ||
47 | await server.videos.upload({ attributes }) | ||
48 | } | ||
49 | } | ||
50 | |||
51 | await doubleFollow(servers[0], servers[1]) | ||
52 | |||
53 | paths = [ | ||
54 | `/api/v1/video-channels/root_channel/videos`, | ||
55 | `/api/v1/accounts/root/videos`, | ||
56 | '/api/v1/videos', | ||
57 | '/api/v1/search/videos' | ||
58 | ] | ||
59 | |||
60 | remotePaths = [ | ||
61 | `/api/v1/video-channels/root_channel@${servers[1].host}/videos`, | ||
62 | `/api/v1/accounts/root@${servers[1].host}/videos`, | ||
63 | '/api/v1/videos', | ||
64 | '/api/v1/search/videos' | ||
65 | ] | ||
66 | }) | ||
67 | |||
68 | describe('Check deprecated videos filter', function () { | ||
69 | |||
70 | async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) { | ||
71 | const videosResults: Video[][] = [] | ||
72 | |||
73 | for (const path of paths) { | ||
74 | const res = await makeGetRequest({ | ||
75 | url: server.url, | ||
76 | path, | ||
77 | token, | ||
78 | query: { | ||
79 | sort: 'createdAt', | ||
80 | filter | ||
81 | }, | ||
82 | expectedStatus | ||
83 | }) | ||
84 | |||
85 | videosResults.push(res.body.data.map(v => v.name)) | ||
86 | } | ||
87 | |||
88 | return videosResults | ||
89 | } | ||
90 | |||
91 | it('Should display local videos', async function () { | ||
92 | for (const server of servers) { | ||
93 | const namesResults = await getVideosNames(server, server.accessToken, 'local') | ||
94 | for (const names of namesResults) { | ||
95 | expect(names).to.have.lengthOf(1) | ||
96 | expect(names[0]).to.equal('public ' + server.serverNumber) | ||
97 | } | ||
98 | } | ||
99 | }) | ||
100 | |||
101 | it('Should display all local videos by the admin or the moderator', async function () { | ||
102 | for (const server of servers) { | ||
103 | for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { | ||
104 | |||
105 | const namesResults = await getVideosNames(server, token, 'all-local') | ||
106 | for (const names of namesResults) { | ||
107 | expect(names).to.have.lengthOf(3) | ||
108 | |||
109 | expect(names[0]).to.equal('public ' + server.serverNumber) | ||
110 | expect(names[1]).to.equal('unlisted ' + server.serverNumber) | ||
111 | expect(names[2]).to.equal('private ' + server.serverNumber) | ||
112 | } | ||
113 | } | ||
114 | } | ||
115 | }) | ||
116 | |||
117 | it('Should display all videos by the admin or the moderator', async function () { | ||
118 | for (const server of servers) { | ||
119 | for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { | ||
120 | |||
121 | const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames(server, token, 'all') | ||
122 | expect(channelVideos).to.have.lengthOf(3) | ||
123 | expect(accountVideos).to.have.lengthOf(3) | ||
124 | |||
125 | expect(videos).to.have.lengthOf(5) | ||
126 | expect(searchVideos).to.have.lengthOf(5) | ||
127 | } | ||
128 | } | ||
129 | }) | ||
130 | }) | ||
131 | |||
132 | describe('Check videos filters', function () { | ||
133 | |||
134 | async function listVideos (options: { | ||
135 | server: PeerTubeServer | ||
136 | path: string | ||
137 | isLocal?: boolean | ||
138 | include?: VideoInclude | ||
139 | category?: number | ||
140 | tagsAllOf?: string[] | ||
141 | token?: string | ||
142 | expectedStatus?: HttpStatusCode | ||
143 | }) { | ||
144 | const res = await makeGetRequest({ | ||
145 | url: options.server.url, | ||
146 | path: options.path, | ||
147 | token: options.token ?? options.server.accessToken, | ||
148 | query: { | ||
149 | ...pick(options, [ 'isLocal', 'include', 'category', 'tagsAllOf' ]), | ||
150 | |||
151 | sort: 'createdAt' | ||
152 | }, | ||
153 | expectedStatus: options.expectedStatus ?? HttpStatusCode.OK_200 | ||
154 | }) | ||
155 | |||
156 | return res.body.data as Video[] | ||
157 | } | ||
158 | |||
159 | async function getVideosNames (options: { | ||
160 | server: PeerTubeServer | ||
161 | isLocal?: boolean | ||
162 | include?: VideoInclude | ||
163 | token?: string | ||
164 | expectedStatus?: HttpStatusCode | ||
165 | }) { | ||
166 | const videosResults: string[][] = [] | ||
167 | |||
168 | for (const path of paths) { | ||
169 | const videos = await listVideos({ ...options, path }) | ||
170 | |||
171 | videosResults.push(videos.map(v => v.name)) | ||
172 | } | ||
173 | |||
174 | return videosResults | ||
175 | } | ||
176 | |||
177 | it('Should display local videos', async function () { | ||
178 | for (const server of servers) { | ||
179 | const namesResults = await getVideosNames({ server, isLocal: true }) | ||
180 | |||
181 | for (const names of namesResults) { | ||
182 | expect(names).to.have.lengthOf(1) | ||
183 | expect(names[0]).to.equal('public ' + server.serverNumber) | ||
184 | } | ||
185 | } | ||
186 | }) | ||
187 | |||
188 | it('Should display local videos with hidden privacy by the admin or the moderator', async function () { | ||
189 | for (const server of servers) { | ||
190 | for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { | ||
191 | |||
192 | const namesResults = await getVideosNames({ | ||
193 | server, | ||
194 | token, | ||
195 | isLocal: true, | ||
196 | include: VideoInclude.HIDDEN_PRIVACY | ||
197 | }) | ||
198 | |||
199 | for (const names of namesResults) { | ||
200 | expect(names).to.have.lengthOf(3) | ||
201 | |||
202 | expect(names[0]).to.equal('public ' + server.serverNumber) | ||
203 | expect(names[1]).to.equal('unlisted ' + server.serverNumber) | ||
204 | expect(names[2]).to.equal('private ' + server.serverNumber) | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | }) | ||
209 | |||
210 | it('Should display all videos by the admin or the moderator', async function () { | ||
211 | for (const server of servers) { | ||
212 | for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { | ||
213 | |||
214 | const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames({ | ||
215 | server, | ||
216 | token, | ||
217 | include: VideoInclude.HIDDEN_PRIVACY | ||
218 | }) | ||
219 | |||
220 | expect(channelVideos).to.have.lengthOf(3) | ||
221 | expect(accountVideos).to.have.lengthOf(3) | ||
222 | |||
223 | expect(videos).to.have.lengthOf(5) | ||
224 | expect(searchVideos).to.have.lengthOf(5) | ||
225 | } | ||
226 | } | ||
227 | }) | ||
228 | |||
229 | it('Should display only remote videos', async function () { | ||
230 | this.timeout(40000) | ||
231 | |||
232 | await servers[1].videos.upload({ attributes: { name: 'remote video' } }) | ||
233 | |||
234 | await waitJobs(servers) | ||
235 | |||
236 | const finder = (videos: Video[]) => videos.find(v => v.name === 'remote video') | ||
237 | |||
238 | for (const path of remotePaths) { | ||
239 | { | ||
240 | const videos = await listVideos({ server: servers[0], path }) | ||
241 | const video = finder(videos) | ||
242 | expect(video).to.exist | ||
243 | } | ||
244 | |||
245 | { | ||
246 | const videos = await listVideos({ server: servers[0], path, isLocal: false }) | ||
247 | const video = finder(videos) | ||
248 | expect(video).to.exist | ||
249 | } | ||
250 | |||
251 | { | ||
252 | const videos = await listVideos({ server: servers[0], path, isLocal: true }) | ||
253 | const video = finder(videos) | ||
254 | expect(video).to.not.exist | ||
255 | } | ||
256 | } | ||
257 | }) | ||
258 | |||
259 | it('Should include not published videos', async function () { | ||
260 | await servers[0].config.enableLive({ allowReplay: false, transcoding: false }) | ||
261 | await servers[0].live.create({ fields: { name: 'live video', channelId: servers[0].store.channel.id, privacy: VideoPrivacy.PUBLIC } }) | ||
262 | |||
263 | const finder = (videos: Video[]) => videos.find(v => v.name === 'live video') | ||
264 | |||
265 | for (const path of paths) { | ||
266 | { | ||
267 | const videos = await listVideos({ server: servers[0], path }) | ||
268 | const video = finder(videos) | ||
269 | expect(video).to.not.exist | ||
270 | expect(videos[0].state).to.not.exist | ||
271 | expect(videos[0].waitTranscoding).to.not.exist | ||
272 | } | ||
273 | |||
274 | { | ||
275 | const videos = await listVideos({ server: servers[0], path, include: VideoInclude.NOT_PUBLISHED_STATE }) | ||
276 | const video = finder(videos) | ||
277 | expect(video).to.exist | ||
278 | expect(video.state).to.exist | ||
279 | } | ||
280 | } | ||
281 | }) | ||
282 | |||
283 | it('Should include blacklisted videos', async function () { | ||
284 | const { id } = await servers[0].videos.upload({ attributes: { name: 'blacklisted' } }) | ||
285 | |||
286 | await servers[0].blacklist.add({ videoId: id }) | ||
287 | |||
288 | const finder = (videos: Video[]) => videos.find(v => v.name === 'blacklisted') | ||
289 | |||
290 | for (const path of paths) { | ||
291 | { | ||
292 | const videos = await listVideos({ server: servers[0], path }) | ||
293 | const video = finder(videos) | ||
294 | expect(video).to.not.exist | ||
295 | expect(videos[0].blacklisted).to.not.exist | ||
296 | } | ||
297 | |||
298 | { | ||
299 | const videos = await listVideos({ server: servers[0], path, include: VideoInclude.BLACKLISTED }) | ||
300 | const video = finder(videos) | ||
301 | expect(video).to.exist | ||
302 | expect(video.blacklisted).to.be.true | ||
303 | } | ||
304 | } | ||
305 | }) | ||
306 | |||
307 | it('Should include videos from muted account', async function () { | ||
308 | const finder = (videos: Video[]) => videos.find(v => v.name === 'remote video') | ||
309 | |||
310 | await servers[0].blocklist.addToServerBlocklist({ account: 'root@' + servers[1].host }) | ||
311 | |||
312 | for (const path of remotePaths) { | ||
313 | { | ||
314 | const videos = await listVideos({ server: servers[0], path }) | ||
315 | const video = finder(videos) | ||
316 | expect(video).to.not.exist | ||
317 | |||
318 | // Some paths won't have videos | ||
319 | if (videos[0]) { | ||
320 | expect(videos[0].blockedOwner).to.not.exist | ||
321 | expect(videos[0].blockedServer).to.not.exist | ||
322 | } | ||
323 | } | ||
324 | |||
325 | { | ||
326 | const videos = await listVideos({ server: servers[0], path, include: VideoInclude.BLOCKED_OWNER }) | ||
327 | |||
328 | const video = finder(videos) | ||
329 | expect(video).to.exist | ||
330 | expect(video.blockedServer).to.be.false | ||
331 | expect(video.blockedOwner).to.be.true | ||
332 | } | ||
333 | } | ||
334 | |||
335 | await servers[0].blocklist.removeFromServerBlocklist({ account: 'root@' + servers[1].host }) | ||
336 | }) | ||
337 | |||
338 | it('Should include videos from muted server', async function () { | ||
339 | const finder = (videos: Video[]) => videos.find(v => v.name === 'remote video') | ||
340 | |||
341 | await servers[0].blocklist.addToServerBlocklist({ server: servers[1].host }) | ||
342 | |||
343 | for (const path of remotePaths) { | ||
344 | { | ||
345 | const videos = await listVideos({ server: servers[0], path }) | ||
346 | const video = finder(videos) | ||
347 | expect(video).to.not.exist | ||
348 | |||
349 | // Some paths won't have videos | ||
350 | if (videos[0]) { | ||
351 | expect(videos[0].blockedOwner).to.not.exist | ||
352 | expect(videos[0].blockedServer).to.not.exist | ||
353 | } | ||
354 | } | ||
355 | |||
356 | { | ||
357 | const videos = await listVideos({ server: servers[0], path, include: VideoInclude.BLOCKED_OWNER }) | ||
358 | const video = finder(videos) | ||
359 | expect(video).to.exist | ||
360 | expect(video.blockedServer).to.be.true | ||
361 | expect(video.blockedOwner).to.be.false | ||
362 | } | ||
363 | } | ||
364 | |||
365 | await servers[0].blocklist.removeFromServerBlocklist({ server: servers[1].host }) | ||
366 | }) | ||
367 | |||
368 | it('Should filter by tags and category', async function () { | ||
369 | await servers[0].videos.upload({ attributes: { name: 'tag filter', tags: [ 'tag1', 'tag2' ] } }) | ||
370 | await servers[0].videos.upload({ attributes: { name: 'tag filter with category', tags: [ 'tag3' ], category: 4 } }) | ||
371 | |||
372 | for (const path of paths) { | ||
373 | { | ||
374 | |||
375 | const videos = await listVideos({ server: servers[0], path, tagsAllOf: [ 'tag1', 'tag2' ] }) | ||
376 | expect(videos).to.have.lengthOf(1) | ||
377 | expect(videos[0].name).to.equal('tag filter') | ||
378 | |||
379 | } | ||
380 | |||
381 | { | ||
382 | const videos = await listVideos({ server: servers[0], path, tagsAllOf: [ 'tag1', 'tag3' ] }) | ||
383 | expect(videos).to.have.lengthOf(0) | ||
384 | } | ||
385 | |||
386 | { | ||
387 | const { data, total } = await servers[0].videos.list({ tagsAllOf: [ 'tag3' ], categoryOneOf: [ 4 ] }) | ||
388 | expect(total).to.equal(1) | ||
389 | expect(data[0].name).to.equal('tag filter with category') | ||
390 | } | ||
391 | |||
392 | { | ||
393 | const { total } = await servers[0].videos.list({ tagsAllOf: [ 'tag4' ], categoryOneOf: [ 4 ] }) | ||
394 | expect(total).to.equal(0) | ||
395 | } | ||
396 | } | ||
397 | }) | ||
398 | }) | ||
399 | |||
400 | after(async function () { | ||
401 | await cleanupTests(servers) | ||
402 | }) | ||
403 | }) | ||
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts deleted file mode 100644 index 2306807bf..000000000 --- a/server/tests/api/videos/videos-filter.ts +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import { expect } from 'chai' | ||
5 | import { | ||
6 | cleanupTests, | ||
7 | createMultipleServers, | ||
8 | doubleFollow, | ||
9 | makeGetRequest, | ||
10 | PeerTubeServer, | ||
11 | setAccessTokensToServers | ||
12 | } from '@shared/extra-utils' | ||
13 | import { HttpStatusCode, UserRole, Video, VideoPrivacy } from '@shared/models' | ||
14 | |||
15 | async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) { | ||
16 | const paths = [ | ||
17 | '/api/v1/video-channels/root_channel/videos', | ||
18 | '/api/v1/accounts/root/videos', | ||
19 | '/api/v1/videos', | ||
20 | '/api/v1/search/videos' | ||
21 | ] | ||
22 | |||
23 | const videosResults: Video[][] = [] | ||
24 | |||
25 | for (const path of paths) { | ||
26 | const res = await makeGetRequest({ | ||
27 | url: server.url, | ||
28 | path, | ||
29 | token, | ||
30 | query: { | ||
31 | sort: 'createdAt', | ||
32 | filter | ||
33 | }, | ||
34 | expectedStatus | ||
35 | }) | ||
36 | |||
37 | videosResults.push(res.body.data.map(v => v.name)) | ||
38 | } | ||
39 | |||
40 | return videosResults | ||
41 | } | ||
42 | |||
43 | describe('Test videos filter', function () { | ||
44 | let servers: PeerTubeServer[] | ||
45 | |||
46 | // --------------------------------------------------------------- | ||
47 | |||
48 | before(async function () { | ||
49 | this.timeout(160000) | ||
50 | |||
51 | servers = await createMultipleServers(2) | ||
52 | |||
53 | await setAccessTokensToServers(servers) | ||
54 | |||
55 | for (const server of servers) { | ||
56 | const moderator = { username: 'moderator', password: 'my super password' } | ||
57 | await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) | ||
58 | server['moderatorAccessToken'] = await server.login.getAccessToken(moderator) | ||
59 | |||
60 | await server.videos.upload({ attributes: { name: 'public ' + server.serverNumber } }) | ||
61 | |||
62 | { | ||
63 | const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED } | ||
64 | await server.videos.upload({ attributes }) | ||
65 | } | ||
66 | |||
67 | { | ||
68 | const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE } | ||
69 | await server.videos.upload({ attributes }) | ||
70 | } | ||
71 | } | ||
72 | |||
73 | await doubleFollow(servers[0], servers[1]) | ||
74 | }) | ||
75 | |||
76 | describe('Check videos filter', function () { | ||
77 | |||
78 | it('Should display local videos', async function () { | ||
79 | for (const server of servers) { | ||
80 | const namesResults = await getVideosNames(server, server.accessToken, 'local') | ||
81 | for (const names of namesResults) { | ||
82 | expect(names).to.have.lengthOf(1) | ||
83 | expect(names[0]).to.equal('public ' + server.serverNumber) | ||
84 | } | ||
85 | } | ||
86 | }) | ||
87 | |||
88 | it('Should display all local videos by the admin or the moderator', async function () { | ||
89 | for (const server of servers) { | ||
90 | for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { | ||
91 | |||
92 | const namesResults = await getVideosNames(server, token, 'all-local') | ||
93 | for (const names of namesResults) { | ||
94 | expect(names).to.have.lengthOf(3) | ||
95 | |||
96 | expect(names[0]).to.equal('public ' + server.serverNumber) | ||
97 | expect(names[1]).to.equal('unlisted ' + server.serverNumber) | ||
98 | expect(names[2]).to.equal('private ' + server.serverNumber) | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | }) | ||
103 | |||
104 | it('Should display all videos by the admin or the moderator', async function () { | ||
105 | for (const server of servers) { | ||
106 | for (const token of [ server.accessToken, server['moderatorAccessToken'] ]) { | ||
107 | |||
108 | const [ channelVideos, accountVideos, videos, searchVideos ] = await getVideosNames(server, token, 'all') | ||
109 | expect(channelVideos).to.have.lengthOf(3) | ||
110 | expect(accountVideos).to.have.lengthOf(3) | ||
111 | |||
112 | expect(videos).to.have.lengthOf(5) | ||
113 | expect(searchVideos).to.have.lengthOf(5) | ||
114 | } | ||
115 | } | ||
116 | }) | ||
117 | }) | ||
118 | |||
119 | after(async function () { | ||
120 | await cleanupTests(servers) | ||
121 | }) | ||
122 | }) | ||