diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /server/tests/api/search/search-playlists.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'server/tests/api/search/search-playlists.ts')
-rw-r--r-- | server/tests/api/search/search-playlists.ts | 83 |
1 files changed, 36 insertions, 47 deletions
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts index ab17d55e9..22e9b8fca 100644 --- a/server/tests/api/search/search-playlists.ts +++ b/server/tests/api/search/search-playlists.ts | |||
@@ -2,82 +2,71 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPlaylist, VideoPlaylistPrivacy } from '@shared/models' | ||
6 | import { | 5 | import { |
7 | addVideoInPlaylist, | ||
8 | advancedVideoPlaylistSearch, | ||
9 | cleanupTests, | 6 | cleanupTests, |
10 | createVideoPlaylist, | 7 | createSingleServer, |
11 | flushAndRunServer, | 8 | PeerTubeServer, |
12 | searchVideoPlaylists, | 9 | SearchCommand, |
13 | ServerInfo, | ||
14 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
15 | setDefaultVideoChannel, | 11 | setDefaultVideoChannel |
16 | uploadVideoAndGetId | 12 | } from '@shared/extra-utils' |
17 | } from '../../../../shared/extra-utils' | 13 | import { VideoPlaylistPrivacy } from '@shared/models' |
18 | 14 | ||
19 | const expect = chai.expect | 15 | const expect = chai.expect |
20 | 16 | ||
21 | describe('Test playlists search', function () { | 17 | describe('Test playlists search', function () { |
22 | let server: ServerInfo = null | 18 | let server: PeerTubeServer = null |
19 | let command: SearchCommand | ||
23 | 20 | ||
24 | before(async function () { | 21 | before(async function () { |
25 | this.timeout(30000) | 22 | this.timeout(30000) |
26 | 23 | ||
27 | server = await flushAndRunServer(1) | 24 | server = await createSingleServer(1) |
28 | 25 | ||
29 | await setAccessTokensToServers([ server ]) | 26 | await setAccessTokensToServers([ server ]) |
30 | await setDefaultVideoChannel([ server ]) | 27 | await setDefaultVideoChannel([ server ]) |
31 | 28 | ||
32 | const videoId = (await uploadVideoAndGetId({ server: server, videoName: 'video' })).uuid | 29 | const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid |
33 | 30 | ||
34 | { | 31 | { |
35 | const attributes = { | 32 | const attributes = { |
36 | displayName: 'Dr. Kenzo Tenma hospital videos', | 33 | displayName: 'Dr. Kenzo Tenma hospital videos', |
37 | privacy: VideoPlaylistPrivacy.PUBLIC, | 34 | privacy: VideoPlaylistPrivacy.PUBLIC, |
38 | videoChannelId: server.videoChannel.id | 35 | videoChannelId: server.store.channel.id |
39 | } | 36 | } |
40 | const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 37 | const created = await server.playlists.create({ attributes }) |
41 | 38 | ||
42 | await addVideoInPlaylist({ | 39 | await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) |
43 | url: server.url, | ||
44 | token: server.accessToken, | ||
45 | playlistId: res.body.videoPlaylist.id, | ||
46 | elementAttrs: { videoId } | ||
47 | }) | ||
48 | } | 40 | } |
49 | 41 | ||
50 | { | 42 | { |
51 | const attributes = { | 43 | const attributes = { |
52 | displayName: 'Johan & Anna Libert musics', | 44 | displayName: 'Johan & Anna Libert musics', |
53 | privacy: VideoPlaylistPrivacy.PUBLIC, | 45 | privacy: VideoPlaylistPrivacy.PUBLIC, |
54 | videoChannelId: server.videoChannel.id | 46 | videoChannelId: server.store.channel.id |
55 | } | 47 | } |
56 | const res = await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 48 | const created = await server.playlists.create({ attributes }) |
57 | 49 | ||
58 | await addVideoInPlaylist({ | 50 | await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } }) |
59 | url: server.url, | ||
60 | token: server.accessToken, | ||
61 | playlistId: res.body.videoPlaylist.id, | ||
62 | elementAttrs: { videoId } | ||
63 | }) | ||
64 | } | 51 | } |
65 | 52 | ||
66 | { | 53 | { |
67 | const attributes = { | 54 | const attributes = { |
68 | displayName: 'Inspector Lunge playlist', | 55 | displayName: 'Inspector Lunge playlist', |
69 | privacy: VideoPlaylistPrivacy.PUBLIC, | 56 | privacy: VideoPlaylistPrivacy.PUBLIC, |
70 | videoChannelId: server.videoChannel.id | 57 | videoChannelId: server.store.channel.id |
71 | } | 58 | } |
72 | await createVideoPlaylist({ url: server.url, token: server.accessToken, playlistAttrs: attributes }) | 59 | await server.playlists.create({ attributes }) |
73 | } | 60 | } |
61 | |||
62 | command = server.search | ||
74 | }) | 63 | }) |
75 | 64 | ||
76 | it('Should make a simple search and not have results', async function () { | 65 | it('Should make a simple search and not have results', async function () { |
77 | const res = await searchVideoPlaylists(server.url, 'abc') | 66 | const body = await command.searchPlaylists({ search: 'abc' }) |
78 | 67 | ||
79 | expect(res.body.total).to.equal(0) | 68 | expect(body.total).to.equal(0) |
80 | expect(res.body.data).to.have.lengthOf(0) | 69 | expect(body.data).to.have.lengthOf(0) |
81 | }) | 70 | }) |
82 | 71 | ||
83 | it('Should make a search and have results', async function () { | 72 | it('Should make a search and have results', async function () { |
@@ -87,11 +76,11 @@ describe('Test playlists search', function () { | |||
87 | start: 0, | 76 | start: 0, |
88 | count: 1 | 77 | count: 1 |
89 | } | 78 | } |
90 | const res = await advancedVideoPlaylistSearch(server.url, search) | 79 | const body = await command.advancedPlaylistSearch({ search }) |
91 | expect(res.body.total).to.equal(1) | 80 | expect(body.total).to.equal(1) |
92 | expect(res.body.data).to.have.lengthOf(1) | 81 | expect(body.data).to.have.lengthOf(1) |
93 | 82 | ||
94 | const playlist: VideoPlaylist = res.body.data[0] | 83 | const playlist = body.data[0] |
95 | expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') | 84 | expect(playlist.displayName).to.equal('Dr. Kenzo Tenma hospital videos') |
96 | expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid) | 85 | expect(playlist.url).to.equal(server.url + '/video-playlists/' + playlist.uuid) |
97 | } | 86 | } |
@@ -102,11 +91,11 @@ describe('Test playlists search', function () { | |||
102 | start: 0, | 91 | start: 0, |
103 | count: 1 | 92 | count: 1 |
104 | } | 93 | } |
105 | const res = await advancedVideoPlaylistSearch(server.url, search) | 94 | const body = await command.advancedPlaylistSearch({ search }) |
106 | expect(res.body.total).to.equal(1) | 95 | expect(body.total).to.equal(1) |
107 | expect(res.body.data).to.have.lengthOf(1) | 96 | expect(body.data).to.have.lengthOf(1) |
108 | 97 | ||
109 | const playlist: VideoPlaylist = res.body.data[0] | 98 | const playlist = body.data[0] |
110 | expect(playlist.displayName).to.equal('Johan & Anna Libert musics') | 99 | expect(playlist.displayName).to.equal('Johan & Anna Libert musics') |
111 | } | 100 | } |
112 | }) | 101 | }) |
@@ -117,9 +106,9 @@ describe('Test playlists search', function () { | |||
117 | start: 0, | 106 | start: 0, |
118 | count: 1 | 107 | count: 1 |
119 | } | 108 | } |
120 | const res = await advancedVideoPlaylistSearch(server.url, search) | 109 | const body = await command.advancedPlaylistSearch({ search }) |
121 | expect(res.body.total).to.equal(0) | 110 | expect(body.total).to.equal(0) |
122 | expect(res.body.data).to.have.lengthOf(0) | 111 | expect(body.data).to.have.lengthOf(0) |
123 | }) | 112 | }) |
124 | 113 | ||
125 | after(async function () { | 114 | after(async function () { |