aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-activitypub-video-playlists.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/search/search-activitypub-video-playlists.ts')
-rw-r--r--server/tests/api/search/search-activitypub-video-playlists.ts84
1 files changed, 44 insertions, 40 deletions
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts
index 4c08e9548..1df18173a 100644
--- a/server/tests/api/search/search-activitypub-video-playlists.ts
+++ b/server/tests/api/search/search-activitypub-video-playlists.ts
@@ -9,15 +9,15 @@ import {
9 deleteVideoPlaylist, 9 deleteVideoPlaylist,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getVideoPlaylistsList, 11 getVideoPlaylistsList,
12 searchVideoPlaylists, 12 SearchCommand,
13 ServerInfo, 13 ServerInfo,
14 setAccessTokensToServers, 14 setAccessTokensToServers,
15 setDefaultVideoChannel, 15 setDefaultVideoChannel,
16 uploadVideoAndGetId, 16 uploadVideoAndGetId,
17 wait 17 wait,
18} from '../../../../shared/extra-utils' 18 waitJobs
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19} from '@shared/extra-utils'
20import { VideoPlaylist, VideoPlaylistPrivacy } from '../../../../shared/models/videos' 20import { VideoPlaylistPrivacy } from '@shared/models'
21 21
22const expect = chai.expect 22const expect = chai.expect
23 23
@@ -27,6 +27,8 @@ describe('Test ActivityPub playlists search', function () {
27 let playlistServer2UUID: string 27 let playlistServer2UUID: string
28 let video2Server2: string 28 let video2Server2: string
29 29
30 let command: SearchCommand
31
30 before(async function () { 32 before(async function () {
31 this.timeout(120000) 33 this.timeout(120000)
32 34
@@ -78,38 +80,40 @@ describe('Test ActivityPub playlists search', function () {
78 } 80 }
79 81
80 await waitJobs(servers) 82 await waitJobs(servers)
83
84 command = servers[0].searchCommand
81 }) 85 })
82 86
83 it('Should not find a remote playlist', async function () { 87 it('Should not find a remote playlist', async function () {
84 { 88 {
85 const search = 'http://localhost:' + servers[1].port + '/video-playlists/43' 89 const search = 'http://localhost:' + servers[1].port + '/video-playlists/43'
86 const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) 90 const body = await command.searchPlaylists({ search, token: servers[0].accessToken })
87 91
88 expect(res.body.total).to.equal(0) 92 expect(body.total).to.equal(0)
89 expect(res.body.data).to.be.an('array') 93 expect(body.data).to.be.an('array')
90 expect(res.body.data).to.have.lengthOf(0) 94 expect(body.data).to.have.lengthOf(0)
91 } 95 }
92 96
93 { 97 {
94 // Without token 98 // Without token
95 const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID 99 const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID
96 const res = await searchVideoPlaylists(servers[0].url, search) 100 const body = await command.searchPlaylists({ search })
97 101
98 expect(res.body.total).to.equal(0) 102 expect(body.total).to.equal(0)
99 expect(res.body.data).to.be.an('array') 103 expect(body.data).to.be.an('array')
100 expect(res.body.data).to.have.lengthOf(0) 104 expect(body.data).to.have.lengthOf(0)
101 } 105 }
102 }) 106 })
103 107
104 it('Should search a local playlist', async function () { 108 it('Should search a local playlist', async function () {
105 const search = 'http://localhost:' + servers[0].port + '/video-playlists/' + playlistServer1UUID 109 const search = 'http://localhost:' + servers[0].port + '/video-playlists/' + playlistServer1UUID
106 const res = await searchVideoPlaylists(servers[0].url, search) 110 const body = await command.searchPlaylists({ search })
107 111
108 expect(res.body.total).to.equal(1) 112 expect(body.total).to.equal(1)
109 expect(res.body.data).to.be.an('array') 113 expect(body.data).to.be.an('array')
110 expect(res.body.data).to.have.lengthOf(1) 114 expect(body.data).to.have.lengthOf(1)
111 expect(res.body.data[0].displayName).to.equal('playlist 1 on server 1') 115 expect(body.data[0].displayName).to.equal('playlist 1 on server 1')
112 expect(res.body.data[0].videosLength).to.equal(2) 116 expect(body.data[0].videosLength).to.equal(2)
113 }) 117 })
114 118
115 it('Should search a local playlist with an alternative URL', async function () { 119 it('Should search a local playlist with an alternative URL', async function () {
@@ -120,13 +124,13 @@ describe('Test ActivityPub playlists search', function () {
120 124
121 for (const search of searches) { 125 for (const search of searches) {
122 for (const token of [ undefined, servers[0].accessToken ]) { 126 for (const token of [ undefined, servers[0].accessToken ]) {
123 const res = await searchVideoPlaylists(servers[0].url, search, token) 127 const body = await command.searchPlaylists({ search, token })
124 128
125 expect(res.body.total).to.equal(1) 129 expect(body.total).to.equal(1)
126 expect(res.body.data).to.be.an('array') 130 expect(body.data).to.be.an('array')
127 expect(res.body.data).to.have.lengthOf(1) 131 expect(body.data).to.have.lengthOf(1)
128 expect(res.body.data[0].displayName).to.equal('playlist 1 on server 1') 132 expect(body.data[0].displayName).to.equal('playlist 1 on server 1')
129 expect(res.body.data[0].videosLength).to.equal(2) 133 expect(body.data[0].videosLength).to.equal(2)
130 } 134 }
131 } 135 }
132 }) 136 })
@@ -139,13 +143,13 @@ describe('Test ActivityPub playlists search', function () {
139 ] 143 ]
140 144
141 for (const search of searches) { 145 for (const search of searches) {
142 const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) 146 const body = await command.searchPlaylists({ search, token: servers[0].accessToken })
143 147
144 expect(res.body.total).to.equal(1) 148 expect(body.total).to.equal(1)
145 expect(res.body.data).to.be.an('array') 149 expect(body.data).to.be.an('array')
146 expect(res.body.data).to.have.lengthOf(1) 150 expect(body.data).to.have.lengthOf(1)
147 expect(res.body.data[0].displayName).to.equal('playlist 1 on server 2') 151 expect(body.data[0].displayName).to.equal('playlist 1 on server 2')
148 expect(res.body.data[0].videosLength).to.equal(1) 152 expect(body.data[0].videosLength).to.equal(1)
149 } 153 }
150 }) 154 })
151 155
@@ -172,16 +176,16 @@ describe('Test ActivityPub playlists search', function () {
172 176
173 // Will run refresh async 177 // Will run refresh async
174 const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID 178 const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID
175 await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) 179 await command.searchPlaylists({ search, token: servers[0].accessToken })
176 180
177 // Wait refresh 181 // Wait refresh
178 await wait(5000) 182 await wait(5000)
179 183
180 const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) 184 const body = await command.searchPlaylists({ search, token: servers[0].accessToken })
181 expect(res.body.total).to.equal(1) 185 expect(body.total).to.equal(1)
182 expect(res.body.data).to.have.lengthOf(1) 186 expect(body.data).to.have.lengthOf(1)
183 187
184 const playlist: VideoPlaylist = res.body.data[0] 188 const playlist = body.data[0]
185 expect(playlist.videosLength).to.equal(2) 189 expect(playlist.videosLength).to.equal(2)
186 }) 190 })
187 191
@@ -196,14 +200,14 @@ describe('Test ActivityPub playlists search', function () {
196 200
197 // Will run refresh async 201 // Will run refresh async
198 const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID 202 const search = 'http://localhost:' + servers[1].port + '/video-playlists/' + playlistServer2UUID
199 await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) 203 await command.searchPlaylists({ search, token: servers[0].accessToken })
200 204
201 // Wait refresh 205 // Wait refresh
202 await wait(5000) 206 await wait(5000)
203 207
204 const res = await searchVideoPlaylists(servers[0].url, search, servers[0].accessToken) 208 const body = await command.searchPlaylists({ search, token: servers[0].accessToken })
205 expect(res.body.total).to.equal(0) 209 expect(body.total).to.equal(0)
206 expect(res.body.data).to.have.lengthOf(0) 210 expect(body.data).to.have.lengthOf(0)
207 }) 211 })
208 212
209 after(async function () { 213 after(async function () {