X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Fhandle-down.ts;h=068654d8c4f3906b73c4ce21bed57b6b013e8f3f;hb=79ad1706f3cf009e04db9cd9e6a721801d93e64e;hp=18a0d9ce3187d47d8bce71725adb221762de6841;hpb=cf7a61b5a2b68fd966c4a355e37e84b048ed296b;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 18a0d9ce3..068654d8c 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -5,24 +5,31 @@ import 'mocha' import { JobState, Video } from '../../../../shared/models' import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' -import { completeVideoCheck, getVideo, immutableAssign, reRunServer, unfollow, viewVideo } from '../../utils' + import { + cleanupTests, + completeVideoCheck, flushAndRunMultipleServers, + getVideo, getVideosList, + immutableAssign, killallServers, + reRunServer, ServerInfo, setAccessTokensToServers, + unfollow, + updateVideo, uploadVideo, wait -} from '../../utils/index' -import { follow, getFollowersListPaginationAndSort } from '../../utils/server/follows' -import { getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/extra-utils' +import { follow, getFollowersListPaginationAndSort } from '../../../../shared/extra-utils/server/follows' +import { getJobsListPaginationAndSort, waitJobs } from '../../../../shared/extra-utils/server/jobs' import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' +} from '../../../../shared/extra-utils/videos/video-comments' const expect = chai.expect @@ -53,46 +60,50 @@ describe('Test handle downs', function () { privacy: VideoPrivacy.UNLISTED }) - const checkAttributes = { - name: 'my super name for server 1', - category: 5, - licence: 4, - language: 'ja', - nsfw: true, - description: 'my super description for server 1', - support: 'my super support text for server 1', - account: { - name: 'root', - host: 'localhost:9001' - }, - isLocal: false, - duration: 10, - tags: [ 'tag1p1', 'tag2p1' ], - privacy: VideoPrivacy.PUBLIC, - commentsEnabled: true, - channel: { - name: 'Default root channel', - description: '', - isLocal: false - }, - fixture: 'video_short1.webm', - files: [ - { - resolution: 720, - size: 572456 - } - ] - } - - const unlistedCheckAttributes = immutableAssign(checkAttributes, { - privacy: VideoPrivacy.UNLISTED - }) + let checkAttributes: any + let unlistedCheckAttributes: any before(async function () { this.timeout(30000) servers = await flushAndRunMultipleServers(3) + checkAttributes = { + name: 'my super name for server 1', + category: 5, + licence: 4, + language: 'ja', + nsfw: true, + description: 'my super description for server 1', + support: 'my super support text for server 1', + account: { + name: 'root', + host: 'localhost:' + servers[0].port + }, + isLocal: false, + duration: 10, + tags: [ 'tag1p1', 'tag2p1' ], + privacy: VideoPrivacy.PUBLIC, + commentsEnabled: true, + downloadEnabled: true, + channel: { + name: 'root_channel', + displayName: 'Main root channel', + description: '', + isLocal: false + }, + fixture: 'video_short1.webm', + files: [ + { + resolution: 720, + size: 572456 + } + ] + } + unlistedCheckAttributes = immutableAssign(checkAttributes, { + privacy: VideoPrivacy.UNLISTED + }) + // Get the access tokens await setAccessTokensToServers(servers) }) @@ -163,7 +174,7 @@ describe('Test handle downs', function () { const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 2, 'createdAt') expect(res.body.data).to.be.an('array') expect(res.body.data).to.have.lengthOf(1) - expect(res.body.data[0].follower.host).to.equal('localhost:9003') + expect(res.body.data[0].follower.host).to.equal('localhost:' + servers[2].port) }) it('Should not have pending/processing jobs anymore', async function () { @@ -193,15 +204,15 @@ describe('Test handle downs', function () { expect(res.body.data).to.have.lengthOf(2) }) - it('Should send a view to server 3, and automatically fetch the video', async function () { + it('Should send an update to server 3, and automatically fetch the video', async function () { this.timeout(15000) const res1 = await getVideosList(servers[2].url) expect(res1.body.data).to.be.an('array') expect(res1.body.data).to.have.lengthOf(11) - await viewVideo(servers[0].url, missedVideo1.uuid) - await viewVideo(servers[0].url, unlistedVideo.uuid) + await updateVideo(servers[0].url, servers[0].accessToken, missedVideo1.uuid, { }) + await updateVideo(servers[0].url, servers[0].accessToken, unlistedVideo.uuid, { }) await waitJobs(servers) @@ -289,6 +300,6 @@ describe('Test handle downs', function () { }) after(async function () { - killallServers(servers) + await cleanupTests(servers) }) })