aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/videos/videos.ts')
-rw-r--r--shared/extra-utils/videos/videos.ts27
1 files changed, 24 insertions, 3 deletions
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 929eb42ca..0b6a54046 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -1,6 +1,5 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
2 2
3import { HttpStatusCode } from '@shared/core-utils'
4import { expect } from 'chai' 3import { expect } from 'chai'
5import { pathExists, readdir, readFile } from 'fs-extra' 4import { pathExists, readdir, readFile } from 'fs-extra'
6import * as parseTorrent from 'parse-torrent' 5import * as parseTorrent from 'parse-torrent'
@@ -8,9 +7,18 @@ import { extname, join } from 'path'
8import * as request from 'supertest' 7import * as request from 'supertest'
9import { v4 as uuidv4 } from 'uuid' 8import { v4 as uuidv4 } from 'uuid'
10import validator from 'validator' 9import validator from 'validator'
10import { HttpStatusCode } from '@shared/core-utils'
11import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 11import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
12import { VideoDetails, VideoPrivacy } from '../../models/videos' 12import { VideoDetails, VideoPrivacy } from '../../models/videos'
13import { buildAbsoluteFixturePath, buildServerDirectory, dateIsValid, immutableAssign, testImage, webtorrentAdd } from '../miscs/miscs' 13import {
14 buildAbsoluteFixturePath,
15 buildServerDirectory,
16 dateIsValid,
17 immutableAssign,
18 testImage,
19 wait,
20 webtorrentAdd
21} from '../miscs/miscs'
14import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests' 22import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests'
15import { waitJobs } from '../server/jobs' 23import { waitJobs } from '../server/jobs'
16import { ServerInfo } from '../server/servers' 24import { ServerInfo } from '../server/servers'
@@ -423,8 +431,21 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg
423 req.field('originallyPublishedAt', attributes.originallyPublishedAt) 431 req.field('originallyPublishedAt', attributes.originallyPublishedAt)
424 } 432 }
425 433
426 return req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture)) 434 const res = await req.attach('videofile', buildAbsoluteFixturePath(attributes.fixture))
427 .expect(specialStatus) 435 .expect(specialStatus)
436
437 // Wait torrent generation
438 if (specialStatus === HttpStatusCode.OK_200) {
439 let video: VideoDetails
440 do {
441 const resVideo = await getVideoWithToken(url, accessToken, res.body.video.uuid)
442 video = resVideo.body
443
444 await wait(50)
445 } while (!video.files[0].torrentUrl)
446 }
447
448 return res
428} 449}
429 450
430function updateVideo ( 451function updateVideo (