diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 8 | ||||
-rw-r--r-- | shared/extra-utils/miscs/sql.ts | 35 | ||||
-rw-r--r-- | shared/extra-utils/search/videos.ts | 19 | ||||
-rw-r--r-- | shared/extra-utils/server/config.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/server/follows.ts | 26 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/users/accounts.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/users/user-notifications.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/users.ts | 50 | ||||
-rw-r--r-- | shared/extra-utils/videos/video-channels.ts | 37 | ||||
-rw-r--r-- | shared/extra-utils/videos/video-playlists.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 9 |
12 files changed, 138 insertions, 64 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index d1ffb7be4..fb6430e4f 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import { isAbsolute, join } from 'path' | 4 | import { basename, isAbsolute, join, resolve } from 'path' |
5 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
6 | import * as WebTorrent from 'webtorrent' | 6 | import * as WebTorrent from 'webtorrent' |
7 | import { pathExists, readFile } from 'fs-extra' | 7 | import { pathExists, readFile } from 'fs-extra' |
@@ -34,7 +34,11 @@ function webtorrentAdd (torrent: string, refreshWebTorrent = false) { | |||
34 | 34 | ||
35 | function root () { | 35 | function root () { |
36 | // We are in /miscs | 36 | // We are in /miscs |
37 | return join(__dirname, '..', '..', '..') | 37 | let root = join(__dirname, '..', '..', '..') |
38 | |||
39 | if (basename(root) === 'dist') root = resolve(root, '..') | ||
40 | |||
41 | return root | ||
38 | } | 42 | } |
39 | 43 | ||
40 | async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { | 44 | async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { |
diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 3cfae5c23..34477cb78 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts | |||
@@ -1,11 +1,12 @@ | |||
1 | import { QueryTypes, Sequelize } from 'sequelize' | 1 | import { QueryTypes, Sequelize } from 'sequelize' |
2 | import { ServerInfo } from '../server/servers' | ||
2 | 3 | ||
3 | let sequelizes: { [ id: number ]: Sequelize } = {} | 4 | let sequelizes: { [ id: number ]: Sequelize } = {} |
4 | 5 | ||
5 | function getSequelize (serverNumber: number) { | 6 | function getSequelize (internalServerNumber: number) { |
6 | if (sequelizes[serverNumber]) return sequelizes[serverNumber] | 7 | if (sequelizes[internalServerNumber]) return sequelizes[internalServerNumber] |
7 | 8 | ||
8 | const dbname = 'peertube_test' + serverNumber | 9 | const dbname = 'peertube_test' + internalServerNumber |
9 | const username = 'peertube' | 10 | const username = 'peertube' |
10 | const password = 'peertube' | 11 | const password = 'peertube' |
11 | const host = 'localhost' | 12 | const host = 'localhost' |
@@ -18,37 +19,37 @@ function getSequelize (serverNumber: number) { | |||
18 | logging: false | 19 | logging: false |
19 | }) | 20 | }) |
20 | 21 | ||
21 | sequelizes[serverNumber] = seq | 22 | sequelizes[internalServerNumber] = seq |
22 | 23 | ||
23 | return seq | 24 | return seq |
24 | } | 25 | } |
25 | 26 | ||
26 | function setActorField (serverNumber: number, to: string, field: string, value: string) { | 27 | function setActorField (internalServerNumber: number, to: string, field: string, value: string) { |
27 | const seq = getSequelize(serverNumber) | 28 | const seq = getSequelize(internalServerNumber) |
28 | 29 | ||
29 | const options = { type: QueryTypes.UPDATE } | 30 | const options = { type: QueryTypes.UPDATE } |
30 | 31 | ||
31 | return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options) | 32 | return seq.query(`UPDATE actor SET "${field}" = '${value}' WHERE url = '${to}'`, options) |
32 | } | 33 | } |
33 | 34 | ||
34 | function setVideoField (serverNumber: number, uuid: string, field: string, value: string) { | 35 | function setVideoField (internalServerNumber: number, uuid: string, field: string, value: string) { |
35 | const seq = getSequelize(serverNumber) | 36 | const seq = getSequelize(internalServerNumber) |
36 | 37 | ||
37 | const options = { type: QueryTypes.UPDATE } | 38 | const options = { type: QueryTypes.UPDATE } |
38 | 39 | ||
39 | return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) | 40 | return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) |
40 | } | 41 | } |
41 | 42 | ||
42 | function setPlaylistField (serverNumber: number, uuid: string, field: string, value: string) { | 43 | function setPlaylistField (internalServerNumber: number, uuid: string, field: string, value: string) { |
43 | const seq = getSequelize(serverNumber) | 44 | const seq = getSequelize(internalServerNumber) |
44 | 45 | ||
45 | const options = { type: QueryTypes.UPDATE } | 46 | const options = { type: QueryTypes.UPDATE } |
46 | 47 | ||
47 | return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) | 48 | return seq.query(`UPDATE "videoPlaylist" SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) |
48 | } | 49 | } |
49 | 50 | ||
50 | async function countVideoViewsOf (serverNumber: number, uuid: string) { | 51 | async function countVideoViewsOf (internalServerNumber: number, uuid: string) { |
51 | const seq = getSequelize(serverNumber) | 52 | const seq = getSequelize(internalServerNumber) |
52 | 53 | ||
53 | // tslint:disable | 54 | // tslint:disable |
54 | const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` | 55 | const query = `SELECT SUM("videoView"."views") AS "total" FROM "videoView" INNER JOIN "video" ON "video"."id" = "videoView"."videoId" WHERE "video"."uuid" = '${uuid}'` |
@@ -62,11 +63,11 @@ async function countVideoViewsOf (serverNumber: number, uuid: string) { | |||
62 | return parseInt(total + '', 10) | 63 | return parseInt(total + '', 10) |
63 | } | 64 | } |
64 | 65 | ||
65 | async function closeAllSequelize (servers: any[]) { | 66 | async function closeAllSequelize (servers: ServerInfo[]) { |
66 | for (let i = 1; i <= servers.length; i++) { | 67 | for (const server of servers) { |
67 | if (sequelizes[ i ]) { | 68 | if (sequelizes[ server.internalServerNumber ]) { |
68 | await sequelizes[ i ].close() | 69 | await sequelizes[ server.internalServerNumber ].close() |
69 | delete sequelizes[ i ] | 70 | delete sequelizes[ server.internalServerNumber ] |
70 | } | 71 | } |
71 | } | 72 | } |
72 | } | 73 | } |
diff --git a/shared/extra-utils/search/videos.ts b/shared/extra-utils/search/videos.ts index ba4627017..5cf8d8cf0 100644 --- a/shared/extra-utils/search/videos.ts +++ b/shared/extra-utils/search/videos.ts | |||
@@ -6,9 +6,11 @@ import { immutableAssign } from '../miscs/miscs' | |||
6 | 6 | ||
7 | function searchVideo (url: string, search: string) { | 7 | function searchVideo (url: string, search: string) { |
8 | const path = '/api/v1/search/videos' | 8 | const path = '/api/v1/search/videos' |
9 | |||
10 | const query = { sort: '-publishedAt', search: search } | ||
9 | const req = request(url) | 11 | const req = request(url) |
10 | .get(path) | 12 | .get(path) |
11 | .query({ sort: '-publishedAt', search }) | 13 | .query(query) |
12 | .set('Accept', 'application/json') | 14 | .set('Accept', 'application/json') |
13 | 15 | ||
14 | return req.expect(200) | 16 | return req.expect(200) |
@@ -30,11 +32,15 @@ function searchVideoWithToken (url: string, search: string, token: string, query | |||
30 | function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { | 32 | function searchVideoWithPagination (url: string, search: string, start: number, count: number, sort?: string) { |
31 | const path = '/api/v1/search/videos' | 33 | const path = '/api/v1/search/videos' |
32 | 34 | ||
35 | const query = { | ||
36 | start, | ||
37 | search, | ||
38 | count | ||
39 | } | ||
40 | |||
33 | const req = request(url) | 41 | const req = request(url) |
34 | .get(path) | 42 | .get(path) |
35 | .query({ start }) | 43 | .query(query) |
36 | .query({ search }) | ||
37 | .query({ count }) | ||
38 | 44 | ||
39 | if (sort) req.query({ sort }) | 45 | if (sort) req.query({ sort }) |
40 | 46 | ||
@@ -46,10 +52,11 @@ function searchVideoWithPagination (url: string, search: string, start: number, | |||
46 | function searchVideoWithSort (url: string, search: string, sort: string) { | 52 | function searchVideoWithSort (url: string, search: string, sort: string) { |
47 | const path = '/api/v1/search/videos' | 53 | const path = '/api/v1/search/videos' |
48 | 54 | ||
55 | const query = { search, sort } | ||
56 | |||
49 | return request(url) | 57 | return request(url) |
50 | .get(path) | 58 | .get(path) |
51 | .query({ search }) | 59 | .query(query) |
52 | .query({ sort }) | ||
53 | .set('Accept', 'application/json') | 60 | .set('Accept', 'application/json') |
54 | .expect(200) | 61 | .expect(200) |
55 | .expect('Content-Type', /json/) | 62 | .expect('Content-Type', /json/) |
diff --git a/shared/extra-utils/server/config.ts b/shared/extra-utils/server/config.ts index deb77e9c0..2b7965bc2 100644 --- a/shared/extra-utils/server/config.ts +++ b/shared/extra-utils/server/config.ts | |||
@@ -91,13 +91,15 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) { | |||
91 | transcoding: { | 91 | transcoding: { |
92 | enabled: true, | 92 | enabled: true, |
93 | allowAdditionalExtensions: true, | 93 | allowAdditionalExtensions: true, |
94 | allowAudioFiles: true, | ||
94 | threads: 1, | 95 | threads: 1, |
95 | resolutions: { | 96 | resolutions: { |
96 | '240p': false, | 97 | '240p': false, |
97 | '360p': true, | 98 | '360p': true, |
98 | '480p': true, | 99 | '480p': true, |
99 | '720p': false, | 100 | '720p': false, |
100 | '1080p': false | 101 | '1080p': false, |
102 | '2160p': false | ||
101 | }, | 103 | }, |
102 | hls: { | 104 | hls: { |
103 | enabled: false | 105 | enabled: false |
diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts index 1505804de..0379bb109 100644 --- a/shared/extra-utils/server/follows.ts +++ b/shared/extra-utils/server/follows.ts | |||
@@ -1,17 +1,21 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { ServerInfo } from './servers' | 2 | import { ServerInfo } from './servers' |
3 | import { waitJobs } from './jobs' | 3 | import { waitJobs } from './jobs' |
4 | import { makeGetRequest, makePostBodyRequest } from '..' | 4 | import { makePostBodyRequest } from '../requests/requests' |
5 | 5 | ||
6 | function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { | 6 | function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { |
7 | const path = '/api/v1/server/followers' | 7 | const path = '/api/v1/server/followers' |
8 | 8 | ||
9 | const query = { | ||
10 | start, | ||
11 | count, | ||
12 | sort, | ||
13 | search | ||
14 | } | ||
15 | |||
9 | return request(url) | 16 | return request(url) |
10 | .get(path) | 17 | .get(path) |
11 | .query({ start }) | 18 | .query(query) |
12 | .query({ count }) | ||
13 | .query({ sort }) | ||
14 | .query({ search }) | ||
15 | .set('Accept', 'application/json') | 19 | .set('Accept', 'application/json') |
16 | .expect(200) | 20 | .expect(200) |
17 | .expect('Content-Type', /json/) | 21 | .expect('Content-Type', /json/) |
@@ -42,12 +46,16 @@ function rejectFollower (url: string, token: string, follower: string, statusCod | |||
42 | function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { | 46 | function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) { |
43 | const path = '/api/v1/server/following' | 47 | const path = '/api/v1/server/following' |
44 | 48 | ||
49 | const query = { | ||
50 | start, | ||
51 | count, | ||
52 | sort, | ||
53 | search | ||
54 | } | ||
55 | |||
45 | return request(url) | 56 | return request(url) |
46 | .get(path) | 57 | .get(path) |
47 | .query({ start }) | 58 | .query(query) |
48 | .query({ count }) | ||
49 | .query({ sort }) | ||
50 | .query({ search }) | ||
51 | .set('Accept', 'application/json') | 59 | .set('Accept', 'application/json') |
52 | .expect(200) | 60 | .expect(200) |
53 | .expect('Content-Type', /json/) | 61 | .expect('Content-Type', /json/) |
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index ed41bfa48..4c7d6862a 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -246,7 +246,7 @@ async function checkTmpIsEmpty (server: ServerInfo) { | |||
246 | } | 246 | } |
247 | 247 | ||
248 | async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { | 248 | async function checkDirectoryIsEmpty (server: ServerInfo, directory: string) { |
249 | const testDirectory = 'test' + server.serverNumber | 249 | const testDirectory = 'test' + server.internalServerNumber |
250 | 250 | ||
251 | const directoryPath = join(root(), testDirectory, directory) | 251 | const directoryPath = join(root(), testDirectory, directory) |
252 | 252 | ||
@@ -284,7 +284,7 @@ function cleanupTests (servers: ServerInfo[]) { | |||
284 | } | 284 | } |
285 | 285 | ||
286 | async function waitUntilLog (server: ServerInfo, str: string, count = 1) { | 286 | async function waitUntilLog (server: ServerInfo, str: string, count = 1) { |
287 | const logfile = join(root(), 'test' + server.serverNumber, 'logs/peertube.log') | 287 | const logfile = join(root(), 'test' + server.internalServerNumber, 'logs/peertube.log') |
288 | 288 | ||
289 | while (true) { | 289 | while (true) { |
290 | const buf = await readFile(logfile) | 290 | const buf = await readFile(logfile) |
diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts index f64a2dbad..627e17cc3 100644 --- a/shared/extra-utils/users/accounts.ts +++ b/shared/extra-utils/users/accounts.ts | |||
@@ -39,7 +39,7 @@ async function expectAccountFollows (url: string, nameWithDomain: string, follow | |||
39 | expect(account.followingCount).to.equal(followingCount, message) | 39 | expect(account.followingCount).to.equal(followingCount, message) |
40 | } | 40 | } |
41 | 41 | ||
42 | async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { | 42 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { |
43 | const testDirectory = 'test' + serverNumber | 43 | const testDirectory = 'test' + serverNumber |
44 | 44 | ||
45 | for (const directory of [ 'avatars' ]) { | 45 | for (const directory of [ 'avatars' ]) { |
@@ -50,7 +50,7 @@ async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: numb | |||
50 | 50 | ||
51 | const files = await readdir(directoryPath) | 51 | const files = await readdir(directoryPath) |
52 | for (const file of files) { | 52 | for (const file of files) { |
53 | expect(file).to.not.contain(actorUUID) | 53 | expect(file).to.not.contain(filename) |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts index 495ff80d9..f7de542bf 100644 --- a/shared/extra-utils/users/user-notifications.ts +++ b/shared/extra-utils/users/user-notifications.ts | |||
@@ -380,7 +380,7 @@ async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, | |||
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | const commentUrl = `http://localhost:9001/videos/watch/${uuid};threadId=${threadId}` | 383 | const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}` |
384 | function emailFinder (email: object) { | 384 | function emailFinder (email: object) { |
385 | return email[ 'text' ].indexOf(commentUrl) !== -1 | 385 | return email[ 'text' ].indexOf(commentUrl) !== -1 |
386 | } | 386 | } |
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts index 2bd37b8be..1c39881d6 100644 --- a/shared/extra-utils/users/users.ts +++ b/shared/extra-utils/users/users.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' | 2 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' |
3 | 3 | ||
4 | import { UserRole } from '../../index' | 4 | import { UserCreate, UserRole } from '../../index' |
5 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' | 5 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' |
6 | import { ServerInfo, userLogin } from '..' | 6 | import { ServerInfo, userLogin } from '..' |
7 | import { UserAdminFlag } from '../../models/users/user-flag.model' | 7 | import { UserAdminFlag } from '../../models/users/user-flag.model' |
8 | import { UserRegister } from '../../models/users/user-register.model' | ||
8 | 9 | ||
9 | type CreateUserArgs = { url: string, | 10 | type CreateUserArgs = { url: string, |
10 | accessToken: string, | 11 | accessToken: string, |
@@ -70,6 +71,31 @@ function registerUser (url: string, username: string, password: string, specialS | |||
70 | .expect(specialStatus) | 71 | .expect(specialStatus) |
71 | } | 72 | } |
72 | 73 | ||
74 | function registerUserWithChannel (options: { | ||
75 | url: string, | ||
76 | user: { username: string, password: string, displayName?: string }, | ||
77 | channel: { name: string, displayName: string } | ||
78 | }) { | ||
79 | const path = '/api/v1/users/register' | ||
80 | const body: UserRegister = { | ||
81 | username: options.user.username, | ||
82 | password: options.user.password, | ||
83 | email: options.user.username + '@example.com', | ||
84 | channel: options.channel | ||
85 | } | ||
86 | |||
87 | if (options.user.displayName) { | ||
88 | Object.assign(body, { displayName: options.user.displayName }) | ||
89 | } | ||
90 | |||
91 | return makePostBodyRequest({ | ||
92 | url: options.url, | ||
93 | path, | ||
94 | fields: body, | ||
95 | statusCodeExpected: 204 | ||
96 | }) | ||
97 | } | ||
98 | |||
73 | function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { | 99 | function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { |
74 | const path = '/api/v1/users/me' | 100 | const path = '/api/v1/users/me' |
75 | 101 | ||
@@ -138,12 +164,16 @@ function getUsersList (url: string, accessToken: string) { | |||
138 | function getUsersListPaginationAndSort (url: string, accessToken: string, start: number, count: number, sort: string, search?: string) { | 164 | function getUsersListPaginationAndSort (url: string, accessToken: string, start: number, count: number, sort: string, search?: string) { |
139 | const path = '/api/v1/users' | 165 | const path = '/api/v1/users' |
140 | 166 | ||
167 | const query = { | ||
168 | start, | ||
169 | count, | ||
170 | sort, | ||
171 | search | ||
172 | } | ||
173 | |||
141 | return request(url) | 174 | return request(url) |
142 | .get(path) | 175 | .get(path) |
143 | .query({ start }) | 176 | .query(query) |
144 | .query({ count }) | ||
145 | .query({ sort }) | ||
146 | .query({ search }) | ||
147 | .set('Accept', 'application/json') | 177 | .set('Accept', 'application/json') |
148 | .set('Authorization', 'Bearer ' + accessToken) | 178 | .set('Authorization', 'Bearer ' + accessToken) |
149 | .expect(200) | 179 | .expect(200) |
@@ -293,13 +323,16 @@ function askSendVerifyEmail (url: string, email: string) { | |||
293 | }) | 323 | }) |
294 | } | 324 | } |
295 | 325 | ||
296 | function verifyEmail (url: string, userId: number, verificationString: string, statusCodeExpected = 204) { | 326 | function verifyEmail (url: string, userId: number, verificationString: string, isPendingEmail = false, statusCodeExpected = 204) { |
297 | const path = '/api/v1/users/' + userId + '/verify-email' | 327 | const path = '/api/v1/users/' + userId + '/verify-email' |
298 | 328 | ||
299 | return makePostBodyRequest({ | 329 | return makePostBodyRequest({ |
300 | url, | 330 | url, |
301 | path, | 331 | path, |
302 | fields: { verificationString }, | 332 | fields: { |
333 | verificationString, | ||
334 | isPendingEmail | ||
335 | }, | ||
303 | statusCodeExpected | 336 | statusCodeExpected |
304 | }) | 337 | }) |
305 | } | 338 | } |
@@ -312,6 +345,7 @@ export { | |||
312 | getMyUserInformation, | 345 | getMyUserInformation, |
313 | getMyUserVideoRating, | 346 | getMyUserVideoRating, |
314 | deleteMe, | 347 | deleteMe, |
348 | registerUserWithChannel, | ||
315 | getMyUserVideoQuotaUsed, | 349 | getMyUserVideoQuotaUsed, |
316 | getUsersList, | 350 | getUsersList, |
317 | getUsersListPaginationAndSort, | 351 | getUsersListPaginationAndSort, |
diff --git a/shared/extra-utils/videos/video-channels.ts b/shared/extra-utils/videos/video-channels.ts index 93a257bf9..3e79cf15a 100644 --- a/shared/extra-utils/videos/video-channels.ts +++ b/shared/extra-utils/videos/video-channels.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos' | 2 | import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos' |
3 | import { updateAvatarRequest } from '../requests/requests' | 3 | import { makeGetRequest, updateAvatarRequest } from '../requests/requests' |
4 | import { getMyUserInformation, ServerInfo } from '..' | 4 | import { getMyUserInformation, ServerInfo } from '..' |
5 | import { User } from '../..' | 5 | import { User } from '../..' |
6 | 6 | ||
@@ -19,14 +19,28 @@ function getVideoChannelsList (url: string, start: number, count: number, sort?: | |||
19 | .expect('Content-Type', /json/) | 19 | .expect('Content-Type', /json/) |
20 | } | 20 | } |
21 | 21 | ||
22 | function getAccountVideoChannelsList (url: string, accountName: string, specialStatus = 200) { | 22 | function getAccountVideoChannelsList (parameters: { |
23 | url: string, | ||
24 | accountName: string, | ||
25 | start?: number, | ||
26 | count?: number, | ||
27 | sort?: string, | ||
28 | specialStatus?: number | ||
29 | }) { | ||
30 | const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200 } = parameters | ||
31 | |||
23 | const path = '/api/v1/accounts/' + accountName + '/video-channels' | 32 | const path = '/api/v1/accounts/' + accountName + '/video-channels' |
24 | 33 | ||
25 | return request(url) | 34 | return makeGetRequest({ |
26 | .get(path) | 35 | url, |
27 | .set('Accept', 'application/json') | 36 | path, |
28 | .expect(specialStatus) | 37 | query: { |
29 | .expect('Content-Type', /json/) | 38 | start, |
39 | count, | ||
40 | sort | ||
41 | }, | ||
42 | statusCodeExpected: specialStatus | ||
43 | }) | ||
30 | } | 44 | } |
31 | 45 | ||
32 | function addVideoChannel ( | 46 | function addVideoChannel ( |
@@ -60,12 +74,13 @@ function updateVideoChannel ( | |||
60 | attributes: VideoChannelUpdate, | 74 | attributes: VideoChannelUpdate, |
61 | expectedStatus = 204 | 75 | expectedStatus = 204 |
62 | ) { | 76 | ) { |
63 | const body = {} | 77 | const body: any = {} |
64 | const path = '/api/v1/video-channels/' + channelName | 78 | const path = '/api/v1/video-channels/' + channelName |
65 | 79 | ||
66 | if (attributes.displayName) body['displayName'] = attributes.displayName | 80 | if (attributes.displayName) body.displayName = attributes.displayName |
67 | if (attributes.description) body['description'] = attributes.description | 81 | if (attributes.description) body.description = attributes.description |
68 | if (attributes.support) body['support'] = attributes.support | 82 | if (attributes.support) body.support = attributes.support |
83 | if (attributes.bulkVideosSupportUpdate) body.bulkVideosSupportUpdate = attributes.bulkVideosSupportUpdate | ||
69 | 84 | ||
70 | return request(url) | 85 | return request(url) |
71 | .put(path) | 86 | .put(path) |
diff --git a/shared/extra-utils/videos/video-playlists.ts b/shared/extra-utils/videos/video-playlists.ts index 4d110a131..fd62bef19 100644 --- a/shared/extra-utils/videos/video-playlists.ts +++ b/shared/extra-utils/videos/video-playlists.ts | |||
@@ -252,10 +252,10 @@ function reorderVideosPlaylist (options: { | |||
252 | 252 | ||
253 | async function checkPlaylistFilesWereRemoved ( | 253 | async function checkPlaylistFilesWereRemoved ( |
254 | playlistUUID: string, | 254 | playlistUUID: string, |
255 | serverNumber: number, | 255 | internalServerNumber: number, |
256 | directories = [ 'thumbnails' ] | 256 | directories = [ 'thumbnails' ] |
257 | ) { | 257 | ) { |
258 | const testDirectory = 'test' + serverNumber | 258 | const testDirectory = 'test' + internalServerNumber |
259 | 259 | ||
260 | for (const directory of directories) { | 260 | for (const directory of directories) { |
261 | const directoryPath = join(root(), testDirectory, directory) | 261 | const directoryPath = join(root(), testDirectory, directory) |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index b5a07b792..c78563232 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -362,6 +362,10 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg | |||
362 | .field('privacy', attributes.privacy.toString()) | 362 | .field('privacy', attributes.privacy.toString()) |
363 | .field('channelId', attributes.channelId) | 363 | .field('channelId', attributes.channelId) |
364 | 364 | ||
365 | if (attributes.support !== undefined) { | ||
366 | req.field('support', attributes.support) | ||
367 | } | ||
368 | |||
365 | if (attributes.description !== undefined) { | 369 | if (attributes.description !== undefined) { |
366 | req.field('description', attributes.description) | 370 | req.field('description', attributes.description) |
367 | } | 371 | } |
@@ -524,7 +528,6 @@ async function completeVideoCheck ( | |||
524 | expect(video.nsfw).to.equal(attributes.nsfw) | 528 | expect(video.nsfw).to.equal(attributes.nsfw) |
525 | expect(video.description).to.equal(attributes.description) | 529 | expect(video.description).to.equal(attributes.description) |
526 | expect(video.account.id).to.be.a('number') | 530 | expect(video.account.id).to.be.a('number') |
527 | expect(video.account.uuid).to.be.a('string') | ||
528 | expect(video.account.host).to.equal(attributes.account.host) | 531 | expect(video.account.host).to.equal(attributes.account.host) |
529 | expect(video.account.name).to.equal(attributes.account.name) | 532 | expect(video.account.name).to.equal(attributes.account.name) |
530 | expect(video.channel.displayName).to.equal(attributes.channel.displayName) | 533 | expect(video.channel.displayName).to.equal(attributes.channel.displayName) |
@@ -568,8 +571,8 @@ async function completeVideoCheck ( | |||
568 | expect(file).not.to.be.undefined | 571 | expect(file).not.to.be.undefined |
569 | 572 | ||
570 | let extension = extname(attributes.fixture) | 573 | let extension = extname(attributes.fixture) |
571 | // Transcoding enabled on server 2, extension will always be .mp4 | 574 | // Transcoding enabled: extension will always be .mp4 |
572 | if (attributes.account.host === 'localhost:9002') extension = '.mp4' | 575 | if (attributes.files.length > 1) extension = '.mp4' |
573 | 576 | ||
574 | const magnetUri = file.magnetUri | 577 | const magnetUri = file.magnetUri |
575 | expect(file.magnetUri).to.have.lengthOf.above(2) | 578 | expect(file.magnetUri).to.have.lengthOf.above(2) |