- 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)
- })
-
- it('Should filter by tags and category', async function () {
- const res1 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] })
- expect(res1.body.total).to.equal(1)
- expect(res1.body.data[0].name).to.equal('my super video updated')
-
- const res2 = await getVideosWithFilters(server.url, { tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] })
- expect(res2.body.total).to.equal(0)
- })
-
- it('Should have the video updated', async function () {
- this.timeout(60000)
+ for (const video of data) {
+ const videoName = video.name.replace(' name', '')
+ await testImage(server.url, videoName, video.thumbnailPath)
+ }
+ })
+
+ it('Should list only the two first videos', async function () {
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: 'name' })
+
+ expect(total).to.equal(6)
+ expect(data.length).to.equal(2)
+ expect(data[0].name).to.equal(videosListBase[0].name)
+ expect(data[1].name).to.equal(videosListBase[1].name)
+ })
+
+ it('Should list only the next three videos', async function () {
+ const { total, data } = await server.videos.list({ start: 2, count: 3, sort: 'name' })
+
+ expect(total).to.equal(6)
+ expect(data.length).to.equal(3)
+ expect(data[0].name).to.equal(videosListBase[2].name)
+ expect(data[1].name).to.equal(videosListBase[3].name)
+ expect(data[2].name).to.equal(videosListBase[4].name)
+ })
+
+ it('Should list the last video', async function () {
+ const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name' })
+
+ expect(total).to.equal(6)
+ expect(data.length).to.equal(1)
+ expect(data[0].name).to.equal(videosListBase[5].name)
+ })
+
+ it('Should not have the total field', async function () {
+ const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name', skipCount: true })
+
+ expect(total).to.not.exist
+ expect(data.length).to.equal(1)
+ expect(data[0].name).to.equal(videosListBase[5].name)
+ })
+
+ it('Should list and sort by name in descending order', async function () {
+ const { total, data } = await server.videos.list({ sort: '-name' })
+
+ expect(total).to.equal(6)
+ expect(data.length).to.equal(6)
+ expect(data[0].name).to.equal('video_short.webm name')
+ expect(data[1].name).to.equal('video_short.ogv name')
+ expect(data[2].name).to.equal('video_short.mp4 name')
+ expect(data[3].name).to.equal('video_short3.webm name')
+ expect(data[4].name).to.equal('video_short2.webm name')
+ expect(data[5].name).to.equal('video_short1.webm name')
+
+ videoId = data[3].uuid
+ videoId2 = data[5].uuid
+ })
+
+ it('Should list and sort by trending in descending order', async function () {
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-trending' })
+
+ expect(total).to.equal(6)
+ expect(data.length).to.equal(2)
+ })
+
+ it('Should list and sort by hotness in descending order', async function () {
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-hot' })
+
+ expect(total).to.equal(6)
+ expect(data.length).to.equal(2)
+ })
+
+ it('Should list and sort by best in descending order', async function () {
+ const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-best' })
+
+ expect(total).to.equal(6)
+ expect(data.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 server.videos.update({ id: videoId, attributes })
+ })