aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/videos-filter.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/videos-filter.ts')
-rw-r--r--server/tests/api/videos/videos-filter.ts122
1 files changed, 0 insertions, 122 deletions
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
3import 'mocha'
4import { expect } from 'chai'
5import {
6 cleanupTests,
7 createMultipleServers,
8 doubleFollow,
9 makeGetRequest,
10 PeerTubeServer,
11 setAccessTokensToServers
12} from '@shared/extra-utils'
13import { HttpStatusCode, UserRole, Video, VideoPrivacy } from '@shared/models'
14
15async 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
43describe('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})