]>
Commit | Line | Data |
---|---|---|
37a44fc9 C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
af971e06 | 5 | import { VideoPlaylistPrivacy } from '@shared/models' |
37a44fc9 | 6 | import { |
37a44fc9 | 7 | cleanupTests, |
37a44fc9 | 8 | flushAndRunServer, |
af971e06 | 9 | SearchCommand, |
37a44fc9 C |
10 | ServerInfo, |
11 | setAccessTokensToServers, | |
12 | setDefaultVideoChannel, | |
13 | uploadVideoAndGetId | |
14 | } from '../../../../shared/extra-utils' | |
15 | ||
16 | const expect = chai.expect | |
17 | ||
18 | describe('Test playlists search', function () { | |
19 | let server: ServerInfo = null | |
af971e06 | 20 | let command: SearchCommand |
37a44fc9 C |
21 | |
22 | before(async function () { | |
23 | this.timeout(30000) | |
24 | ||
25 | server = await flushAndRunServer(1) | |
26 | ||
27 | await setAccessTokensToServers([ server ]) | |
28 | await setDefaultVideoChannel([ server ]) | |
29 | ||
30 | const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid | |
31 | ||
32 | { | |
33 | const attributes = { | |
34 | displayName: 'Dr. Kenzo Tenma hospital videos', | |
35 | privacy: VideoPlaylistPrivacy.PUBLIC, | |
36 | videoChannelId: server.videoChannel.id | |
37 | } | |
e6346d59 C |
38 | const created = await server.playlistsCommand.create({ attributes }) |
39 | ||
40 | await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) | |
37a44fc9 C |
41 | } |
42 | ||
43 | { | |
44 | const attributes = { | |
45 | displayName: 'Johan & Anna Libert musics', | |
46 | privacy: VideoPlaylistPrivacy.PUBLIC, | |
47 | videoChannelId: server.videoChannel.id | |
48 | } | |
e6346d59 C |
49 | const created = await server.playlistsCommand.create({ attributes }) |
50 | ||
51 | await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) | |
37a44fc9 C |
52 | } |
53 | ||
54 | { | |
55 | const attributes = { | |
56 | displayName: 'Inspector Lunge playlist', | |
57 | privacy: VideoPlaylistPrivacy.PUBLIC, | |
58 | videoChannelId: server.videoChannel.id | |
59 | } | |
e6346d59 | 60 | await server.playlistsCommand.create({ attributes }) |
37a44fc9 | 61 | } |
af971e06 C |
62 | |
63 | command = server.searchCommand | |
37a44fc9 C |
64 | }) |
65 | ||
66 | it('Should make a simple search and not have results', async function () { | |
af971e06 | 67 | const body = await command.searchPlaylists({ search: 'abc' }) |
37a44fc9 | 68 | |
af971e06 C |
69 | expect(body.total).to.equal(0) |
70 | expect(body.data).to.have.lengthOf(0) | |
37a44fc9 C |
71 | }) |
72 | ||
73 | it('Should make a search and have results', async function () { | |
74 | { | |
75 | const search = { | |
76 | search: 'tenma', | |
77 | start: 0, | |
78 | count: 1 | |
79 | } | |
af971e06 C |
80 | const body = await command.advancedPlaylistSearch({ search }) |
81 | expect(body.total).to.equal(1) | |
82 | expect(body.data).to.have.lengthOf(1) | |
37a44fc9 | 83 | |
af971e06 | 84 | const playlist = body.data[0] |
37a44fc9 C |
85 | expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') |
86 | expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid) | |
87 | } | |
88 | ||
89 | { | |
90 | const search = { | |
91 | search: 'Anna Livert', | |
92 | start: 0, | |
93 | count: 1 | |
94 | } | |
af971e06 C |
95 | const body = await command.advancedPlaylistSearch({ search }) |
96 | expect(body.total).to.equal(1) | |
97 | expect(body.data).to.have.lengthOf(1) | |
37a44fc9 | 98 | |
af971e06 | 99 | const playlist = body.data[0] |
37a44fc9 C |
100 | expect(playlist.displayName).to.equal('Johan & Anna Libert musics') |
101 | } | |
102 | }) | |
103 | ||
104 | it('Should not display playlists without videos', async function () { | |
105 | const search = { | |
106 | search: 'Lunge', | |
107 | start: 0, | |
108 | count: 1 | |
109 | } | |
af971e06 C |
110 | const body = await command.advancedPlaylistSearch({ search }) |
111 | expect(body.total).to.equal(0) | |
112 | expect(body.data).to.have.lengthOf(0) | |
37a44fc9 C |
113 | }) |
114 | ||
115 | after(async function () { | |
116 | await cleanupTests([ server ]) | |
117 | }) | |
118 | }) |