aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-playlist-thumbnails.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/video-playlist-thumbnails.ts')
-rw-r--r--server/tests/api/videos/video-playlist-thumbnails.ts144
1 files changed, 57 insertions, 87 deletions
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts
index a93a0b7de..f0b2ca169 100644
--- a/server/tests/api/videos/video-playlist-thumbnails.ts
+++ b/server/tests/api/videos/video-playlist-thumbnails.ts
@@ -1,21 +1,15 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
4import * as chai from 'chai'
5import { 5import {
6 addVideoInPlaylist,
7 cleanupTests, 6 cleanupTests,
8 createVideoPlaylist, 7 createMultipleServers,
9 doubleFollow, 8 doubleFollow,
10 flushAndRunMultipleServers, 9 PeerTubeServer,
11 getVideoPlaylistsList,
12 removeVideoFromPlaylist,
13 reorderVideosPlaylist,
14 ServerInfo,
15 setAccessTokensToServers, 10 setAccessTokensToServers,
16 setDefaultVideoChannel, 11 setDefaultVideoChannel,
17 testImage, 12 testImage,
18 uploadVideoAndGetId,
19 waitJobs 13 waitJobs
20} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
21import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' 15import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
@@ -23,10 +17,10 @@ import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/
23const expect = chai.expect 17const expect = chai.expect
24 18
25describe('Playlist thumbnail', function () { 19describe('Playlist thumbnail', function () {
26 let servers: ServerInfo[] = [] 20 let servers: PeerTubeServer[] = []
27 21
28 let playlistWithoutThumbnail: number 22 let playlistWithoutThumbnailId: number
29 let playlistWithThumbnail: number 23 let playlistWithThumbnailId: number
30 24
31 let withThumbnailE1: number 25 let withThumbnailE1: number
32 let withThumbnailE2: number 26 let withThumbnailE2: number
@@ -36,22 +30,22 @@ describe('Playlist thumbnail', function () {
36 let video1: number 30 let video1: number
37 let video2: number 31 let video2: number
38 32
39 async function getPlaylistWithoutThumbnail (server: ServerInfo) { 33 async function getPlaylistWithoutThumbnail (server: PeerTubeServer) {
40 const res = await getVideoPlaylistsList(server.url, 0, 10) 34 const body = await server.playlists.list({ start: 0, count: 10 })
41 35
42 return res.body.data.find(p => p.displayName === 'playlist without thumbnail') 36 return body.data.find(p => p.displayName === 'playlist without thumbnail')
43 } 37 }
44 38
45 async function getPlaylistWithThumbnail (server: ServerInfo) { 39 async function getPlaylistWithThumbnail (server: PeerTubeServer) {
46 const res = await getVideoPlaylistsList(server.url, 0, 10) 40 const body = await server.playlists.list({ start: 0, count: 10 })
47 41
48 return res.body.data.find(p => p.displayName === 'playlist with thumbnail') 42 return body.data.find(p => p.displayName === 'playlist with thumbnail')
49 } 43 }
50 44
51 before(async function () { 45 before(async function () {
52 this.timeout(120000) 46 this.timeout(120000)
53 47
54 servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: false } }) 48 servers = await createMultipleServers(2, { transcoding: { enabled: false } })
55 49
56 // Get the access tokens 50 // Get the access tokens
57 await setAccessTokensToServers(servers) 51 await setAccessTokensToServers(servers)
@@ -60,8 +54,8 @@ describe('Playlist thumbnail', function () {
60 // Server 1 and server 2 follow each other 54 // Server 1 and server 2 follow each other
61 await doubleFollow(servers[0], servers[1]) 55 await doubleFollow(servers[0], servers[1])
62 56
63 video1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).id 57 video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).id
64 video2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).id 58 video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).id
65 59
66 await waitJobs(servers) 60 await waitJobs(servers)
67 }) 61 })
@@ -69,24 +63,20 @@ describe('Playlist thumbnail', function () {
69 it('Should automatically update the thumbnail when adding an element', async function () { 63 it('Should automatically update the thumbnail when adding an element', async function () {
70 this.timeout(30000) 64 this.timeout(30000)
71 65
72 const res = await createVideoPlaylist({ 66 const created = await servers[1].playlists.create({
73 url: servers[1].url, 67 attributes: {
74 token: servers[1].accessToken,
75 playlistAttrs: {
76 displayName: 'playlist without thumbnail', 68 displayName: 'playlist without thumbnail',
77 privacy: VideoPlaylistPrivacy.PUBLIC, 69 privacy: VideoPlaylistPrivacy.PUBLIC,
78 videoChannelId: servers[1].videoChannel.id 70 videoChannelId: servers[1].store.channel.id
79 } 71 }
80 }) 72 })
81 playlistWithoutThumbnail = res.body.videoPlaylist.id 73 playlistWithoutThumbnailId = created.id
82 74
83 const res2 = await addVideoInPlaylist({ 75 const added = await servers[1].playlists.addElement({
84 url: servers[1].url, 76 playlistId: playlistWithoutThumbnailId,
85 token: servers[1].accessToken, 77 attributes: { videoId: video1 }
86 playlistId: playlistWithoutThumbnail,
87 elementAttrs: { videoId: video1 }
88 }) 78 })
89 withoutThumbnailE1 = res2.body.videoPlaylistElement.id 79 withoutThumbnailE1 = added.id
90 80
91 await waitJobs(servers) 81 await waitJobs(servers)
92 82
@@ -99,25 +89,21 @@ describe('Playlist thumbnail', function () {
99 it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () { 89 it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () {
100 this.timeout(30000) 90 this.timeout(30000)
101 91
102 const res = await createVideoPlaylist({ 92 const created = await servers[1].playlists.create({
103 url: servers[1].url, 93 attributes: {
104 token: servers[1].accessToken,
105 playlistAttrs: {
106 displayName: 'playlist with thumbnail', 94 displayName: 'playlist with thumbnail',
107 privacy: VideoPlaylistPrivacy.PUBLIC, 95 privacy: VideoPlaylistPrivacy.PUBLIC,
108 videoChannelId: servers[1].videoChannel.id, 96 videoChannelId: servers[1].store.channel.id,
109 thumbnailfile: 'thumbnail.jpg' 97 thumbnailfile: 'thumbnail.jpg'
110 } 98 }
111 }) 99 })
112 playlistWithThumbnail = res.body.videoPlaylist.id 100 playlistWithThumbnailId = created.id
113 101
114 const res2 = await addVideoInPlaylist({ 102 const added = await servers[1].playlists.addElement({
115 url: servers[1].url, 103 playlistId: playlistWithThumbnailId,
116 token: servers[1].accessToken, 104 attributes: { videoId: video1 }
117 playlistId: playlistWithThumbnail,
118 elementAttrs: { videoId: video1 }
119 }) 105 })
120 withThumbnailE1 = res2.body.videoPlaylistElement.id 106 withThumbnailE1 = added.id
121 107
122 await waitJobs(servers) 108 await waitJobs(servers)
123 109
@@ -130,19 +116,15 @@ describe('Playlist thumbnail', function () {
130 it('Should automatically update the thumbnail when moving the first element', async function () { 116 it('Should automatically update the thumbnail when moving the first element', async function () {
131 this.timeout(30000) 117 this.timeout(30000)
132 118
133 const res = await addVideoInPlaylist({ 119 const added = await servers[1].playlists.addElement({
134 url: servers[1].url, 120 playlistId: playlistWithoutThumbnailId,
135 token: servers[1].accessToken, 121 attributes: { videoId: video2 }
136 playlistId: playlistWithoutThumbnail,
137 elementAttrs: { videoId: video2 }
138 }) 122 })
139 withoutThumbnailE2 = res.body.videoPlaylistElement.id 123 withoutThumbnailE2 = added.id
140 124
141 await reorderVideosPlaylist({ 125 await servers[1].playlists.reorderElements({
142 url: servers[1].url, 126 playlistId: playlistWithoutThumbnailId,
143 token: servers[1].accessToken, 127 attributes: {
144 playlistId: playlistWithoutThumbnail,
145 elementAttrs: {
146 startPosition: 1, 128 startPosition: 1,
147 insertAfterPosition: 2 129 insertAfterPosition: 2
148 } 130 }
@@ -159,19 +141,15 @@ describe('Playlist thumbnail', function () {
159 it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () { 141 it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () {
160 this.timeout(30000) 142 this.timeout(30000)
161 143
162 const res = await addVideoInPlaylist({ 144 const added = await servers[1].playlists.addElement({
163 url: servers[1].url, 145 playlistId: playlistWithThumbnailId,
164 token: servers[1].accessToken, 146 attributes: { videoId: video2 }
165 playlistId: playlistWithThumbnail,
166 elementAttrs: { videoId: video2 }
167 }) 147 })
168 withThumbnailE2 = res.body.videoPlaylistElement.id 148 withThumbnailE2 = added.id
169 149
170 await reorderVideosPlaylist({ 150 await servers[1].playlists.reorderElements({
171 url: servers[1].url, 151 playlistId: playlistWithThumbnailId,
172 token: servers[1].accessToken, 152 attributes: {
173 playlistId: playlistWithThumbnail,
174 elementAttrs: {
175 startPosition: 1, 153 startPosition: 1,
176 insertAfterPosition: 2 154 insertAfterPosition: 2
177 } 155 }
@@ -188,11 +166,9 @@ describe('Playlist thumbnail', function () {
188 it('Should automatically update the thumbnail when deleting the first element', async function () { 166 it('Should automatically update the thumbnail when deleting the first element', async function () {
189 this.timeout(30000) 167 this.timeout(30000)
190 168
191 await removeVideoFromPlaylist({ 169 await servers[1].playlists.removeElement({
192 url: servers[1].url, 170 playlistId: playlistWithoutThumbnailId,
193 token: servers[1].accessToken, 171 elementId: withoutThumbnailE1
194 playlistId: playlistWithoutThumbnail,
195 playlistElementId: withoutThumbnailE1
196 }) 172 })
197 173
198 await waitJobs(servers) 174 await waitJobs(servers)
@@ -206,11 +182,9 @@ describe('Playlist thumbnail', function () {
206 it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () { 182 it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () {
207 this.timeout(30000) 183 this.timeout(30000)
208 184
209 await removeVideoFromPlaylist({ 185 await servers[1].playlists.removeElement({
210 url: servers[1].url, 186 playlistId: playlistWithThumbnailId,
211 token: servers[1].accessToken, 187 elementId: withThumbnailE1
212 playlistId: playlistWithThumbnail,
213 playlistElementId: withThumbnailE1
214 }) 188 })
215 189
216 await waitJobs(servers) 190 await waitJobs(servers)
@@ -224,11 +198,9 @@ describe('Playlist thumbnail', function () {
224 it('Should the thumbnail when we delete the last element', async function () { 198 it('Should the thumbnail when we delete the last element', async function () {
225 this.timeout(30000) 199 this.timeout(30000)
226 200
227 await removeVideoFromPlaylist({ 201 await servers[1].playlists.removeElement({
228 url: servers[1].url, 202 playlistId: playlistWithoutThumbnailId,
229 token: servers[1].accessToken, 203 elementId: withoutThumbnailE2
230 playlistId: playlistWithoutThumbnail,
231 playlistElementId: withoutThumbnailE2
232 }) 204 })
233 205
234 await waitJobs(servers) 206 await waitJobs(servers)
@@ -242,11 +214,9 @@ describe('Playlist thumbnail', function () {
242 it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () { 214 it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () {
243 this.timeout(30000) 215 this.timeout(30000)
244 216
245 await removeVideoFromPlaylist({ 217 await servers[1].playlists.removeElement({
246 url: servers[1].url, 218 playlistId: playlistWithThumbnailId,
247 token: servers[1].accessToken, 219 elementId: withThumbnailE2
248 playlistId: playlistWithThumbnail,
249 playlistElementId: withThumbnailE2
250 }) 220 })
251 221
252 await waitJobs(servers) 222 await waitJobs(servers)