aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins
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/plugins
parent72cbfc5695ec5ebdb9721d3648218f63feeaeac5 (diff)
downloadPeerTube-e6346d59e63135cf012ed18c102d3b0179ef565f.tar.gz
PeerTube-e6346d59e63135cf012ed18c102d3b0179ef565f.tar.zst
PeerTube-e6346d59e63135cf012ed18c102d3b0179ef565f.zip
Introduce playlist command
Diffstat (limited to 'server/tests/plugins')
-rw-r--r--server/tests/plugins/action-hooks.ts17
-rw-r--r--server/tests/plugins/filter-hooks.ts10
-rw-r--r--server/tests/plugins/video-constants.ts17
3 files changed, 12 insertions, 32 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 5e9dc3515..fd83bf2ac 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -5,10 +5,8 @@ import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/mode
5import { 5import {
6 addVideoCommentReply, 6 addVideoCommentReply,
7 addVideoCommentThread, 7 addVideoCommentThread,
8 addVideoInPlaylist,
9 blockUser, 8 blockUser,
10 createUser, 9 createUser,
11 createVideoPlaylist,
12 deleteVideoComment, 10 deleteVideoComment,
13 PluginsCommand, 11 PluginsCommand,
14 registerUser, 12 registerUser,
@@ -180,15 +178,13 @@ describe('Test plugin action hooks', function () {
180 178
181 before(async function () { 179 before(async function () {
182 { 180 {
183 const res = await createVideoPlaylist({ 181 const { id } = await servers[0].playlistsCommand.create({
184 url: servers[0].url, 182 attributes: {
185 token: servers[0].accessToken,
186 playlistAttrs: {
187 displayName: 'My playlist', 183 displayName: 'My playlist',
188 privacy: VideoPlaylistPrivacy.PRIVATE 184 privacy: VideoPlaylistPrivacy.PRIVATE
189 } 185 }
190 }) 186 })
191 playlistId = res.body.videoPlaylist.id 187 playlistId = id
192 } 188 }
193 189
194 { 190 {
@@ -198,12 +194,7 @@ describe('Test plugin action hooks', function () {
198 }) 194 })
199 195
200 it('Should run action:api.video-playlist-element.created', async function () { 196 it('Should run action:api.video-playlist-element.created', async function () {
201 await addVideoInPlaylist({ 197 await servers[0].playlistsCommand.addElement({ playlistId, attributes: { videoId } })
202 url: servers[0].url,
203 token: servers[0].accessToken,
204 playlistId,
205 elementAttrs: { videoId }
206 })
207 198
208 await checkHook('action:api.video-playlist-element.created') 199 await checkHook('action:api.video-playlist-element.created')
209 }) 200 })
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index e938663da..203642d8d 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -7,7 +7,6 @@ import {
7 addVideoCommentReply, 7 addVideoCommentReply,
8 addVideoCommentThread, 8 addVideoCommentThread,
9 cleanupTests, 9 cleanupTests,
10 createVideoPlaylist,
11 doubleFollow, 10 doubleFollow,
12 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
13 getAccountVideos, 12 getAccountVideos,
@@ -15,7 +14,6 @@ import {
15 getVideo, 14 getVideo,
16 getVideoChannelVideos, 15 getVideoChannelVideos,
17 getVideoCommentThreads, 16 getVideoCommentThreads,
18 getVideoPlaylist,
19 getVideosList, 17 getVideosList,
20 getVideosListPagination, 18 getVideosListPagination,
21 getVideoThreadComments, 19 getVideoThreadComments,
@@ -443,11 +441,11 @@ describe('Test plugin filter hooks', function () {
443 } 441 }
444 442
445 { 443 {
446 const playlistAttrs = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC } 444 const attributes = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
447 const res = await createVideoPlaylist({ url: servers[0].url, token: servers[0].accessToken, playlistAttrs }) 445 const { id } = await servers[0].playlistsCommand.create({ attributes })
448 446
449 const resPlaylist = await getVideoPlaylist(servers[0].url, res.body.videoPlaylist.id) 447 const playlist = await servers[0].playlistsCommand.get({ playlistId: id })
450 embedPlaylists.push(resPlaylist.body) 448 embedPlaylists.push(playlist)
451 } 449 }
452 } 450 }
453 }) 451 })
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index 4124e8a52..4a05af042 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -5,13 +5,11 @@ import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createVideoPlaylist,
9 flushAndRunServer, 8 flushAndRunServer,
10 getVideo, 9 getVideo,
11 getVideoCategories, 10 getVideoCategories,
12 getVideoLanguages, 11 getVideoLanguages,
13 getVideoLicences, 12 getVideoLicences,
14 getVideoPlaylistPrivacies,
15 getVideoPrivacies, 13 getVideoPrivacies,
16 PluginsCommand, 14 PluginsCommand,
17 ServerInfo, 15 ServerInfo,
@@ -79,8 +77,7 @@ describe('Test plugin altering video constants', function () {
79 }) 77 })
80 78
81 it('Should have updated playlist privacies', async function () { 79 it('Should have updated playlist privacies', async function () {
82 const res = await getVideoPlaylistPrivacies(server.url) 80 const playlistPrivacies = await server.playlistsCommand.getPrivacies()
83 const playlistPrivacies = res.body
84 81
85 expect(playlistPrivacies[1]).to.exist 82 expect(playlistPrivacies[1]).to.exist
86 expect(playlistPrivacies[2]).to.exist 83 expect(playlistPrivacies[2]).to.exist
@@ -93,13 +90,8 @@ describe('Test plugin altering video constants', function () {
93 }) 90 })
94 91
95 it('Should not be able to create a video with this privacy', async function () { 92 it('Should not be able to create a video with this privacy', async function () {
96 const attrs = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE } 93 const attributes = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE }
97 await createVideoPlaylist({ 94 await server.playlistsCommand.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
98 url: server.url,
99 token: server.accessToken,
100 playlistAttrs: attrs,
101 expectedStatus: HttpStatusCode.BAD_REQUEST_400
102 })
103 }) 95 })
104 96
105 it('Should be able to upload a video with these values', async function () { 97 it('Should be able to upload a video with these values', async function () {
@@ -162,8 +154,7 @@ describe('Test plugin altering video constants', function () {
162 } 154 }
163 155
164 { 156 {
165 const res = await getVideoPlaylistPrivacies(server.url) 157 const playlistPrivacies = await server.playlistsCommand.getPrivacies()
166 const playlistPrivacies = res.body
167 158
168 expect(playlistPrivacies[1]).to.exist 159 expect(playlistPrivacies[1]).to.exist
169 expect(playlistPrivacies[2]).to.exist 160 expect(playlistPrivacies[2]).to.exist