diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/videos.ts | 15 | ||||
-rw-r--r-- | server/tests/api/videos/multiple-servers.ts | 8 | ||||
-rw-r--r-- | server/tests/api/videos/services.ts | 3 | ||||
-rw-r--r-- | server/tests/api/videos/video-transcoder.ts | 74 | ||||
-rw-r--r-- | server/tests/cli/create-transcoding-job.ts | 2 | ||||
-rw-r--r-- | server/tests/utils/videos/videos.ts | 3 |
6 files changed, 81 insertions, 24 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 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { VideoDetails } from '../../../../shared/models/videos' | 5 | import { VideoDetails, VideoState } from '../../../../shared/models/videos' |
6 | import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' | 6 | import { getVideoFileFPS } from '../../../helpers/ffmpeg-utils' |
7 | import { | 7 | import { |
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' |
11 | import { join } from 'path' | 22 | import { 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 | ||
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index 557dd8af9..fe1c0c03d 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts | |||
@@ -65,7 +65,7 @@ describe('Test create transcoding jobs', function () { | |||
65 | const env = getEnvCli(servers[0]) | 65 | const env = getEnvCli(servers[0]) |
66 | await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`) | 66 | await execCLI(`${env} npm run create-transcoding-job -- -v ${video2UUID}`) |
67 | 67 | ||
68 | await wait(30000) | 68 | await wait(40000) |
69 | 69 | ||
70 | for (const server of servers) { | 70 | for (const server of servers) { |
71 | const res = await getVideosList(server.url) | 71 | const res = await getVideosList(server.url) |
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index ab0ce12ec..2c1d20ef1 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -27,6 +27,7 @@ type VideoAttributes = { | |||
27 | language?: string | 27 | language?: string |
28 | nsfw?: boolean | 28 | nsfw?: boolean |
29 | commentsEnabled?: boolean | 29 | commentsEnabled?: boolean |
30 | waitTranscoding?: boolean | ||
30 | description?: string | 31 | description?: string |
31 | tags?: string[] | 32 | tags?: string[] |
32 | channelId?: number | 33 | channelId?: number |
@@ -326,6 +327,7 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg | |||
326 | language: 'zh', | 327 | language: 'zh', |
327 | channelId: defaultChannelId, | 328 | channelId: defaultChannelId, |
328 | nsfw: true, | 329 | nsfw: true, |
330 | waitTranscoding: false, | ||
329 | description: 'my super description', | 331 | description: 'my super description', |
330 | support: 'my super support text', | 332 | support: 'my super support text', |
331 | tags: [ 'tag' ], | 333 | tags: [ 'tag' ], |
@@ -341,6 +343,7 @@ async function uploadVideo (url: string, accessToken: string, videoAttributesArg | |||
341 | .field('name', attributes.name) | 343 | .field('name', attributes.name) |
342 | .field('nsfw', JSON.stringify(attributes.nsfw)) | 344 | .field('nsfw', JSON.stringify(attributes.nsfw)) |
343 | .field('commentsEnabled', JSON.stringify(attributes.commentsEnabled)) | 345 | .field('commentsEnabled', JSON.stringify(attributes.commentsEnabled)) |
346 | .field('waitTranscoding', JSON.stringify(attributes.waitTranscoding)) | ||
344 | .field('privacy', attributes.privacy.toString()) | 347 | .field('privacy', attributes.privacy.toString()) |
345 | .field('channelId', attributes.channelId) | 348 | .field('channelId', attributes.channelId) |
346 | 349 | ||