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