aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/search/search-index.ts')
-rw-r--r--server/tests/api/search/search-index.ts62
1 files changed, 57 insertions, 5 deletions
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts
index 849a8a893..00f79232a 100644
--- a/server/tests/api/search/search-index.ts
+++ b/server/tests/api/search/search-index.ts
@@ -2,19 +2,21 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { advancedVideoChannelSearch, searchVideoChannel } from '@shared/extra-utils/search/video-channels'
6import { Video, VideoChannel, VideoPlaylist, VideoPlaylistPrivacy, VideoPlaylistType, VideosSearchQuery } from '@shared/models'
5import { 7import {
8 advancedVideoPlaylistSearch,
9 advancedVideosSearch,
6 cleanupTests, 10 cleanupTests,
7 flushAndRunServer, 11 flushAndRunServer,
12 immutableAssign,
8 searchVideo, 13 searchVideo,
14 searchVideoPlaylists,
9 ServerInfo, 15 ServerInfo,
10 setAccessTokensToServers, 16 setAccessTokensToServers,
11 updateCustomSubConfig, 17 updateCustomSubConfig,
12 uploadVideo, 18 uploadVideo
13 advancedVideosSearch,
14 immutableAssign
15} from '../../../../shared/extra-utils' 19} from '../../../../shared/extra-utils'
16import { searchVideoChannel, advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels'
17import { VideosSearchQuery, Video, VideoChannel } from '@shared/models'
18 20
19const expect = chai.expect 21const expect = chai.expect
20 22
@@ -277,6 +279,56 @@ describe('Test videos search', function () {
277 }) 279 })
278 }) 280 })
279 281
282 describe('Playlists search', async function () {
283
284 it('Should make a simple search and not have results', async function () {
285 const res = await searchVideoPlaylists(server.url, 'a'.repeat(500))
286
287 expect(res.body.total).to.equal(0)
288 expect(res.body.data).to.have.lengthOf(0)
289 })
290
291 it('Should make a search and have results', async function () {
292 const res = await advancedVideoPlaylistSearch(server.url, { search: 'E2E playlist', sort: '-match' })
293
294 expect(res.body.total).to.be.greaterThan(0)
295 expect(res.body.data).to.have.length.greaterThan(0)
296
297 const videoPlaylist: VideoPlaylist = res.body.data[0]
298
299 expect(videoPlaylist.url).to.equal('https://peertube2.cpy.re/videos/watch/playlist/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
300 expect(videoPlaylist.thumbnailUrl).to.exist
301 expect(videoPlaylist.embedUrl).to.equal('https://peertube2.cpy.re/video-playlists/embed/73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
302
303 expect(videoPlaylist.type.id).to.equal(VideoPlaylistType.REGULAR)
304 expect(videoPlaylist.privacy.id).to.equal(VideoPlaylistPrivacy.PUBLIC)
305 expect(videoPlaylist.videosLength).to.exist
306
307 expect(videoPlaylist.createdAt).to.exist
308 expect(videoPlaylist.updatedAt).to.exist
309
310 expect(videoPlaylist.uuid).to.equal('73804a40-da9a-40c2-b1eb-2c6d9eec8f0a')
311 expect(videoPlaylist.displayName).to.exist
312
313 expect(videoPlaylist.ownerAccount.url).to.equal('https://peertube2.cpy.re/accounts/chocobozzz')
314 expect(videoPlaylist.ownerAccount.name).to.equal('chocobozzz')
315 expect(videoPlaylist.ownerAccount.host).to.equal('peertube2.cpy.re')
316 expect(videoPlaylist.ownerAccount.avatar).to.exist
317
318 expect(videoPlaylist.videoChannel.url).to.equal('https://peertube2.cpy.re/video-channels/chocobozzz_channel')
319 expect(videoPlaylist.videoChannel.name).to.equal('chocobozzz_channel')
320 expect(videoPlaylist.videoChannel.host).to.equal('peertube2.cpy.re')
321 expect(videoPlaylist.videoChannel.avatar).to.exist
322 })
323
324 it('Should have a correct pagination', async function () {
325 const res = await advancedVideoChannelSearch(server.url, { search: 'root', start: 0, count: 2 })
326
327 expect(res.body.total).to.be.greaterThan(2)
328 expect(res.body.data).to.have.lengthOf(2)
329 })
330 })
331
280 after(async function () { 332 after(async function () {
281 await cleanupTests([ server ]) 333 await cleanupTests([ server ])
282 }) 334 })