import 'mocha'
import * as chai from 'chai'
-import * as request from 'supertest'
-import { HttpStatusCode } from '@shared/core-utils'
+import request from 'supertest'
import {
buildAbsoluteFixturePath,
checkTmpIsEmpty,
checkVideoFilesWereRemoved,
cleanupTests,
- completeVideoCheck,
+ createMultipleServers,
dateIsValid,
doubleFollow,
- createMultipleServers,
PeerTubeServer,
+ saveVideoInServers,
setAccessTokensToServers,
testImage,
wait,
waitJobs,
webtorrentAdd
-} from '@shared/extra-utils'
-import { VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
+} from '@shared/server-commands'
+import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
+import { completeVideoCheck } from '@server/tests/shared/video'
const expect = chai.expect
describe('It should list local videos', function () {
it('Should list only local videos on server 1', async function () {
- const { data, total } = await servers[0].videos.list({ filter: 'local' })
+ const { data, total } = await servers[0].videos.list({ isLocal: true })
expect(total).to.equal(1)
expect(data).to.be.an('array')
})
it('Should list only local videos on server 2', async function () {
- const { data, total } = await servers[1].videos.list({ filter: 'local' })
+ const { data, total } = await servers[1].videos.list({ isLocal: true })
expect(total).to.equal(1)
expect(data).to.be.an('array')
})
it('Should list only local videos on server 3', async function () {
- const { data, total } = await servers[2].videos.list({ filter: 'local' })
+ const { data, total } = await servers[2].videos.list({ isLocal: true })
expect(total).to.equal(2)
expect(data).to.be.an('array')
})
describe('Should manipulate these videos', function () {
- it('Should update the video 3 by asking server 3', async function () {
+ let updatedAtMin: Date
+
+ it('Should update video 3', async function () {
this.timeout(10000)
const attributes = {
previewfile: 'preview.jpg'
}
+ updatedAtMin = new Date()
await servers[2].videos.update({ id: toRemove[0].id, attributes })
await waitJobs(servers)
const videoUpdated = data.find(video => video.name === 'my super video updated')
expect(!!videoUpdated).to.be.true
+ expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
+
const isLocal = server.url === 'http://localhost:' + servers[2].port
const checkAttributes = {
name: 'my super video updated',
}
})
- it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
+ it('Should only update thumbnail and update updatedAt attribute', async function () {
this.timeout(10000)
- await servers[2].videos.remove({ id: toRemove[0].id })
- await servers[2].videos.remove({ id: toRemove[1].id })
+ const attributes = {
+ thumbnailfile: 'thumbnail.jpg'
+ }
+
+ updatedAtMin = new Date()
+ await servers[2].videos.update({ id: toRemove[0].id, attributes })
await waitJobs(servers)
- })
- it('Should not have files of videos 3 and 3-2 on each server', async function () {
for (const server of servers) {
- await checkVideoFilesWereRemoved(toRemove[0].uuid, server)
- await checkVideoFilesWereRemoved(toRemove[1].uuid, server)
+ const { data } = await server.videos.list()
+
+ const videoUpdated = data.find(video => video.name === 'my super video updated')
+ expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
+ }
+ })
+
+ it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
+ this.timeout(30000)
+
+ for (const id of [ toRemove[0].id, toRemove[1].id ]) {
+ await saveVideoInServers(servers, id)
+
+ await servers[2].videos.remove({ id })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
+ }
}
})
files: [
{
resolution: 720,
- size: 59000
+ size: 61000
},
{
resolution: 480,
- size: 34000
+ size: 40000
},
{
resolution: 360,
- size: 31000
+ size: 32000
},
{
resolution: 240,