aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/videos.ts')
-rw-r--r--server/tests/utils/videos.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos.ts
index 2a9a236ca..08fa48da6 100644
--- a/server/tests/utils/videos.ts
+++ b/server/tests/utils/videos.ts
@@ -6,6 +6,7 @@ import * as parseTorrent from 'parse-torrent'
6import { makeGetRequest } from './requests' 6import { makeGetRequest } from './requests'
7import { readFilePromise } from './miscs' 7import { readFilePromise } from './miscs'
8import { ServerInfo } from './servers' 8import { ServerInfo } from './servers'
9import { getMyUserInformation } from './users'
9 10
10type VideoAttributes = { 11type VideoAttributes = {
11 name?: string 12 name?: string
@@ -15,6 +16,7 @@ type VideoAttributes = {
15 nsfw?: boolean 16 nsfw?: boolean
16 description?: string 17 description?: string
17 tags?: string[] 18 tags?: string[]
19 channelId?: number
18 fixture?: string 20 fixture?: string
19} 21}
20 22
@@ -162,8 +164,14 @@ async function testVideoImage (url: string, imageName: string, imagePath: string
162 } 164 }
163} 165}
164 166
165function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) { 167async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) {
166 const path = '/api/v1/videos/upload' 168 const path = '/api/v1/videos/upload'
169 let defaultChannelId = '1'
170
171 try {
172 const res = await getMyUserInformation(url, accessToken)
173 defaultChannelId = res.body.videoChannels[0].id
174 } catch (e) { /* empty */ }
167 175
168 // Default attributes 176 // Default attributes
169 let attributes = { 177 let attributes = {
@@ -171,6 +179,7 @@ function uploadVideo (url: string, accessToken: string, videoAttributesArg: Vide
171 category: 5, 179 category: 5,
172 licence: 4, 180 licence: 4,
173 language: 3, 181 language: 3,
182 channelId: defaultChannelId,
174 nsfw: true, 183 nsfw: true,
175 description: 'my super description', 184 description: 'my super description',
176 tags: [ 'tag' ], 185 tags: [ 'tag' ],
@@ -187,6 +196,7 @@ function uploadVideo (url: string, accessToken: string, videoAttributesArg: Vide
187 .field('licence', attributes.licence.toString()) 196 .field('licence', attributes.licence.toString())
188 .field('nsfw', JSON.stringify(attributes.nsfw)) 197 .field('nsfw', JSON.stringify(attributes.nsfw))
189 .field('description', attributes.description) 198 .field('description', attributes.description)
199 .field('channelId', attributes.channelId)
190 200
191 if (attributes.language !== undefined) { 201 if (attributes.language !== undefined) {
192 req.field('language', attributes.language.toString()) 202 req.field('language', attributes.language.toString())