X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-playlists.ts;h=9dad58c8cc9626560e49647515e5768efdc77842;hb=59fd824cf3434a8417b73230f1840fed327e3495;hp=0bfb5bcd4050f292be3236f7c9b5f788da2e6048;hpb=371906639ee9b6ea4daae504bc7c2b15856c3f38;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 0bfb5bcd4..9dad58c8c 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' +import * as chai from 'chai' +import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' import { addVideoChannel, addVideoInPlaylist, @@ -41,15 +42,9 @@ import { uploadVideo, uploadVideoAndGetId, userLogin, + wait, waitJobs } from '../../../../shared/extra-utils' -import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model' -import { VideoPrivacy } from '../../../../shared/models/videos' -import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' -import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' -import { User } from '../../../../shared/models/users' -import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' import { addAccountToAccountBlocklist, addAccountToServerBlocklist, @@ -60,6 +55,13 @@ import { removeServerFromAccountBlocklist, removeServerFromServerBlocklist } from '../../../../shared/extra-utils/users/blocklist' +import { User } from '../../../../shared/models/users' +import { VideoPrivacy } from '../../../../shared/models/videos' +import { VideoExistInPlaylist } from '../../../../shared/models/videos/playlist/video-exist-in-playlist.model' +import { VideoPlaylistElement, VideoPlaylistElementType } from '../../../../shared/models/videos/playlist/video-playlist-element.model' +import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' +import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' +import { VideoPlaylist } from '../../../../shared/models/videos/playlist/video-playlist.model' const expect = chai.expect @@ -121,24 +123,18 @@ describe('Test video playlists', function () { await doubleFollow(servers[0], servers[2]) { - const serverPromises: Promise[][] = [] + servers[0].videos = [] + servers[1].videos = [] + servers[2].videos = [] for (const server of servers) { - const videoPromises: Promise[] = [] - for (let i = 0; i < 7; i++) { - videoPromises.push( - uploadVideo(server.url, server.accessToken, { name: `video ${i} server ${server.serverNumber}`, nsfw: false }) - .then(res => res.body.video) - ) - } + const name = `video ${i} server ${server.serverNumber}` + const resVideo = await uploadVideo(server.url, server.accessToken, { name, nsfw: false }) - serverPromises.push(videoPromises) + server.videos.push(resVideo.body.video) + } } - - servers[0].videos = await Promise.all(serverPromises[0]) - servers[1].videos = await Promise.all(serverPromises[1]) - servers[2].videos = await Promise.all(serverPromises[2]) } nsfwVideoServer1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'NSFW video', nsfw: true })).id @@ -227,6 +223,8 @@ describe('Test video playlists', function () { }) await waitJobs(servers) + // Processing a playlist by the receiver could be long + await wait(3000) for (const server of servers) { const res = await getVideoPlaylistsList(server.url, 0, 5) @@ -310,6 +308,7 @@ describe('Test video playlists', function () { } await waitJobs(servers) + await wait(3000) for (const server of [ servers[0], servers[1] ]) { const res = await getVideoPlaylistsList(server.url, 0, 5) @@ -451,6 +450,7 @@ describe('Test video playlists', function () { }) await waitJobs(servers) + await wait(3000) for (const server of servers) { const results = [ @@ -628,7 +628,7 @@ describe('Test video playlists', function () { let video3: string before(async function () { - this.timeout(30000) + this.timeout(60000) groupUser1 = [ Object.assign({}, servers[0], { accessToken: userAccessTokenServer1 }) ] groupWithoutToken1 = [ Object.assign({}, servers[0], { accessToken: undefined }) ] @@ -656,6 +656,8 @@ describe('Test video playlists', function () { video2 = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 90' })).uuid video3 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 91', nsfw: true })).uuid + await waitJobs(servers) + await addVideo({ videoId: video1, startTimestamp: 15, stopTimestamp: 28 }) await addVideo({ videoId: video2, startTimestamp: 35 }) await addVideo({ videoId: video3 }) @@ -1084,7 +1086,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 200) + await getVideoPlaylist(server.url, videoPlaylistIds.uuid, HttpStatusCode.OK_200) } const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE } @@ -1093,11 +1095,11 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of [ servers[1], servers[2] ]) { - await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 404) + await getVideoPlaylist(server.url, videoPlaylistIds.uuid, HttpStatusCode.NOT_FOUND_404) } - await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, 401) + await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, HttpStatusCode.UNAUTHORIZED_401) - await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, 200) + await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, HttpStatusCode.OK_200) }) }) @@ -1111,7 +1113,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - await getVideoPlaylist(server.url, playlistServer1UUID, 404) + await getVideoPlaylist(server.url, playlistServer1UUID, HttpStatusCode.NOT_FOUND_404) } }) @@ -1171,7 +1173,7 @@ describe('Test video playlists', function () { expect(res3.body.displayName).to.equal('channel playlist') expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) - await getVideoPlaylist(servers[1].url, videoPlaylistUUID, 404) + await getVideoPlaylist(servers[1].url, videoPlaylistUUID, HttpStatusCode.NOT_FOUND_404) }) it('Should delete an account and delete its playlists', async function () {