aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/check-params/videos.ts15
-rw-r--r--server/tests/api/videos/multiple-servers.ts8
-rw-r--r--server/tests/api/videos/services.ts3
-rw-r--r--server/tests/api/videos/video-transcoder.ts74
4 files changed, 77 insertions, 23 deletions
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index bc6c7fc46..04bed3b44 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -175,6 +175,7 @@ describe('Test videos API validator', function () {
175 language: 'pt', 175 language: 'pt',
176 nsfw: false, 176 nsfw: false,
177 commentsEnabled: true, 177 commentsEnabled: true,
178 waitTranscoding: true,
178 description: 'my super description', 179 description: 'my super description',
179 support: 'my super support text', 180 support: 'my super support text',
180 tags: [ 'tag1', 'tag2' ], 181 tags: [ 'tag1', 'tag2' ],
@@ -224,20 +225,6 @@ describe('Test videos API validator', function () {
224 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 225 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
225 }) 226 })
226 227
227 it('Should fail without nsfw attribute', async function () {
228 const fields = omit(baseCorrectParams, 'nsfw')
229 const attaches = baseCorrectAttaches
230
231 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
232 })
233
234 it('Should fail without commentsEnabled attribute', async function () {
235 const fields = omit(baseCorrectParams, 'commentsEnabled')
236 const attaches = baseCorrectAttaches
237
238 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
239 })
240
241 it('Should fail with a long description', async function () { 228 it('Should fail with a long description', async function () {
242 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) }) 229 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
243 const attaches = baseCorrectAttaches 230 const attaches = baseCorrectAttaches
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 5f9a76621..edc46a644 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -924,7 +924,7 @@ describe('Test multiple servers', function () {
924 924
925 describe('With minimum parameters', function () { 925 describe('With minimum parameters', function () {
926 it('Should upload and propagate the video', async function () { 926 it('Should upload and propagate the video', async function () {
927 this.timeout(50000) 927 this.timeout(60000)
928 928
929 const path = '/api/v1/videos/upload' 929 const path = '/api/v1/videos/upload'
930 930
@@ -934,16 +934,14 @@ describe('Test multiple servers', function () {
934 .set('Authorization', 'Bearer ' + servers[1].accessToken) 934 .set('Authorization', 'Bearer ' + servers[1].accessToken)
935 .field('name', 'minimum parameters') 935 .field('name', 'minimum parameters')
936 .field('privacy', '1') 936 .field('privacy', '1')
937 .field('nsfw', 'false')
938 .field('channelId', '1') 937 .field('channelId', '1')
939 .field('commentsEnabled', 'true')
940 938
941 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') 939 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
942 940
943 await req.attach('videofile', filePath) 941 await req.attach('videofile', filePath)
944 .expect(200) 942 .expect(200)
945 943
946 await wait(25000) 944 await wait(40000)
947 945
948 for (const server of servers) { 946 for (const server of servers) {
949 const res = await getVideosList(server.url) 947 const res = await getVideosList(server.url)
@@ -964,7 +962,7 @@ describe('Test multiple servers', function () {
964 }, 962 },
965 isLocal, 963 isLocal,
966 duration: 5, 964 duration: 5,
967 commentsEnabled: true, 965 commentsEnabled: false,
968 tags: [ ], 966 tags: [ ],
969 privacy: VideoPrivacy.PUBLIC, 967 privacy: VideoPrivacy.PUBLIC,
970 channel: { 968 channel: {
diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts
index 45b4a1a81..51db000a2 100644
--- a/server/tests/api/videos/services.ts
+++ b/server/tests/api/videos/services.ts
@@ -32,7 +32,8 @@ describe('Test services', function () {
32 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid 32 const oembedUrl = 'http://localhost:9001/videos/watch/' + server.video.uuid
33 33
34 const res = await getOEmbed(server.url, oembedUrl) 34 const res = await getOEmbed(server.url, oembedUrl)
35 const expectedHtml = `<iframe width="560" height="315" src="http://localhost:9001/videos/embed/${server.video.uuid}" ` + 35 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
36 `src="http://localhost:9001/videos/embed/${server.video.uuid}" ` +
36 'frameborder="0" allowfullscreen></iframe>' 37 'frameborder="0" allowfullscreen></iframe>'
37 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg' 38 const expectedThumbnailUrl = 'http://localhost:9001/static/previews/' + server.video.uuid + '.jpg'
38 39
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index ef929960d..1eace6491 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -2,11 +2,22 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoDetails } from '../../../../shared/models/videos' 5import { VideoDetails, VideoState } from '../../../../shared/models/videos'
6import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' 6import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils'
7import { 7import {
8 flushAndRunMultipleServers, flushTests, getVideo, getVideosList, killallServers, root, ServerInfo, setAccessTokensToServers, uploadVideo, 8 doubleFollow,
9 wait, webtorrentAdd 9 flushAndRunMultipleServers,
10 flushTests,
11 getMyVideos,
12 getVideo,
13 getVideosList,
14 killallServers,
15 root,
16 ServerInfo,
17 setAccessTokensToServers,
18 uploadVideo,
19 wait,
20 webtorrentAdd
10} from '../../utils' 21} from '../../utils'
11import { join } from 'path' 22import { join } from 'path'
12 23
@@ -109,6 +120,63 @@ describe('Test video transcoding', function () {
109 } 120 }
110 }) 121 })
111 122
123 it('Should wait transcoding before publishing the video', async function () {
124 this.timeout(80000)
125
126 await doubleFollow(servers[0], servers[1])
127
128 await wait(15000)
129
130 {
131 // Upload the video, but wait transcoding
132 const videoAttributes = {
133 name: 'waiting video',
134 fixture: 'video_short1.webm',
135 waitTranscoding: true
136 }
137 const resVideo = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, videoAttributes)
138 const videoId = resVideo.body.video.uuid
139
140 // Should be in transcode state
141 const { body } = await getVideo(servers[ 1 ].url, videoId)
142 expect(body.name).to.equal('waiting video')
143 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
144 expect(body.state.label).to.equal('To transcode')
145 expect(body.waitTranscoding).to.be.true
146
147 // Should have my video
148 const resMyVideos = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 10)
149 const videoToFindInMine = resMyVideos.body.data.find(v => v.name === 'waiting video')
150 expect(videoToFindInMine).not.to.be.undefined
151 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
152 expect(videoToFindInMine.state.label).to.equal('To transcode')
153 expect(videoToFindInMine.waitTranscoding).to.be.true
154
155 // Should not list this video
156 const resVideos = await getVideosList(servers[1].url)
157 const videoToFindInList = resVideos.body.data.find(v => v.name === 'waiting video')
158 expect(videoToFindInList).to.be.undefined
159
160 // Server 1 should not have the video yet
161 await getVideo(servers[0].url, videoId, 404)
162 }
163
164 await wait(30000)
165
166 for (const server of servers) {
167 const res = await getVideosList(server.url)
168 const videoToFind = res.body.data.find(v => v.name === 'waiting video')
169 expect(videoToFind).not.to.be.undefined
170
171 const res2 = await getVideo(server.url, videoToFind.id)
172 const videoDetails: VideoDetails = res2.body
173
174 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
175 expect(videoDetails.state.label).to.equal('Published')
176 expect(videoDetails.waitTranscoding).to.be.true
177 }
178 })
179
112 after(async function () { 180 after(async function () {
113 killallServers(servers) 181 killallServers(servers)
114 182