+ await uploadVideo(server.url, server.accessToken, videoAttributes, HttpStatusCode.OK_200, mode)
+ }
+ })
+
+ it('Should have the correct durations', async function () {
+ const res = await getVideosList(server.url)
+
+ expect(res.body.total).to.equal(6)
+ const videos = res.body.data
+ expect(videos).to.be.an('array')
+ expect(videos).to.have.lengthOf(6)
+
+ const videosByName = keyBy<{ duration: number }>(videos, 'name')
+ expect(videosByName['video_short.mp4 name'].duration).to.equal(5)
+ expect(videosByName['video_short.ogv name'].duration).to.equal(5)
+ expect(videosByName['video_short.webm name'].duration).to.equal(5)
+ expect(videosByName['video_short1.webm name'].duration).to.equal(10)
+ expect(videosByName['video_short2.webm name'].duration).to.equal(5)
+ expect(videosByName['video_short3.webm name'].duration).to.equal(5)
+ })
+
+ it('Should have the correct thumbnails', async function () {
+ const res = await getVideosList(server.url)
+
+ const videos = res.body.data
+ // For the next test
+ videosListBase = videos
+
+ for (const video of videos) {
+ const videoName = video.name.replace(' name', '')
+ await testImage(server.url, videoName, video.thumbnailPath)
+ }
+ })
+
+ it('Should list only the two first videos', async function () {
+ const res = await getVideosListPagination(server.url, 0, 2, 'name')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(2)
+ expect(videos[0].name).to.equal(videosListBase[0].name)
+ expect(videos[1].name).to.equal(videosListBase[1].name)
+ })
+
+ it('Should list only the next three videos', async function () {
+ const res = await getVideosListPagination(server.url, 2, 3, 'name')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(3)
+ expect(videos[0].name).to.equal(videosListBase[2].name)
+ expect(videos[1].name).to.equal(videosListBase[3].name)
+ expect(videos[2].name).to.equal(videosListBase[4].name)
+ })
+
+ it('Should list the last video', async function () {
+ const res = await getVideosListPagination(server.url, 5, 6, 'name')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(1)
+ expect(videos[0].name).to.equal(videosListBase[5].name)
+ })
+
+ it('Should not have the total field', async function () {
+ const res = await getVideosListPagination(server.url, 5, 6, 'name', true)
+
+ const videos = res.body.data
+ expect(res.body.total).to.not.exist
+ expect(videos.length).to.equal(1)
+ expect(videos[0].name).to.equal(videosListBase[5].name)
+ })
+
+ it('Should list and sort by name in descending order', async function () {
+ const res = await getVideosListSort(server.url, '-name')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(6)
+ expect(videos[0].name).to.equal('video_short.webm name')
+ expect(videos[1].name).to.equal('video_short.ogv name')
+ expect(videos[2].name).to.equal('video_short.mp4 name')
+ expect(videos[3].name).to.equal('video_short3.webm name')
+ expect(videos[4].name).to.equal('video_short2.webm name')
+ expect(videos[5].name).to.equal('video_short1.webm name')
+
+ videoId = videos[3].uuid
+ videoId2 = videos[5].uuid
+ })
+
+ it('Should list and sort by trending in descending order', async function () {
+ const res = await getVideosListPagination(server.url, 0, 2, '-trending')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(2)
+ })
+
+ it('Should list and sort by hotness in descending order', async function () {
+ const res = await getVideosListPagination(server.url, 0, 2, '-hot')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(2)
+ })
+
+ it('Should list and sort by best in descending order', async function () {
+ const res = await getVideosListPagination(server.url, 0, 2, '-best')
+
+ const videos = res.body.data
+ expect(res.body.total).to.equal(6)
+ expect(videos.length).to.equal(2)
+ })
+
+ it('Should update a video', async function () {
+ const attributes = {
+ name: 'my super video updated',
+ category: 4,
+ licence: 2,
+ language: 'ar',
+ nsfw: false,
+ description: 'my super description updated',
+ commentsEnabled: false,
+ downloadEnabled: false,
+ tags: [ 'tagup1', 'tagup2' ]
+ }
+ await updateVideo(server.url, server.accessToken, videoId, attributes)
+ })