aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/single-server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/videos/single-server.ts')
-rw-r--r--server/tests/api/videos/single-server.ts272
1 files changed, 67 insertions, 205 deletions
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index c503ec0e7..831be3422 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -4,6 +4,7 @@ import * as chai from 'chai'
4import { keyBy } from 'lodash' 4import { keyBy } from 'lodash'
5import 'mocha' 5import 'mocha'
6import { join } from 'path' 6import { join } from 'path'
7import { VideoPrivacy } from '../../../../shared/models/videos'
7import { 8import {
8 dateIsValid, 9 dateIsValid,
9 flushTests, 10 flushTests,
@@ -29,9 +30,9 @@ import {
29 updateVideo, 30 updateVideo,
30 uploadVideo, 31 uploadVideo,
31 wait, 32 wait,
32 webtorrentAdd 33 webtorrentAdd,
33} from '../../utils/index' 34 viewVideo, completeVideoCheck, immutableAssign
34import { viewVideo } from '../../utils/videos/videos' 35} from '../../utils'
35 36
36const expect = chai.expect 37const expect = chai.expect
37 38
@@ -41,6 +42,56 @@ describe('Test a single server', function () {
41 let videoUUID = '' 42 let videoUUID = ''
42 let videosListBase: any[] = null 43 let videosListBase: any[] = null
43 44
45 const getCheckAttributes = {
46 name: 'my super name',
47 category: 2,
48 licence: 6,
49 language: 3,
50 nsfw: true,
51 description: 'my super description',
52 host: 'localhost:9001',
53 account: 'root',
54 isLocal: true,
55 tags: [ 'tag1', 'tag2', 'tag3' ],
56 privacy: VideoPrivacy.PUBLIC,
57 channel: {
58 name: 'Default root channel',
59 isLocal: true
60 },
61 fixture: 'video_short.webm',
62 files: [
63 {
64 resolution: 720,
65 size: 218910
66 }
67 ]
68 }
69
70 const updateCheckAttributes = {
71 name: 'my super video updated',
72 category: 4,
73 licence: 2,
74 language: 5,
75 nsfw: true,
76 description: 'my super description updated',
77 host: 'localhost:9001',
78 account: 'root',
79 isLocal: true,
80 tags: [ 'tagup1', 'tagup2' ],
81 privacy: VideoPrivacy.PUBLIC,
82 channel: {
83 name: 'Default root channel',
84 isLocal: true
85 },
86 fixture: 'video_short3.webm',
87 files: [
88 {
89 resolution: 720,
90 size: 292677
91 }
92 ]
93 }
94
44 before(async function () { 95 before(async function () {
45 this.timeout(10000) 96 this.timeout(10000)
46 97
@@ -107,9 +158,12 @@ describe('Test a single server', function () {
107 expect(res.body.video).to.not.be.undefined 158 expect(res.body.video).to.not.be.undefined
108 expect(res.body.video.id).to.equal(1) 159 expect(res.body.video.id).to.equal(1)
109 expect(res.body.video.uuid).to.have.length.above(5) 160 expect(res.body.video.uuid).to.have.length.above(5)
161
162 videoId = res.body.video.id
163 videoUUID = res.body.video.uuid
110 }) 164 })
111 165
112 it('Should seed the uploaded video', async function () { 166 it('Should get and seed the uploaded video', async function () {
113 // Yes, this could be long 167 // Yes, this could be long
114 this.timeout(60000) 168 this.timeout(60000)
115 169
@@ -120,86 +174,7 @@ describe('Test a single server', function () {
120 expect(res.body.data.length).to.equal(1) 174 expect(res.body.data.length).to.equal(1)
121 175
122 const video = res.body.data[0] 176 const video = res.body.data[0]
123 expect(video.name).to.equal('my super name') 177 await completeVideoCheck(server.url, video, getCheckAttributes)
124 expect(video.category).to.equal(2)
125 expect(video.categoryLabel).to.equal('Films')
126 expect(video.licence).to.equal(6)
127 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
128 expect(video.language).to.equal(3)
129 expect(video.languageLabel).to.equal('Mandarin')
130 expect(video.nsfw).to.be.ok
131 expect(video.description).to.equal('my super description')
132 expect(video.serverHost).to.equal('localhost:9001')
133 expect(video.accountName).to.equal('root')
134 expect(video.isLocal).to.be.true
135 expect(dateIsValid(video.createdAt)).to.be.true
136 expect(dateIsValid(video.updatedAt)).to.be.true
137
138 const res2 = await getVideo(server.url, res.body.data[0].id)
139 const videoDetails = res2.body
140
141 expect(videoDetails.files).to.have.lengthOf(1)
142
143 const file = videoDetails.files[0]
144 const magnetUri = file.magnetUri
145 expect(file.magnetUri).to.have.lengthOf.above(2)
146 expect(file.torrentUrl).to.equal(`${server.url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
147 expect(file.fileUrl).to.equal(`${server.url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
148 expect(file.resolution).to.equal(720)
149 expect(file.resolutionLabel).to.equal('720p')
150 expect(file.size).to.equal(218910)
151
152 const test = await testVideoImage(server.url, 'video_short.webm', videoDetails.thumbnailPath)
153 expect(test).to.equal(true)
154
155 videoId = videoDetails.id
156 videoUUID = videoDetails.uuid
157
158 const torrent = await webtorrentAdd(magnetUri)
159 expect(torrent.files).to.be.an('array')
160 expect(torrent.files.length).to.equal(1)
161 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
162 })
163
164 it('Should get the video', async function () {
165 // Yes, this could be long
166 this.timeout(60000)
167
168 const res = await getVideo(server.url, videoId)
169
170 const video = res.body
171 expect(video.name).to.equal('my super name')
172 expect(video.category).to.equal(2)
173 expect(video.categoryLabel).to.equal('Films')
174 expect(video.licence).to.equal(6)
175 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
176 expect(video.language).to.equal(3)
177 expect(video.languageLabel).to.equal('Mandarin')
178 expect(video.nsfw).to.be.ok
179 expect(video.description).to.equal('my super description')
180 expect(video.serverHost).to.equal('localhost:9001')
181 expect(video.accountName).to.equal('root')
182 expect(video.isLocal).to.be.true
183 expect(dateIsValid(video.createdAt)).to.be.true
184 expect(dateIsValid(video.updatedAt)).to.be.true
185 expect(video.channel.name).to.equal('Default root channel')
186 expect(video.channel.isLocal).to.be.true
187 expect(dateIsValid(video.channel.createdAt)).to.be.true
188 expect(dateIsValid(video.channel.updatedAt)).to.be.true
189
190 expect(video.files).to.have.lengthOf(1)
191
192 const file = video.files[0]
193 expect(file.magnetUri).to.have.lengthOf.above(2)
194 expect(file.resolution).to.equal(720)
195 expect(file.resolutionLabel).to.equal('720p')
196 expect(file.size).to.equal(218910)
197
198 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
199 expect(test).to.equal(true)
200
201 // Wait the async views increment
202 await wait(500)
203 }) 178 })
204 179
205 it('Should get the video by UUID', async function () { 180 it('Should get the video by UUID', async function () {
@@ -209,10 +184,7 @@ describe('Test a single server', function () {
209 const res = await getVideo(server.url, videoUUID) 184 const res = await getVideo(server.url, videoUUID)
210 185
211 const video = res.body 186 const video = res.body
212 expect(video.name).to.equal('my super name') 187 await completeVideoCheck(server.url, video, getCheckAttributes)
213
214 // Wait the async views increment
215 await wait(500)
216 }) 188 })
217 189
218 it('Should have the views updated', async function () { 190 it('Should have the views updated', async function () {
@@ -234,23 +206,7 @@ describe('Test a single server', function () {
234 expect(res.body.data.length).to.equal(1) 206 expect(res.body.data.length).to.equal(1)
235 207
236 const video = res.body.data[0] 208 const video = res.body.data[0]
237 expect(video.name).to.equal('my super name') 209 await completeVideoCheck(server.url, video, getCheckAttributes)
238 expect(video.category).to.equal(2)
239 expect(video.categoryLabel).to.equal('Films')
240 expect(video.licence).to.equal(6)
241 expect(video.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
242 expect(video.language).to.equal(3)
243 expect(video.languageLabel).to.equal('Mandarin')
244 expect(video.nsfw).to.be.ok
245 expect(video.description).to.equal('my super description')
246 expect(video.serverHost).to.equal('localhost:9001')
247 expect(video.accountName).to.equal('root')
248 expect(video.isLocal).to.be.true
249 expect(dateIsValid(video.createdAt)).to.be.true
250 expect(dateIsValid(video.updatedAt)).to.be.true
251
252 const test = await testVideoImage(server.url, 'video_short.webm', video.thumbnailPath)
253 expect(test).to.equal(true)
254 }) 210 })
255 211
256 // Not implemented yet 212 // Not implemented yet
@@ -337,10 +293,10 @@ describe('Test a single server', function () {
337 it('Should remove the video', async function () { 293 it('Should remove the video', async function () {
338 await removeVideo(server.url, server.accessToken, videoId) 294 await removeVideo(server.url, server.accessToken, videoId)
339 295
340 const files1 = await readdirPromise(join(__dirname, '..', '..', '..', '..', 'test1/videos/')) 296 const files1 = await readdirPromise(join(__dirname, '..', '..', '..', '..', 'test1', 'videos'))
341 expect(files1).to.have.lengthOf(0) 297 expect(files1).to.have.lengthOf(0)
342 298
343 const files2 = await readdirPromise(join(__dirname, '..', '..', '..', '..', 'test1/thumbnails/')) 299 const files2 = await readdirPromise(join(__dirname, '..', '..', '..', '..', 'test1', 'thumbnails'))
344 expect(files2).to.have.lengthOf(0) 300 expect(files2).to.have.lengthOf(0)
345 }) 301 })
346 302
@@ -547,127 +503,33 @@ describe('Test a single server', function () {
547 this.timeout(60000) 503 this.timeout(60000)
548 504
549 const res = await getVideo(server.url, videoId) 505 const res = await getVideo(server.url, videoId)
550
551 const video = res.body 506 const video = res.body
552 507
553 expect(video.name).to.equal('my super video updated') 508 await completeVideoCheck(server.url, video, updateCheckAttributes)
554 expect(video.category).to.equal(4)
555 expect(video.categoryLabel).to.equal('Art')
556 expect(video.licence).to.equal(2)
557 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
558 expect(video.language).to.equal(5)
559 expect(video.languageLabel).to.equal('Arabic')
560 expect(video.nsfw).to.be.ok
561 expect(video.description).to.equal('my super description updated')
562 expect(video.serverHost).to.equal('localhost:9001')
563 expect(video.accountName).to.equal('root')
564 expect(video.account.name).to.equal('root')
565 expect(video.isLocal).to.be.true
566 expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
567 expect(dateIsValid(video.createdAt)).to.be.true
568 expect(dateIsValid(video.updatedAt)).to.be.true
569
570 expect(video.channel.name).to.equal('Default root channel')
571 expect(video.channel.isLocal).to.be.true
572 expect(dateIsValid(video.channel.createdAt)).to.be.true
573 expect(dateIsValid(video.channel.updatedAt)).to.be.true
574
575 expect(video.files).to.have.lengthOf(1)
576
577 const file = video.files[0]
578 const magnetUri = file.magnetUri
579 expect(file.magnetUri).to.have.lengthOf.above(2)
580 expect(file.resolution).to.equal(720)
581 expect(file.resolutionLabel).to.equal('720p')
582 expect(file.size).to.equal(292677)
583
584 const test = await testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath)
585 expect(test).to.equal(true)
586
587 const torrent = await webtorrentAdd(magnetUri)
588 expect(torrent.files).to.be.an('array')
589 expect(torrent.files.length).to.equal(1)
590 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
591 }) 509 })
592 510
593 it('Should update only the tags of a video', async function () { 511 it('Should update only the tags of a video', async function () {
594 const attributes = { 512 const attributes = {
595 tags: [ 'tag1', 'tag2', 'supertag' ] 513 tags: [ 'supertag', 'tag1', 'tag2' ]
596 } 514 }
597
598 await updateVideo(server.url, server.accessToken, videoId, attributes) 515 await updateVideo(server.url, server.accessToken, videoId, attributes)
599 516
600 const res = await getVideo(server.url, videoId) 517 const res = await getVideo(server.url, videoId)
601 const video = res.body 518 const video = res.body
602 519
603 expect(video.name).to.equal('my super video updated') 520 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes))
604 expect(video.category).to.equal(4)
605 expect(video.categoryLabel).to.equal('Art')
606 expect(video.licence).to.equal(2)
607 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
608 expect(video.language).to.equal(5)
609 expect(video.languageLabel).to.equal('Arabic')
610 expect(video.nsfw).to.be.ok
611 expect(video.description).to.equal('my super description updated')
612 expect(video.serverHost).to.equal('localhost:9001')
613 expect(video.accountName).to.equal('root')
614 expect(video.isLocal).to.be.true
615 expect(video.tags).to.deep.equal([ 'supertag', 'tag1', 'tag2' ])
616 expect(dateIsValid(video.createdAt)).to.be.true
617 expect(dateIsValid(video.updatedAt)).to.be.true
618
619 expect(video.channel.name).to.equal('Default root channel')
620 expect(video.channel.isLocal).to.be.true
621 expect(dateIsValid(video.channel.createdAt)).to.be.true
622 expect(dateIsValid(video.channel.updatedAt)).to.be.true
623
624 expect(video.files).to.have.lengthOf(1)
625
626 const file = video.files[0]
627 expect(file.magnetUri).to.have.lengthOf.above(2)
628 expect(file.resolution).to.equal(720)
629 expect(file.resolutionLabel).to.equal('720p')
630 expect(file.size).to.equal(292677)
631 }) 521 })
632 522
633 it('Should update only the description of a video', async function () { 523 it('Should update only the description of a video', async function () {
634 const attributes = { 524 const attributes = {
635 description: 'hello everybody' 525 description: 'hello everybody'
636 } 526 }
637
638 await updateVideo(server.url, server.accessToken, videoId, attributes) 527 await updateVideo(server.url, server.accessToken, videoId, attributes)
639 528
640 const res = await getVideo(server.url, videoId) 529 const res = await getVideo(server.url, videoId)
641 const video = res.body 530 const video = res.body
642 531
643 expect(video.name).to.equal('my super video updated') 532 await completeVideoCheck(server.url, video, Object.assign(updateCheckAttributes, attributes))
644 expect(video.category).to.equal(4)
645 expect(video.categoryLabel).to.equal('Art')
646 expect(video.licence).to.equal(2)
647 expect(video.licenceLabel).to.equal('Attribution - Share Alike')
648 expect(video.language).to.equal(5)
649 expect(video.languageLabel).to.equal('Arabic')
650 expect(video.nsfw).to.be.ok
651 expect(video.description).to.equal('hello everybody')
652 expect(video.serverHost).to.equal('localhost:9001')
653 expect(video.accountName).to.equal('root')
654 expect(video.isLocal).to.be.true
655 expect(video.tags).to.deep.equal([ 'supertag', 'tag1', 'tag2' ])
656 expect(dateIsValid(video.createdAt)).to.be.true
657 expect(dateIsValid(video.updatedAt)).to.be.true
658
659 expect(video.channel.name).to.equal('Default root channel')
660 expect(video.channel.isLocal).to.be.true
661 expect(dateIsValid(video.channel.createdAt)).to.be.true
662 expect(dateIsValid(video.channel.updatedAt)).to.be.true
663
664 expect(video.files).to.have.lengthOf(1)
665
666 const file = video.files[0]
667 expect(file.magnetUri).to.have.lengthOf.above(2)
668 expect(file.resolution).to.equal(720)
669 expect(file.resolutionLabel).to.equal('720p')
670 expect(file.size).to.equal(292677)
671 }) 533 })
672 534
673 it('Should like a video', async function () { 535 it('Should like a video', async function () {