From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/api/videos/audio-only.ts | 8 +- server/tests/api/videos/multiple-servers.ts | 168 +++++++++---------- server/tests/api/videos/resumable-upload.ts | 18 +- server/tests/api/videos/single-server.ts | 90 +++++----- server/tests/api/videos/video-captions.ts | 24 +-- server/tests/api/videos/video-change-ownership.ts | 50 +++--- server/tests/api/videos/video-channels.ts | 92 +++++------ server/tests/api/videos/video-comments.ts | 8 +- server/tests/api/videos/video-description.ts | 16 +- server/tests/api/videos/video-hls.ts | 22 +-- server/tests/api/videos/video-imports.ts | 44 ++--- server/tests/api/videos/video-nsfw.ts | 52 +++--- .../tests/api/videos/video-playlist-thumbnails.ts | 36 ++-- server/tests/api/videos/video-playlists.ts | 184 ++++++++++----------- server/tests/api/videos/video-privacy.ts | 56 +++---- server/tests/api/videos/video-schedule-update.ts | 20 +-- server/tests/api/videos/video-transcoder.ts | 122 +++++++------- server/tests/api/videos/videos-filter.ts | 10 +- server/tests/api/videos/videos-history.ts | 30 ++-- server/tests/api/videos/videos-overview.ts | 24 +-- server/tests/api/videos/videos-views-cleaner.ts | 22 +-- 21 files changed, 548 insertions(+), 548 deletions(-) (limited to 'server/tests/api/videos') diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts index e31905b36..b2952e38b 100644 --- a/server/tests/api/videos/audio-only.ts +++ b/server/tests/api/videos/audio-only.ts @@ -48,13 +48,13 @@ describe('Test audio only video transcoding', function () { it('Should upload a video and transcode it', async function () { this.timeout(120000) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'audio only' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } }) videoUUID = uuid await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) expect(video.streamingPlaylists).to.have.lengthOf(1) for (const files of [ video.files, video.streamingPlaylists[0].files ]) { @@ -68,8 +68,8 @@ describe('Test audio only video transcoding', function () { it('0p transcoded video should not have video', async function () { const paths = [ - servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')), - servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) + servers[0].servers.buildDirectory(join('videos', videoUUID + '-0.mp4')), + servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) ] for (const path of paths) { diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 5c13ac629..89d842307 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -44,8 +44,8 @@ describe('Test multiple servers', function () { displayName: 'my channel', description: 'super channel' } - await servers[0].channelsCommand.create({ attributes: videoChannel }) - const { data } = await servers[0].channelsCommand.list({ start: 0, count: 1 }) + await servers[0].channels.create({ attributes: videoChannel }) + const { data } = await servers[0].channels.list({ start: 0, count: 1 }) videoChannelId = data[0].id } @@ -59,7 +59,7 @@ describe('Test multiple servers', function () { it('Should not have videos for all servers', async function () { for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.be.an('array') expect(data.length).to.equal(0) } @@ -82,7 +82,7 @@ describe('Test multiple servers', function () { channelId: videoChannelId, fixture: 'video_short1.webm' } - await servers[0].videosCommand.upload({ attributes }) + await servers[0].videos.upload({ attributes }) await waitJobs(servers) @@ -125,7 +125,7 @@ describe('Test multiple servers', function () { ] } - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.be.an('array') expect(data.length).to.equal(1) const video = data[0] @@ -142,8 +142,8 @@ describe('Test multiple servers', function () { username: 'user1', password: 'super_password' } - await servers[1].usersCommand.create({ username: user.username, password: user.password }) - const userAccessToken = await servers[1].loginCommand.getAccessToken(user) + await servers[1].users.create({ username: user.username, password: user.password }) + const userAccessToken = await servers[1].login.getAccessToken(user) const attributes = { name: 'my super name for server 2', @@ -158,7 +158,7 @@ describe('Test multiple servers', function () { thumbnailfile: 'thumbnail.jpg', previewfile: 'preview.jpg' } - await servers[1].videosCommand.upload({ token: userAccessToken, attributes, mode: 'resumable' }) + await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' }) // Transcoding await waitJobs(servers) @@ -213,7 +213,7 @@ describe('Test multiple servers', function () { previewfile: 'preview' } - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.be.an('array') expect(data.length).to.equal(2) const video = data[1] @@ -237,7 +237,7 @@ describe('Test multiple servers', function () { tags: [ 'tag1p3' ], fixture: 'video_short3.webm' } - await servers[2].videosCommand.upload({ attributes }) + await servers[2].videos.upload({ attributes }) } { @@ -252,7 +252,7 @@ describe('Test multiple servers', function () { tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], fixture: 'video_short.webm' } - await servers[2].videosCommand.upload({ attributes }) + await servers[2].videos.upload({ attributes }) } await waitJobs(servers) @@ -260,7 +260,7 @@ describe('Test multiple servers', function () { // All servers should have this video for (const server of servers) { const isLocal = server.url === 'http://localhost:' + servers[2].port - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.be.an('array') expect(data.length).to.equal(4) @@ -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].videosCommand.list({ filter: 'local' }) + const { data, total } = await servers[0].videos.list({ filter: 'local' }) 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].videosCommand.list({ filter: 'local' }) + const { data, total } = await servers[1].videos.list({ filter: 'local' }) 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].videosCommand.list({ filter: 'local' }) + const { data, total } = await servers[2].videos.list({ filter: 'local' }) expect(total).to.equal(2) expect(data).to.be.an('array') @@ -381,13 +381,13 @@ describe('Test multiple servers', function () { it('Should add the file 1 by asking server 3', async function () { this.timeout(10000) - const { data } = await servers[2].videosCommand.list() + const { data } = await servers[2].videos.list() const video = data[0] toRemove.push(data[2]) toRemove.push(data[3]) - const videoDetails = await servers[2].videosCommand.get({ id: video.id }) + const videoDetails = await servers[2].videos.get({ id: video.id }) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) expect(torrent.files).to.be.an('array') expect(torrent.files.length).to.equal(1) @@ -397,10 +397,10 @@ describe('Test multiple servers', function () { it('Should add the file 2 by asking server 1', async function () { this.timeout(10000) - const { data } = await servers[0].videosCommand.list() + const { data } = await servers[0].videos.list() const video = data[1] - const videoDetails = await servers[0].videosCommand.get({ id: video.id }) + const videoDetails = await servers[0].videos.get({ id: video.id }) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) expect(torrent.files).to.be.an('array') @@ -411,10 +411,10 @@ describe('Test multiple servers', function () { it('Should add the file 3 by asking server 2', async function () { this.timeout(10000) - const { data } = await servers[1].videosCommand.list() + const { data } = await servers[1].videos.list() const video = data[2] - const videoDetails = await servers[1].videosCommand.get({ id: video.id }) + const videoDetails = await servers[1].videos.get({ id: video.id }) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) expect(torrent.files).to.be.an('array') @@ -425,10 +425,10 @@ describe('Test multiple servers', function () { it('Should add the file 3-2 by asking server 1', async function () { this.timeout(10000) - const { data } = await servers[0].videosCommand.list() + const { data } = await servers[0].videos.list() const video = data[3] - const videoDetails = await servers[0].videosCommand.get({ id: video.id }) + const videoDetails = await servers[0].videos.get({ id: video.id }) const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) expect(torrent.files).to.be.an('array') @@ -439,10 +439,10 @@ describe('Test multiple servers', function () { it('Should add the file 2 in 360p by asking server 1', async function () { this.timeout(10000) - const { data } = await servers[0].videosCommand.list() + const { data } = await servers[0].videos.list() const video = data.find(v => v.name === 'my super name for server 2') - const videoDetails = await servers[0].videosCommand.get({ id: video.id }) + const videoDetails = await servers[0].videos.get({ id: video.id }) const file = videoDetails.files.find(f => f.resolution.id === 360) expect(file).not.to.be.undefined @@ -462,17 +462,17 @@ describe('Test multiple servers', function () { before(async function () { { - const { data } = await servers[0].videosCommand.list() + const { data } = await servers[0].videos.list() remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid) } { - const { data } = await servers[1].videosCommand.list() + const { data } = await servers[1].videos.list() remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid) } { - const { data } = await servers[2].videosCommand.list() + const { data } = await servers[2].videos.list() localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid) remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid) } @@ -481,16 +481,16 @@ describe('Test multiple servers', function () { it('Should view multiple videos on owned servers', async function () { this.timeout(30000) - await servers[2].videosCommand.view({ id: localVideosServer3[0] }) + await servers[2].videos.view({ id: localVideosServer3[0] }) await wait(1000) - await servers[2].videosCommand.view({ id: localVideosServer3[0] }) - await servers[2].videosCommand.view({ id: localVideosServer3[1] }) + await servers[2].videos.view({ id: localVideosServer3[0] }) + await servers[2].videos.view({ id: localVideosServer3[1] }) await wait(1000) - await servers[2].videosCommand.view({ id: localVideosServer3[0] }) - await servers[2].videosCommand.view({ id: localVideosServer3[0] }) + await servers[2].videos.view({ id: localVideosServer3[0] }) + await servers[2].videos.view({ id: localVideosServer3[0] }) await waitJobs(servers) @@ -500,7 +500,7 @@ describe('Test multiple servers', function () { await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video0 = data.find(v => v.uuid === localVideosServer3[0]) const video1 = data.find(v => v.uuid === localVideosServer3[1]) @@ -514,16 +514,16 @@ describe('Test multiple servers', function () { this.timeout(45000) const tasks: Promise[] = [] - tasks.push(servers[0].videosCommand.view({ id: remoteVideosServer1[0] })) - tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] })) - tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] })) - tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[0] })) - tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] })) - tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] })) - tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] })) - tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] })) - tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] })) - tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] })) + tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] })) + tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] })) + tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] })) + tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] })) + tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] })) + tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] })) + tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] })) + tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })) + tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })) + tasks.push(servers[2].videos.view({ id: localVideosServer3[1] })) await Promise.all(tasks) @@ -537,7 +537,7 @@ describe('Test multiple servers', function () { let baseVideos = null for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() // Initialize base videos for future comparisons if (baseVideos === null) { @@ -555,17 +555,17 @@ describe('Test multiple servers', function () { it('Should like and dislikes videos on different services', async function () { this.timeout(50000) - await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' }) + await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }) await wait(500) - await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'dislike' }) + await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' }) await wait(500) - await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' }) - await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'like' }) + await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' }) + await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' }) await wait(500) - await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'dislike' }) - await servers[2].videosCommand.rate({ id: remoteVideosServer3[1], rating: 'dislike' }) + await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' }) + await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' }) await wait(500) - await servers[2].videosCommand.rate({ id: remoteVideosServer3[0], rating: 'like' }) + await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' }) await waitJobs(servers) await wait(5000) @@ -573,7 +573,7 @@ describe('Test multiple servers', function () { let baseVideos = null for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() // Initialize base videos for future comparisons if (baseVideos === null) { @@ -608,7 +608,7 @@ describe('Test multiple servers', function () { previewfile: 'preview.jpg' } - await servers[2].videosCommand.update({ id: toRemove[0].id, attributes }) + await servers[2].videos.update({ id: toRemove[0].id, attributes }) await waitJobs(servers) }) @@ -617,7 +617,7 @@ describe('Test multiple servers', function () { this.timeout(10000) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const videoUpdated = data.find(video => video.name === 'my super video updated') expect(!!videoUpdated).to.be.true @@ -665,8 +665,8 @@ describe('Test multiple servers', function () { it('Should remove the videos 3 and 3-2 by asking server 3', async function () { this.timeout(10000) - await servers[2].videosCommand.remove({ id: toRemove[0].id }) - await servers[2].videosCommand.remove({ id: toRemove[1].id }) + await servers[2].videos.remove({ id: toRemove[0].id }) + await servers[2].videos.remove({ id: toRemove[1].id }) await waitJobs(servers) }) @@ -680,7 +680,7 @@ describe('Test multiple servers', function () { it('Should have videos 1 and 3 on each server', async function () { for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.be.an('array') expect(data.length).to.equal(2) @@ -697,7 +697,7 @@ describe('Test multiple servers', function () { it('Should get the same video by UUID on each server', async function () { let baseVideo = null for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) if (baseVideo === null) { baseVideo = video @@ -720,7 +720,7 @@ describe('Test multiple servers', function () { it('Should get the preview from each server', async function () { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) await testImage(server.url, 'video_short1-preview.webm', video.previewPath) } @@ -735,36 +735,36 @@ describe('Test multiple servers', function () { { const text = 'my super first comment' - await servers[0].commentsCommand.createThread({ videoId: videoUUID, text }) + await servers[0].comments.createThread({ videoId: videoUUID, text }) } { const text = 'my super second comment' - await servers[2].commentsCommand.createThread({ videoId: videoUUID, text }) + await servers[2].comments.createThread({ videoId: videoUUID, text }) } await waitJobs(servers) { - const threadId = await servers[1].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) + const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) const text = 'my super answer to thread 1' - await servers[1].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text }) + await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text }) } await waitJobs(servers) { - const threadId = await servers[2].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) + const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) - const body = await servers[2].commentsCommand.getThread({ videoId: videoUUID, threadId }) + const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId }) const childCommentId = body.children[0].comment.id const text3 = 'my second answer to thread 1' - await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 }) + await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 }) const text2 = 'my super answer to answer of thread 1' - await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }) + await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }) } await waitJobs(servers) @@ -772,7 +772,7 @@ describe('Test multiple servers', function () { it('Should have these threads', async function () { for (const server of servers) { - const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) + const body = await server.comments.listThreads({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.be.an('array') @@ -804,10 +804,10 @@ describe('Test multiple servers', function () { it('Should have these comments', async function () { for (const server of servers) { - const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) + const body = await server.comments.listThreads({ videoId: videoUUID }) const threadId = body.data.find(c => c.text === 'my super first comment').id - const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId }) + const tree = await server.comments.getThread({ videoId: videoUUID, threadId }) expect(tree.comment.text).equal('my super first comment') expect(tree.comment.account.name).equal('root') @@ -837,17 +837,17 @@ describe('Test multiple servers', function () { it('Should delete a reply', async function () { this.timeout(10000) - await servers[2].commentsCommand.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) + await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) await waitJobs(servers) }) it('Should have this comment marked as deleted', async function () { for (const server of servers) { - const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID }) + const { data } = await server.comments.listThreads({ videoId: videoUUID }) const threadId = data.find(c => c.text === 'my super first comment').id - const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId }) + const tree = await server.comments.getThread({ videoId: videoUUID, threadId }) expect(tree.comment.text).equal('my super first comment') const firstChild = tree.children[0] @@ -868,16 +868,16 @@ describe('Test multiple servers', function () { it('Should delete the thread comments', async function () { this.timeout(10000) - const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID }) + const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) const commentId = data.find(c => c.text === 'my super first comment').id - await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId }) + await servers[0].comments.delete({ videoId: videoUUID, commentId }) await waitJobs(servers) }) it('Should have the threads marked as deleted on other servers too', async function () { for (const server of servers) { - const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) + const body = await server.comments.listThreads({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.be.an('array') @@ -913,16 +913,16 @@ describe('Test multiple servers', function () { it('Should delete a remote thread by the origin server', async function () { this.timeout(5000) - const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID }) + const { data } = await servers[0].comments.listThreads({ videoId: videoUUID }) const commentId = data.find(c => c.text === 'my super second comment').id - await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId }) + await servers[0].comments.delete({ videoId: videoUUID, commentId }) await waitJobs(servers) }) it('Should have the threads marked as deleted on other servers too', async function () { for (const server of servers) { - const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) + const body = await server.comments.listThreads({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -957,17 +957,17 @@ describe('Test multiple servers', function () { downloadEnabled: false } - await servers[0].videosCommand.update({ id: videoUUID, attributes }) + await servers[0].videos.update({ id: videoUUID, attributes }) await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) expect(video.commentsEnabled).to.be.false expect(video.downloadEnabled).to.be.false const text = 'my super forbidden comment' - await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) + await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) } }) }) @@ -992,7 +992,7 @@ describe('Test multiple servers', function () { await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === 'minimum parameters') const isLocal = server.url === 'http://localhost:' + servers[1].port diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index b7756a4a8..2f1cf8a55 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts @@ -36,14 +36,14 @@ describe('Test resumable upload', function () { const attributes = { name: 'video', - channelId: server.videoChannel.id, + channelId: server.store.channel.id, privacy: VideoPrivacy.PUBLIC, fixture: defaultFixture } const mimetype = 'video/mp4' - const res = await server.videosCommand.prepareResumableUpload({ attributes, size, mimetype }) + const res = await server.videos.prepareResumableUpload({ attributes, size, mimetype }) return res.header['location'].split('?')[1] } @@ -61,7 +61,7 @@ describe('Test resumable upload', function () { const size = await buildSize(defaultFixture, options.size) const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture) - return server.videosCommand.sendResumableChunks({ + return server.videos.sendResumableChunks({ pathUploadId, videoFilePath: absoluteFilePath, size, @@ -75,7 +75,7 @@ describe('Test resumable upload', function () { const uploadId = uploadIdArg.replace(/^upload_id=/, '') const subPath = join('tmp', 'resumable-uploads', uploadId) - const filePath = server.serversCommand.buildDirectory(subPath) + const filePath = server.servers.buildDirectory(subPath) const exists = await pathExists(filePath) if (expectedSize === null) { @@ -90,7 +90,7 @@ describe('Test resumable upload', function () { async function countResumableUploads () { const subPath = join('tmp', 'resumable-uploads') - const filePath = server.serversCommand.buildDirectory(subPath) + const filePath = server.servers.buildDirectory(subPath) const files = await readdir(filePath) return files.length @@ -103,10 +103,10 @@ describe('Test resumable upload', function () { await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) - const body = await server.usersCommand.getMyInfo() + const body = await server.users.getMyInfo() rootId = body.id - await server.usersCommand.update({ userId: rootId, videoQuota: 10_000_000 }) + await server.users.update({ userId: rootId, videoQuota: 10_000_000 }) }) describe('Directory cleaning', function () { @@ -125,13 +125,13 @@ describe('Test resumable upload', function () { }) it('Should not delete recent uploads', async function () { - await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) + await server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) expect(await countResumableUploads()).to.equal(2) }) it('Should delete old uploads', async function () { - await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) + await server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) expect(await countResumableUploads()).to.equal(0) }) diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index da0b2011e..12c1f7b2f 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -100,35 +100,35 @@ describe('Test a single server', function () { }) it('Should list video categories', async function () { - const categories = await server.videosCommand.getCategories() + const categories = await server.videos.getCategories() expect(Object.keys(categories)).to.have.length.above(10) expect(categories[11]).to.equal('News & Politics') }) it('Should list video licences', async function () { - const licences = await server.videosCommand.getLicences() + const licences = await server.videos.getLicences() expect(Object.keys(licences)).to.have.length.above(5) expect(licences[3]).to.equal('Attribution - No Derivatives') }) it('Should list video languages', async function () { - const languages = await server.videosCommand.getLanguages() + const languages = await server.videos.getLanguages() expect(Object.keys(languages)).to.have.length.above(5) expect(languages['ru']).to.equal('Russian') }) it('Should list video privacies', async function () { - const privacies = await server.videosCommand.getPrivacies() + const privacies = await server.videos.getPrivacies() expect(Object.keys(privacies)).to.have.length.at.least(3) expect(privacies[3]).to.equal('Private') }) it('Should not have videos', async function () { - const { data, total } = await server.videosCommand.list() + const { data, total } = await server.videos.list() expect(total).to.equal(0) expect(data).to.be.an('array') @@ -145,7 +145,7 @@ describe('Test a single server', function () { licence: 6, tags: [ 'tag1', 'tag2', 'tag3' ] } - const video = await server.videosCommand.upload({ attributes, mode }) + const video = await server.videos.upload({ attributes, mode }) expect(video).to.not.be.undefined expect(video.id).to.equal(1) expect(video.uuid).to.have.length.above(5) @@ -157,7 +157,7 @@ describe('Test a single server', function () { it('Should get and seed the uploaded video', async function () { this.timeout(5000) - const { data, total } = await server.videosCommand.list() + const { data, total } = await server.videos.list() expect(total).to.equal(1) expect(data).to.be.an('array') @@ -170,42 +170,42 @@ describe('Test a single server', function () { it('Should get the video by UUID', async function () { this.timeout(5000) - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) await completeVideoCheck(server, video, getCheckAttributes()) }) it('Should have the views updated', async function () { this.timeout(20000) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) await wait(1500) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) await wait(1500) - await server.videosCommand.view({ id: videoId }) - await server.videosCommand.view({ id: videoId }) + await server.videos.view({ id: videoId }) + await server.videos.view({ id: videoId }) // Wait the repeatable job await wait(8000) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.views).to.equal(3) }) it('Should remove the video', async function () { - await server.videosCommand.remove({ id: videoId }) + await server.videos.remove({ id: videoId }) await checkVideoFilesWereRemoved(videoUUID, server) }) it('Should not have videos', async function () { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(0) expect(data).to.be.an('array') @@ -232,12 +232,12 @@ describe('Test a single server', function () { fixture: video } - await server.videosCommand.upload({ attributes, mode }) + await server.videos.upload({ attributes, mode }) } }) it('Should have the correct durations', async function () { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(6) expect(data).to.be.an('array') @@ -255,7 +255,7 @@ describe('Test a single server', function () { }) it('Should have the correct thumbnails', async function () { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() // For the next test videosListBase = data @@ -267,7 +267,7 @@ describe('Test a single server', function () { }) it('Should list only the two first videos', async function () { - const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: 'name' }) + const { total, data } = await server.videos.list({ start: 0, count: 2, sort: 'name' }) expect(total).to.equal(6) expect(data.length).to.equal(2) @@ -276,7 +276,7 @@ describe('Test a single server', function () { }) it('Should list only the next three videos', async function () { - const { total, data } = await server.videosCommand.list({ start: 2, count: 3, sort: 'name' }) + const { total, data } = await server.videos.list({ start: 2, count: 3, sort: 'name' }) expect(total).to.equal(6) expect(data.length).to.equal(3) @@ -286,7 +286,7 @@ describe('Test a single server', function () { }) it('Should list the last video', async function () { - const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name' }) + const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name' }) expect(total).to.equal(6) expect(data.length).to.equal(1) @@ -294,7 +294,7 @@ describe('Test a single server', function () { }) it('Should not have the total field', async function () { - const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name', skipCount: true }) + 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) @@ -302,7 +302,7 @@ describe('Test a single server', function () { }) it('Should list and sort by name in descending order', async function () { - const { total, data } = await server.videosCommand.list({ sort: '-name' }) + const { total, data } = await server.videos.list({ sort: '-name' }) expect(total).to.equal(6) expect(data.length).to.equal(6) @@ -318,21 +318,21 @@ describe('Test a single server', function () { }) it('Should list and sort by trending in descending order', async function () { - const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-trending' }) + 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.videosCommand.list({ start: 0, count: 2, sort: '-hot' }) + 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.videosCommand.list({ start: 0, count: 2, sort: '-best' }) + const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-best' }) expect(total).to.equal(6) expect(data.length).to.equal(2) @@ -350,18 +350,18 @@ describe('Test a single server', function () { downloadEnabled: false, tags: [ 'tagup1', 'tagup2' ] } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) }) it('Should filter by tags and category', async function () { { - const { data, total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) + const { data, total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) expect(total).to.equal(1) expect(data[0].name).to.equal('my super video updated') } { - const { total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) + const { total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) expect(total).to.equal(0) } }) @@ -369,7 +369,7 @@ describe('Test a single server', function () { it('Should have the video updated', async function () { this.timeout(60000) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) await completeVideoCheck(server, video, updateCheckAttributes()) }) @@ -378,9 +378,9 @@ describe('Test a single server', function () { const attributes = { tags: [ 'supertag', 'tag1', 'tag2' ] } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes)) }) @@ -389,27 +389,27 @@ describe('Test a single server', function () { const attributes = { description: 'hello everybody' } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) await completeVideoCheck(server, video, expectedAttributes) }) it('Should like a video', async function () { - await server.videosCommand.rate({ id: videoId, rating: 'like' }) + await server.videos.rate({ id: videoId, rating: 'like' }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.likes).to.equal(1) expect(video.dislikes).to.equal(0) }) it('Should dislike the same video', async function () { - await server.videosCommand.rate({ id: videoId, rating: 'dislike' }) + await server.videos.rate({ id: videoId, rating: 'dislike' }) - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) expect(video.likes).to.equal(0) expect(video.dislikes).to.equal(1) @@ -419,9 +419,9 @@ describe('Test a single server', function () { { const now = new Date() const attributes = { originallyPublishedAt: now.toISOString() } - await server.videosCommand.update({ id: videoId, attributes }) + await server.videos.update({ id: videoId, attributes }) - const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) + const { data } = await server.videos.list({ sort: '-originallyPublishedAt' }) const names = data.map(v => v.name) expect(names[0]).to.equal('my super video updated') @@ -435,9 +435,9 @@ describe('Test a single server', function () { { const now = new Date() const attributes = { originallyPublishedAt: now.toISOString() } - await server.videosCommand.update({ id: videoId2, attributes }) + await server.videos.update({ id: videoId2, attributes }) - const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) + const { data } = await server.videos.list({ sort: '-originallyPublishedAt' }) const names = data.map(v => v.name) expect(names[0]).to.equal('video_short1.webm name') diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 4c67e96f7..abc07194d 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts @@ -32,7 +32,7 @@ describe('Test video captions', function () { await waitJobs(servers) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'my video name' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'my video name' } }) videoUUID = uuid await waitJobs(servers) @@ -40,7 +40,7 @@ describe('Test video captions', function () { it('Should list the captions and return an empty list', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.listVideoCaptions({ videoId: videoUUID }) expect(body.total).to.equal(0) expect(body.data).to.have.lengthOf(0) } @@ -49,13 +49,13 @@ describe('Test video captions', function () { it('Should create two new captions', async function () { this.timeout(30000) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.createVideoCaption({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good1.vtt' }) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.createVideoCaption({ language: 'zh', videoId: videoUUID, fixture: 'subtitle-good2.vtt', @@ -67,7 +67,7 @@ describe('Test video captions', function () { it('Should list these uploaded captions', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.listVideoCaptions({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -88,7 +88,7 @@ describe('Test video captions', function () { it('Should replace an existing caption', async function () { this.timeout(30000) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.createVideoCaption({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good2.vtt' @@ -99,7 +99,7 @@ describe('Test video captions', function () { it('Should have this caption updated', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.listVideoCaptions({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -114,7 +114,7 @@ describe('Test video captions', function () { it('Should replace an existing caption with a srt file and convert it', async function () { this.timeout(30000) - await servers[0].captionsCommand.createVideoCaption({ + await servers[0].captions.createVideoCaption({ language: 'ar', videoId: videoUUID, fixture: 'subtitle-good.srt' @@ -128,7 +128,7 @@ describe('Test video captions', function () { it('Should have this caption updated and converted', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.listVideoCaptions({ videoId: videoUUID }) expect(body.total).to.equal(2) expect(body.data).to.have.lengthOf(2) @@ -157,14 +157,14 @@ describe('Test video captions', function () { it('Should remove one caption', async function () { this.timeout(30000) - await servers[0].captionsCommand.deleteVideoCaption({ videoId: videoUUID, language: 'ar' }) + await servers[0].captions.deleteVideoCaption({ videoId: videoUUID, language: 'ar' }) await waitJobs(servers) }) it('Should only list the caption that was not deleted', async function () { for (const server of servers) { - const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) + const body = await server.captions.listVideoCaptions({ videoId: videoUUID }) expect(body.total).to.equal(1) expect(body.data).to.have.lengthOf(1) @@ -178,7 +178,7 @@ describe('Test video captions', function () { }) it('Should remove the video, and thus all video captions', async function () { - await servers[0].videosCommand.remove({ id: videoUUID }) + await servers[0].videos.remove({ id: videoUUID }) await checkVideoFilesWereRemoved(videoUUID, servers[0]) }) diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index b85edd920..352eb5ea3 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts @@ -43,7 +43,7 @@ describe('Test video change ownership - nominal', function () { await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { transcoding: { enabled: false @@ -54,16 +54,16 @@ describe('Test video change ownership - nominal', function () { } }) - firstUserToken = await servers[0].usersCommand.generateUserAndToken(firstUser) - secondUserToken = await servers[0].usersCommand.generateUserAndToken(secondUser) + firstUserToken = await servers[0].users.generateUserAndToken(firstUser) + secondUserToken = await servers[0].users.generateUserAndToken(secondUser) { - const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: firstUserToken }) + const { videoChannels } = await servers[0].users.getMyInfo({ token: firstUserToken }) firstUserChannelId = videoChannels[0].id } { - const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: secondUserToken }) + const { videoChannels } = await servers[0].users.getMyInfo({ token: secondUserToken }) secondUserChannelId = videoChannels[0].id } @@ -72,19 +72,19 @@ describe('Test video change ownership - nominal', function () { name: 'my super name', description: 'my super description' } - const { id } = await servers[0].videosCommand.upload({ token: firstUserToken, attributes }) + const { id } = await servers[0].videos.upload({ token: firstUserToken, attributes }) - servers[0].video = await servers[0].videosCommand.get({ id }) + servers[0].store.video = await servers[0].videos.get({ id }) } { const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC } - const video = await servers[0].liveCommand.create({ token: firstUserToken, fields: attributes }) + const video = await servers[0].live.create({ token: firstUserToken, fields: attributes }) liveId = video.id } - command = servers[0].changeOwnershipCommand + command = servers[0].changeOwnership await doubleFollow(servers[0], servers[1]) }) @@ -110,7 +110,7 @@ describe('Test video change ownership - nominal', function () { it('Should send a request to change ownership of a video', async function () { this.timeout(15000) - await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser }) + await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser }) }) it('Should only return a request to change ownership for the second user', async function () { @@ -136,7 +136,7 @@ describe('Test video change ownership - nominal', function () { it('Should accept the same change ownership request without crashing', async function () { this.timeout(10000) - await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser }) + await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser }) }) it('Should not create multiple change ownership requests while one is waiting', async function () { @@ -164,7 +164,7 @@ describe('Test video change ownership - nominal', function () { it('Should send a new request to change ownership of a video', async function () { this.timeout(15000) - await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser }) + await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser }) }) it('Should return two requests to change ownership for the second user', async function () { @@ -208,7 +208,7 @@ describe('Test video change ownership - nominal', function () { it('Should have the channel of the video updated', async function () { for (const server of servers) { - const video = await server.videosCommand.get({ id: servers[0].video.uuid }) + const video = await server.videos.get({ id: servers[0].store.video.uuid }) expect(video.name).to.equal('my super name') expect(video.channel.displayName).to.equal('Main second channel') @@ -237,7 +237,7 @@ describe('Test video change ownership - nominal', function () { await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: servers[0].video.uuid }) + const video = await server.videos.get({ id: servers[0].store.video.uuid }) expect(video.name).to.equal('my super name') expect(video.channel.displayName).to.equal('Main second channel') @@ -266,35 +266,35 @@ describe('Test video change ownership - quota too small', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await server.usersCommand.create({ username: secondUser, videoQuota: 10 }) + await server.users.create({ username: secondUser, videoQuota: 10 }) - firstUserToken = await server.usersCommand.generateUserAndToken(firstUser) - secondUserToken = await server.loginCommand.getAccessToken(secondUser) + firstUserToken = await server.users.generateUserAndToken(firstUser) + secondUserToken = await server.login.getAccessToken(secondUser) // Upload some videos on the server const attributes = { name: 'my super name', description: 'my super description' } - await server.videosCommand.upload({ token: firstUserToken, attributes }) + await server.videos.upload({ token: firstUserToken, attributes }) await waitJobs(server) - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data.length).to.equal(1) - server.video = data.find(video => video.name === 'my super name') + server.store.video = data.find(video => video.name === 'my super name') }) it('Should send a request to change ownership of a video', async function () { this.timeout(15000) - await server.changeOwnershipCommand.create({ token: firstUserToken, videoId: server.video.id, username: secondUser }) + await server.changeOwnership.create({ token: firstUserToken, videoId: server.store.video.id, username: secondUser }) }) it('Should only return a request to change ownership for the second user', async function () { { - const body = await server.changeOwnershipCommand.list({ token: firstUserToken }) + const body = await server.changeOwnership.list({ token: firstUserToken }) expect(body.total).to.equal(0) expect(body.data).to.be.an('array') @@ -302,7 +302,7 @@ describe('Test video change ownership - quota too small', function () { } { - const body = await server.changeOwnershipCommand.list({ token: secondUserToken }) + const body = await server.changeOwnership.list({ token: secondUserToken }) expect(body.total).to.equal(1) expect(body.data).to.be.an('array') @@ -315,10 +315,10 @@ describe('Test video change ownership - quota too small', function () { it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () { this.timeout(10000) - const { videoChannels } = await server.usersCommand.getMyInfo({ token: secondUserToken }) + const { videoChannels } = await server.users.getMyInfo({ token: secondUserToken }) const channelId = videoChannels[0].id - await server.changeOwnershipCommand.accept({ + await server.changeOwnership.accept({ token: secondUserToken, ownershipId: lastRequestId, channelId, diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 170cc942e..1efef932c 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -21,7 +21,7 @@ import { User, VideoChannel } from '@shared/models' const expect = chai.expect async function findChannel (server: ServerInfo, channelId: number) { - const body = await server.channelsCommand.list({ sort: '-name' }) + const body = await server.channels.list({ sort: '-name' }) return body.data.find(c => c.id === channelId) } @@ -49,7 +49,7 @@ describe('Test video channels', function () { }) it('Should have one video channel (created with root)', async () => { - const body = await servers[0].channelsCommand.list({ start: 0, count: 2 }) + const body = await servers[0].channels.list({ start: 0, count: 2 }) expect(body.total).to.equal(1) expect(body.data).to.be.an('array') @@ -66,14 +66,14 @@ describe('Test video channels', function () { description: 'super video channel description', support: 'super video channel support text' } - const created = await servers[0].channelsCommand.create({ attributes: videoChannel }) + const created = await servers[0].channels.create({ attributes: videoChannel }) secondVideoChannelId = created.id } // The channel is 1 is propagated to servers 2 { const attributes = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } - const { uuid } = await servers[0].videosCommand.upload({ attributes }) + const { uuid } = await servers[0].videos.upload({ attributes }) videoUUID = uuid } @@ -81,7 +81,7 @@ describe('Test video channels', function () { }) it('Should have two video channels when getting my information', async () => { - userInfo = await servers[0].usersCommand.getMyInfo() + userInfo = await servers[0].users.getMyInfo() expect(userInfo.videoChannels).to.be.an('array') expect(userInfo.videoChannels).to.have.lengthOf(2) @@ -99,7 +99,7 @@ describe('Test video channels', function () { }) it('Should have two video channels when getting account channels on server 1', async function () { - const body = await servers[0].channelsCommand.listByAccount({ accountName }) + const body = await servers[0].channels.listByAccount({ accountName }) expect(body.total).to.equal(2) const videoChannels = body.data @@ -118,7 +118,7 @@ describe('Test video channels', function () { it('Should paginate and sort account channels', async function () { { - const body = await servers[0].channelsCommand.listByAccount({ + const body = await servers[0].channels.listByAccount({ accountName, start: 0, count: 1, @@ -133,7 +133,7 @@ describe('Test video channels', function () { } { - const body = await servers[0].channelsCommand.listByAccount({ + const body = await servers[0].channels.listByAccount({ accountName, start: 0, count: 1, @@ -146,7 +146,7 @@ describe('Test video channels', function () { } { - const body = await servers[0].channelsCommand.listByAccount({ + const body = await servers[0].channels.listByAccount({ accountName, start: 1, count: 1, @@ -160,7 +160,7 @@ describe('Test video channels', function () { }) it('Should have one video channel when getting account channels on server 2', async function () { - const body = await servers[1].channelsCommand.listByAccount({ accountName }) + const body = await servers[1].channels.listByAccount({ accountName }) expect(body.total).to.equal(1) expect(body.data).to.be.an('array') @@ -174,7 +174,7 @@ describe('Test video channels', function () { }) it('Should list video channels', async function () { - const body = await servers[0].channelsCommand.list({ start: 1, count: 1, sort: '-name' }) + const body = await servers[0].channels.list({ start: 1, count: 1, sort: '-name' }) expect(body.total).to.equal(2) expect(body.data).to.be.an('array') @@ -192,14 +192,14 @@ describe('Test video channels', function () { support: 'support updated' } - await servers[0].channelsCommand.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }) + await servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }) await waitJobs(servers) }) it('Should have video channel updated', async function () { for (const server of servers) { - const body = await server.channelsCommand.list({ start: 0, count: 1, sort: '-name' }) + const body = await server.channels.list({ start: 0, count: 1, sort: '-name' }) expect(body.total).to.equal(2) expect(body.data).to.be.an('array') @@ -214,7 +214,7 @@ describe('Test video channels', function () { it('Should not have updated the video support field', async function () { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) expect(video.support).to.equal('video support field') } }) @@ -227,12 +227,12 @@ describe('Test video channels', function () { bulkVideosSupportUpdate: true } - await servers[0].channelsCommand.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }) + await servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }) await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) expect(video.support).to.equal(videoChannelAttributes.support) } }) @@ -242,7 +242,7 @@ describe('Test video channels', function () { const fixture = 'avatar.png' - await servers[0].channelsCommand.updateImage({ + await servers[0].channels.updateImage({ channelName: 'second_video_channel', fixture, type: 'avatar' @@ -257,7 +257,7 @@ describe('Test video channels', function () { await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png') await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true) - const row = await server.sqlCommand.getActorImage(basename(avatarPaths[server.port])) + const row = await server.sql.getActorImage(basename(avatarPaths[server.port])) expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height) expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width) } @@ -268,7 +268,7 @@ describe('Test video channels', function () { const fixture = 'banner.jpg' - await servers[0].channelsCommand.updateImage({ + await servers[0].channels.updateImage({ channelName: 'second_video_channel', fixture, type: 'banner' @@ -277,13 +277,13 @@ describe('Test video channels', function () { await waitJobs(servers) for (const server of servers) { - const videoChannel = await server.channelsCommand.get({ channelName: 'second_video_channel@' + servers[0].host }) + const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host }) bannerPaths[server.port] = videoChannel.banner.path await testImage(server.url, 'banner-resized', bannerPaths[server.port]) await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true) - const row = await server.sqlCommand.getActorImage(basename(bannerPaths[server.port])) + const row = await server.sql.getActorImage(basename(bannerPaths[server.port])) expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height) expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width) } @@ -292,7 +292,7 @@ describe('Test video channels', function () { it('Should delete the video channel avatar', async function () { this.timeout(15000) - await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) + await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) await waitJobs(servers) @@ -307,7 +307,7 @@ describe('Test video channels', function () { it('Should delete the video channel banner', async function () { this.timeout(15000) - await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'banner' }) + await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'banner' }) await waitJobs(servers) @@ -324,7 +324,7 @@ describe('Test video channels', function () { for (const server of servers) { const channelURI = 'second_video_channel@localhost:' + servers[0].port - const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI }) + const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) expect(total).to.equal(1) expect(data).to.be.an('array') @@ -336,7 +336,7 @@ describe('Test video channels', function () { it('Should change the video channel of a video', async function () { this.timeout(10000) - await servers[0].videosCommand.update({ id: videoUUID, attributes: { channelId: servers[0].videoChannel.id } }) + await servers[0].videos.update({ id: videoUUID, attributes: { channelId: servers[0].store.channel.id } }) await waitJobs(servers) }) @@ -347,13 +347,13 @@ describe('Test video channels', function () { for (const server of servers) { { const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port - const { total } = await server.videosCommand.listByChannel({ videoChannelName: secondChannelURI }) + const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI }) expect(total).to.equal(0) } { const channelURI = 'root_channel@localhost:' + servers[0].port - const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI }) + const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) expect(total).to.equal(1) expect(data).to.be.an('array') @@ -364,11 +364,11 @@ describe('Test video channels', function () { }) it('Should delete video channel', async function () { - await servers[0].channelsCommand.delete({ channelName: 'second_video_channel' }) + await servers[0].channels.delete({ channelName: 'second_video_channel' }) }) it('Should have video channel deleted', async function () { - const body = await servers[0].channelsCommand.list({ start: 0, count: 10 }) + const body = await servers[0].channels.list({ start: 0, count: 10 }) expect(body.total).to.equal(1) expect(body.data).to.be.an('array') @@ -379,15 +379,15 @@ describe('Test video channels', function () { it('Should create the main channel with an uuid if there is a conflict', async function () { { const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' } - const created = await servers[0].channelsCommand.create({ attributes: videoChannel }) + const created = await servers[0].channels.create({ attributes: videoChannel }) totoChannel = created.id } { - await servers[0].usersCommand.create({ username: 'toto', password: 'password' }) - const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' }) + await servers[0].users.create({ username: 'toto', password: 'password' }) + const accessToken = await servers[0].login.getAccessToken({ username: 'toto', password: 'password' }) - const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: accessToken }) + const { videoChannels } = await servers[0].users.getMyInfo({ token: accessToken }) const videoChannel = videoChannels[0] expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) } @@ -397,7 +397,7 @@ describe('Test video channels', function () { this.timeout(10000) { - const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true }) + const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) for (const channel of data) { expect(channel).to.haveOwnProperty('viewsPerDay') @@ -411,21 +411,21 @@ describe('Test video channels', function () { } { - // video has been posted on channel servers[0].videoChannel.id since last update - await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' }) - await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' }) + // video has been posted on channel servers[0].store.videoChannel.id since last update + await servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' }) + await servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' }) // Wait the repeatable job await wait(8000) - const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true }) - const channelWithView = data.find(channel => channel.id === servers[0].videoChannel.id) + const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) + const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id) expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2) } }) it('Should report correct videos count', async function () { - const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true }) + const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) const totoChannel = data.find(c => c.name === 'toto_channel') const rootChannel = data.find(c => c.name === 'root_channel') @@ -436,7 +436,7 @@ describe('Test video channels', function () { it('Should search among account video channels', async function () { { - const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'root' }) + const body = await servers[0].channels.listByAccount({ accountName, search: 'root' }) expect(body.total).to.equal(1) const channels = body.data @@ -444,7 +444,7 @@ describe('Test video channels', function () { } { - const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'does not exist' }) + const body = await servers[0].channels.listByAccount({ accountName, search: 'does not exist' }) expect(body.total).to.equal(0) const channels = body.data @@ -455,21 +455,21 @@ describe('Test video channels', function () { it('Should list channels by updatedAt desc if a video has been uploaded', async function () { this.timeout(30000) - await servers[0].videosCommand.upload({ attributes: { channelId: totoChannel } }) + await servers[0].videos.upload({ attributes: { channelId: totoChannel } }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.channelsCommand.listByAccount({ accountName, sort: '-updatedAt' }) + const { data } = await server.channels.listByAccount({ accountName, sort: '-updatedAt' }) expect(data[0].name).to.equal('toto_channel') expect(data[1].name).to.equal('root_channel') } - await servers[0].videosCommand.upload({ attributes: { channelId: servers[0].videoChannel.id } }) + await servers[0].videos.upload({ attributes: { channelId: servers[0].store.channel.id } }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.channelsCommand.listByAccount({ accountName, sort: '-updatedAt' }) + const { data } = await server.channels.listByAccount({ accountName, sort: '-updatedAt' }) expect(data[0].name).to.equal('root_channel') expect(data[1].name).to.equal('toto_channel') diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 41be54c81..adb59bd74 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -32,15 +32,15 @@ describe('Test video comments', function () { await setAccessTokensToServers([ server ]) - const { id, uuid } = await server.videosCommand.upload() + const { id, uuid } = await server.videos.upload() videoUUID = uuid videoId = id - await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) + await server.users.updateMyAvatar({ fixture: 'avatar.png' }) - userAccessTokenServer1 = await server.usersCommand.generateUserAndToken('user1') + userAccessTokenServer1 = await server.users.generateUserAndToken('user1') - command = server.commentsCommand + command = server.comments }) describe('User comments', function () { diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts index 6ac9206f5..b89247288 100644 --- a/server/tests/api/videos/video-description.ts +++ b/server/tests/api/videos/video-description.ts @@ -31,11 +31,11 @@ describe('Test video description', function () { const attributes = { description: longDescription } - await servers[0].videosCommand.upload({ attributes }) + await servers[0].videos.upload({ attributes }) await waitJobs(servers) - const { data } = await servers[0].videosCommand.list() + const { data } = await servers[0].videos.list() videoId = data[0].id videoUUID = data[0].uuid @@ -43,7 +43,7 @@ describe('Test video description', function () { it('Should have a truncated description on each server', async function () { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) // 30 characters * 6 -> 240 characters const truncatedDescription = 'my super description for server 1'.repeat(7) + @@ -55,9 +55,9 @@ describe('Test video description', function () { it('Should fetch long description on each server', async function () { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) - const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath }) + const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath }) expect(description).to.equal(longDescription) } }) @@ -68,18 +68,18 @@ describe('Test video description', function () { const attributes = { description: 'short description' } - await servers[0].videosCommand.update({ id: videoId, attributes }) + await servers[0].videos.update({ id: videoId, attributes }) await waitJobs(servers) }) it('Should have a small description on each server', async function () { for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) expect(video.description).to.equal('short description') - const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath }) + const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath }) expect(description).to.equal('short description') } }) diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index d63b81694..9d79f2683 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts @@ -25,7 +25,7 @@ const expect = chai.expect async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videoUUID }) + const videoDetails = await server.videos.get({ id: videoUUID }) const baseUrl = `http://${videoDetails.account.host}` expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) @@ -62,7 +62,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn { await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) - const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: hlsPlaylist.playlistUrl }) + const masterPlaylist = await server.streamingPlaylists.get({ url: hlsPlaylist.playlistUrl }) for (const resolution of resolutions) { expect(masterPlaylist).to.contain(`${resolution}.m3u8`) @@ -72,7 +72,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn { for (const resolution of resolutions) { - const subPlaylist = await server.streamingPlaylistsCommand.get({ + const subPlaylist = await server.streamingPlaylists.get({ url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` }) @@ -107,7 +107,7 @@ describe('Test HLS videos', function () { it('Should upload a video and transcode it to HLS', async function () { this.timeout(120000) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) videoUUID = uuid await waitJobs(servers) @@ -118,7 +118,7 @@ describe('Test HLS videos', function () { it('Should upload an audio file and transcode it to HLS', async function () { this.timeout(120000) - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) videoAudioUUID = uuid await waitJobs(servers) @@ -129,7 +129,7 @@ describe('Test HLS videos', function () { it('Should update the video', async function () { this.timeout(10000) - await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }) + await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }) await waitJobs(servers) @@ -139,14 +139,14 @@ describe('Test HLS videos', function () { it('Should delete videos', async function () { this.timeout(10000) - await servers[0].videosCommand.remove({ id: videoUUID }) - await servers[0].videosCommand.remove({ id: videoAudioUUID }) + await servers[0].videos.remove({ id: videoUUID }) + await servers[0].videos.remove({ id: videoAudioUUID }) await waitJobs(servers) for (const server of servers) { - await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) - await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.videos.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.videos.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) @@ -192,7 +192,7 @@ describe('Test HLS videos', function () { describe('With only HLS enabled', function () { before(async function () { - await servers[0].configCommand.updateCustomSubConfig({ + await servers[0].config.updateCustomSubConfig({ newConfig: { transcoding: { enabled: true, diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 31fdfe12e..8b6542aa4 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts @@ -26,7 +26,7 @@ describe('Test video imports', function () { if (areHttpImportTestsDisabled()) return async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) { - const videoHttp = await server.videosCommand.get({ id: idHttp }) + const videoHttp = await server.videos.get({ id: idHttp }) expect(videoHttp.name).to.equal('small video - youtube') // FIXME: youtube-dl seems broken @@ -43,8 +43,8 @@ describe('Test video imports', function () { expect(originallyPublishedAt.getMonth()).to.equal(0) expect(originallyPublishedAt.getFullYear()).to.equal(2019) - const videoMagnet = await server.videosCommand.get({ id: idMagnet }) - const videoTorrent = await server.videosCommand.get({ id: idTorrent }) + const videoMagnet = await server.videos.get({ id: idMagnet }) + const videoTorrent = await server.videos.get({ id: idTorrent }) for (const video of [ videoMagnet, videoTorrent ]) { expect(video.category.label).to.equal('Misc') @@ -59,12 +59,12 @@ describe('Test video imports', function () { expect(videoTorrent.name).to.contain('你好 世界 720p.mp4') expect(videoMagnet.name).to.contain('super peertube2 video') - const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: idHttp }) + const bodyCaptions = await server.captions.listVideoCaptions({ videoId: idHttp }) expect(bodyCaptions.total).to.equal(2) } async function checkVideoServer2 (server: ServerInfo, id: number | string) { - const video = await server.videosCommand.get({ id }) + const video = await server.videos.get({ id }) expect(video.name).to.equal('my super name') expect(video.category.label).to.equal('Entertainment') @@ -76,7 +76,7 @@ describe('Test video imports', function () { expect(video.files).to.have.lengthOf(1) - const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: id }) + const bodyCaptions = await server.captions.listVideoCaptions({ videoId: id }) expect(bodyCaptions.total).to.equal(2) } @@ -89,12 +89,12 @@ describe('Test video imports', function () { await setAccessTokensToServers(servers) { - const { videoChannels } = await servers[0].usersCommand.getMyInfo() + const { videoChannels } = await servers[0].users.getMyInfo() channelIdServer1 = videoChannels[0].id } { - const { videoChannels } = await servers[1].usersCommand.getMyInfo() + const { videoChannels } = await servers[1].users.getMyInfo() channelIdServer2 = videoChannels[0].id } @@ -111,7 +111,7 @@ describe('Test video imports', function () { { const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() } - const { video } = await servers[0].importsCommand.importVideo({ attributes }) + const { video } = await servers[0].imports.importVideo({ attributes }) expect(video.name).to.equal('small video - youtube') expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`)) @@ -120,7 +120,7 @@ describe('Test video imports', function () { await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath) await testImage(servers[0].url, 'video_import_preview', video.previewPath) - const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: video.id }) + const bodyCaptions = await servers[0].captions.listVideoCaptions({ videoId: video.id }) const videoCaptions = bodyCaptions.data expect(videoCaptions).to.have.lengthOf(2) @@ -166,7 +166,7 @@ Ajouter un sous-titre est vraiment facile`) description: 'this is a super torrent description', tags: [ 'tag_torrent1', 'tag_torrent2' ] } - const { video } = await servers[0].importsCommand.importVideo({ attributes }) + const { video } = await servers[0].imports.importVideo({ attributes }) expect(video.name).to.equal('super peertube2 video') } @@ -177,13 +177,13 @@ Ajouter un sous-titre est vraiment facile`) description: 'this is a super torrent description', tags: [ 'tag_torrent1', 'tag_torrent2' ] } - const { video } = await servers[0].importsCommand.importVideo({ attributes }) + const { video } = await servers[0].imports.importVideo({ attributes }) expect(video.name).to.equal('你好 世界 720p.mp4') } }) it('Should list the videos to import in my videos on server 1', async function () { - const { total, data } = await servers[0].videosCommand.listMyVideos({ sort: 'createdAt' }) + const { total, data } = await servers[0].videos.listMyVideos({ sort: 'createdAt' }) expect(total).to.equal(3) @@ -194,7 +194,7 @@ Ajouter un sous-titre est vraiment facile`) }) it('Should list the videos to import in my imports on server 1', async function () { - const { total, data: videoImports } = await servers[0].importsCommand.getMyVideoImports({ sort: '-createdAt' }) + const { total, data: videoImports } = await servers[0].imports.getMyVideoImports({ sort: '-createdAt' }) expect(total).to.equal(3) expect(videoImports).to.have.lengthOf(3) @@ -221,7 +221,7 @@ Ajouter un sous-titre est vraiment facile`) await waitJobs(servers) for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(3) expect(data).to.have.lengthOf(3) @@ -244,7 +244,7 @@ Ajouter un sous-titre est vraiment facile`) description: 'my super description', tags: [ 'supertag1', 'supertag2' ] } - const { video } = await servers[1].importsCommand.importVideo({ attributes }) + const { video } = await servers[1].imports.importVideo({ attributes }) expect(video.name).to.equal('my super name') }) @@ -254,7 +254,7 @@ Ajouter un sous-titre est vraiment facile`) await waitJobs(servers) for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(4) expect(data).to.have.lengthOf(4) @@ -274,13 +274,13 @@ Ajouter un sous-titre est vraiment facile`) channelId: channelIdServer2, privacy: VideoPrivacy.PUBLIC } - const { video } = await servers[1].importsCommand.importVideo({ attributes }) + const { video } = await servers[1].imports.importVideo({ attributes }) const videoUUID = video.uuid await waitJobs(servers) for (const server of servers) { - const video = await server.videosCommand.get({ id: videoUUID }) + const video = await server.videos.get({ id: videoUUID }) expect(video.name).to.equal('transcoded video') expect(video.files).to.have.lengthOf(4) @@ -316,7 +316,7 @@ Ajouter un sous-titre est vraiment facile`) } } } - await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) + await servers[0].config.updateCustomSubConfig({ newConfig: config }) const attributes = { name: 'hdr video', @@ -324,13 +324,13 @@ Ajouter un sous-titre est vraiment facile`) channelId: channelIdServer1, privacy: VideoPrivacy.PUBLIC } - const { video: videoImported } = await servers[0].importsCommand.importVideo({ attributes }) + const { video: videoImported } = await servers[0].imports.importVideo({ attributes }) const videoUUID = videoImported.uuid await waitJobs(servers) // test resolution - const video = await servers[0].videosCommand.get({ id: videoUUID }) + const video = await servers[0].videos.get({ id: videoUUID }) expect(video.name).to.equal('hdr video') const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id })) expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index b8fff096d..95395a582 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -18,7 +18,7 @@ describe('Test video NSFW policy', function () { let customConfig: CustomConfig async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { - const user = await server.usersCommand.getMyInfo() + const user = await server.users.getMyInfo() const videoChannelName = user.videoChannels[0].name const accountName = user.account.name + '@' + user.account.host const hasQuery = Object.keys(query).length !== 0 @@ -26,15 +26,15 @@ describe('Test video NSFW policy', function () { if (token) { promises = [ - server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), - server.videosCommand.listWithToken({ token, ...query }), - server.videosCommand.listByAccount({ token, accountName, ...query }), - server.videosCommand.listByChannel({ token, videoChannelName, ...query }) + server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), + server.videos.listWithToken({ token, ...query }), + server.videos.listByAccount({ token, accountName, ...query }), + server.videos.listByChannel({ token, videoChannelName, ...query }) ] // Overviews do not support video filters if (!hasQuery) { - const p = server.overviewsCommand.getVideos({ page: 1, token }) + const p = server.overviews.getVideos({ page: 1, token }) .then(res => createOverviewRes(res)) promises.push(p) } @@ -43,15 +43,15 @@ describe('Test video NSFW policy', function () { } promises = [ - server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }), - server.videosCommand.list(), - server.videosCommand.listByAccount({ accountName }), - server.videosCommand.listByChannel({ videoChannelName }) + server.search.searchVideos({ search: 'n', sort: '-publishedAt' }), + server.videos.list(), + server.videos.listByAccount({ accountName }), + server.videos.listByChannel({ videoChannelName }) ] // Overviews do not support video filters if (!hasQuery) { - const p = server.overviewsCommand.getVideos({ page: 1 }) + const p = server.overviews.getVideos({ page: 1 }) .then(res => createOverviewRes(res)) promises.push(p) } @@ -68,20 +68,20 @@ describe('Test video NSFW policy', function () { { const attributes = { name: 'nsfw', nsfw: true, category: 1 } - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) } { const attributes = { name: 'normal', nsfw: false, category: 1 } - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) } - customConfig = await server.configCommand.getCustomConfig() + customConfig = await server.config.getCustomConfig() }) describe('Instance default NSFW policy', function () { it('Should display NSFW videos with display default NSFW policy', async function () { - const serverConfig = await server.configCommand.getConfig() + const serverConfig = await server.config.getConfig() expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display') for (const body of await getVideosFunctions()) { @@ -96,9 +96,9 @@ describe('Test video NSFW policy', function () { it('Should not display NSFW videos with do_not_list default NSFW policy', async function () { customConfig.instance.defaultNSFWPolicy = 'do_not_list' - await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) + await server.config.updateCustomConfig({ newCustomConfig: customConfig }) - const serverConfig = await server.configCommand.getConfig() + const serverConfig = await server.config.getConfig() expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list') for (const body of await getVideosFunctions()) { @@ -112,9 +112,9 @@ describe('Test video NSFW policy', function () { it('Should display NSFW videos with blur default NSFW policy', async function () { customConfig.instance.defaultNSFWPolicy = 'blur' - await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) + await server.config.updateCustomConfig({ newCustomConfig: customConfig }) - const serverConfig = await server.configCommand.getConfig() + const serverConfig = await server.config.getConfig() expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur') for (const body of await getVideosFunctions()) { @@ -133,17 +133,17 @@ describe('Test video NSFW policy', function () { it('Should create a user having the default nsfw policy', async function () { const username = 'user1' const password = 'my super password' - await server.usersCommand.create({ username: username, password: password }) + await server.users.create({ username: username, password: password }) - userAccessToken = await server.loginCommand.getAccessToken({ username, password }) + userAccessToken = await server.login.getAccessToken({ username, password }) - const user = await server.usersCommand.getMyInfo({ token: userAccessToken }) + const user = await server.users.getMyInfo({ token: userAccessToken }) expect(user.nsfwPolicy).to.equal('blur') }) it('Should display NSFW videos with blur user NSFW policy', async function () { customConfig.instance.defaultNSFWPolicy = 'do_not_list' - await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) + await server.config.updateCustomConfig({ newCustomConfig: customConfig }) for (const body of await getVideosFunctions(userAccessToken)) { expect(body.total).to.equal(2) @@ -156,7 +156,7 @@ describe('Test video NSFW policy', function () { }) it('Should display NSFW videos with display user NSFW policy', async function () { - await server.usersCommand.updateMe({ nsfwPolicy: 'display' }) + await server.users.updateMe({ nsfwPolicy: 'display' }) for (const body of await getVideosFunctions(server.accessToken)) { expect(body.total).to.equal(2) @@ -169,7 +169,7 @@ describe('Test video NSFW policy', function () { }) it('Should not display NSFW videos with do_not_list user NSFW policy', async function () { - await server.usersCommand.updateMe({ nsfwPolicy: 'do_not_list' }) + await server.users.updateMe({ nsfwPolicy: 'do_not_list' }) for (const body of await getVideosFunctions(server.accessToken)) { expect(body.total).to.equal(1) @@ -181,7 +181,7 @@ describe('Test video NSFW policy', function () { }) it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () { - const { total, data } = await server.videosCommand.listMyVideos() + const { total, data } = await server.videos.listMyVideos() expect(total).to.equal(2) expect(data).to.have.lengthOf(2) diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts index 14739af20..709f64c4d 100644 --- a/server/tests/api/videos/video-playlist-thumbnails.ts +++ b/server/tests/api/videos/video-playlist-thumbnails.ts @@ -31,13 +31,13 @@ describe('Playlist thumbnail', function () { let video2: number async function getPlaylistWithoutThumbnail (server: ServerInfo) { - const body = await server.playlistsCommand.list({ start: 0, count: 10 }) + const body = await server.playlists.list({ start: 0, count: 10 }) return body.data.find(p => p.displayName === 'playlist without thumbnail') } async function getPlaylistWithThumbnail (server: ServerInfo) { - const body = await server.playlistsCommand.list({ start: 0, count: 10 }) + const body = await server.playlists.list({ start: 0, count: 10 }) return body.data.find(p => p.displayName === 'playlist with thumbnail') } @@ -54,8 +54,8 @@ describe('Playlist thumbnail', function () { // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) - video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).id - video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).id + video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).id + video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).id await waitJobs(servers) }) @@ -63,16 +63,16 @@ describe('Playlist thumbnail', function () { it('Should automatically update the thumbnail when adding an element', async function () { this.timeout(30000) - const created = await servers[1].playlistsCommand.create({ + const created = await servers[1].playlists.create({ attributes: { displayName: 'playlist without thumbnail', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) playlistWithoutThumbnailId = created.id - const added = await servers[1].playlistsCommand.addElement({ + const added = await servers[1].playlists.addElement({ playlistId: playlistWithoutThumbnailId, attributes: { videoId: video1 } }) @@ -89,17 +89,17 @@ describe('Playlist thumbnail', function () { it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () { this.timeout(30000) - const created = await servers[1].playlistsCommand.create({ + const created = await servers[1].playlists.create({ attributes: { displayName: 'playlist with thumbnail', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[1].videoChannel.id, + videoChannelId: servers[1].store.channel.id, thumbnailfile: 'thumbnail.jpg' } }) playlistWithThumbnailId = created.id - const added = await servers[1].playlistsCommand.addElement({ + const added = await servers[1].playlists.addElement({ playlistId: playlistWithThumbnailId, attributes: { videoId: video1 } }) @@ -116,13 +116,13 @@ describe('Playlist thumbnail', function () { it('Should automatically update the thumbnail when moving the first element', async function () { this.timeout(30000) - const added = await servers[1].playlistsCommand.addElement({ + const added = await servers[1].playlists.addElement({ playlistId: playlistWithoutThumbnailId, attributes: { videoId: video2 } }) withoutThumbnailE2 = added.id - await servers[1].playlistsCommand.reorderElements({ + await servers[1].playlists.reorderElements({ playlistId: playlistWithoutThumbnailId, attributes: { startPosition: 1, @@ -141,13 +141,13 @@ describe('Playlist thumbnail', function () { it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () { this.timeout(30000) - const added = await servers[1].playlistsCommand.addElement({ + const added = await servers[1].playlists.addElement({ playlistId: playlistWithThumbnailId, attributes: { videoId: video2 } }) withThumbnailE2 = added.id - await servers[1].playlistsCommand.reorderElements({ + await servers[1].playlists.reorderElements({ playlistId: playlistWithThumbnailId, attributes: { startPosition: 1, @@ -166,7 +166,7 @@ describe('Playlist thumbnail', function () { it('Should automatically update the thumbnail when deleting the first element', async function () { this.timeout(30000) - await servers[1].playlistsCommand.removeElement({ + await servers[1].playlists.removeElement({ playlistId: playlistWithoutThumbnailId, elementId: withoutThumbnailE1 }) @@ -182,7 +182,7 @@ describe('Playlist thumbnail', function () { it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () { this.timeout(30000) - await servers[1].playlistsCommand.removeElement({ + await servers[1].playlists.removeElement({ playlistId: playlistWithThumbnailId, elementId: withThumbnailE1 }) @@ -198,7 +198,7 @@ describe('Playlist thumbnail', function () { it('Should the thumbnail when we delete the last element', async function () { this.timeout(30000) - await servers[1].playlistsCommand.removeElement({ + await servers[1].playlists.removeElement({ playlistId: playlistWithoutThumbnailId, elementId: withoutThumbnailE2 }) @@ -214,7 +214,7 @@ describe('Playlist thumbnail', function () { it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () { this.timeout(30000) - await servers[1].playlistsCommand.removeElement({ + await servers[1].playlists.removeElement({ playlistId: playlistWithThumbnailId, elementId: withThumbnailE2 }) diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 40f61ca19..0dc53d4c0 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts @@ -36,7 +36,7 @@ async function checkPlaylistElementType ( total: number ) { for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }) expect(body.total).to.equal(total) const videoElement = body.data.find(e => e.position === position) @@ -86,26 +86,26 @@ describe('Test video playlists', function () { // Server 1 and server 3 follow each other await doubleFollow(servers[0], servers[2]) - commands = servers.map(s => s.playlistsCommand) + commands = servers.map(s => s.playlists) { - servers[0].videos = [] - servers[1].videos = [] - servers[2].videos = [] + servers[0].store.videos = [] + servers[1].store.videos = [] + servers[2].store.videos = [] for (const server of servers) { for (let i = 0; i < 7; i++) { const name = `video ${i} server ${server.serverNumber}` - const video = await server.videosCommand.upload({ attributes: { name, nsfw: false } }) + const video = await server.videos.upload({ attributes: { name, nsfw: false } }) - server.videos.push(video) + server.store.videos.push(video) } } } - nsfwVideoServer1 = (await servers[0].videosCommand.quickUpload({ name: 'NSFW video', nsfw: true })).id + nsfwVideoServer1 = (await servers[0].videos.quickUpload({ name: 'NSFW video', nsfw: true })).id - userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1') + userTokenServer1 = await servers[0].users.generateUserAndToken('user1') await waitJobs(servers) }) @@ -149,7 +149,7 @@ describe('Test video playlists', function () { }) it('Should get private playlist for a classic user', async function () { - const token = await servers[0].usersCommand.generateUserAndToken('toto') + const token = await servers[0].users.generateUserAndToken('toto') const body = await commands[0].listByAccount({ token, handle: 'toto' }) @@ -172,7 +172,7 @@ describe('Test video playlists', function () { privacy: VideoPlaylistPrivacy.PUBLIC, description: 'my super description', thumbnailfile: 'thumbnail.jpg', - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) @@ -181,13 +181,13 @@ describe('Test video playlists', function () { await wait(3000) for (const server of servers) { - const body = await server.playlistsCommand.list({ start: 0, count: 5 }) + const body = await server.playlists.list({ start: 0, count: 5 }) expect(body.total).to.equal(1) expect(body.data).to.have.lengthOf(1) const playlistFromList = body.data[0] - const playlistFromGet = await server.playlistsCommand.get({ playlistId: playlistFromList.uuid }) + const playlistFromGet = await server.playlists.get({ playlistId: playlistFromList.uuid }) for (const playlist of [ playlistFromGet, playlistFromList ]) { expect(playlist.id).to.be.a('number') @@ -217,23 +217,23 @@ describe('Test video playlists', function () { this.timeout(30000) { - const playlist = await servers[1].playlistsCommand.create({ + const playlist = await servers[1].playlists.create({ attributes: { displayName: 'playlist 2', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) playlistServer2Id1 = playlist.id } { - const playlist = await servers[1].playlistsCommand.create({ + const playlist = await servers[1].playlists.create({ attributes: { displayName: 'playlist 3', privacy: VideoPlaylistPrivacy.PUBLIC, thumbnailfile: 'thumbnail.jpg', - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) @@ -242,13 +242,13 @@ describe('Test video playlists', function () { } for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) { - await servers[1].playlistsCommand.addElement({ + await servers[1].playlists.addElement({ playlistId: id, - attributes: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 } + attributes: { videoId: servers[1].store.videos[0].id, startTimestamp: 1, stopTimestamp: 2 } }) - await servers[1].playlistsCommand.addElement({ + await servers[1].playlists.addElement({ playlistId: id, - attributes: { videoId: servers[1].videos[1].id } + attributes: { videoId: servers[1].store.videos[1].id } }) } @@ -256,7 +256,7 @@ describe('Test video playlists', function () { await wait(3000) for (const server of [ servers[0], servers[1] ]) { - const body = await server.playlistsCommand.list({ start: 0, count: 5 }) + const body = await server.playlists.list({ start: 0, count: 5 }) const playlist2 = body.data.find(p => p.displayName === 'playlist 2') expect(playlist2).to.not.be.undefined @@ -267,7 +267,7 @@ describe('Test video playlists', function () { await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) } - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined }) @@ -278,7 +278,7 @@ describe('Test video playlists', function () { // Server 2 and server 3 follow each other await doubleFollow(servers[1], servers[2]) - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) const playlist2 = body.data.find(p => p.displayName === 'playlist 2') expect(playlist2).to.not.be.undefined @@ -294,7 +294,7 @@ describe('Test video playlists', function () { this.timeout(30000) { - const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: 'createdAt' }) + const body = await servers[2].playlists.list({ start: 1, count: 2, sort: 'createdAt' }) expect(body.total).to.equal(3) const data = body.data @@ -304,7 +304,7 @@ describe('Test video playlists', function () { } { - const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: '-createdAt' }) + const body = await servers[2].playlists.list({ start: 1, count: 2, sort: '-createdAt' }) expect(body.total).to.equal(3) const data = body.data @@ -331,7 +331,7 @@ describe('Test video playlists', function () { this.timeout(30000) { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }) expect(body.total).to.equal(2) const data = body.data @@ -340,7 +340,7 @@ describe('Test video playlists', function () { } { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' }) expect(body.total).to.equal(2) const data = body.data @@ -349,7 +349,7 @@ describe('Test video playlists', function () { } { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' }) expect(body.total).to.equal(1) const data = body.data @@ -358,7 +358,7 @@ describe('Test video playlists', function () { } { - const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' }) + const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' }) expect(body.total).to.equal(0) const data = body.data @@ -375,17 +375,17 @@ describe('Test video playlists', function () { this.timeout(30000) { - unlistedPlaylist = await servers[1].playlistsCommand.create({ + unlistedPlaylist = await servers[1].playlists.create({ attributes: { displayName: 'playlist unlisted', privacy: VideoPlaylistPrivacy.UNLISTED, - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id } }) } { - privatePlaylist = await servers[1].playlistsCommand.create({ + privatePlaylist = await servers[1].playlists.create({ attributes: { displayName: 'playlist private', privacy: VideoPlaylistPrivacy.PRIVATE @@ -400,8 +400,8 @@ describe('Test video playlists', function () { it('Should not list unlisted or private playlists', async function () { for (const server of servers) { const results = [ - await server.playlistsCommand.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), - await server.playlistsCommand.list({ start: 0, count: 2, sort: '-createdAt' }) + await server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), + await server.playlists.list({ start: 0, count: 2, sort: '-createdAt' }) ] expect(results[0].total).to.equal(2) @@ -417,23 +417,23 @@ describe('Test video playlists', function () { }) it('Should not get unlisted playlist using only the id', async function () { - await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }) + await servers[1].playlists.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }) }) it('Should get unlisted plyaylist using uuid or shortUUID', async function () { - await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.uuid }) - await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.shortUUID }) + await servers[1].playlists.get({ playlistId: unlistedPlaylist.uuid }) + await servers[1].playlists.get({ playlistId: unlistedPlaylist.shortUUID }) }) it('Should not get private playlist without token', async function () { for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { - await servers[1].playlistsCommand.get({ playlistId: id, expectedStatus: 401 }) + await servers[1].playlists.get({ playlistId: id, expectedStatus: 401 }) } }) it('Should get private playlist with a token', async function () { for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { - await servers[1].playlistsCommand.get({ token: servers[1].accessToken, playlistId: id }) + await servers[1].playlists.get({ token: servers[1].accessToken, playlistId: id }) } }) }) @@ -443,13 +443,13 @@ describe('Test video playlists', function () { it('Should update a playlist', async function () { this.timeout(30000) - await servers[1].playlistsCommand.update({ + await servers[1].playlists.update({ attributes: { displayName: 'playlist 3 updated', description: 'description updated', privacy: VideoPlaylistPrivacy.UNLISTED, thumbnailfile: 'thumbnail.jpg', - videoChannelId: servers[1].videoChannel.id + videoChannelId: servers[1].store.channel.id }, playlistId: playlistServer2Id2 }) @@ -457,7 +457,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const playlist = await server.playlistsCommand.get({ playlistId: playlistServer2UUID2 }) + const playlist = await server.playlists.get({ playlistId: playlistServer2UUID2 }) expect(playlist.displayName).to.equal('playlist 3 updated') expect(playlist.description).to.equal('description updated') @@ -491,23 +491,23 @@ describe('Test video playlists', function () { attributes: { displayName: 'playlist 4', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) playlistServer1Id = playlist.id playlistServer1UUID = playlist.uuid - await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) - await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 }) - await addVideo({ videoId: servers[2].videos[2].uuid }) + await addVideo({ videoId: servers[0].store.videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) + await addVideo({ videoId: servers[2].store.videos[1].uuid, startTimestamp: 35 }) + await addVideo({ videoId: servers[2].store.videos[2].uuid }) { - const element = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 }) + const element = await addVideo({ videoId: servers[0].store.videos[3].uuid, stopTimestamp: 35 }) playlistElementServer1Video4 = element.id } { - const element = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) + const element = await addVideo({ videoId: servers[0].store.videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) playlistElementServer1Video5 = element.id } @@ -527,7 +527,7 @@ describe('Test video playlists', function () { for (const server of servers) { { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) expect(body.total).to.equal(8) @@ -576,7 +576,7 @@ describe('Test video playlists', function () { } { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 }) expect(body.data).to.have.lengthOf(2) } } @@ -606,7 +606,7 @@ describe('Test video playlists', function () { attributes: { displayName: 'playlist 56', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) @@ -617,9 +617,9 @@ describe('Test video playlists', function () { return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes }) } - video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid - video2 = (await servers[1].videosCommand.quickUpload({ name: 'video 90' })).uuid - video3 = (await servers[0].videosCommand.quickUpload({ name: 'video 91', nsfw: true })).uuid + video1 = (await servers[0].videos.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid + video2 = (await servers[1].videos.quickUpload({ name: 'video 90' })).uuid + video3 = (await servers[0].videos.quickUpload({ name: 'video 91', nsfw: true })).uuid await waitJobs(servers) @@ -637,7 +637,7 @@ describe('Test video playlists', function () { const position = 1 { - await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } }) + await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -647,7 +647,7 @@ describe('Test video playlists', function () { } { - await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } }) + await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -665,7 +665,7 @@ describe('Test video playlists', function () { const position = 1 { - await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true }) + await servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -675,7 +675,7 @@ describe('Test video playlists', function () { } { - await servers[0].blacklistCommand.remove({ videoId: video1 }) + await servers[0].blacklist.remove({ videoId: video1 }) await waitJobs(servers) await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) @@ -689,7 +689,7 @@ describe('Test video playlists', function () { it('Should update the element type if the account or server of the video is blocked', async function () { this.timeout(90000) - const command = servers[0].blocklistCommand + const command = servers[0].blocklist const name = 'video 90' const position = 2 @@ -778,7 +778,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) const names = body.data.map(v => v.video.name) expect(names).to.deep.equal([ @@ -807,7 +807,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) const names = body.data.map(v => v.video.name) expect(names).to.deep.equal([ @@ -835,7 +835,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) const names = elements.map(v => v.video.name) expect(names).to.deep.equal([ @@ -878,7 +878,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) expect(elements[0].video.name).to.equal('video 3 server 1') expect(elements[0].position).to.equal(1) @@ -894,16 +894,16 @@ describe('Test video playlists', function () { it('Should check videos existence in my playlist', async function () { const videoIds = [ - servers[0].videos[0].id, + servers[0].store.videos[0].id, 42000, - servers[0].videos[3].id, + servers[0].store.videos[3].id, 43000, - servers[0].videos[4].id + servers[0].store.videos[4].id ] const obj = await commands[0].videosExist({ videoIds }) { - const elem = obj[servers[0].videos[0].id] + const elem = obj[servers[0].store.videos[0].id] expect(elem).to.have.lengthOf(1) expect(elem[0].playlistElementId).to.exist expect(elem[0].playlistId).to.equal(playlistServer1Id) @@ -912,7 +912,7 @@ describe('Test video playlists', function () { } { - const elem = obj[servers[0].videos[3].id] + const elem = obj[servers[0].store.videos[3].id] expect(elem).to.have.lengthOf(1) expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4) expect(elem[0].playlistId).to.equal(playlistServer1Id) @@ -921,7 +921,7 @@ describe('Test video playlists', function () { } { - const elem = obj[servers[0].videos[4].id] + const elem = obj[servers[0].store.videos[4].id] expect(elem).to.have.lengthOf(1) expect(elem[0].playlistId).to.equal(playlistServer1Id) expect(elem[0].startTimestamp).to.equal(45) @@ -934,29 +934,29 @@ describe('Test video playlists', function () { it('Should automatically update updatedAt field of playlists', async function () { const server = servers[1] - const videoId = servers[1].videos[5].id + const videoId = servers[1].store.videos[5].id async function getPlaylistNames () { - const { data } = await server.playlistsCommand.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }) + const { data } = await server.playlists.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }) return data.map(p => p.displayName) } const attributes = { videoId } - const element1 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id1, attributes }) - const element2 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id2, attributes }) + const element1 = await server.playlists.addElement({ playlistId: playlistServer2Id1, attributes }) + const element2 = await server.playlists.addElement({ playlistId: playlistServer2Id2, attributes }) const names1 = await getPlaylistNames() expect(names1[0]).to.equal('playlist 3 updated') expect(names1[1]).to.equal('playlist 2') - await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id }) + await server.playlists.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id }) const names2 = await getPlaylistNames() expect(names2[0]).to.equal('playlist 2') expect(names2[1]).to.equal('playlist 3 updated') - await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id }) + await server.playlists.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id }) const names3 = await getPlaylistNames() expect(names3[0]).to.equal('playlist 3 updated') @@ -972,7 +972,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) + const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) expect(body.total).to.equal(6) const elements = body.data @@ -1005,14 +1005,14 @@ describe('Test video playlists', function () { attributes: { displayName: 'my super public playlist', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: servers[0].videoChannel.id + videoChannelId: servers[0].store.channel.id } }) await waitJobs(servers) for (const server of servers) { - await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 }) + await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 }) } const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE } @@ -1021,7 +1021,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of [ servers[1], servers[2] ]) { - await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) @@ -1039,7 +1039,7 @@ describe('Test video playlists', function () { await waitJobs(servers) for (const server of servers) { - await server.playlistsCommand.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await server.playlists.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } }) @@ -1057,16 +1057,16 @@ describe('Test video playlists', function () { const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist') { - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) expect(body.total).to.equal(3) expect(finder(body.data)).to.not.be.undefined } - await servers[2].followsCommand.unfollow({ target: servers[0] }) + await servers[2].follows.unfollow({ target: servers[0] }) { - const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) + const body = await servers[2].playlists.list({ start: 0, count: 5 }) expect(body.total).to.equal(1) expect(finder(body.data)).to.be.undefined @@ -1076,7 +1076,7 @@ describe('Test video playlists', function () { it('Should delete a channel and put the associated playlist in private mode', async function () { this.timeout(30000) - const channel = await servers[0].channelsCommand.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }) + const channel = await servers[0].channels.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }) const playlistCreated = await commands[0].create({ attributes: { @@ -1088,7 +1088,7 @@ describe('Test video playlists', function () { await waitJobs(servers) - await servers[0].channelsCommand.delete({ channelName: 'super_channel' }) + await servers[0].channels.delete({ channelName: 'super_channel' }) await waitJobs(servers) @@ -1096,15 +1096,15 @@ describe('Test video playlists', function () { expect(body.displayName).to.equal('channel playlist') expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) - await servers[1].playlistsCommand.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[1].playlists.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) it('Should delete an account and delete its playlists', async function () { this.timeout(30000) - const { userId, token } = await servers[0].usersCommand.generate('user_1') + const { userId, token } = await servers[0].users.generate('user_1') - const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token }) + const { videoChannels } = await servers[0].users.getMyInfo({ token }) const userChannel = videoChannels[0] await commands[0].create({ @@ -1121,18 +1121,18 @@ describe('Test video playlists', function () { { for (const server of [ servers[0], servers[1] ]) { - const body = await server.playlistsCommand.list({ start: 0, count: 15 }) + const body = await server.playlists.list({ start: 0, count: 15 }) expect(finder(body.data)).to.not.be.undefined } } - await servers[0].usersCommand.remove({ userId }) + await servers[0].users.remove({ userId }) await waitJobs(servers) { for (const server of [ servers[0], servers[1] ]) { - const body = await server.playlistsCommand.list({ start: 0, count: 15 }) + const body = await server.playlists.list({ start: 0, count: 15 }) expect(finder(body.data)).to.be.undefined } diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index bcf431edb..de08a9e7b 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts @@ -52,28 +52,28 @@ describe('Test video privacy', function () { for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { const attributes = { privacy } - await servers[0].videosCommand.upload({ attributes }) + await servers[0].videos.upload({ attributes }) } await waitJobs(servers) }) it('Should not have these private and internal videos on server 2', async function () { - const { total, data } = await servers[1].videosCommand.list() + const { total, data } = await servers[1].videos.list() expect(total).to.equal(0) expect(data).to.have.lengthOf(0) }) it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { - const { total, data } = await servers[0].videosCommand.list() + const { total, data } = await servers[0].videos.list() expect(total).to.equal(0) expect(data).to.have.lengthOf(0) }) it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { - const { total, data } = await servers[0].videosCommand.listWithToken() + const { total, data } = await servers[0].videos.listWithToken() expect(total).to.equal(1) expect(data).to.have.lengthOf(1) @@ -82,7 +82,7 @@ describe('Test video privacy', function () { }) it('Should list my (private and internal) videos', async function () { - const { total, data } = await servers[0].videosCommand.listMyVideos() + const { total, data } = await servers[0].videos.listMyVideos() expect(total).to.equal(2) expect(data).to.have.lengthOf(2) @@ -97,8 +97,8 @@ describe('Test video privacy', function () { }) it('Should not be able to watch the private/internal video with non authenticated user', async function () { - await servers[0].videosCommand.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) - await servers[0].videosCommand.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) + await servers[0].videos.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) + await servers[0].videos.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) }) it('Should not be able to watch the private video with another user', async function () { @@ -108,11 +108,11 @@ describe('Test video privacy', function () { username: 'hello', password: 'super password' } - await servers[0].usersCommand.create({ username: user.username, password: user.password }) + await servers[0].users.create({ username: user.username, password: user.password }) - anotherUserToken = await servers[0].loginCommand.getAccessToken(user) + anotherUserToken = await servers[0].login.getAccessToken(user) - await servers[0].videosCommand.getWithToken({ + await servers[0].videos.getWithToken({ token: anotherUserToken, id: privateVideoUUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 @@ -120,11 +120,11 @@ describe('Test video privacy', function () { }) it('Should be able to watch the internal video with another user', async function () { - await servers[0].videosCommand.getWithToken({ token: anotherUserToken, id: internalVideoUUID }) + await servers[0].videos.getWithToken({ token: anotherUserToken, id: internalVideoUUID }) }) it('Should be able to watch the private video with the correct user', async function () { - await servers[0].videosCommand.getWithToken({ id: privateVideoUUID }) + await servers[0].videos.getWithToken({ id: privateVideoUUID }) }) }) @@ -137,7 +137,7 @@ describe('Test video privacy', function () { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) // Server 2 has transcoding enabled await waitJobs(servers) @@ -145,7 +145,7 @@ describe('Test video privacy', function () { it('Should not have this unlisted video listed on server 1 and 2', async function () { for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(0) expect(data).to.have.lengthOf(0) @@ -153,7 +153,7 @@ describe('Test video privacy', function () { }) it('Should list my (unlisted) videos', async function () { - const { total, data } = await servers[1].videosCommand.listMyVideos() + const { total, data } = await servers[1].videos.listMyVideos() expect(total).to.equal(1) expect(data).to.have.lengthOf(1) @@ -162,13 +162,13 @@ describe('Test video privacy', function () { }) it('Should not be able to get this unlisted video using its id', async function () { - await servers[1].videosCommand.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + await servers[1].videos.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should be able to get this unlisted video using its uuid/shortUUID', async function () { for (const server of servers) { for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { - const video = await server.videosCommand.get({ id }) + const video = await server.videos.get({ id }) expect(video.name).to.equal('unlisted video') } @@ -182,13 +182,13 @@ describe('Test video privacy', function () { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } - await servers[0].videosCommand.upload({ attributes }) + await servers[0].videos.upload({ attributes }) await waitJobs(servers) }) it('Should list my new unlisted video', async function () { - const { total, data } = await servers[0].videosCommand.listMyVideos() + const { total, data } = await servers[0].videos.listMyVideos() expect(total).to.equal(3) expect(data).to.have.lengthOf(3) @@ -197,13 +197,13 @@ describe('Test video privacy', function () { }) it('Should be able to get non-federated unlisted video from origin', async function () { - const video = await servers[0].videosCommand.get({ id: nonFederatedUnlistedVideoUUID }) + const video = await servers[0].videos.get({ id: nonFederatedUnlistedVideoUUID }) expect(video.name).to.equal('unlisted video') }) it('Should not be able to get non-federated unlisted video from federated server', async function () { - await servers[1].videosCommand.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[1].videos.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) }) }) @@ -220,7 +220,7 @@ describe('Test video privacy', function () { privacy: VideoPrivacy.PUBLIC } - await servers[0].videosCommand.update({ id: privateVideoId, attributes }) + await servers[0].videos.update({ id: privateVideoId, attributes }) } { @@ -228,7 +228,7 @@ describe('Test video privacy', function () { name: 'internal video becomes public', privacy: VideoPrivacy.PUBLIC } - await servers[0].videosCommand.update({ id: internalVideoId, attributes }) + await servers[0].videos.update({ id: internalVideoId, attributes }) } await waitJobs(servers) @@ -236,7 +236,7 @@ describe('Test video privacy', function () { it('Should have this new public video listed on server 1 and 2', async function () { for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(2) expect(data).to.have.lengthOf(2) @@ -258,20 +258,20 @@ describe('Test video privacy', function () { it('Should set these videos as private and internal', async function () { this.timeout(10000) - await servers[0].videosCommand.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } }) - await servers[0].videosCommand.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } }) + await servers[0].videos.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } }) + await servers[0].videos.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } }) await waitJobs(servers) for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(0) expect(data).to.have.lengthOf(0) } { - const { total, data } = await servers[0].videosCommand.listMyVideos() + const { total, data } = await servers[0].videos.listMyVideos() expect(total).to.equal(3) expect(data).to.have.lengthOf(3) diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index 635ae6ff1..3938b47c8 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts @@ -49,25 +49,25 @@ describe('Test video update scheduler', function () { } } - await servers[0].videosCommand.upload({ attributes }) + await servers[0].videos.upload({ attributes }) await waitJobs(servers) }) it('Should not list the video (in privacy mode)', async function () { for (const server of servers) { - const { total } = await server.videosCommand.list() + const { total } = await server.videos.list() expect(total).to.equal(0) } }) it('Should have my scheduled video in my account videos', async function () { - const { total, data } = await servers[0].videosCommand.listMyVideos() + const { total, data } = await servers[0].videos.listMyVideos() expect(total).to.equal(1) const videoFromList = data[0] - const videoFromGet = await servers[0].videosCommand.getWithToken({ id: videoFromList.uuid }) + const videoFromGet = await servers[0].videos.getWithToken({ id: videoFromList.uuid }) for (const video of [ videoFromList, videoFromGet ]) { expect(video.name).to.equal('video 1') @@ -84,7 +84,7 @@ describe('Test video update scheduler', function () { await waitJobs(servers) for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(1) expect(data[0].name).to.equal('video 1') @@ -99,7 +99,7 @@ describe('Test video update scheduler', function () { privacy: VideoPrivacy.PRIVATE } - const { uuid } = await servers[0].videosCommand.upload({ attributes }) + const { uuid } = await servers[0].videos.upload({ attributes }) video2UUID = uuid await waitJobs(servers) @@ -116,20 +116,20 @@ describe('Test video update scheduler', function () { } } - await servers[0].videosCommand.update({ id: video2UUID, attributes }) + await servers[0].videos.update({ id: video2UUID, attributes }) await waitJobs(servers) }) it('Should not display the updated video', async function () { for (const server of servers) { - const { total } = await server.videosCommand.list() + const { total } = await server.videos.list() expect(total).to.equal(1) } }) it('Should have my scheduled updated video in my account videos', async function () { - const { total, data } = await servers[0].videosCommand.listMyVideos() + const { total, data } = await servers[0].videos.listMyVideos() expect(total).to.equal(2) const video = data.find(v => v.uuid === video2UUID) @@ -149,7 +149,7 @@ describe('Test video update scheduler', function () { await waitJobs(servers) for (const server of servers) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(2) const video = data.find(v => v.uuid === video2UUID) diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index b41c68283..37450eeeb 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -32,7 +32,7 @@ import { const expect = chai.expect function updateConfigForTranscoding (server: ServerInfo) { - return server.configCommand.updateCustomSubConfig({ + return server.config.updateCustomSubConfig({ newConfig: { transcoding: { enabled: true, @@ -82,15 +82,15 @@ describe('Test video transcoding', function () { description: 'my super description for server 1', fixture: 'video_short.webm' } - await servers[0].videosCommand.upload({ attributes }) + await servers[0].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data[0] - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(1) const magnetUri = videoDetails.files[0].magnetUri @@ -111,15 +111,15 @@ describe('Test video transcoding', function () { description: 'my super description for server 2', fixture: 'video_short.webm' } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) @@ -143,11 +143,11 @@ describe('Test video transcoding', function () { fixture: 'video_short1.webm', waitTranscoding: true } - const { uuid } = await servers[1].videosCommand.upload({ attributes }) + const { uuid } = await servers[1].videos.upload({ attributes }) const videoId = uuid // Should be in transcode state - const body = await servers[1].videosCommand.get({ id: videoId }) + const body = await servers[1].videos.get({ id: videoId }) expect(body.name).to.equal('waiting video') expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) expect(body.state.label).to.equal('To transcode') @@ -155,7 +155,7 @@ describe('Test video transcoding', function () { { // Should have my video - const { data } = await servers[1].videosCommand.listMyVideos() + const { data } = await servers[1].videos.listMyVideos() const videoToFindInMine = data.find(v => v.name === attributes.name) expect(videoToFindInMine).not.to.be.undefined expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) @@ -165,23 +165,23 @@ describe('Test video transcoding', function () { { // Should not list this video - const { data } = await servers[1].videosCommand.list() + const { data } = await servers[1].videos.list() const videoToFindInList = data.find(v => v.name === attributes.name) expect(videoToFindInList).to.be.undefined } // Server 1 should not have the video yet - await servers[0].videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) + await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) } await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const videoToFind = data.find(v => v.name === 'waiting video') expect(videoToFind).not.to.be.undefined - const videoDetails = await server.videosCommand.get({ id: videoToFind.id }) + const videoDetails = await server.videos.get({ id: videoToFind.id }) expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) expect(videoDetails.state.label).to.equal('Published') @@ -207,15 +207,15 @@ describe('Test video transcoding', function () { fixture } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) const magnetUri = videoDetails.files[0].magnetUri @@ -232,7 +232,7 @@ describe('Test video transcoding', function () { fixture: 'video_short_4k.mp4' } - const { uuid } = await servers[1].videosCommand.upload({ attributes }) + const { uuid } = await servers[1].videos.upload({ attributes }) video4k = uuid await waitJobs(servers) @@ -240,7 +240,7 @@ describe('Test video transcoding', function () { const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: video4k }) + const videoDetails = await server.videos.get({ id: video4k }) expect(videoDetails.files).to.have.lengthOf(resolutions.length) for (const r of resolutions) { @@ -260,19 +260,19 @@ describe('Test video transcoding', function () { name: 'mp3_256k', fixture: 'video_short_mp3_256k.mp4' } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) const probe = await getAudioStream(path) if (probe.audioStream) { @@ -291,18 +291,18 @@ describe('Test video transcoding', function () { name: 'no_audio', fixture: 'video_short_no_audio.mp4' } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) const probe = await getAudioStream(path) expect(probe).to.not.have.property('audioStream') } @@ -315,21 +315,21 @@ describe('Test video transcoding', function () { name: 'untouched_audio', fixture: 'video_short.mp4' } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) const fixturePath = buildAbsoluteFixturePath(attributes.fixture) const fixtureVideoProbe = await getAudioStream(fixturePath) - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) const videoProbe = await getAudioStream(path) @@ -348,7 +348,7 @@ describe('Test video transcoding', function () { function runSuite (mode: 'legacy' | 'resumable') { before(async function () { - await servers[1].configCommand.updateCustomSubConfig({ + await servers[1].config.updateCustomSubConfig({ newConfig: { transcoding: { hls: { enabled: true }, @@ -372,15 +372,15 @@ describe('Test video transcoding', function () { this.timeout(60_000) const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } - await servers[1].videosCommand.upload({ attributes, mode }) + await servers[1].videos.upload({ attributes, mode }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === 'audio_with_preview') - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(1) @@ -396,15 +396,15 @@ describe('Test video transcoding', function () { this.timeout(60_000) const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' } - await servers[1].videosCommand.upload({ attributes, mode }) + await servers[1].videos.upload({ attributes, mode }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === 'audio_without_preview') - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(1) @@ -419,7 +419,7 @@ describe('Test video transcoding', function () { it('Should upload an audio file and create an audio version only', async function () { this.timeout(60_000) - await servers[1].configCommand.updateCustomSubConfig({ + await servers[1].config.updateCustomSubConfig({ newConfig: { transcoding: { hls: { enabled: true }, @@ -434,12 +434,12 @@ describe('Test video transcoding', function () { }) const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } - const { id } = await servers[1].videosCommand.upload({ attributes, mode }) + const { id } = await servers[1].videos.upload({ attributes, mode }) await waitJobs(servers) for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id }) + const videoDetails = await server.videos.get({ id }) for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) { expect(files).to.have.lengthOf(2) @@ -470,15 +470,15 @@ describe('Test video transcoding', function () { description: 'my super 30fps description for server 2', fixture: '60fps_720p_small.mp4' } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) @@ -487,13 +487,13 @@ describe('Test video transcoding', function () { expect(videoDetails.files[3].fps).to.be.below(31) for (const resolution of [ '240', '360', '480' ]) { - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) const fps = await getVideoFileFPS(path) expect(fps).to.be.below(31) } - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4')) const fps = await getVideoFileFPS(path) expect(fps).to.be.above(58).and.below(62) @@ -518,23 +518,23 @@ describe('Test video transcoding', function () { fixture: tempFixturePath } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) { - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4')) const fps = await getVideoFileFPS(path) expect(fps).to.be.equal(25) } { - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4')) const fps = await getVideoFileFPS(path) expect(fps).to.be.equal(59) } @@ -561,17 +561,17 @@ describe('Test video transcoding', function () { fixture: tempFixturePath } - await servers[1].videosCommand.upload({ attributes }) + await servers[1].videos.upload({ attributes }) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() const video = data.find(v => v.name === attributes.name) for (const resolution of [ '240', '360', '480', '720', '1080' ]) { - const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) @@ -602,21 +602,21 @@ describe('Test video transcoding', function () { hls: { enabled: true } } } - await servers[1].configCommand.updateCustomSubConfig({ newConfig }) + await servers[1].config.updateCustomSubConfig({ newConfig }) const attributes = { name: 'low bitrate', fixture: 'low-bitrate.mp4' } - const { uuid } = await servers[1].videosCommand.upload({ attributes }) + const { uuid } = await servers[1].videos.upload({ attributes }) await waitJobs(servers) const resolutions = [ 240, 360, 480, 720, 1080 ] for (const r of resolutions) { const path = `videos/${uuid}-${r}.mp4` - const size = await servers[1].serversCommand.getServerFileSize(path) + const size = await servers[1].servers.getServerFileSize(path) expect(size, `${path} not below ${60_000}`).to.be.below(60_000) } }) @@ -627,11 +627,11 @@ describe('Test video transcoding', function () { it('Should provide valid ffprobe data', async function () { this.timeout(160_000) - const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'ffprobe data' })).uuid + const videoUUID = (await servers[1].videos.quickUpload({ name: 'ffprobe data' })).uuid await waitJobs(servers) { - const path = servers[1].serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4')) + const path = servers[1].servers.buildDirectory(join('videos', videoUUID + '-240.mp4')) const metadata = await getMetadataFromFile(path) // expected format properties @@ -661,7 +661,7 @@ describe('Test video transcoding', function () { } for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videoUUID }) + const videoDetails = await server.videos.get({ id: videoUUID }) const videoFiles = videoDetails.files .concat(videoDetails.streamingPlaylists[0].files) @@ -673,7 +673,7 @@ describe('Test video transcoding', function () { expect(file.metadataUrl).to.contain(servers[1].url) expect(file.metadataUrl).to.contain(videoUUID) - const metadata = await server.videosCommand.getFileMetadata({ url: file.metadataUrl }) + const metadata = await server.videos.getFileMetadata({ url: file.metadataUrl }) expect(metadata).to.have.nested.property('format.size') } } @@ -690,7 +690,7 @@ describe('Test video transcoding', function () { describe('Transcoding job queue', function () { it('Should have the appropriate priorities for transcoding jobs', async function () { - const body = await servers[1].jobsCommand.getJobsList({ + const body = await servers[1].jobs.getJobsList({ start: 0, count: 100, sort: '-createdAt', diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts index 4a5a83ee6..af1541dbd 100644 --- a/server/tests/api/videos/videos-filter.ts +++ b/server/tests/api/videos/videos-filter.ts @@ -55,19 +55,19 @@ describe('Test videos filter', function () { for (const server of servers) { const moderator = { username: 'moderator', password: 'my super password' } - await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) - server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator) + await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) + server['moderatorAccessToken'] = await server.login.getAccessToken(moderator) - await server.videosCommand.upload({ attributes: { name: 'public ' + server.serverNumber } }) + await server.videos.upload({ attributes: { name: 'public ' + server.serverNumber } }) { const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED } - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) } { const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE } - await server.videosCommand.upload({ attributes }) + await server.videos.upload({ attributes }) } } diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index 8614078f1..4b5e581d1 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -33,20 +33,20 @@ describe('Test videos history', function () { await setAccessTokensToServers([ server ]) - command = server.historyCommand + command = server.history { - const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 1' } }) + const { uuid } = await server.videos.upload({ attributes: { name: 'video 1' } }) video1UUID = uuid } { - const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 2' } }) + const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } }) video2UUID = uuid } { - const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 3' } }) + const { uuid } = await server.videos.upload({ attributes: { name: 'video 3' } }) video3UUID = uuid } @@ -54,15 +54,15 @@ describe('Test videos history', function () { username: 'user_1', password: 'super password' } - await server.usersCommand.create({ username: user.username, password: user.password }) - userAccessToken = await server.loginCommand.getAccessToken(user) + await server.users.create({ username: user.username, password: user.password }) + userAccessToken = await server.login.getAccessToken(user) }) it('Should get videos, without watching history', async function () { - const { data } = await server.videosCommand.listWithToken() + const { data } = await server.videos.listWithToken() for (const video of data) { - const videoDetails = await server.videosCommand.getWithToken({ id: video.id }) + const videoDetails = await server.videos.getWithToken({ id: video.id }) expect(video.userHistory).to.be.undefined expect(videoDetails.userHistory).to.be.undefined @@ -78,12 +78,12 @@ describe('Test videos history', function () { const videosOfVideos: Video[][] = [] { - const { data } = await server.videosCommand.listWithToken() + const { data } = await server.videos.listWithToken() videosOfVideos.push(data) } { - const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' }) + const body = await server.search.searchVideos({ token: server.accessToken, search: 'video' }) videosOfVideos.push(body.data) } @@ -102,21 +102,21 @@ describe('Test videos history', function () { } { - const videoDetails = await server.videosCommand.getWithToken({ id: video1UUID }) + const videoDetails = await server.videos.getWithToken({ id: video1UUID }) expect(videoDetails.userHistory).to.not.be.undefined expect(videoDetails.userHistory.currentTime).to.equal(3) } { - const videoDetails = await server.videosCommand.getWithToken({ id: video2UUID }) + const videoDetails = await server.videos.getWithToken({ id: video2UUID }) expect(videoDetails.userHistory).to.not.be.undefined expect(videoDetails.userHistory.currentTime).to.equal(8) } { - const videoDetails = await server.videosCommand.getWithToken({ id: video3UUID }) + const videoDetails = await server.videos.getWithToken({ id: video3UUID }) expect(videoDetails.userHistory).to.be.undefined } @@ -164,7 +164,7 @@ describe('Test videos history', function () { }) it('Should disable videos history', async function () { - await server.usersCommand.updateMe({ + await server.users.updateMe({ videosHistoryEnabled: false }) @@ -172,7 +172,7 @@ describe('Test videos history', function () { }) it('Should re-enable videos history', async function () { - await server.usersCommand.updateMe({ + await server.users.updateMe({ videosHistoryEnabled: true }) diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 969393842..f0657b334 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts @@ -25,7 +25,7 @@ describe('Test a videos overview', function () { }) it('Should send empty overview', async function () { - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 0) }) @@ -35,7 +35,7 @@ describe('Test a videos overview', function () { await wait(3000) - await server.videosCommand.upload({ + await server.videos.upload({ attributes: { name: 'video 0', category: 3, @@ -43,7 +43,7 @@ describe('Test a videos overview', function () { } }) - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 0) }) @@ -53,7 +53,7 @@ describe('Test a videos overview', function () { { for (let i = 1; i < 6; i++) { - await server.videosCommand.upload({ + await server.videos.upload({ attributes: { name: 'video ' + i, category: 3, @@ -66,13 +66,13 @@ describe('Test a videos overview', function () { } { - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 1) } { - const overview = await server.overviewsCommand.getVideos({ page: 2 }) + const overview = await server.overviews.getVideos({ page: 2 }) expect(overview.tags).to.have.lengthOf(1) expect(overview.categories).to.have.lengthOf(0) @@ -81,8 +81,8 @@ describe('Test a videos overview', function () { }) it('Should have the correct overview', async function () { - const overview1 = await server.overviewsCommand.getVideos({ page: 1 }) - const overview2 = await server.overviewsCommand.getVideos({ page: 2 }) + const overview1 = await server.overviews.getVideos({ page: 1 }) + const overview2 = await server.overviews.getVideos({ page: 2 }) for (const arr of [ overview1.tags, overview1.categories, overview1.channels, overview2.tags ]) { expect(arr).to.have.lengthOf(1) @@ -108,18 +108,18 @@ describe('Test a videos overview', function () { }) it('Should hide muted accounts', async function () { - const token = await server.usersCommand.generateUserAndToken('choco') + const token = await server.users.generateUserAndToken('choco') - await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host }) + await server.blocklist.addToMyBlocklist({ token, account: 'root@' + server.host }) { - const body = await server.overviewsCommand.getVideos({ page: 1 }) + const body = await server.overviews.getVideos({ page: 1 }) testOverviewCount(body, 1) } { - const body = await server.overviewsCommand.getVideos({ page: 1, token }) + const body = await server.overviews.getVideos({ page: 1, token }) testOverviewCount(body, 0) } diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts index 7ded1bf38..238662cf3 100644 --- a/server/tests/api/videos/videos-views-cleaner.ts +++ b/server/tests/api/videos/videos-views-cleaner.ts @@ -30,15 +30,15 @@ describe('Test video views cleaner', function () { await doubleFollow(servers[0], servers[1]) - videoIdServer1 = (await servers[0].videosCommand.quickUpload({ name: 'video server 1' })).uuid - videoIdServer2 = (await servers[1].videosCommand.quickUpload({ name: 'video server 2' })).uuid + videoIdServer1 = (await servers[0].videos.quickUpload({ name: 'video server 1' })).uuid + videoIdServer2 = (await servers[1].videos.quickUpload({ name: 'video server 2' })).uuid await waitJobs(servers) - await servers[0].videosCommand.view({ id: videoIdServer1 }) - await servers[1].videosCommand.view({ id: videoIdServer1 }) - await servers[0].videosCommand.view({ id: videoIdServer2 }) - await servers[1].videosCommand.view({ id: videoIdServer2 }) + await servers[0].videos.view({ id: videoIdServer1 }) + await servers[1].videos.view({ id: videoIdServer1 }) + await servers[0].videos.view({ id: videoIdServer2 }) + await servers[1].videos.view({ id: videoIdServer2 }) await waitJobs(servers) }) @@ -56,14 +56,14 @@ describe('Test video views cleaner', function () { { for (const server of servers) { - const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1) + const total = await server.sql.countVideoViewsOf(videoIdServer1) expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') } } { for (const server of servers) { - const total = await server.sqlCommand.countVideoViewsOf(videoIdServer2) + const total = await server.sql.countVideoViewsOf(videoIdServer2) expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') } } @@ -82,16 +82,16 @@ describe('Test video views cleaner', function () { { for (const server of servers) { - const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1) + const total = await server.sql.countVideoViewsOf(videoIdServer1) expect(total).to.equal(2) } } { - const totalServer1 = await servers[0].sqlCommand.countVideoViewsOf(videoIdServer2) + const totalServer1 = await servers[0].sql.countVideoViewsOf(videoIdServer2) expect(totalServer1).to.equal(0) - const totalServer2 = await servers[1].sqlCommand.countVideoViewsOf(videoIdServer2) + const totalServer2 = await servers[1].sql.countVideoViewsOf(videoIdServer2) expect(totalServer2).to.equal(2) } }) -- cgit v1.2.3