X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Ftests%2Fapi%2Fvideos%2Fmultiple-servers.ts;h=cb83fa0f07ac7984c7860f4815398b9bf590f47b;hb=bf54587a3e2ad9c2c186828f2a5682b91ee2cc00;hp=562079a154d78fddf21f65a77ae9a7bed106bc4d;hpb=254d3579f5338f5fd775c17d15cdfc37078bcfb4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 562079a15..cb83fa0f0 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -2,25 +2,25 @@ 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 @@ -349,7 +349,7 @@ describe('Test multiple servers', function () { 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') @@ -358,7 +358,7 @@ describe('Test multiple servers', function () { }) 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') @@ -367,7 +367,7 @@ describe('Test multiple servers', function () { }) 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') @@ -591,7 +591,9 @@ describe('Test multiple servers', function () { }) 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 = { @@ -608,6 +610,7 @@ describe('Test multiple servers', function () { previewfile: 'preview.jpg' } + updatedAtMin = new Date() await servers[2].videos.update({ id: toRemove[0].id, attributes }) await waitJobs(servers) @@ -622,6 +625,8 @@ describe('Test multiple servers', function () { 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', @@ -662,19 +667,39 @@ describe('Test multiple servers', function () { } }) - 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 }) + } } }) @@ -1024,15 +1049,15 @@ describe('Test multiple servers', function () { files: [ { resolution: 720, - size: 59000 + size: 61000 }, { resolution: 480, - size: 34000 + size: 40000 }, { resolution: 360, - size: 31000 + size: 32000 }, { resolution: 240,