diff --git a/scripts/benchmark.ts b/scripts/benchmark.ts
index d9e4a08ab..1d980063b 100644
--- a/scripts/benchmark.ts
+++ b/scripts/benchmark.ts
@@ -210,29 +210,29 @@ async function prepare () {
}
for (let i = 0; i < 10; i++) {
- await server.videosCommand.upload({ attributes: { ...attributes, name: 'my super video ' + i } })
+ await server.videos.upload({ attributes: { ...attributes, name: 'my super video ' + i } })
}
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
video = data.find(v => v.name === 'my super video 1')
for (let i = 0; i < 10; i++) {
const text = 'my super first comment'
- const created = await server.commentsCommand.createThread({ videoId: video.id, text })
+ const created = await server.comments.createThread({ videoId: video.id, text })
threadId = created.id
const text1 = 'my super answer to thread 1'
- const child = await server.commentsCommand.addReply({ videoId: video.id, toCommentId: threadId, text: text1 })
+ const child = await server.comments.addReply({ videoId: video.id, toCommentId: threadId, text: text1 })
const text2 = 'my super answer to answer of thread 1'
- await server.commentsCommand.addReply({ videoId: video.id, toCommentId: child.id, text: text2 })
+ await server.comments.addReply({ videoId: video.id, toCommentId: child.id, text: text2 })
const text3 = 'my second answer to thread 1'
- await server.commentsCommand.addReply({ videoId: video.id, toCommentId: threadId, text: text3 })
+ await server.comments.addReply({ videoId: video.id, toCommentId: threadId, text: text3 })
}
for (const caption of [ 'ar', 'fr', 'en', 'zh' ]) {
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: caption,
videoId: video.id,
fixture: 'subtitle-good2.vtt'
diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts
index dcf758711..1421824da 100644
--- a/server/tests/api/activitypub/cleaner.ts
+++ b/server/tests/api/activitypub/cleaner.ts
@@ -46,9 +46,9 @@ describe('Test AP cleaner', function () {
// Create 1 comment per video
// Update 1 remote URL and 1 local URL on
- videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'server 1' })).uuid
- videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid
- videoUUID3 = (await servers[2].videosCommand.quickUpload({ name: 'server 3' })).uuid
+ videoUUID1 = (await servers[0].videos.quickUpload({ name: 'server 1' })).uuid
+ videoUUID2 = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid
+ videoUUID3 = (await servers[2].videos.quickUpload({ name: 'server 3' })).uuid
videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ]
@@ -56,8 +56,8 @@ describe('Test AP cleaner', function () {
for (const server of servers) {
for (const uuid of videoUUIDs) {
- await server.videosCommand.rate({ id: uuid, rating: 'like' })
- await server.commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ await server.videos.rate({ id: uuid, rating: 'like' })
+ await server.comments.createThread({ videoId: uuid, text: 'comment' })
}
}
@@ -67,7 +67,7 @@ describe('Test AP cleaner', function () {
it('Should have the correct likes', async function () {
for (const server of servers) {
for (const uuid of videoUUIDs) {
- const video = await server.videosCommand.get({ id: uuid })
+ const video = await server.videos.get({ id: uuid })
expect(video.likes).to.equal(3)
expect(video.dislikes).to.equal(0)
@@ -78,9 +78,9 @@ describe('Test AP cleaner', function () {
it('Should destroy server 3 internal likes and correctly clean them', async function () {
this.timeout(20000)
- await servers[2].sqlCommand.deleteAll('accountVideoRate')
+ await servers[2].sql.deleteAll('accountVideoRate')
for (const uuid of videoUUIDs) {
- await servers[2].sqlCommand.setVideoField(uuid, 'likes', '0')
+ await servers[2].sql.setVideoField(uuid, 'likes', '0')
}
await wait(5000)
@@ -88,14 +88,14 @@ describe('Test AP cleaner', function () {
// Updated rates of my video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID1 })
+ const video = await servers[0].videos.get({ id: videoUUID1 })
expect(video.likes).to.equal(2)
expect(video.dislikes).to.equal(0)
}
// Did not update rates of a remote video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID2 })
+ const video = await servers[0].videos.get({ id: videoUUID2 })
expect(video.likes).to.equal(3)
expect(video.dislikes).to.equal(0)
}
@@ -106,7 +106,7 @@ describe('Test AP cleaner', function () {
for (const server of servers) {
for (const uuid of videoUUIDs) {
- await server.videosCommand.rate({ id: uuid, rating: 'dislike' })
+ await server.videos.rate({ id: uuid, rating: 'dislike' })
}
}
@@ -114,7 +114,7 @@ describe('Test AP cleaner', function () {
for (const server of servers) {
for (const uuid of videoUUIDs) {
- const video = await server.videosCommand.get({ id: uuid })
+ const video = await server.videos.get({ id: uuid })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(3)
}
@@ -124,10 +124,10 @@ describe('Test AP cleaner', function () {
it('Should destroy server 3 internal dislikes and correctly clean them', async function () {
this.timeout(20000)
- await servers[2].sqlCommand.deleteAll('accountVideoRate')
+ await servers[2].sql.deleteAll('accountVideoRate')
for (const uuid of videoUUIDs) {
- await servers[2].sqlCommand.setVideoField(uuid, 'dislikes', '0')
+ await servers[2].sql.setVideoField(uuid, 'dislikes', '0')
}
await wait(5000)
@@ -135,14 +135,14 @@ describe('Test AP cleaner', function () {
// Updated rates of my video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID1 })
+ const video = await servers[0].videos.get({ id: videoUUID1 })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(2)
}
// Did not update rates of a remote video
{
- const video = await servers[0].videosCommand.get({ id: videoUUID2 })
+ const video = await servers[0].videos.get({ id: videoUUID2 })
expect(video.likes).to.equal(0)
expect(video.dislikes).to.equal(3)
}
@@ -151,15 +151,15 @@ describe('Test AP cleaner', function () {
it('Should destroy server 3 internal shares and correctly clean them', async function () {
this.timeout(20000)
- const preCount = await servers[0].sqlCommand.getCount('videoShare')
+ const preCount = await servers[0].sql.getCount('videoShare')
expect(preCount).to.equal(6)
- await servers[2].sqlCommand.deleteAll('videoShare')
+ await servers[2].sql.deleteAll('videoShare')
await wait(5000)
await waitJobs(servers)
// Still 6 because we don't have remote shares on local videos
- const postCount = await servers[0].sqlCommand.getCount('videoShare')
+ const postCount = await servers[0].sql.getCount('videoShare')
expect(postCount).to.equal(6)
})
@@ -167,17 +167,17 @@ describe('Test AP cleaner', function () {
this.timeout(20000)
{
- const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 })
+ const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 })
expect(total).to.equal(3)
}
- await servers[2].sqlCommand.deleteAll('videoComment')
+ await servers[2].sql.deleteAll('videoComment')
await wait(5000)
await waitJobs(servers)
{
- const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 })
+ const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 })
expect(total).to.equal(2)
}
})
@@ -188,7 +188,7 @@ describe('Test AP cleaner', function () {
async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') {
const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` +
`INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'`
- const res = await servers[0].sqlCommand.selectQuery(query)
+ const res = await servers[0].sql.selectQuery(query)
for (const rate of res) {
const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`)
@@ -217,7 +217,7 @@ describe('Test AP cleaner', function () {
{
const query = `UPDATE "accountVideoRate" SET url = url || 'stan'`
- await servers[1].sqlCommand.updateQuery(query)
+ await servers[1].sql.updateQuery(query)
await wait(5000)
await waitJobs(servers)
@@ -234,7 +234,7 @@ describe('Test AP cleaner', function () {
const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` +
`INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'`
- const res = await servers[0].sqlCommand.selectQuery(query)
+ const res = await servers[0].sql.selectQuery(query)
for (const comment of res) {
const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`)
@@ -260,7 +260,7 @@ describe('Test AP cleaner', function () {
{
const query = `UPDATE "videoComment" SET url = url || 'kyle'`
- await servers[1].sqlCommand.updateQuery(query)
+ await servers[1].sql.updateQuery(query)
await wait(5000)
await waitJobs(servers)
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index 0190df04c..5845045a3 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -68,12 +68,12 @@ describe('Test activitypub', function () {
await setDefaultVideoChannel(servers)
{
- video = await await servers[0].videosCommand.quickUpload({ name: 'video' })
+ video = await await servers[0].videos.quickUpload({ name: 'video' })
}
{
- const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id }
- playlist = await servers[0].playlistsCommand.create({ attributes })
+ const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].store.channel.id }
+ playlist = await servers[0].playlists.create({ attributes })
}
await doubleFollow(servers[0], servers[1])
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 5ab4a85d7..34694a773 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -21,24 +21,24 @@ describe('Test ActivityPub fetcher', function () {
const user = { username: 'user1', password: 'password' }
for (const server of servers) {
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
}
- const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ const userAccessToken = await servers[0].login.getAccessToken(user)
- await servers[0].videosCommand.upload({ attributes: { name: 'video root' } })
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'bad video root' } })
- await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'video user' } })
+ await servers[0].videos.upload({ attributes: { name: 'video root' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } })
+ await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } })
{
const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
- await servers[0].sqlCommand.setActorField(to, 'url', value)
+ await servers[0].sql.setActorField(to, 'url', value)
}
{
const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid
- await servers[0].sqlCommand.setVideoField(uuid, 'url', value)
+ await servers[0].sql.setVideoField(uuid, 'url', value)
}
})
@@ -49,7 +49,7 @@ describe('Test ActivityPub fetcher', function () {
await waitJobs(servers)
{
- const { total, data } = await servers[0].videosCommand.list({ sort: 'createdAt' })
+ const { total, data } = await servers[0].videos.list({ sort: 'createdAt' })
expect(total).to.equal(3)
expect(data[0].name).to.equal('video root')
@@ -58,7 +58,7 @@ describe('Test ActivityPub fetcher', function () {
}
{
- const { total, data } = await servers[1].videosCommand.list({ sort: 'createdAt' })
+ const { total, data } = await servers[1].videos.list({ sort: 'createdAt' })
expect(total).to.equal(1)
expect(data[0].name).to.equal('video root')
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 5af4b1edb..d2f71e857 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -34,28 +34,28 @@ describe('Test AP refresher', function () {
await setDefaultVideoChannel(servers)
{
- videoUUID1 = (await servers[1].videosCommand.quickUpload({ name: 'video1' })).uuid
- videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'video2' })).uuid
- videoUUID3 = (await servers[1].videosCommand.quickUpload({ name: 'video3' })).uuid
+ videoUUID1 = (await servers[1].videos.quickUpload({ name: 'video1' })).uuid
+ videoUUID2 = (await servers[1].videos.quickUpload({ name: 'video2' })).uuid
+ videoUUID3 = (await servers[1].videos.quickUpload({ name: 'video3' })).uuid
}
{
- const token1 = await servers[1].usersCommand.generateUserAndToken('user1')
- await servers[1].videosCommand.upload({ token: token1, attributes: { name: 'video4' } })
+ const token1 = await servers[1].users.generateUserAndToken('user1')
+ await servers[1].videos.upload({ token: token1, attributes: { name: 'video4' } })
- const token2 = await servers[1].usersCommand.generateUserAndToken('user2')
- await servers[1].videosCommand.upload({ token: token2, attributes: { name: 'video5' } })
+ const token2 = await servers[1].users.generateUserAndToken('user2')
+ await servers[1].videos.upload({ token: token2, attributes: { name: 'video5' } })
}
{
- const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
- const created = await servers[1].playlistsCommand.create({ attributes })
+ const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
+ const created = await servers[1].playlists.create({ attributes })
playlistUUID1 = created.uuid
}
{
- const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id }
- const created = await servers[1].playlistsCommand.create({ attributes })
+ const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
+ const created = await servers[1].playlists.create({ attributes })
playlistUUID2 = created.uuid
}
@@ -70,15 +70,15 @@ describe('Test AP refresher', function () {
await wait(10000)
// Change UUID so the remote server returns a 404
- await servers[1].sqlCommand.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
+ await servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
- await servers[0].videosCommand.get({ id: videoUUID1 })
- await servers[0].videosCommand.get({ id: videoUUID2 })
+ await servers[0].videos.get({ id: videoUUID1 })
+ await servers[0].videos.get({ id: videoUUID2 })
await waitJobs(servers)
- await servers[0].videosCommand.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
- await servers[0].videosCommand.get({ id: videoUUID2 })
+ await servers[0].videos.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: videoUUID2 })
})
it('Should not update a remote video if the remote instance is down', async function () {
@@ -86,18 +86,18 @@ describe('Test AP refresher', function () {
await killallServers([ servers[1] ])
- await servers[1].sqlCommand.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
+ await servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
// Video will need a refresh
await wait(10000)
- await servers[0].videosCommand.get({ id: videoUUID3 })
+ await servers[0].videos.get({ id: videoUUID3 })
// The refresh should fail
await waitJobs([ servers[0] ])
await reRunServer(servers[1])
- await servers[0].videosCommand.get({ id: videoUUID3 })
+ await servers[0].videos.get({ id: videoUUID3 })
})
})
@@ -106,13 +106,13 @@ describe('Test AP refresher', function () {
it('Should remove a deleted actor', async function () {
this.timeout(60000)
- const command = servers[0].accountsCommand
+ const command = servers[0].accounts
await wait(10000)
// Change actor name so the remote server returns a 404
const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
- await servers[1].sqlCommand.setActorField(to, 'preferredUsername', 'toto')
+ await servers[1].sql.setActorField(to, 'preferredUsername', 'toto')
await command.get({ accountName: 'user1@localhost:' + servers[1].port })
await command.get({ accountName: 'user2@localhost:' + servers[1].port })
@@ -132,15 +132,15 @@ describe('Test AP refresher', function () {
await wait(10000)
// Change UUID so the remote server returns a 404
- await servers[1].sqlCommand.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
+ await servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID1 })
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID2 })
+ await servers[0].playlists.get({ playlistId: playlistUUID1 })
+ await servers[0].playlists.get({ playlistId: playlistUUID2 })
await waitJobs(servers)
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
- await servers[0].playlistsCommand.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].playlists.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
+ await servers[0].playlists.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index c32940070..ab0eb256e 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -24,8 +24,8 @@ function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey:
const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
return Promise.all([
- onServer.sqlCommand.setActorField(url, 'publicKey', publicKey),
- onServer.sqlCommand.setActorField(url, 'privateKey', privateKey)
+ onServer.sql.setActorField(url, 'publicKey', publicKey),
+ onServer.sql.setActorField(url, 'privateKey', privateKey)
])
}
@@ -33,8 +33,8 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat
const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
return Promise.all([
- onServer.sqlCommand.setActorField(url, 'createdAt', updatedAt),
- onServer.sqlCommand.setActorField(url, 'updatedAt', updatedAt)
+ onServer.sql.setActorField(url, 'createdAt', updatedAt),
+ onServer.sql.setActorField(url, 'updatedAt', updatedAt)
])
}
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 199cc5599..7a6790ba8 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -39,12 +39,12 @@ describe('Test abuses API validators', function () {
await setAccessTokensToServers([ server ])
- userToken = await server.usersCommand.generateUserAndToken('user_1')
- userToken2 = await server.usersCommand.generateUserAndToken('user_2')
+ userToken = await server.users.generateUserAndToken('user_1')
+ userToken2 = await server.users.generateUserAndToken('user_2')
- server.video = await server.videosCommand.upload()
+ server.store.video = await server.videos.upload()
- command = server.abusesCommand
+ command = server.abuses
})
describe('When listing abuses for admins', function () {
@@ -224,25 +224,25 @@ describe('Test abuses API validators', function () {
})
it('Should fail with a non authenticated user', async function () {
- const fields = { video: { id: server.video.id }, reason: 'my super reason' }
+ const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a reason too short', async function () {
- const fields = { video: { id: server.video.id }, reason: 'h' }
+ const fields = { video: { id: server.store.video.id }, reason: 'h' }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should fail with a too big reason', async function () {
- const fields = { video: { id: server.video.id }, reason: 'super'.repeat(605) }
+ const fields = { video: { id: server.store.video.id }, reason: 'super'.repeat(605) }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should succeed with the correct parameters (basic)', async function () {
- const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' }
+ const fields: AbuseCreate = { video: { id: server.store.video.shortUUID }, reason: 'my super reason' }
const res = await makePostBodyRequest({
url: server.url,
@@ -255,19 +255,19 @@ describe('Test abuses API validators', function () {
})
it('Should fail with a wrong predefined reason', async function () {
- const fields = { video: { id: server.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
+ const fields = { video: { id: server.store.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should fail with negative timestamps', async function () {
- const fields = { video: { id: server.video.id, startAt: -1 }, reason: 'my super reason' }
+ const fields = { video: { id: server.store.video.id, startAt: -1 }, reason: 'my super reason' }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
it('Should fail mith misordered startAt/endAt', async function () {
- const fields = { video: { id: server.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
+ const fields = { video: { id: server.store.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
})
@@ -275,7 +275,7 @@ describe('Test abuses API validators', function () {
it('Should succeed with the corret parameters (advanced)', async function () {
const fields: AbuseCreate = {
video: {
- id: server.video.id,
+ id: server.store.video.id,
startAt: 1,
endAt: 5
},
@@ -414,8 +414,8 @@ describe('Test abuses API validators', function () {
await doubleFollow(anotherServer, server)
- const server2VideoId = await anotherServer.videosCommand.getId({ uuid: server.video.uuid })
- await anotherServer.abusesCommand.report({ reason: 'remote server', videoId: server2VideoId })
+ const server2VideoId = await anotherServer.videos.getId({ uuid: server.store.video.uuid })
+ await anotherServer.abuses.report({ reason: 'remote server', videoId: server2VideoId })
await waitJobs([ server, anotherServer ])
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index 45d440c47..223322626 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -40,7 +40,7 @@ describe('Test accounts API validators', function () {
describe('When getting an account', function () {
it('Should return 404 with a non existing name', async function () {
- await server.accountsCommand.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.accounts.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index 18238bb04..14e45e503 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -33,9 +33,9 @@ describe('Test blocklist API validators', function () {
server = servers[0]
const user = { username: 'user1', password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
await doubleFollow(servers[0], servers[1])
})
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
index 3f80c79a8..69ff7dd96 100644
--- a/server/tests/api/check-params/bulk.ts
+++ b/server/tests/api/check-params/bulk.ts
@@ -23,9 +23,9 @@ describe('Test bulk API validators', function () {
await setAccessTokensToServers([ server ])
const user = { username: 'user1', password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When removing comments of', function () {
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index c204d9415..6fd26864e 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -205,8 +205,8 @@ describe('Test config API validators', function () {
username: 'user1',
password: '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)
})
describe('When getting the configuration', function () {
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 4eed1661a..d2541777f 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -26,7 +26,7 @@ describe('Test contact form API validators', function () {
// Email is disabled
server = await flushAndRunServer(1)
- command = server.contactFormCommand
+ command = server.contactForm
})
it('Should not accept a contact form if emails are disabled', async function () {
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts
index 58b0b8600..3d84fb3e6 100644
--- a/server/tests/api/check-params/custom-pages.ts
+++ b/server/tests/api/check-params/custom-pages.ts
@@ -25,9 +25,9 @@ describe('Test custom pages validators', function () {
await setAccessTokensToServers([ server ])
const user = { username: 'user1', password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
})
describe('When updating instance homepage', function () {
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 2a7485cf3..609f9566e 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -29,8 +29,8 @@ describe('Test debug API validators', function () {
username: 'user1',
password: 'my 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)
})
describe('When getting debug endpoint', function () {
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 24e483448..fae3712ce 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -39,8 +39,8 @@ describe('Test server follows API validators', function () {
password: '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)
})
describe('When adding follows', function () {
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index 29439bebf..3786e8612 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -34,8 +34,8 @@ describe('Test jobs API validators', function () {
username: 'user1',
password: 'my 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)
})
describe('When listing jobs', function () {
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 4b54fc31c..20f27dd1d 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -35,7 +35,7 @@ describe('Test video lives API validator', function () {
await setAccessTokensToServers([ server ])
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -48,19 +48,19 @@ describe('Test video lives API validator', function () {
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ await server.users.create({ username: username, password: password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
{
- const { videoChannels } = await server.usersCommand.getMyInfo()
+ const { videoChannels } = await server.users.getMyInfo()
channelId = videoChannels[0].id
}
{
- videoIdNotLive = (await server.videosCommand.quickUpload({ name: 'not live' })).id
+ videoIdNotLive = (await server.videos.quickUpload({ name: 'not live' })).id
}
- command = server.liveCommand
+ command = server.live
})
describe('When creating a live', function () {
@@ -144,10 +144,10 @@ describe('Test video lives API validator', function () {
username: 'fake',
password: 'fake_password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessTokenUser = await server.loginCommand.getAccessToken(user)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser })
+ const accessTokenUser = await server.login.getAccessToken(user)
+ const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
const customChannelId = videoChannels[0].id
const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -230,7 +230,7 @@ describe('Test video lives API validator', function () {
})
it('Should forbid if live is disabled', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: false
@@ -250,7 +250,7 @@ describe('Test video lives API validator', function () {
it('Should forbid to save replay if not enabled by the admin', async function () {
const fields = { ...baseCorrectParams, saveReplay: true }
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -271,7 +271,7 @@ describe('Test video lives API validator', function () {
it('Should allow to save replay if enabled by the admin', async function () {
const fields = { ...baseCorrectParams, saveReplay: true }
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -290,7 +290,7 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max instance lives is reached', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -309,7 +309,7 @@ describe('Test video lives API validator', function () {
})
it('Should not allow live if max user lives is reached', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -401,7 +401,7 @@ describe('Test video lives API validator', function () {
})
it('Should fail to update replay status if replay is not allowed on the instance', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 69eaad69f..cf8f77959 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -29,8 +29,8 @@ describe('Test logs API validators', function () {
username: 'user1',
password: 'my 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)
})
describe('When getting logs', function () {
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 08fb2397f..d4b72c0f4 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -42,17 +42,17 @@ describe('Test server plugins API validators', function () {
password: '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)
{
- const res = await server.pluginsCommand.install({ npmName: npmPlugin })
+ const res = await server.plugins.install({ npmName: npmPlugin })
const plugin = res.body as PeerTubePlugin
npmVersion = plugin.version
}
{
- const res = await server.pluginsCommand.install({ npmName: themePlugin })
+ const res = await server.plugins.install({ npmName: themePlugin })
const plugin = res.body as PeerTubePlugin
themeVersion = plugin.version
}
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index b1692b986..fca92fde4 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -40,16 +40,16 @@ describe('Test server redundancy API validators', function () {
password: 'password'
}
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
- userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ username: user.username, password: user.password })
+ userAccessToken = await servers[0].login.getAccessToken(user)
- videoIdLocal = (await servers[0].videosCommand.quickUpload({ name: 'video' })).id
+ videoIdLocal = (await servers[0].videos.quickUpload({ name: 'video' })).id
- const remoteUUID = (await servers[1].videosCommand.quickUpload({ name: 'video' })).uuid
+ const remoteUUID = (await servers[1].videos.quickUpload({ name: 'video' })).uuid
await waitJobs(servers)
- videoRemote = await servers[0].videosCommand.get({ id: remoteUUID })
+ videoRemote = await servers[0].videos.get({ id: remoteUUID })
})
describe('When listing redundancies', function () {
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 7973c112f..1acfa0922 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -14,7 +14,7 @@ import {
} from '@shared/extra-utils'
function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
- return server.configCommand.updateCustomSubConfig({
+ return server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index f86712b4e..83435c24a 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -25,14 +25,14 @@ describe('Test services API validators', function () {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- server.video = await server.videosCommand.upload({ attributes: { name: 'my super name' } })
+ server.store.video = await server.videos.upload({ attributes: { name: 'my super name' } })
{
- const created = await server.playlistsCommand.create({
+ const created = await server.playlists.create({
attributes: {
displayName: 'super playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
})
@@ -48,7 +48,7 @@ describe('Test services API validators', function () {
})
it('Should fail with an invalid host', async function () {
- const embedUrl = 'http://hello.com/videos/watch/' + server.video.uuid
+ const embedUrl = 'http://hello.com/videos/watch/' + server.store.video.uuid
await checkParamEmbed(server, embedUrl)
})
@@ -63,37 +63,37 @@ describe('Test services API validators', function () {
})
it('Should fail with an invalid path', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl)
})
it('Should fail with an invalid max height', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' })
})
it('Should fail with an invalid max width', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' })
})
it('Should fail with an invalid format', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' })
})
it('Should fail with a non supported format', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' })
})
it('Should succeed with the correct params with a video', async function () {
- const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
+ const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
const query = {
format: 'json',
maxheight: 400,
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index 164c581e3..4ca544790 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -29,12 +29,12 @@ describe('Test upload quota', function () {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
rootId = user.id
- await server.usersCommand.update({ userId: rootId, videoQuota: 42 })
+ await server.users.update({ userId: rootId, videoQuota: 42 })
- command = server.videosCommand
+ command = server.videos
})
describe('When having a video quota', function () {
@@ -43,8 +43,8 @@ describe('Test upload quota', function () {
this.timeout(30000)
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
- await server.usersCommand.register(user)
- const userToken = await server.loginCommand.getAccessToken(user)
+ await server.users.register(user)
+ const userToken = await server.login.getAccessToken(user)
const attributes = { fixture: 'video_short2.webm' }
for (let i = 0; i < 5; i++) {
@@ -58,8 +58,8 @@ describe('Test upload quota', function () {
this.timeout(30000)
const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
- await server.usersCommand.register(user)
- const userToken = await server.loginCommand.getAccessToken(user)
+ await server.users.register(user)
+ const userToken = await server.login.getAccessToken(user)
const attributes = { fixture: 'video_short2.webm' }
for (let i = 0; i < 5; i++) {
@@ -73,16 +73,16 @@ describe('Test upload quota', function () {
this.timeout(120000)
const baseAttributes = {
- channelId: server.videoChannel.id,
+ channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- await server.importsCommand.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
- await server.importsCommand.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
- await server.importsCommand.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
+ await server.imports.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
await waitJobs([ server ])
- const { total, data: videoImports } = await server.importsCommand.getMyVideoImports()
+ const { total, data: videoImports } = await server.imports.getMyVideoImports()
expect(total).to.equal(3)
expect(videoImports).to.have.lengthOf(3)
@@ -98,7 +98,7 @@ describe('Test upload quota', function () {
describe('When having a daily video quota', function () {
it('Should fail with a user having too many videos daily', async function () {
- await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 })
+ await server.users.update({ userId: rootId, videoQuotaDaily: 42 })
await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' })
await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' })
@@ -107,7 +107,7 @@ describe('Test upload quota', function () {
describe('When having an absolute and daily video quota', function () {
it('Should fail if exceeding total quota', async function () {
- await server.usersCommand.update({
+ await server.users.update({
userId: rootId,
videoQuota: 42,
videoQuotaDaily: 1024 * 1024 * 1024
@@ -118,7 +118,7 @@ describe('Test upload quota', function () {
})
it('Should fail if exceeding daily quota', async function () {
- await server.usersCommand.update({
+ await server.users.update({
userId: rootId,
videoQuota: 1024 * 1024 * 1024,
videoQuotaDaily: 42
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 8ce201d61..885ad68e4 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -38,8 +38,8 @@ describe('Test user subscriptions API validators', function () {
username: 'user1',
password: 'my 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)
})
describe('When listing my subscriptions', function () {
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 33c48a009..bce3f0774 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -60,27 +60,27 @@ describe('Test users API validators', function () {
{
const user = { username: 'user1' }
- await server.usersCommand.create({ ...user })
- userToken = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ ...user })
+ userToken = await server.login.getAccessToken(user)
}
{
const moderator = { username: 'moderator1' }
- await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR })
- moderatorToken = await server.loginCommand.getAccessToken(moderator)
+ await server.users.create({ ...moderator, role: UserRole.MODERATOR })
+ moderatorToken = await server.login.getAccessToken(moderator)
}
{
const moderator = { username: 'moderator2' }
- await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR })
+ await server.users.create({ ...moderator, role: UserRole.MODERATOR })
}
{
- video = await server.videosCommand.upload()
+ video = await server.videos.upload()
}
{
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
userId = data.find(u => u.username === 'user1').id
rootId = data.find(u => u.username === 'root').id
moderatorId = data.find(u => u.username === 'moderator2').id
@@ -341,7 +341,7 @@ describe('Test users API validators', function () {
it('Should fail with a non admin user', async function () {
const user = { username: 'user1' }
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
const fields = {
username: 'user3',
@@ -596,28 +596,28 @@ describe('Test users API validators', function () {
describe('When managing my scoped tokens', function () {
it('Should fail to get my scoped tokens with an non authenticated user', async function () {
- await server.usersCommand.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail to get my scoped tokens with a bad token', async function () {
- await server.usersCommand.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should succeed to get my scoped tokens', async function () {
- await server.usersCommand.getMyScopedTokens()
+ await server.users.getMyScopedTokens()
})
it('Should fail to renew my scoped tokens with an non authenticated user', async function () {
- await server.usersCommand.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail to renew my scoped tokens with a bad token', async function () {
- await server.usersCommand.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should succeed to renew my scoped tokens', async function () {
- await server.usersCommand.renewMyScopedTokens()
+ await server.users.renewMyScopedTokens()
})
})
@@ -769,11 +769,11 @@ describe('Test users API validators', function () {
describe('When getting my information', function () {
it('Should fail with a non authenticated user', async function () {
- await server.usersCommand.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should success with the correct parameters', async function () {
- await server.usersCommand.getMyInfo({ token: userToken })
+ await server.users.getMyInfo({ token: userToken })
})
})
@@ -781,7 +781,7 @@ describe('Test users API validators', function () {
let command: UsersCommand
before(function () {
- command = server.usersCommand
+ command = server.users
})
it('Should fail with a non authenticated user', async function () {
@@ -846,54 +846,54 @@ describe('Test users API validators', function () {
it('Should fail with an incorrect id', async function () {
const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.usersCommand.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.remove(options)
+ await server.users.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should fail with the root user', async function () {
const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should return 404 with a non existing id', async function () {
const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should fail with a non admin user', async function () {
const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should fail on a moderator with a moderator', async function () {
const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
- await server.usersCommand.remove(options)
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.remove(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
it('Should succeed on a user with a moderator', async function () {
const options = { userId, token: moderatorToken }
- await server.usersCommand.banUser(options)
- await server.usersCommand.unbanUser(options)
+ await server.users.banUser(options)
+ await server.users.unbanUser(options)
})
})
describe('When deleting our account', function () {
it('Should fail with with the root account', async function () {
- await server.usersCommand.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
})
@@ -1011,7 +1011,7 @@ describe('Test users API validators', function () {
it('Should fail with an existing channel', async function () {
const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
- await server.channelsCommand.create({ attributes })
+ await server.channels.create({ attributes })
const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
@@ -1055,7 +1055,7 @@ describe('Test users API validators', function () {
describe('When registering multiple users on a server with users limit', function () {
it('Should fail when after 3 registrations', async function () {
- await server.usersCommand.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await server.users.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
})
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index 0fda31b29..51609b982 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -40,41 +40,41 @@ describe('Test video blacklist API validators', function () {
{
const username = 'user1'
const password = 'my super password'
- await servers[0].usersCommand.create({ username: username, password: password })
- userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password })
+ await servers[0].users.create({ username: username, password: password })
+ userAccessToken1 = await servers[0].login.getAccessToken({ username, password })
}
{
const username = 'user2'
const password = 'my super password'
- await servers[0].usersCommand.create({ username: username, password: password })
- userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password })
+ await servers[0].users.create({ username: username, password: password })
+ userAccessToken2 = await servers[0].login.getAccessToken({ username, password })
}
{
- servers[0].video = await servers[0].videosCommand.upload({ token: userAccessToken1 })
+ servers[0].store.video = await servers[0].videos.upload({ token: userAccessToken1 })
}
{
- const { uuid } = await servers[0].videosCommand.upload()
+ const { uuid } = await servers[0].videos.upload()
notBlacklistedVideoId = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload()
+ const { uuid } = await servers[1].videos.upload()
remoteVideoUUID = uuid
}
await waitJobs(servers)
- command = servers[0].blacklistCommand
+ command = servers[0].blacklist
})
describe('When adding a video in blacklist', function () {
const basePath = '/api/v1/videos/'
it('Should fail with nothing', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
})
@@ -86,13 +86,13 @@ describe('Test video blacklist API validators', function () {
})
it('Should fail with a non authenticated user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePostBodyRequest({
url: servers[0].url,
@@ -104,7 +104,7 @@ describe('Test video blacklist API validators', function () {
})
it('Should fail with an invalid reason', async function () {
- const path = basePath + servers[0].video.uuid + '/blacklist'
+ const path = basePath + servers[0].store.video.uuid + '/blacklist'
const fields = { reason: 'a'.repeat(305) }
await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
@@ -124,7 +124,7 @@ describe('Test video blacklist API validators', function () {
})
it('Should succeed with the correct params', async function () {
- const path = basePath + servers[0].video.uuid + '/blacklist'
+ const path = basePath + servers[0].store.video.uuid + '/blacklist'
const fields = {}
await makePostBodyRequest({
@@ -159,13 +159,13 @@ describe('Test video blacklist API validators', function () {
})
it('Should fail with a non authenticated user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- const path = basePath + servers[0].video + '/blacklist'
+ const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
await makePutBodyRequest({
url: servers[0].url,
@@ -177,14 +177,14 @@ describe('Test video blacklist API validators', function () {
})
it('Should fail with an invalid reason', async function () {
- const path = basePath + servers[0].video.uuid + '/blacklist'
+ const path = basePath + servers[0].store.video.uuid + '/blacklist'
const fields = { reason: 'a'.repeat(305) }
await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
})
it('Should succeed with the correct params', async function () {
- const path = basePath + servers[0].video.shortUUID + '/blacklist'
+ const path = basePath + servers[0].store.video.shortUUID + '/blacklist'
const fields = { reason: 'hello' }
await makePutBodyRequest({
@@ -200,27 +200,27 @@ describe('Test video blacklist API validators', function () {
describe('When getting blacklisted video', function () {
it('Should fail with a non authenticated user', async function () {
- await servers[0].videosCommand.get({ id: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[0].videos.get({ id: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with another user', async function () {
- await servers[0].videosCommand.getWithToken({
+ await servers[0].videos.getWithToken({
token: userAccessToken2,
- id: servers[0].video.uuid,
+ id: servers[0].store.video.uuid,
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
it('Should succeed with the owner authenticated user', async function () {
- const video = await servers[0].videosCommand.getWithToken({ token: userAccessToken1, id: servers[0].video.uuid })
+ const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.video.uuid })
expect(video.blacklisted).to.be.true
})
it('Should succeed with an admin', async function () {
- const video = servers[0].video
+ const video = servers[0].store.video
for (const id of [ video.id, video.uuid, video.shortUUID ]) {
- const video = await servers[0].videosCommand.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
+ const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
expect(video.blacklisted).to.be.true
}
})
@@ -229,11 +229,11 @@ describe('Test video blacklist API validators', function () {
describe('When removing a video in blacklist', function () {
it('Should fail with a non authenticated user', async function () {
- await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await command.remove({ token: 'fake token', videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await command.remove({ token: userAccessToken2, videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with an incorrect id', async function () {
@@ -246,7 +246,7 @@ describe('Test video blacklist API validators', function () {
})
it('Should succeed with the correct params', async function () {
- await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
+ await command.remove({ videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
})
})
@@ -254,11 +254,11 @@ describe('Test video blacklist API validators', function () {
const basePath = '/api/v1/videos/blacklist/'
it('Should fail with a non authenticated user', async function () {
- await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[0].blacklist.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
- await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].blacklist.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a bad start pagination', async function () {
@@ -274,11 +274,11 @@ describe('Test video blacklist API validators', function () {
})
it('Should fail with an invalid type', async function () {
- await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await servers[0].blacklist.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should succeed with the correct parameters', async function () {
- await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL })
+ await servers[0].blacklist.list({ type: VideoBlacklistType.MANUAL })
})
})
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index f3941b3fa..913f894b9 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -30,15 +30,15 @@ describe('Test video captions API validator', function () {
await setAccessTokensToServers([ server ])
- video = await server.videosCommand.upload()
+ video = await server.videos.upload()
{
const user = {
username: 'user1',
password: 'my 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)
}
})
@@ -152,7 +152,7 @@ describe('Test video captions API validator', function () {
// })
it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: 'zh',
videoId: video.uuid,
fixture: 'subtitle-good.srt',
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 2b4c17ea1..8e6e32f20 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -44,11 +44,11 @@ describe('Test video channels API validator', function () {
}
{
- await server.usersCommand.create({ username: user.username, password: user.password })
- accessTokenUser = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ accessTokenUser = await server.login.getAccessToken(user)
}
- command = server.channelsCommand
+ command = server.channels
})
describe('When listing a video channels', function () {
@@ -81,7 +81,7 @@ describe('Test video channels API validator', function () {
})
it('Should fail with a unknown account', async function () {
- await server.channelsCommand.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.channels.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should succeed with the correct parameters', async function () {
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index bdf7f91ee..44af9d7e3 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -38,26 +38,26 @@ describe('Test video comments API validator', function () {
await setAccessTokensToServers([ server ])
{
- const video = await server.videosCommand.upload({ attributes: {} })
+ const video = await server.videos.upload({ attributes: {} })
pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
}
{
- const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'coucou' })
+ const created = await server.comments.createThread({ videoId: video.uuid, text: 'coucou' })
commentId = created.id
pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
}
{
const user = { username: 'user1', password: 'my 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)
}
{
const user = { username: 'user2', password: 'my super password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
- userAccessToken2 = await server.loginCommand.getAccessToken(user)
+ await server.users.create({ username: user.username, password: user.password })
+ userAccessToken2 = await server.login.getAccessToken(user)
}
})
@@ -274,7 +274,7 @@ describe('Test video comments API validator', function () {
let commentToDelete: number
{
- const created = await server.commentsCommand.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
+ const created = await server.comments.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
commentToDelete = created.id
}
@@ -289,12 +289,12 @@ describe('Test video comments API validator', function () {
let anotherVideoUUID: string
{
- const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes: { name: 'video' } })
+ const { uuid } = await server.videos.upload({ token: userAccessToken, attributes: { name: 'video' } })
anotherVideoUUID = uuid
}
{
- const created = await server.commentsCommand.createThread({ videoId: anotherVideoUUID, text: 'hello' })
+ const created = await server.comments.createThread({ videoId: anotherVideoUUID, text: 'hello' })
commentToDelete = created.id
}
@@ -316,7 +316,7 @@ describe('Test video comments API validator', function () {
describe('When a video has comments disabled', function () {
before(async function () {
- video = await server.videosCommand.upload({ attributes: { commentsEnabled: false } })
+ video = await server.videos.upload({ attributes: { commentsEnabled: false } })
pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
})
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index d09e473de..1a6b6075f 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -36,11 +36,11 @@ describe('Test video imports API validator', function () {
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ await server.users.create({ username: username, password: password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
{
- const { videoChannels } = await server.usersCommand.getMyInfo()
+ const { videoChannels } = await server.users.getMyInfo()
channelId = videoChannels[0].id
}
})
@@ -162,10 +162,10 @@ describe('Test video imports API validator', function () {
username: 'fake',
password: 'fake_password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessTokenUser = await server.loginCommand.getAccessToken(user)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser })
+ const accessTokenUser = await server.login.getAccessToken(user)
+ const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
const customChannelId = videoChannels[0].id
const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -256,7 +256,7 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import http videos', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
import: {
videos: {
@@ -281,7 +281,7 @@ describe('Test video imports API validator', function () {
})
it('Should forbid to import torrent videos', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
import: {
videos: {
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index ebd7e2413..e0e42ebb0 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -47,10 +47,10 @@ describe('Test video playlists API validator', function () {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- userAccessToken = await server.usersCommand.generateUserAndToken('user1')
- videoId = (await server.videosCommand.quickUpload({ name: 'video 1' })).id
+ userAccessToken = await server.users.generateUserAndToken('user1')
+ videoId = (await server.videos.quickUpload({ name: 'video 1' })).id
- command = server.playlistsCommand
+ command = server.playlists
{
const { data } = await command.listByAccount({
@@ -68,7 +68,7 @@ describe('Test video playlists API validator', function () {
attributes: {
displayName: 'super playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
})
}
@@ -176,7 +176,7 @@ describe('Test video playlists API validator', function () {
const playlist = await command.create({
attributes: {
displayName: 'super playlist',
- videoChannelId: server.videoChannel.id,
+ videoChannelId: server.store.channel.id,
privacy: VideoPlaylistPrivacy.UNLISTED
}
})
@@ -200,7 +200,7 @@ describe('Test video playlists API validator', function () {
displayName: 'display name',
privacy: VideoPlaylistPrivacy.UNLISTED,
thumbnailfile: 'thumbnail.jpg',
- videoChannelId: server.videoChannel.id,
+ videoChannelId: server.store.channel.id,
...attributes
},
@@ -485,8 +485,8 @@ describe('Test video playlists API validator', function () {
}
before(async function () {
- videoId3 = (await server.videosCommand.quickUpload({ name: 'video 3' })).id
- videoId4 = (await server.videosCommand.quickUpload({ name: 'video 4' })).id
+ videoId3 = (await server.videos.quickUpload({ name: 'video 3' })).id
+ videoId4 = (await server.videos.quickUpload({ name: 'video 4' })).id
for (const id of [ videoId3, videoId4 ]) {
await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } })
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index d7bf081d4..cbfdef1db 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -49,13 +49,13 @@ describe('Test video filters validators', function () {
await setDefaultVideoChannel([ server ])
const user = { username: 'user1', password: 'my 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)
const moderator = { username: 'moderator', password: 'my super password' }
- await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
+ await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
- moderatorAccessToken = await server.loginCommand.getAccessToken(moderator)
+ moderatorAccessToken = await server.login.getAccessToken(moderator)
})
describe('When setting a video filter', function () {
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 1da922a17..549c9fa1f 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -29,7 +29,7 @@ describe('Test videos history API validator', function () {
await setAccessTokensToServers([ server ])
- const { uuid } = await server.videosCommand.upload()
+ const { uuid } = await server.videos.upload()
watchingPath = '/api/v1/videos/' + uuid + '/watching'
})
diff --git a/server/tests/api/check-params/videos-overviews.ts b/server/tests/api/check-params/videos-overviews.ts
index 44a936c9f..3597c81d3 100644
--- a/server/tests/api/check-params/videos-overviews.ts
+++ b/server/tests/api/check-params/videos-overviews.ts
@@ -17,12 +17,12 @@ describe('Test videos overview', function () {
describe('When getting videos overview', function () {
it('Should fail with a bad pagination', async function () {
- await server.overviewsCommand.getVideos({ page: 0, expectedStatus: 400 })
- await server.overviewsCommand.getVideos({ page: 100, expectedStatus: 400 })
+ await server.overviews.getVideos({ page: 0, expectedStatus: 400 })
+ await server.overviews.getVideos({ page: 100, expectedStatus: 400 })
})
it('Should succeed with a good pagination', async function () {
- await server.overviewsCommand.getVideos({ page: 1 })
+ await server.overviews.getVideos({ page: 1 })
})
})
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 8f9f33b8c..69bdae7cf 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -44,11 +44,11 @@ describe('Test videos API validator', function () {
const username = 'user1'
const password = 'my super password'
- await server.usersCommand.create({ username: username, password: password })
- userAccessToken = await server.loginCommand.getAccessToken({ username, password })
+ await server.users.create({ username: username, password: password })
+ userAccessToken = await server.login.getAccessToken({ username, password })
{
- const body = await server.usersCommand.getMyInfo()
+ const body = await server.users.getMyInfo()
channelId = body.videoChannels[0].id
channelName = body.videoChannels[0].name
accountName = body.account.name + '@' + body.account.host
@@ -274,10 +274,10 @@ describe('Test videos API validator', function () {
username: 'fake' + randomInt(0, 1500),
password: 'fake_password'
}
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessTokenUser = await server.loginCommand.getAccessToken(user)
- const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser })
+ const accessTokenUser = await server.login.getAccessToken(user)
+ const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
const customChannelId = videoChannels[0].id
const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -484,7 +484,7 @@ describe('Test videos API validator', function () {
}
before(async function () {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
video = data[0]
})
@@ -710,15 +710,15 @@ describe('Test videos API validator', function () {
})
it('Should fail without a correct uuid', async function () {
- await server.videosCommand.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should return 404 with an incorrect video', async function () {
- await server.videosCommand.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Shoud report the appropriate error', async function () {
- const body = await server.videosCommand.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const error = body as unknown as PeerTubeProblemDocument
expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
@@ -734,7 +734,7 @@ describe('Test videos API validator', function () {
})
it('Should succeed with the correct parameters', async function () {
- await server.videosCommand.get({ id: video.shortUUID })
+ await server.videos.get({ id: video.shortUUID })
})
})
@@ -742,7 +742,7 @@ describe('Test videos API validator', function () {
let videoId: number
before(async function () {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
videoId = data[0].id
})
@@ -797,21 +797,21 @@ describe('Test videos API validator', function () {
})
it('Should fail without a correct uuid', async function () {
- await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should fail with a video which does not exist', async function () {
- await server.videosCommand.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should fail with a video of another user without the appropriate right', async function () {
- await server.videosCommand.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a video of another server')
it('Shoud report the appropriate error', async function () {
- const body = await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const error = body as unknown as PeerTubeProblemDocument
expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
@@ -827,7 +827,7 @@ describe('Test videos API validator', function () {
})
it('Should succeed with the correct parameters', async function () {
- await server.videosCommand.remove({ id: video.uuid })
+ await server.videos.remove({ id: video.uuid })
})
})
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts
index 7900b1abe..1c380883c 100644
--- a/server/tests/api/live/live-constraints.ts
+++ b/server/tests/api/live/live-constraints.ts
@@ -32,13 +32,13 @@ describe('Test live constraints', function () {
saveReplay
}
- const { uuid } = await servers[0].liveCommand.create({ token: userAccessToken, fields: liveAttributes })
+ const { uuid } = await servers[0].live.create({ token: userAccessToken, fields: liveAttributes })
return uuid
}
async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.isLive).to.be.false
expect(video.duration).to.be.greaterThan(0)
}
@@ -48,12 +48,12 @@ describe('Test live constraints', function () {
async function waitUntilLivePublishedOnAllServers (videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId })
+ await server.live.waitUntilPublished({ videoId })
}
}
function updateQuota (options: { total: number, daily: number }) {
- return servers[0].usersCommand.update({
+ return servers[0].users.update({
userId,
videoQuota: options.total,
videoQuotaDaily: options.daily
@@ -69,7 +69,7 @@ describe('Test live constraints', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -82,7 +82,7 @@ describe('Test live constraints', function () {
})
{
- const res = await servers[0].usersCommand.generate('user1')
+ const res = await servers[0].users.generate('user1')
userId = res.userId
userChannelId = res.userChannelId
userAccessToken = res.token
@@ -98,7 +98,7 @@ describe('Test live constraints', function () {
this.timeout(60000)
const userVideoLiveoId = await createLiveWrapper(false)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
})
it('Should have size limit depending on user global quota if save replay is enabled', async function () {
@@ -108,7 +108,7 @@ describe('Test live constraints', function () {
await wait(5000)
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
await waitJobs(servers)
@@ -125,7 +125,7 @@ describe('Test live constraints', function () {
await updateQuota({ total: -1, daily: 1 })
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
await waitJobs(servers)
@@ -142,13 +142,13 @@ describe('Test live constraints', function () {
await updateQuota({ total: 10 * 1000 * 1000, daily: -1 })
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
})
it('Should have max duration limit', async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -163,7 +163,7 @@ describe('Test live constraints', function () {
})
const userVideoLiveoId = await createLiveWrapper(true)
- await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
+ await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
await waitJobs(servers)
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts
index 707f2edf8..900bd6f5c 100644
--- a/server/tests/api/live/live-permanent.ts
+++ b/server/tests/api/live/live-permanent.ts
@@ -24,20 +24,20 @@ describe('Permanent live', function () {
async function createLiveWrapper (permanentLive: boolean) {
const attributes: LiveVideoCreate = {
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
name: 'my super live',
saveReplay: false,
permanentLive
}
- const { uuid } = await servers[0].liveCommand.create({ fields: attributes })
+ const { uuid } = await servers[0].live.create({ fields: attributes })
return uuid
}
async function checkVideoState (videoId: string, state: VideoState) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.state.id).to.equal(state)
}
}
@@ -54,7 +54,7 @@ describe('Permanent live', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -75,14 +75,14 @@ describe('Permanent live', function () {
const videoUUID = await createLiveWrapper(false)
{
- const live = await servers[0].liveCommand.get({ videoId: videoUUID })
+ const live = await servers[0].live.get({ videoId: videoUUID })
expect(live.permanentLive).to.be.false
}
- await servers[0].liveCommand.update({ videoId: videoUUID, fields: { permanentLive: true } })
+ await servers[0].live.update({ videoId: videoUUID, fields: { permanentLive: true } })
{
- const live = await servers[0].liveCommand.get({ videoId: videoUUID })
+ const live = await servers[0].live.get({ videoId: videoUUID })
expect(live.permanentLive).to.be.true
}
})
@@ -92,7 +92,7 @@ describe('Permanent live', function () {
videoUUID = await createLiveWrapper(true)
- const live = await servers[0].liveCommand.get({ videoId: videoUUID })
+ const live = await servers[0].live.get({ videoId: videoUUID })
expect(live.permanentLive).to.be.true
await waitJobs(servers)
@@ -101,16 +101,16 @@ describe('Permanent live', function () {
it('Should stream into this permanent live', async function () {
this.timeout(120000)
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID })
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId: videoUUID })
+ await server.live.waitUntilPublished({ videoId: videoUUID })
}
await checkVideoState(videoUUID, VideoState.PUBLISHED)
await stopFfmpeg(ffmpegCommand)
- await servers[0].liveCommand.waitUntilWaiting({ videoId: videoUUID })
+ await servers[0].live.waitUntilWaiting({ videoId: videoUUID })
await waitJobs(servers)
})
@@ -122,7 +122,7 @@ describe('Permanent live', function () {
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videoUUID })
+ const videoDetails = await server.videos.get({ id: videoUUID })
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
}
})
@@ -136,7 +136,7 @@ describe('Permanent live', function () {
it('Should be able to stream again in the permanent live', async function () {
this.timeout(20000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -150,15 +150,15 @@ describe('Permanent live', function () {
}
})
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID })
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId: videoUUID })
+ await server.live.waitUntilPublished({ videoId: videoUUID })
}
await checkVideoState(videoUUID, VideoState.PUBLISHED)
- const count = await servers[0].liveCommand.countPlaylists({ videoUUID })
+ const count = await servers[0].live.countPlaylists({ videoUUID })
// master playlist and 720p playlist
expect(count).to.equal(2)
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index a87a2cd12..7a33df90a 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -30,19 +30,19 @@ describe('Save replay setting', function () {
async function createLiveWrapper (saveReplay: boolean) {
if (liveVideoUUID) {
try {
- await servers[0].videosCommand.remove({ id: liveVideoUUID })
+ await servers[0].videos.remove({ id: liveVideoUUID })
await waitJobs(servers)
} catch {}
}
const attributes: LiveVideoCreate = {
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
name: 'my super live',
saveReplay
}
- const { uuid } = await servers[0].liveCommand.create({ fields: attributes })
+ const { uuid } = await servers[0].live.create({ fields: attributes })
return uuid
}
@@ -50,32 +50,32 @@ describe('Save replay setting', function () {
for (const server of servers) {
const length = existsInList ? 1 : 0
- const { data, total } = await server.videosCommand.list()
+ const { data, total } = await server.videos.list()
expect(data).to.have.lengthOf(length)
expect(total).to.equal(length)
if (expectedStatus) {
- await server.videosCommand.get({ id: videoId, expectedStatus })
+ await server.videos.get({ id: videoId, expectedStatus })
}
}
}
async function checkVideoState (videoId: string, state: VideoState) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.state.id).to.equal(state)
}
}
async function waitUntilLivePublishedOnAllServers (videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId })
+ await server.live.waitUntilPublished({ videoId })
}
}
async function waitUntilLiveSavedOnAllServers (videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilSaved({ videoId })
+ await server.live.waitUntilSaved({ videoId })
}
}
@@ -91,7 +91,7 @@ describe('Save replay setting', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -126,7 +126,7 @@ describe('Save replay setting', function () {
it('Should correctly have updated the live and federated it when streaming in the live', async function () {
this.timeout(30000)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
@@ -142,7 +142,7 @@ describe('Save replay setting', function () {
await stopFfmpeg(ffmpegCommand)
for (const server of servers) {
- await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID })
+ await server.live.waitUntilEnded({ videoId: liveVideoUUID })
}
await waitJobs(servers)
@@ -159,7 +159,7 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(false)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
@@ -167,7 +167,7 @@ describe('Save replay setting', function () {
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await Promise.all([
- servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
+ servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
testFfmpegStreamError(ffmpegCommand, true)
])
@@ -175,8 +175,8 @@ describe('Save replay setting', function () {
await checkVideosExist(liveVideoUUID, false)
- await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
await wait(5000)
await waitJobs(servers)
@@ -188,7 +188,7 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(false)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
@@ -197,7 +197,7 @@ describe('Save replay setting', function () {
await Promise.all([
testFfmpegStreamError(ffmpegCommand, true),
- servers[0].videosCommand.remove({ id: liveVideoUUID })
+ servers[0].videos.remove({ id: liveVideoUUID })
])
await wait(5000)
@@ -224,7 +224,7 @@ describe('Save replay setting', function () {
it('Should correctly have updated the live and federated it when streaming in the live', async function () {
this.timeout(20000)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
@@ -249,11 +249,11 @@ describe('Save replay setting', function () {
it('Should update the saved live and correctly federate the updated attributes', async function () {
this.timeout(30000)
- await servers[0].videosCommand.update({ id: liveVideoUUID, attributes: { name: 'video updated' } })
+ await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated' } })
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoUUID })
+ const video = await server.videos.get({ id: liveVideoUUID })
expect(video.name).to.equal('video updated')
expect(video.isLive).to.be.false
}
@@ -268,14 +268,14 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(true)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await Promise.all([
- servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
+ servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
testFfmpegStreamError(ffmpegCommand, true)
])
@@ -283,8 +283,8 @@ describe('Save replay setting', function () {
await checkVideosExist(liveVideoUUID, false)
- await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
await wait(5000)
await waitJobs(servers)
@@ -296,14 +296,14 @@ describe('Save replay setting', function () {
liveVideoUUID = await createLiveWrapper(true)
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(liveVideoUUID)
await waitJobs(servers)
await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
await Promise.all([
- servers[0].videosCommand.remove({ id: liveVideoUUID }),
+ servers[0].videos.remove({ id: liveVideoUUID }),
testFfmpegStreamError(ffmpegCommand, true)
])
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts
index 1f3d455a8..ad67d6285 100644
--- a/server/tests/api/live/live-socket-messages.ts
+++ b/server/tests/api/live/live-socket-messages.ts
@@ -30,7 +30,7 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -51,11 +51,11 @@ describe('Test live', function () {
async function createLiveWrapper () {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- const { uuid } = await servers[0].liveCommand.create({ fields: liveAttributes })
+ const { uuid } = await servers[0].live.create({ fields: liveAttributes })
return uuid
}
@@ -69,22 +69,22 @@ describe('Test live', function () {
await waitJobs(servers)
{
- const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
- const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
+ const localSocket = servers[0].socketIO.getLiveNotificationSocket()
localSocket.on('state-change', data => localStateChanges.push(data.state))
localSocket.emit('subscribe', { videoId })
}
{
- const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID })
- const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
+ const remoteSocket = servers[1].socketIO.getLiveNotificationSocket()
remoteSocket.on('state-change', data => remoteStateChanges.push(data.state))
remoteSocket.emit('subscribe', { videoId })
}
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
@@ -97,7 +97,7 @@ describe('Test live', function () {
await stopFfmpeg(ffmpegCommand)
for (const server of servers) {
- await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID })
+ await server.live.waitUntilEnded({ videoId: liveVideoUUID })
}
await waitJobs(servers)
@@ -117,22 +117,22 @@ describe('Test live', function () {
await waitJobs(servers)
{
- const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
- const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
+ const localSocket = servers[0].socketIO.getLiveNotificationSocket()
localSocket.on('views-change', data => { localLastVideoViews = data.views })
localSocket.emit('subscribe', { videoId })
}
{
- const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID })
- const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
+ const remoteSocket = servers[1].socketIO.getLiveNotificationSocket()
remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views })
remoteSocket.emit('subscribe', { videoId })
}
- const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
@@ -140,8 +140,8 @@ describe('Test live', function () {
expect(localLastVideoViews).to.equal(0)
expect(remoteLastVideoViews).to.equal(0)
- await servers[0].videosCommand.view({ id: liveVideoUUID })
- await servers[1].videosCommand.view({ id: liveVideoUUID })
+ await servers[0].videos.view({ id: liveVideoUUID })
+ await servers[1].videos.view({ id: liveVideoUUID })
await waitJobs(servers)
await wait(5000)
@@ -161,13 +161,13 @@ describe('Test live', function () {
const liveVideoUUID = await createLiveWrapper()
await waitJobs(servers)
- const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
+ const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
- const socket = servers[0].socketIOCommand.getLiveNotificationSocket()
+ const socket = servers[0].socketIO.getLiveNotificationSocket()
socket.on('state-change', data => stateChanges.push(data.state))
socket.emit('subscribe', { videoId })
- const command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
+ const command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
await waitJobs(servers)
diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts
index 1951b11a5..43222f9c9 100644
--- a/server/tests/api/live/live-views.ts
+++ b/server/tests/api/live/live-views.ts
@@ -31,7 +31,7 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -53,7 +53,7 @@ describe('Test live', function () {
async function countViews (expected: number) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoId })
+ const video = await server.videos.get({ id: liveVideoId })
expect(video.views).to.equal(expected)
}
}
@@ -63,14 +63,14 @@ describe('Test live', function () {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- const live = await servers[0].liveCommand.create({ fields: liveAttributes })
+ const live = await servers[0].live.create({ fields: liveAttributes })
liveVideoId = live.uuid
- command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId })
+ command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
await waitJobs(servers)
})
@@ -82,8 +82,8 @@ describe('Test live', function () {
it('Should view a live twice and display 1 view', async function () {
this.timeout(30000)
- await servers[0].videosCommand.view({ id: liveVideoId })
- await servers[0].videosCommand.view({ id: liveVideoId })
+ await servers[0].videos.view({ id: liveVideoId })
+ await servers[0].videos.view({ id: liveVideoId })
await wait(7000)
@@ -104,9 +104,9 @@ describe('Test live', function () {
it('Should view a live on a remote and on local and display 2 views', async function () {
this.timeout(30000)
- await servers[0].videosCommand.view({ id: liveVideoId })
- await servers[1].videosCommand.view({ id: liveVideoId })
- await servers[1].videosCommand.view({ id: liveVideoId })
+ await servers[0].videos.view({ id: liveVideoId })
+ await servers[1].videos.view({ id: liveVideoId })
+ await servers[1].videos.view({ id: liveVideoId })
await wait(7000)
await waitJobs(servers)
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index c88143982..2cce1f448 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -44,7 +44,7 @@ describe('Test live', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -59,7 +59,7 @@ describe('Test live', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- commands = servers.map(s => s.liveCommand)
+ commands = servers.map(s => s.live)
})
describe('Live creation, update and delete', function () {
@@ -74,7 +74,7 @@ describe('Test live', function () {
language: 'fr',
description: 'super live description',
support: 'support field',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
nsfw: false,
waitTranscoding: false,
name: 'my super live',
@@ -93,7 +93,7 @@ describe('Test live', function () {
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoUUID })
+ const video = await server.videos.get({ id: liveVideoUUID })
expect(video.category.id).to.equal(1)
expect(video.licence.id).to.equal(2)
@@ -101,8 +101,8 @@ describe('Test live', function () {
expect(video.description).to.equal('super live description')
expect(video.support).to.equal('support field')
- expect(video.channel.name).to.equal(servers[0].videoChannel.name)
- expect(video.channel.host).to.equal(servers[0].videoChannel.host)
+ expect(video.channel.name).to.equal(servers[0].store.channel.name)
+ expect(video.channel.host).to.equal(servers[0].store.channel.host)
expect(video.isLive).to.be.true
@@ -117,7 +117,7 @@ describe('Test live', function () {
await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
await testImage(server.url, 'video_short1.webm', video.thumbnailPath)
- const live = await server.liveCommand.get({ videoId: liveVideoUUID })
+ const live = await server.live.get({ videoId: liveVideoUUID })
if (server.url === servers[0].url) {
expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
@@ -136,7 +136,7 @@ describe('Test live', function () {
const attributes: LiveVideoCreate = {
name: 'default live thumbnail',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.UNLISTED,
nsfw: true
}
@@ -147,7 +147,7 @@ describe('Test live', function () {
await waitJobs(servers)
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED)
expect(video.nsfw).to.be.true
@@ -158,7 +158,7 @@ describe('Test live', function () {
it('Should not have the live listed since nobody streams into', 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)
@@ -178,7 +178,7 @@ describe('Test live', function () {
it('Have the live updated', async function () {
for (const server of servers) {
- const live = await server.liveCommand.get({ videoId: liveVideoUUID })
+ const live = await server.live.get({ videoId: liveVideoUUID })
if (server.url === servers[0].url) {
expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
@@ -195,14 +195,14 @@ describe('Test live', function () {
it('Delete the live', async function () {
this.timeout(10000)
- await servers[0].videosCommand.remove({ id: liveVideoUUID })
+ await servers[0].videos.remove({ id: liveVideoUUID })
await waitJobs(servers)
})
it('Should have the live deleted', async function () {
for (const server of servers) {
- await server.videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
- await server.liveCommand.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
+ await server.live.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
})
@@ -215,19 +215,19 @@ describe('Test live', function () {
before(async function () {
this.timeout(120000)
- vodVideoId = (await servers[0].videosCommand.quickUpload({ name: 'vod video' })).uuid
+ vodVideoId = (await servers[0].videos.quickUpload({ name: 'vod video' })).uuid
- const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id }
+ const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id }
const live = await commands[0].create({ fields: liveOptions })
liveVideoId = live.uuid
- ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId })
+ ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
await waitJobs(servers)
})
it('Should only display lives', async function () {
- const { data, total } = await servers[0].videosCommand.list({ isLive: true })
+ const { data, total } = await servers[0].videos.list({ isLive: true })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -235,7 +235,7 @@ describe('Test live', function () {
})
it('Should not display lives', async function () {
- const { data, total } = await servers[0].videosCommand.list({ isLive: false })
+ const { data, total } = await servers[0].videos.list({ isLive: false })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -248,22 +248,22 @@ describe('Test live', function () {
await stopFfmpeg(ffmpegCommand)
await waitJobs(servers)
- const { data } = await servers[0].videosCommand.listMyVideos({ isLive: true })
+ const { data } = await servers[0].videos.listMyVideos({ isLive: true })
const result = data.every(v => v.isLive)
expect(result).to.be.true
})
it('Should not display my lives', async function () {
- const { data } = await servers[0].videosCommand.listMyVideos({ isLive: false })
+ const { data } = await servers[0].videos.listMyVideos({ isLive: false })
const result = data.every(v => !v.isLive)
expect(result).to.be.true
})
after(async function () {
- await servers[0].videosCommand.remove({ id: vodVideoId })
- await servers[0].videosCommand.remove({ id: liveVideoId })
+ await servers[0].videos.remove({ id: vodVideoId })
+ await servers[0].videos.remove({ id: liveVideoId })
})
})
@@ -278,7 +278,7 @@ describe('Test live', function () {
async function createLiveWrapper () {
const liveAttributes = {
name: 'user live',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
saveReplay: false
}
@@ -286,7 +286,7 @@ describe('Test live', function () {
const { uuid } = await commands[0].create({ fields: liveAttributes })
const live = await commands[0].get({ videoId: uuid })
- const video = await servers[0].videosCommand.get({ id: uuid })
+ const video = await servers[0].videos.get({ id: uuid })
return Object.assign(video, live)
}
@@ -316,7 +316,7 @@ describe('Test live', function () {
it('Should list this live now someone stream into it', 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(1)
expect(data).to.have.lengthOf(1)
@@ -332,7 +332,7 @@ describe('Test live', function () {
liveVideo = await createLiveWrapper()
- await servers[0].blacklistCommand.add({ videoId: liveVideo.uuid })
+ await servers[0].blacklist.add({ videoId: liveVideo.uuid })
const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
await testFfmpegStreamError(command, true)
@@ -343,7 +343,7 @@ describe('Test live', function () {
liveVideo = await createLiveWrapper()
- await servers[0].videosCommand.remove({ id: liveVideo.uuid })
+ await servers[0].videos.remove({ id: liveVideo.uuid })
const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
await testFfmpegStreamError(command, true)
@@ -356,7 +356,7 @@ describe('Test live', function () {
async function createLiveWrapper (saveReplay: boolean) {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
saveReplay
}
@@ -367,10 +367,10 @@ describe('Test live', function () {
async function testVideoResolutions (liveVideoId: string, resolutions: number[]) {
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === liveVideoId)).to.exist
- const video = await server.videosCommand.get({ id: liveVideoId })
+ const video = await server.videos.get({ id: liveVideoId })
expect(video.streamingPlaylists).to.have.lengthOf(1)
@@ -387,7 +387,7 @@ describe('Test live', function () {
const segmentName = `${i}-00000${segmentNum}.ts`
await commands[0].waitUntilSegmentGeneration({ videoUUID: video.uuid, resolution: i, segment: segmentNum })
- const subPlaylist = await servers[0].streamingPlaylistsCommand.get({
+ const subPlaylist = await servers[0].streamingPlaylists.get({
url: `${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`
})
@@ -406,7 +406,7 @@ describe('Test live', function () {
}
function updateConf (resolutions: number[]) {
- return servers[0].configCommand.updateCustomSubConfig({
+ return servers[0].config.updateCustomSubConfig({
newConfig: {
live: {
enabled: true,
@@ -490,7 +490,7 @@ describe('Test live', function () {
}
for (const server of servers) {
- const video = await server.videosCommand.get({ id: liveVideoId })
+ const video = await server.videos.get({ id: liveVideoId })
expect(video.state.id).to.equal(VideoState.PUBLISHED)
expect(video.duration).to.be.greaterThan(1)
@@ -515,7 +515,7 @@ describe('Test live', function () {
}
const filename = `${video.uuid}-${resolution}-fragmented.mp4`
- const segmentPath = servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
+ const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
const probe = await ffprobePromise(segmentPath)
const videoStream = await getVideoStreamFromFile(segmentPath, probe)
@@ -542,7 +542,7 @@ describe('Test live', function () {
async function createLiveWrapper (saveReplay: boolean) {
const liveAttributes = {
name: 'live video',
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
privacy: VideoPrivacy.PUBLIC,
saveReplay
}
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 7574b8f4a..97a0d95c4 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -33,7 +33,7 @@ describe('Test abuses', function () {
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- commands = servers.map(s => s.abusesCommand)
+ commands = servers.map(s => s.abuses)
})
describe('Video abuses', function () {
@@ -47,7 +47,7 @@ describe('Test abuses', function () {
name: 'my super name for server 1',
description: 'my super description for server 1'
}
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
}
{
@@ -55,17 +55,17 @@ describe('Test abuses', function () {
name: 'my super name for server 2',
description: 'my super description for server 2'
}
- await servers[1].videosCommand.upload({ attributes })
+ await servers[1].videos.upload({ attributes })
}
// Wait videos propagation, server 2 has transcoding enabled
await waitJobs(servers)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data.length).to.equal(2)
- servers[0].video = data.find(video => video.name === 'my super name for server 1')
- servers[1].video = data.find(video => video.name === 'my super name for server 2')
+ servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
+ servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
})
it('Should not have abuses', async function () {
@@ -80,7 +80,7 @@ describe('Test abuses', function () {
this.timeout(15000)
const reason = 'my super bad reason'
- await commands[0].report({ videoId: servers[0].video.id, reason })
+ await commands[0].report({ videoId: servers[0].store.video.id, reason })
// We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
await waitJobs(servers)
@@ -100,7 +100,7 @@ describe('Test abuses', function () {
expect(abuse.reporterAccount.name).to.equal('root')
expect(abuse.reporterAccount.host).to.equal(servers[0].host)
- expect(abuse.video.id).to.equal(servers[0].video.id)
+ expect(abuse.video.id).to.equal(servers[0].store.video.id)
expect(abuse.video.channel).to.exist
expect(abuse.comment).to.be.null
@@ -127,7 +127,7 @@ describe('Test abuses', function () {
this.timeout(10000)
const reason = 'my super bad reason 2'
- const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid })
+ const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
await commands[0].report({ videoId, reason })
// We wait requests propagation
@@ -146,7 +146,7 @@ describe('Test abuses', function () {
expect(abuse1.reporterAccount.name).to.equal('root')
expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
- expect(abuse1.video.id).to.equal(servers[0].video.id)
+ expect(abuse1.video.id).to.equal(servers[0].store.video.id)
expect(abuse1.video.countReports).to.equal(1)
expect(abuse1.video.nthReport).to.equal(1)
@@ -165,7 +165,7 @@ describe('Test abuses', function () {
expect(abuse2.reporterAccount.name).to.equal('root')
expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
- expect(abuse2.video.id).to.equal(servers[1].video.id)
+ expect(abuse2.video.id).to.equal(servers[1].store.video.id)
expect(abuse2.comment).to.be.null
@@ -200,7 +200,7 @@ describe('Test abuses', function () {
this.timeout(10000)
{
- const videoId = await servers[1].videosCommand.getId({ uuid: servers[0].video.uuid })
+ const videoId = await servers[1].videos.getId({ uuid: servers[0].store.video.uuid })
await commands[1].report({ videoId, reason: 'will mute this' })
await waitJobs(servers)
@@ -211,7 +211,7 @@ describe('Test abuses', function () {
const accountToBlock = 'root@' + servers[1].host
{
- await servers[0].blocklistCommand.addToServerBlocklist({ account: accountToBlock })
+ await servers[0].blocklist.addToServerBlocklist({ account: accountToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(2)
@@ -221,7 +221,7 @@ describe('Test abuses', function () {
}
{
- await servers[0].blocklistCommand.removeFromServerBlocklist({ account: accountToBlock })
+ await servers[0].blocklist.removeFromServerBlocklist({ account: accountToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(3)
@@ -232,7 +232,7 @@ describe('Test abuses', function () {
const serverToBlock = servers[1].host
{
- await servers[0].blocklistCommand.addToServerBlocklist({ server: serverToBlock })
+ await servers[0].blocklist.addToServerBlocklist({ server: serverToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(2)
@@ -242,7 +242,7 @@ describe('Test abuses', function () {
}
{
- await servers[0].blocklistCommand.removeFromServerBlocklist({ server: serverToBlock })
+ await servers[0].blocklist.removeFromServerBlocklist({ server: serverToBlock })
const body = await commands[0].getAdminList()
expect(body.total).to.equal(3)
@@ -252,7 +252,7 @@ describe('Test abuses', function () {
it('Should keep the video abuse when deleting the video', async function () {
this.timeout(10000)
- await servers[1].videosCommand.remove({ id: abuseServer2.video.uuid })
+ await servers[1].videos.remove({ id: abuseServer2.video.uuid })
await waitJobs(servers)
@@ -272,15 +272,15 @@ describe('Test abuses', function () {
// register a second user to have two reporters/reportees
const user = { username: 'user2', password: 'password' }
- await servers[0].usersCommand.create({ ...user })
- const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ ...user })
+ const userAccessToken = await servers[0].login.getAccessToken(user)
// upload a third video via this user
const attributes = {
name: 'my second super name for server 1',
description: 'my second super description for server 1'
}
- const { id } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
+ const { id } = await servers[0].videos.upload({ token: userAccessToken, attributes })
const video3Id = id
// resume with the test
@@ -288,7 +288,7 @@ describe('Test abuses', function () {
await commands[0].report({ videoId: video3Id, reason: reason3 })
const reason4 = 'my super bad reason 4'
- await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: reason4 })
+ await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: reason4 })
{
const body = await commands[0].getAdminList()
@@ -301,7 +301,7 @@ describe('Test abuses', function () {
expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
- const abuseServer1 = abuses.find(a => a.video.id === servers[0].video.id)
+ const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.video.id)
expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
}
})
@@ -312,7 +312,7 @@ describe('Test abuses', function () {
const reason5 = 'my super bad reason 5'
const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
const createRes = await commands[0].report({
- videoId: servers[0].video.id,
+ videoId: servers[0].store.video.id,
reason: reason5,
predefinedReasons: predefinedReasons5,
startAt: 1,
@@ -391,10 +391,10 @@ describe('Test abuses', function () {
async function getComment (server: ServerInfo, videoIdArg: number | string) {
const videoId = typeof videoIdArg === 'string'
- ? await server.videosCommand.getId({ uuid: videoIdArg })
+ ? await server.videos.getId({ uuid: videoIdArg })
: videoIdArg
- const { data } = await server.commentsCommand.listThreads({ videoId })
+ const { data } = await server.comments.listThreads({ videoId })
return data[0]
}
@@ -402,11 +402,11 @@ describe('Test abuses', function () {
before(async function () {
this.timeout(50000)
- servers[0].video = await await servers[0].videosCommand.quickUpload({ name: 'server 1' })
- servers[1].video = await await servers[1].videosCommand.quickUpload({ name: 'server 2' })
+ servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
+ servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
- await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' })
- await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' })
+ await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
+ await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
await waitJobs(servers)
})
@@ -414,7 +414,7 @@ describe('Test abuses', function () {
it('Should report abuse on a comment', async function () {
this.timeout(15000)
- const comment = await getComment(servers[0], servers[0].video.id)
+ const comment = await getComment(servers[0], servers[0].store.video.id)
const reason = 'it is a bad comment'
await commands[0].report({ commentId: comment.id, reason })
@@ -424,7 +424,7 @@ describe('Test abuses', function () {
it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () {
{
- const comment = await getComment(servers[0], servers[0].video.id)
+ const comment = await getComment(servers[0], servers[0].store.video.id)
const body = await commands[0].getAdminList({ filter: 'comment' })
expect(body.total).to.equal(1)
@@ -442,8 +442,8 @@ describe('Test abuses', function () {
expect(abuse.comment.id).to.equal(comment.id)
expect(abuse.comment.text).to.equal(comment.text)
expect(abuse.comment.video.name).to.equal('server 1')
- expect(abuse.comment.video.id).to.equal(servers[0].video.id)
- expect(abuse.comment.video.uuid).to.equal(servers[0].video.uuid)
+ expect(abuse.comment.video.id).to.equal(servers[0].store.video.id)
+ expect(abuse.comment.video.uuid).to.equal(servers[0].store.video.uuid)
expect(abuse.countReportsForReporter).to.equal(5)
expect(abuse.countReportsForReportee).to.equal(5)
@@ -459,7 +459,7 @@ describe('Test abuses', function () {
it('Should report abuse on a remote comment', async function () {
this.timeout(10000)
- const comment = await getComment(servers[0], servers[1].video.uuid)
+ const comment = await getComment(servers[0], servers[1].store.video.uuid)
const reason = 'it is a really bad comment'
await commands[0].report({ commentId: comment.id, reason })
@@ -468,7 +468,7 @@ describe('Test abuses', function () {
})
it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
- const commentServer2 = await getComment(servers[0], servers[1].video.id)
+ const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
{
const body = await commands[0].getAdminList({ filter: 'comment' })
@@ -493,7 +493,7 @@ describe('Test abuses', function () {
expect(abuse2.comment.id).to.equal(commentServer2.id)
expect(abuse2.comment.text).to.equal(commentServer2.text)
expect(abuse2.comment.video.name).to.equal('server 2')
- expect(abuse2.comment.video.uuid).to.equal(servers[1].video.uuid)
+ expect(abuse2.comment.video.uuid).to.equal(servers[1].store.video.uuid)
expect(abuse2.state.id).to.equal(AbuseState.PENDING)
expect(abuse2.state.label).to.equal('Pending')
@@ -527,9 +527,9 @@ describe('Test abuses', function () {
it('Should keep the comment abuse when deleting the comment', async function () {
this.timeout(10000)
- const commentServer2 = await getComment(servers[0], servers[1].video.id)
+ const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
- await servers[0].commentsCommand.delete({ videoId: servers[1].video.uuid, commentId: commentServer2.id })
+ await servers[0].comments.delete({ videoId: servers[1].store.video.uuid, commentId: commentServer2.id })
await waitJobs(servers)
@@ -592,16 +592,16 @@ describe('Test abuses', function () {
describe('Account abuses', function () {
function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
- return server.accountsCommand.get({ accountName: targetName + '@' + targetServer.host })
+ return server.accounts.get({ accountName: targetName + '@' + targetServer.host })
}
before(async function () {
this.timeout(50000)
- await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' })
+ await servers[0].users.create({ username: 'user_1', password: 'donald' })
- const token = await servers[1].usersCommand.generateUserAndToken('user_2')
- await servers[1].videosCommand.upload({ token, attributes: { name: 'super video' } })
+ const token = await servers[1].users.generateUserAndToken('user_2')
+ await servers[1].videos.upload({ token, attributes: { name: 'super video' } })
await waitJobs(servers)
})
@@ -702,7 +702,7 @@ describe('Test abuses', function () {
this.timeout(10000)
const account = await getAccountFromServer(servers[1], 'user_2', servers[1])
- await servers[1].usersCommand.remove({ userId: account.userId })
+ await servers[1].users.remove({ userId: account.userId })
await waitJobs(servers)
@@ -759,11 +759,11 @@ describe('Test abuses', function () {
let userAccessToken: string
before(async function () {
- userAccessToken = await servers[0].usersCommand.generateUserAndToken('user_42')
+ userAccessToken = await servers[0].users.generateUserAndToken('user_42')
- await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' })
+ await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: 'user reason 1' })
- const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid })
+ const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' })
})
@@ -830,9 +830,9 @@ describe('Test abuses', function () {
let abuseMessageModerationId: number
before(async function () {
- userToken = await servers[0].usersCommand.generateUserAndToken('user_43')
+ userToken = await servers[0].users.generateUserAndToken('user_43')
- const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' })
+ const body = await commands[0].report({ token: userToken, videoId: servers[0].store.video.id, reason: 'user 43 reason 1' })
abuseId = body.abuse.id
})
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts
index 92a0ec681..6b56fdd65 100644
--- a/server/tests/api/moderation/blocklist-notification.ts
+++ b/server/tests/api/moderation/blocklist-notification.ts
@@ -8,7 +8,7 @@ import { UserNotificationType } from '@shared/models'
const expect = chai.expect
async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) {
- const { data } = await server.notificationsCommand.list({ token, start: 0, count: 10, unread: true })
+ const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true })
expect(data).to.have.lengthOf(expected.length)
for (const type of expected) {
@@ -26,24 +26,24 @@ describe('Test blocklist', function () {
async function resetState () {
try {
- await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
- await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
+ await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
+ await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
} catch {}
await waitJobs(servers)
- await servers[0].notificationsCommand.markAsReadAll({ token: userToken1 })
- await servers[0].notificationsCommand.markAsReadAll({ token: userToken2 })
+ await servers[0].notifications.markAsReadAll({ token: userToken1 })
+ await servers[0].notifications.markAsReadAll({ token: userToken2 })
{
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video' } })
videoUUID = uuid
await waitJobs(servers)
}
{
- await servers[1].commentsCommand.createThread({
+ await servers[1].comments.createThread({
token: remoteUserToken,
videoId: videoUUID,
text: '@user2@' + servers[0].host + ' hello'
@@ -52,8 +52,8 @@ describe('Test blocklist', function () {
{
- await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
- await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
+ await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
+ await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
}
await waitJobs(servers)
@@ -67,29 +67,29 @@ describe('Test blocklist', function () {
{
const user = { username: 'user1', password: 'password' }
- await servers[0].usersCommand.create({
+ await servers[0].users.create({
username: user.username,
password: user.password,
videoQuota: -1,
videoQuotaDaily: -1
})
- userToken1 = await servers[0].loginCommand.getAccessToken(user)
- await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } })
+ userToken1 = await servers[0].login.getAccessToken(user)
+ await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
}
{
const user = { username: 'user2', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- userToken2 = await servers[0].loginCommand.getAccessToken(user)
+ userToken2 = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user3', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
+ await servers[1].users.create({ username: user.username, password: user.password })
- remoteUserToken = await servers[1].loginCommand.getAccessToken(user)
+ remoteUserToken = await servers[1].login.getAccessToken(user)
}
await doubleFollow(servers[0], servers[1])
@@ -111,7 +111,7 @@ describe('Test blocklist', function () {
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
await waitJobs(servers)
})
@@ -124,7 +124,7 @@ describe('Test blocklist', function () {
await checkNotifications(servers[0], userToken2, notifs)
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
})
})
@@ -144,7 +144,7 @@ describe('Test blocklist', function () {
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, server: servers[1].host })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken1, server: servers[1].host })
await waitJobs(servers)
})
@@ -157,7 +157,7 @@ describe('Test blocklist', function () {
await checkNotifications(servers[0], userToken2, notifs)
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
})
})
@@ -184,7 +184,7 @@ describe('Test blocklist', function () {
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToServerBlocklist({ account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.addToServerBlocklist({ account: 'user3@' + servers[1].host })
await waitJobs(servers)
})
@@ -192,7 +192,7 @@ describe('Test blocklist', function () {
await checkNotifications(servers[0], userToken1, [])
await checkNotifications(servers[0], userToken2, [])
- await servers[0].blocklistCommand.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
+ await servers[0].blocklist.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
})
})
@@ -219,7 +219,7 @@ describe('Test blocklist', function () {
it('Should block an account', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToServerBlocklist({ server: servers[1].host })
+ await servers[0].blocklist.addToServerBlocklist({ server: servers[1].host })
await waitJobs(servers)
})
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts
index 3c3b2d6fd..9a4a3b3b9 100644
--- a/server/tests/api/moderation/blocklist.ts
+++ b/server/tests/api/moderation/blocklist.ts
@@ -18,24 +18,24 @@ const expect = chai.expect
async function checkAllVideos (server: ServerInfo, token: string) {
{
- const { data } = await server.videosCommand.listWithToken({ token })
+ const { data } = await server.videos.listWithToken({ token })
expect(data).to.have.lengthOf(5)
}
{
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(5)
}
}
async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
const threads = data.filter(t => t.isDeleted === false)
expect(threads).to.have.lengthOf(2)
for (const thread of threads) {
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId: thread.id, token })
+ const tree = await server.comments.getThread({ videoId: videoUUID, threadId: thread.id, token })
expect(tree.children).to.have.lengthOf(1)
}
}
@@ -45,13 +45,13 @@ async function checkCommentNotification (
comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
check: 'presence' | 'absence'
) {
- const command = comment.server.commentsCommand
+ const command = comment.server.comments
const { threadId, createdAt } = await command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text })
await waitJobs([ mainServer, comment.server ])
- const { data } = await mainServer.notificationsCommand.list({ start: 0, count: 30 })
+ const { data } = await mainServer.notifications.list({ start: 0, count: 30 })
const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
@@ -80,44 +80,44 @@ describe('Test blocklist', function () {
servers = await flushAndRunMultipleServers(3)
await setAccessTokensToServers(servers)
- command = servers[0].blocklistCommand
- commentsCommand = servers.map(s => s.commentsCommand)
+ command = servers[0].blocklist
+ commentsCommand = servers.map(s => s.comments)
{
const user = { username: 'user1', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- userToken1 = await servers[0].loginCommand.getAccessToken(user)
- await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } })
+ userToken1 = await servers[0].login.getAccessToken(user)
+ await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
}
{
const user = { username: 'moderator', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- userModeratorToken = await servers[0].loginCommand.getAccessToken(user)
+ userModeratorToken = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user2', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
+ await servers[1].users.create({ username: user.username, password: user.password })
- userToken2 = await servers[1].loginCommand.getAccessToken(user)
- await servers[1].videosCommand.upload({ token: userToken2, attributes: { name: 'video user 2' } })
+ userToken2 = await servers[1].login.getAccessToken(user)
+ await servers[1].videos.upload({ token: userToken2, attributes: { name: 'video user 2' } })
}
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
videoUUID1 = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
videoUUID2 = uuid
}
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
videoUUID3 = uuid
}
@@ -159,7 +159,7 @@ describe('Test blocklist', function () {
})
it('Should hide its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(4)
@@ -172,7 +172,7 @@ describe('Test blocklist', function () {
})
it('Should hide its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(3)
@@ -289,12 +289,12 @@ describe('Test blocklist', function () {
// Server 1 and 3 should only have uploader comments
for (const server of [ servers[0], servers[2] ]) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
expect(data).to.have.lengthOf(1)
expect(data[0].text).to.equal('uploader')
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id })
+ const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
if (server.serverNumber === 1) expect(tree.children).to.have.lengthOf(0)
else expect(tree.children).to.have.lengthOf(1)
@@ -306,7 +306,7 @@ describe('Test blocklist', function () {
})
it('Should display its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(4)
const v = data.find(v => v.name === 'video user 2')
@@ -315,7 +315,7 @@ describe('Test blocklist', function () {
it('Should display its comments on my video', async function () {
for (const server of servers) {
- const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
+ const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
// Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment
if (server.serverNumber === 3) {
@@ -327,7 +327,7 @@ describe('Test blocklist', function () {
expect(data[0].text).to.equal('uploader')
expect(data[1].text).to.equal('comment user 2')
- const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id })
+ const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
expect(tree.children).to.have.lengthOf(1)
expect(tree.children[0].comment.text).to.equal('reply by user 2')
expect(tree.children[0].children).to.have.lengthOf(1)
@@ -378,7 +378,7 @@ describe('Test blocklist', function () {
})
it('Should hide its videos', async function () {
- const { data } = await servers[0].videosCommand.listWithToken()
+ const { data } = await servers[0].videos.listWithToken()
expect(data).to.have.lengthOf(3)
@@ -488,7 +488,7 @@ describe('Test blocklist', function () {
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
- const { data } = await servers[0].videosCommand.listWithToken({ token })
+ const { data } = await servers[0].videos.listWithToken({ token })
expect(data).to.have.lengthOf(4)
@@ -503,7 +503,7 @@ describe('Test blocklist', function () {
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
- const { data } = await servers[0].videosCommand.listWithToken({ token })
+ const { data } = await servers[0].videos.listWithToken({ token })
expect(data).to.have.lengthOf(3)
@@ -581,7 +581,7 @@ describe('Test blocklist', function () {
it('Should display its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
- const { data } = await servers[0].videosCommand.listWithToken({ token })
+ const { data } = await servers[0].videos.listWithToken({ token })
expect(data).to.have.lengthOf(4)
const v = data.find(v => v.name === 'video user 2')
@@ -639,8 +639,8 @@ describe('Test blocklist', function () {
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[0].accessToken ]) {
const requests = [
- servers[0].videosCommand.list(),
- servers[0].videosCommand.listWithToken({ token })
+ servers[0].videos.list(),
+ servers[0].videos.listWithToken({ token })
]
for (const req of requests) {
@@ -688,13 +688,13 @@ describe('Test blocklist', function () {
{
const now = new Date()
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[1].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
+ await servers[1].follows.follow({ targets: [ servers[0].host ] })
await waitJobs(servers)
- const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 })
+ const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
const commentNotifications = data.filter(n => {
return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
})
@@ -749,13 +749,13 @@ describe('Test blocklist', function () {
{
const now = new Date()
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[1].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- await servers[1].followsCommand.follow({ targets: [ servers[0].host ] })
+ await servers[1].follows.follow({ targets: [ servers[0].host ] })
await waitJobs(servers)
- const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 })
+ const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
const commentNotifications = data.filter(n => {
return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
})
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts
index 2f2e678e7..d23d23bcb 100644
--- a/server/tests/api/moderation/video-blacklist.ts
+++ b/server/tests/api/moderation/video-blacklist.ts
@@ -25,10 +25,10 @@ describe('Test video blacklist', function () {
let command: BlacklistCommand
async function blacklistVideosOnServer (server: ServerInfo) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
for (const video of data) {
- await server.blacklistCommand.add({ videoId: video.id, reason: 'super reason' })
+ await server.blacklist.add({ videoId: video.id, reason: 'super reason' })
}
}
@@ -45,13 +45,13 @@ describe('Test video blacklist', function () {
await doubleFollow(servers[0], servers[1])
// Upload 2 videos on server 2
- await servers[1].videosCommand.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } })
- await servers[1].videosCommand.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } })
+ await servers[1].videos.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } })
+ await servers[1].videos.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } })
// Wait videos propagation, server 2 has transcoding enabled
await waitJobs(servers)
- command = servers[0].blacklistCommand
+ command = servers[0].blacklist
// Blacklist the two videos on server 1
await blacklistVideosOnServer(servers[0])
@@ -61,7 +61,7 @@ describe('Test video blacklist', function () {
it('Should not have the video blacklisted in videos list/search 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.be.an('array')
@@ -69,7 +69,7 @@ describe('Test video blacklist', function () {
}
{
- const body = await servers[0].searchCommand.searchVideos({ search: 'video' })
+ const body = await servers[0].search.searchVideos({ search: 'video' })
expect(body.total).to.equal(0)
expect(body.data).to.be.an('array')
@@ -79,7 +79,7 @@ describe('Test video blacklist', function () {
it('Should have the blacklisted video in videos list/search 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(2)
expect(data).to.be.an('array')
@@ -87,7 +87,7 @@ describe('Test video blacklist', function () {
}
{
- const body = await servers[1].searchCommand.searchVideos({ search: 'video' })
+ const body = await servers[1].search.searchVideos({ search: 'video' })
expect(body.total).to.equal(2)
expect(body.data).to.be.an('array')
@@ -181,7 +181,7 @@ describe('Test video blacklist', function () {
it('Should display blacklisted videos', async function () {
await blacklistVideosOnServer(servers[1])
- const { total, data } = await servers[1].videosCommand.listMyVideos()
+ const { total, data } = await servers[1].videos.listMyVideos()
expect(total).to.equal(2)
expect(data).to.have.lengthOf(2)
@@ -198,7 +198,7 @@ describe('Test video blacklist', function () {
let blacklist = []
it('Should not have any video in videos list 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.be.an('array')
expect(data.length).to.equal(0)
@@ -215,7 +215,7 @@ describe('Test video blacklist', function () {
})
it('Should have the ex-blacklisted video in videos list 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(1)
expect(data).to.be.an('array')
@@ -244,11 +244,11 @@ describe('Test video blacklist', function () {
this.timeout(10000)
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 3' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 3' } })
video3UUID = uuid
}
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 4' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 4' } })
video4UUID = uuid
}
@@ -263,12 +263,12 @@ describe('Test video blacklist', function () {
await waitJobs(servers)
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data.find(v => v.uuid === video3UUID)).to.be.undefined
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
expect(data.find(v => v.uuid === video3UUID)).to.not.be.undefined
}
})
@@ -281,7 +281,7 @@ describe('Test video blacklist', function () {
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
}
})
@@ -289,12 +289,12 @@ describe('Test video blacklist', function () {
it('Should have the video unfederated even after an Update AP message', async function () {
this.timeout(10000)
- await servers[0].videosCommand.update({ id: video4UUID, attributes: { description: 'super description' } })
+ await servers[0].videos.update({ id: video4UUID, attributes: { description: 'super description' } })
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
}
})
@@ -318,7 +318,7 @@ describe('Test video blacklist', function () {
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined
}
})
@@ -348,36 +348,36 @@ describe('Test video blacklist', function () {
{
const user = { username: 'user_without_flag', password: 'password' }
- await servers[0].usersCommand.create({
+ await servers[0].users.create({
username: user.username,
adminFlags: UserAdminFlag.NONE,
password: user.password,
role: UserRole.USER
})
- userWithoutFlag = await servers[0].loginCommand.getAccessToken(user)
+ userWithoutFlag = await servers[0].login.getAccessToken(user)
- const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: userWithoutFlag })
+ const { videoChannels } = await servers[0].users.getMyInfo({ token: userWithoutFlag })
channelOfUserWithoutFlag = videoChannels[0].id
}
{
const user = { username: 'user_with_flag', password: 'password' }
- await servers[0].usersCommand.create({
+ await servers[0].users.create({
username: user.username,
adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST,
password: user.password,
role: UserRole.USER
})
- userWithFlag = await servers[0].loginCommand.getAccessToken(user)
+ userWithFlag = await servers[0].login.getAccessToken(user)
}
await waitJobs(servers)
})
it('Should auto blacklist a video on upload', async function () {
- await servers[0].videosCommand.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } })
+ await servers[0].videos.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } })
const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(1)
@@ -392,7 +392,7 @@ describe('Test video blacklist', function () {
name: 'URL import',
channelId: channelOfUserWithoutFlag
}
- await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes })
+ await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(2)
@@ -405,7 +405,7 @@ describe('Test video blacklist', function () {
name: 'Torrent import',
channelId: channelOfUserWithoutFlag
}
- await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes })
+ await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(3)
@@ -413,7 +413,7 @@ describe('Test video blacklist', function () {
})
it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () {
- await servers[0].videosCommand.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } })
+ await servers[0].videos.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } })
const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
expect(body.total).to.equal(3)
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts
index 03fbe0b70..5a5bdb0c8 100644
--- a/server/tests/api/notifications/admin-notifications.ts
+++ b/server/tests/api/notifications/admin-notifications.ts
@@ -58,8 +58,8 @@ describe('Test admin notifications', function () {
token: server.accessToken
}
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' })
- await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
+ await server.plugins.install({ npmName: 'peertube-plugin-hello-world' })
+ await server.plugins.install({ npmName: 'peertube-theme-background-red' })
})
describe('Latest PeerTube version notification', function () {
@@ -118,8 +118,8 @@ describe('Test admin notifications', function () {
it('Should send a notification to admins on new plugin version', async function () {
this.timeout(30000)
- await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
- await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1')
+ await server.sql.setPluginVersion('hello-world', '0.0.1')
+ await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
await wait(6000)
await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence')
@@ -140,8 +140,8 @@ describe('Test admin notifications', function () {
it('Should send a new notification after a new plugin release', async function () {
this.timeout(30000)
- await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
- await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1')
+ await server.sql.setPluginVersion('hello-world', '0.0.1')
+ await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
await wait(6000)
expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index a74b38e8a..133b6340f 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -52,9 +52,9 @@ describe('Test comments notifications', function () {
it('Should not send a new comment notification after a comment on another video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
@@ -64,9 +64,9 @@ describe('Test comments notifications', function () {
it('Should not send a new comment notification if I comment my own video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
@@ -76,25 +76,25 @@ describe('Test comments notifications', function () {
it('Should not send a new comment notification if the account is muted', async function () {
this.timeout(20000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
})
it('Should send a new comment notification after a local comment on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
const commentId = created.id
await waitJobs(servers)
@@ -104,15 +104,15 @@ describe('Test comments notifications', function () {
it('Should send a new comment notification after a remote comment on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
await waitJobs(servers)
- await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
await waitJobs(servers)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
+ const { data } = await servers[0].comments.listThreads({ videoId: uuid })
expect(data).to.have.lengthOf(1)
const commentId = data[0].id
@@ -122,11 +122,11 @@ describe('Test comments notifications', function () {
it('Should send a new comment notification after a local reply on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
- const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
+ const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
await waitJobs(servers)
await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
@@ -135,22 +135,22 @@ describe('Test comments notifications', function () {
it('Should send a new comment notification after a remote reply on my video', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
await waitJobs(servers)
{
- const created = await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ const created = await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
const threadId = created.id
- await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
+ await servers[1].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
}
await waitJobs(servers)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
+ const { data } = await servers[0].comments.listThreads({ videoId: uuid })
expect(data).to.have.lengthOf(1)
const threadId = data[0].id
- const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId })
+ const tree = await servers[0].comments.getThread({ videoId: uuid, threadId })
expect(tree.children).to.have.lengthOf(1)
const commentId = tree.children[0].comment.id
@@ -161,9 +161,9 @@ describe('Test comments notifications', function () {
it('Should convert markdown in comment to html', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'cool video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'cool video' } })
- await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText })
+ await servers[0].comments.createThread({ videoId: uuid, text: commentText })
await waitJobs(servers)
@@ -183,16 +183,16 @@ describe('Test comments notifications', function () {
token: userToken
}
- await servers[0].usersCommand.updateMe({ displayName: 'super root name' })
- await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' })
+ await servers[0].users.updateMe({ displayName: 'super root name' })
+ await servers[1].users.updateMe({ displayName: 'super root 2 name' })
})
it('Should not send a new mention comment notification if I mention the video owner', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
- const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
+ const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -201,9 +201,9 @@ describe('Test comments notifications', function () {
it('Should not send a new mention comment notification if I mention myself', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
+ const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -212,25 +212,25 @@ describe('Test comments notifications', function () {
it('Should not send a new mention notification if the account is muted', async function () {
this.timeout(10000)
- await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
+ const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
- await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' })
+ await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
})
it('Should not send a new mention notification if the remote account mention a local account', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
await waitJobs(servers)
- const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' })
+ const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence')
@@ -239,14 +239,14 @@ describe('Test comments notifications', function () {
it('Should send a new mention notification after local comments', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
+ const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
- const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
+ const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
await waitJobs(servers)
await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
@@ -255,27 +255,27 @@ describe('Test comments notifications', function () {
it('Should send a new mention notification after remote comments', async function () {
this.timeout(20000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
await waitJobs(servers)
const text1 = `hello @user_1@localhost:${servers[0].port} 1`
- const { id: server2ThreadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: text1 })
+ const { id: server2ThreadId } = await servers[1].comments.createThread({ videoId: uuid, text: text1 })
await waitJobs(servers)
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid })
+ const { data } = await servers[0].comments.listThreads({ videoId: uuid })
expect(data).to.have.lengthOf(1)
const server1ThreadId = data[0].id
await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
- await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
+ await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
await waitJobs(servers)
- const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId: server1ThreadId })
+ const tree = await servers[0].comments.getThread({ videoId: uuid, threadId: server1ThreadId })
expect(tree.children).to.have.lengthOf(1)
const commentId = tree.children[0].comment.id
@@ -286,11 +286,11 @@ describe('Test comments notifications', function () {
it('Should convert markdown in comment to html', async function () {
this.timeout(10000)
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
- const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' })
+ const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello 1' })
- await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
+ await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
await waitJobs(servers)
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 91a2b4fa5..e7c5badd2 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -62,9 +62,9 @@ describe('Test moderation notifications', function () {
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' })
+ await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -74,12 +74,12 @@ describe('Test moderation notifications', function () {
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
await waitJobs(servers)
- const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid })
- await servers[1].abusesCommand.report({ videoId, reason: 'super reason' })
+ const videoId = await servers[1].videos.getId({ uuid: video.uuid })
+ await servers[1].abuses.report({ videoId, reason: 'super reason' })
await waitJobs(servers)
await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -89,8 +89,8 @@ describe('Test moderation notifications', function () {
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
- const comment = await servers[0].commentsCommand.createThread({
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
+ const comment = await servers[0].comments.createThread({
token: userAccessToken,
videoId: video.id,
text: 'comment abuse ' + buildUUID()
@@ -98,7 +98,7 @@ describe('Test moderation notifications', function () {
await waitJobs(servers)
- await servers[0].abusesCommand.report({ commentId: comment.id, reason: 'super reason' })
+ await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -108,9 +108,9 @@ describe('Test moderation notifications', function () {
this.timeout(20000)
const name = 'video for abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].commentsCommand.createThread({
+ await servers[0].comments.createThread({
token: userAccessToken,
videoId: video.id,
text: 'comment abuse ' + buildUUID()
@@ -118,9 +118,9 @@ describe('Test moderation notifications', function () {
await waitJobs(servers)
- const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid })
+ const { data } = await servers[1].comments.listThreads({ videoId: video.uuid })
const commentId = data[0].id
- await servers[1].abusesCommand.report({ commentId, reason: 'super reason' })
+ await servers[1].abuses.report({ commentId, reason: 'super reason' })
await waitJobs(servers)
await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -130,10 +130,10 @@ describe('Test moderation notifications', function () {
this.timeout(20000)
const username = 'user' + new Date().getTime()
- const { account } = await servers[0].usersCommand.create({ username, password: 'donald' })
+ const { account } = await servers[0].users.create({ username, password: 'donald' })
const accountId = account.id
- await servers[0].abusesCommand.report({ accountId, reason: 'super reason' })
+ await servers[0].abuses.report({ accountId, reason: 'super reason' })
await waitJobs(servers)
await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
@@ -143,13 +143,13 @@ describe('Test moderation notifications', function () {
this.timeout(20000)
const username = 'user' + new Date().getTime()
- const tmpToken = await servers[0].usersCommand.generateUserAndToken(username)
- await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } })
+ const tmpToken = await servers[0].users.generateUserAndToken(username)
+ await servers[0].videos.upload({ token: tmpToken, attributes: { name: 'super video' } })
await waitJobs(servers)
- const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host })
- await servers[1].abusesCommand.report({ accountId: account.id, reason: 'super reason' })
+ const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host })
+ await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' })
await waitJobs(servers)
await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
@@ -169,16 +169,16 @@ describe('Test moderation notifications', function () {
}
const name = 'abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
+ const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
abuseId = body.abuse.id
})
it('Should send a notification to reporter if the abuse has been accepted', async function () {
this.timeout(10000)
- await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
+ await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
await waitJobs(servers)
await checkAbuseStateChange(baseParams, abuseId, AbuseState.ACCEPTED, 'presence')
@@ -187,7 +187,7 @@ describe('Test moderation notifications', function () {
it('Should send a notification to reporter if the abuse has been rejected', async function () {
this.timeout(10000)
- await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.REJECTED } })
+ await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } })
await waitJobs(servers)
await checkAbuseStateChange(baseParams, abuseId, AbuseState.REJECTED, 'presence')
@@ -216,15 +216,15 @@ describe('Test moderation notifications', function () {
}
const name = 'abuse ' + buildUUID()
- const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
{
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
+ const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
abuseId = body.abuse.id
}
{
- const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
+ const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
abuseId2 = body.abuse.id
}
})
@@ -233,7 +233,7 @@ describe('Test moderation notifications', function () {
this.timeout(10000)
const message = 'my super message to users'
- await servers[0].abusesCommand.addMessage({ abuseId, message })
+ await servers[0].abuses.addMessage({ abuseId, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsUser, abuseId, message, 'user_1@example.com', 'presence')
@@ -243,7 +243,7 @@ describe('Test moderation notifications', function () {
this.timeout(10000)
const message = 'my super message that should not be sent to the admin'
- await servers[0].abusesCommand.addMessage({ abuseId, message })
+ await servers[0].abuses.addMessage({ abuseId, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence')
@@ -253,7 +253,7 @@ describe('Test moderation notifications', function () {
this.timeout(10000)
const message = 'my super message to moderators'
- await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
+ await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence')
@@ -263,7 +263,7 @@ describe('Test moderation notifications', function () {
this.timeout(10000)
const message = 'my super message that should not be sent to reporter'
- await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
+ await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
await waitJobs(servers)
await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence')
@@ -286,9 +286,9 @@ describe('Test moderation notifications', function () {
this.timeout(10000)
const name = 'video for abuse ' + buildUUID()
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].blacklistCommand.add({ videoId: uuid })
+ await servers[0].blacklist.add({ videoId: uuid })
await waitJobs(servers)
await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
@@ -298,12 +298,12 @@ describe('Test moderation notifications', function () {
this.timeout(10000)
const name = 'video for abuse ' + buildUUID()
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
- await servers[0].blacklistCommand.add({ videoId: uuid })
+ await servers[0].blacklist.add({ videoId: uuid })
await waitJobs(servers)
- await servers[0].blacklistCommand.remove({ videoId: uuid })
+ await servers[0].blacklist.remove({ videoId: uuid })
await waitJobs(servers)
await wait(500)
@@ -326,7 +326,7 @@ describe('Test moderation notifications', function () {
it('Should send a notification only to moderators when a user registers on the instance', async function () {
this.timeout(10000)
- await servers[0].usersCommand.register({ username: 'user_45' })
+ await servers[0].users.register({ username: 'user_45' })
await waitJobs(servers)
@@ -368,7 +368,7 @@ describe('Test moderation notifications', function () {
it('Should send a notification only to admin when there is a new instance follower', async function () {
this.timeout(20000)
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
@@ -381,7 +381,7 @@ describe('Test moderation notifications', function () {
it('Should send a notification on auto follow back', async function () {
this.timeout(40000)
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[2].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
const config = {
@@ -391,9 +391,9 @@ describe('Test moderation notifications', function () {
}
}
}
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
@@ -405,16 +405,16 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
config.followings.instance.autoFollowBack.enabled = false
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
- await servers[0].followsCommand.unfollow({ target: servers[2] })
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
+ await servers[0].follows.unfollow({ target: servers[2] })
+ await servers[2].follows.unfollow({ target: servers[0] })
})
it('Should send a notification on auto instances index follow', async function () {
this.timeout(30000)
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].follows.unfollow({ target: servers[1] })
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
@@ -424,8 +424,8 @@ describe('Test moderation notifications', function () {
await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
config.followings.instance.autoFollowIndex.enabled = false
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
+ await servers[0].follows.unfollow({ target: servers[1] })
})
})
@@ -460,7 +460,7 @@ describe('Test moderation notifications', function () {
token: userAccessToken
}
- currentCustomConfig = await servers[0].configCommand.getCustomConfig()
+ currentCustomConfig = await servers[0].config.getCustomConfig()
const autoBlacklistTestsCustomConfig = {
...currentCustomConfig,
@@ -476,10 +476,10 @@ describe('Test moderation notifications', function () {
// enable transcoding otherwise own publish notification after transcoding not expected
autoBlacklistTestsCustomConfig.transcoding.enabled = true
- await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
+ await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
- await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
- await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
})
@@ -487,7 +487,7 @@ describe('Test moderation notifications', function () {
this.timeout(40000)
videoName = 'video with auto-blacklist ' + buildUUID()
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } })
videoUUID = uuid
await waitJobs(servers)
@@ -509,7 +509,7 @@ describe('Test moderation notifications', function () {
it('Should send video published and unblacklist after video unblacklisted', async function () {
this.timeout(40000)
- await servers[0].blacklistCommand.remove({ videoId: videoUUID })
+ await servers[0].blacklist.remove({ videoId: videoUUID })
await waitJobs(servers)
@@ -543,9 +543,9 @@ describe('Test moderation notifications', function () {
}
}
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
- await servers[0].blacklistCommand.remove({ videoId: uuid })
+ await servers[0].blacklist.remove({ videoId: uuid })
await waitJobs(servers)
await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
@@ -575,7 +575,7 @@ describe('Test moderation notifications', function () {
}
}
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
await wait(6000)
await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
@@ -589,17 +589,17 @@ describe('Test moderation notifications', function () {
const name = 'video without auto-blacklist ' + buildUUID()
// admin with blacklist right will not be auto-blacklisted
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name } })
await waitJobs(servers)
await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence')
})
after(async () => {
- await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig })
+ await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig })
- await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
- await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
})
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index 41e1b8015..647d783b5 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -31,10 +31,10 @@ describe('Test notifications API', function () {
userNotifications = res.userNotifications
server = res.servers[0]
- await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
+ await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
for (let i = 0; i < 10; i++) {
- await server.videosCommand.randomUpload({ wait: false })
+ await server.videos.randomUpload({ wait: false })
}
await waitJobs([ server ])
@@ -43,14 +43,14 @@ describe('Test notifications API', function () {
describe('Mark as read', function () {
it('Should mark as read some notifications', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 2, count: 3 })
+ const { data } = await server.notifications.list({ token: userToken, start: 2, count: 3 })
const ids = data.map(n => n.id)
- await server.notificationsCommand.markAsRead({ token: userToken, ids })
+ await server.notifications.markAsRead({ token: userToken, ids })
})
it('Should have the notifications marked as read', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10 })
+ const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10 })
expect(data[0].read).to.be.false
expect(data[1].read).to.be.false
@@ -61,7 +61,7 @@ describe('Test notifications API', function () {
})
it('Should only list read notifications', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: false })
+ const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: false })
for (const notification of data) {
expect(notification.read).to.be.true
@@ -69,7 +69,7 @@ describe('Test notifications API', function () {
})
it('Should only list unread notifications', async function () {
- const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true })
+ const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
for (const notification of data) {
expect(notification.read).to.be.false
@@ -77,9 +77,9 @@ describe('Test notifications API', function () {
})
it('Should mark as read all notifications', async function () {
- await server.notificationsCommand.markAsReadAll({ token: userToken })
+ await server.notifications.markAsReadAll({ token: userToken })
- const body = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true })
+ const body = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
expect(body.total).to.equal(0)
expect(body.data).to.have.lengthOf(0)
@@ -101,17 +101,17 @@ describe('Test notifications API', function () {
it('Should not have notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE }
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
const check = { web: true, mail: true }
await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
@@ -120,17 +120,17 @@ describe('Test notifications API', function () {
it('Should only have web notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB }
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
{
const check = { mail: true, web: false }
@@ -146,17 +146,17 @@ describe('Test notifications API', function () {
it('Should only have mail notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL }
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
{
const check = { mail: false, web: true }
@@ -172,7 +172,7 @@ describe('Test notifications API', function () {
it('Should have email and web notifications', async function () {
this.timeout(20000)
- await server.notificationsCommand.updateMySettings({
+ await server.notifications.updateMySettings({
token: userToken,
settings: {
...getAllNotificationsSettings(),
@@ -181,13 +181,13 @@ describe('Test notifications API', function () {
})
{
- const info = await server.usersCommand.getMyInfo({ token: userToken })
+ const info = await server.users.getMyInfo({ token: userToken })
expect(info.notificationSettings.newVideoFromSubscription).to.equal(
UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
)
}
- const { name, uuid } = await server.videosCommand.randomUpload()
+ const { name, uuid } = await server.videos.randomUpload()
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
})
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 4db8c1576..53f8c7594 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -61,7 +61,7 @@ describe('Test user notifications', function () {
await uploadRandomVideoOnServers(servers, 1)
- const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken })
+ const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
expect(notification).to.be.undefined
expect(emails).to.have.lengthOf(0)
@@ -71,7 +71,7 @@ describe('Test user notifications', function () {
it('Should send a new video notification if the user follows the local video publisher', async function () {
this.timeout(15000)
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
await waitJobs(servers)
const { name, uuid } = await uploadRandomVideoOnServers(servers, 1)
@@ -81,7 +81,7 @@ describe('Test user notifications', function () {
it('Should send a new video notification from a remote account', async function () {
this.timeout(150000) // Server 2 has transcoding enabled
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
await waitJobs(servers)
const { name, uuid } = await uploadRandomVideoOnServers(servers, 2)
@@ -153,7 +153,7 @@ describe('Test user notifications', function () {
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
- await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -167,7 +167,7 @@ describe('Test user notifications', function () {
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
- await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -179,7 +179,7 @@ describe('Test user notifications', function () {
const data = { privacy: VideoPrivacy.PRIVATE }
const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
- await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
+ await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
})
@@ -190,7 +190,7 @@ describe('Test user notifications', function () {
const data = { privacy: VideoPrivacy.PRIVATE }
const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
- await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
+ await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
await waitJobs(servers)
await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
@@ -207,7 +207,7 @@ describe('Test user notifications', function () {
privacy: VideoPrivacy.PUBLIC,
targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
@@ -242,7 +242,7 @@ describe('Test user notifications', function () {
await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false })
await waitJobs(servers)
- const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken })
+ const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
if (notification) {
expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED)
}
@@ -278,7 +278,7 @@ describe('Test user notifications', function () {
targetUrl: ImportsCommand.getGoodVideoUrl(),
waitTranscoding: true
}
- const { video } = await servers[1].importsCommand.importVideo({ attributes })
+ const { video } = await servers[1].imports.importVideo({ attributes })
await waitJobs(servers)
await checkVideoIsPublished(baseParams, name, video.uuid, 'presence')
@@ -345,7 +345,7 @@ describe('Test user notifications', function () {
privacy: VideoPrivacy.PRIVATE,
targetUrl: ImportsCommand.getBadVideoUrl()
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
@@ -362,7 +362,7 @@ describe('Test user notifications', function () {
privacy: VideoPrivacy.PRIVATE,
targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const { video } = await servers[0].importsCommand.importVideo({ attributes })
+ const { video } = await servers[0].imports.importVideo({ attributes })
await waitJobs(servers)
await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
@@ -382,16 +382,16 @@ describe('Test user notifications', function () {
token: userAccessToken
}
- await servers[0].usersCommand.updateMe({ displayName: 'super root name' })
+ await servers[0].users.updateMe({ displayName: 'super root name' })
- await servers[0].usersCommand.updateMe({
+ await servers[0].users.updateMe({
token: userAccessToken,
displayName: myUserName
})
- await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' })
+ await servers[1].users.updateMe({ displayName: 'super root 2 name' })
- await servers[0].channelsCommand.update({
+ await servers[0].channels.update({
token: userAccessToken,
channelName: 'user_1_channel',
attributes: { displayName: myChannelName }
@@ -401,23 +401,23 @@ describe('Test user notifications', function () {
it('Should notify when a local channel is following one of our channel', async function () {
this.timeout(50000)
- await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
await waitJobs(servers)
await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
- await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
it('Should notify when a remote channel is following one of our channel', async function () {
this.timeout(50000)
- await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
await waitJobs(servers)
await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
- await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
+ await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
})
// PeerTube does not support accout -> account follows
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts
index efb60dc56..e193b968e 100644
--- a/server/tests/api/redundancy/manage-redundancy.ts
+++ b/server/tests/api/redundancy/manage-redundancy.ts
@@ -53,15 +53,15 @@ describe('Test manage videos redundancy', function () {
// Get the access tokens
await setAccessTokensToServers(servers)
- commands = servers.map(s => s.redundancyCommand)
+ commands = servers.map(s => s.redundancy)
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
video1Server2UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2' } })
video2Server2UUID = uuid
}
@@ -87,7 +87,7 @@ describe('Test manage videos redundancy', function () {
this.timeout(120000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 10)
+ await servers[0].servers.waitUntilLog('Duplicated ', 10)
await waitJobs(servers)
const body = await commands[1].listVideos({ target: 'remote-videos' })
@@ -203,14 +203,14 @@ describe('Test manage videos redundancy', function () {
it('Should manually add a redundancy and list it', async function () {
this.timeout(120000)
- const uuid = (await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
+ const uuid = (await servers[1].videos.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
await waitJobs(servers)
- const videoId = await servers[0].videosCommand.getId({ uuid })
+ const videoId = await servers[0].videos.getId({ uuid })
await commands[0].addVideo({ videoId })
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 15)
+ await servers[0].servers.waitUntilLog('Duplicated ', 15)
await waitJobs(servers)
{
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index b3f6ed160..0378cc122 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -36,21 +36,21 @@ describe('Test redundancy constraints', function () {
async function uploadWrapper (videoName: string) {
// Wait for transcoding
- const { id } = await localServer.videosCommand.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } })
+ const { id } = await localServer.videos.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } })
await waitJobs([ localServer ])
// Update video to schedule a federation
- await localServer.videosCommand.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } })
+ await localServer.videos.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } })
}
async function getTotalRedundanciesLocalServer () {
- const body = await localServer.redundancyCommand.listVideos({ target: 'my-videos' })
+ const body = await localServer.redundancy.listVideos({ target: 'my-videos' })
return body.total
}
async function getTotalRedundanciesRemoteServer () {
- const body = await remoteServer.redundancyCommand.listVideos({ target: 'remote-videos' })
+ const body = await remoteServer.redundancy.listVideos({ target: 'remote-videos' })
return body.total
}
@@ -78,14 +78,14 @@ describe('Test redundancy constraints', function () {
// Get the access tokens
await setAccessTokensToServers(servers)
- await localServer.videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ await localServer.videos.upload({ attributes: { name: 'video 1 server 2' } })
await waitJobs(servers)
// Server 1 and server 2 follow each other
- await remoteServer.followsCommand.follow({ targets: [ localServer.url ] })
+ await remoteServer.follows.follow({ targets: [ localServer.url ] })
await waitJobs(servers)
- await remoteServer.redundancyCommand.updateRedundancy({ host: localServer.host, redundancyAllowed: true })
+ await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true })
await waitJobs(servers)
})
@@ -94,7 +94,7 @@ describe('Test redundancy constraints', function () {
this.timeout(120000)
await waitJobs(servers)
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
{
@@ -123,7 +123,7 @@ describe('Test redundancy constraints', function () {
await uploadWrapper('video 2 server 2')
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 10)
await waitJobs(servers)
{
@@ -152,7 +152,7 @@ describe('Test redundancy constraints', function () {
await uploadWrapper('video 3 server 2')
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 15)
await waitJobs(servers)
{
@@ -169,11 +169,11 @@ describe('Test redundancy constraints', function () {
it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
this.timeout(120000)
- await localServer.followsCommand.follow({ targets: [ remoteServer.url ] })
+ await localServer.follows.follow({ targets: [ remoteServer.url ] })
await waitJobs(servers)
await uploadWrapper('video 4 server 2')
- await remoteServer.serversCommand.waitUntilLog('Duplicated ', 20)
+ await remoteServer.servers.waitUntilLog('Duplicated ', 20)
await waitJobs(servers)
{
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 6ca9c9303..77ea2278e 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -78,11 +78,11 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
await setAccessTokensToServers(servers)
{
- const { uuid, id } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ const { uuid, id } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
video1Server2UUID = uuid
video1Server2Id = id
- await servers[1].videosCommand.view({ id: video1Server2UUID })
+ await servers[1].videos.view({ id: video1Server2UUID })
}
await waitJobs(servers)
@@ -106,7 +106,7 @@ async function check1WebSeed (videoUUID?: string) {
for (const server of servers) {
// With token to avoid issues with video follow constraints
- const video = await server.videosCommand.getWithToken({ id: videoUUID })
+ const video = await server.videos.getWithToken({ id: videoUUID })
for (const f of video.files) {
checkMagnetWebseeds(f, webseeds, server)
@@ -123,7 +123,7 @@ async function check2Webseeds (videoUUID?: string) {
]
for (const server of servers) {
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
for (const file of video.files) {
checkMagnetWebseeds(file, webseeds, server)
@@ -163,7 +163,7 @@ async function check0PlaylistRedundancies (videoUUID?: string) {
for (const server of servers) {
// With token to avoid issues with video follow constraints
- const video = await server.videosCommand.getWithToken({ id: videoUUID })
+ const video = await server.videos.getWithToken({ id: videoUUID })
expect(video.streamingPlaylists).to.be.an('array')
expect(video.streamingPlaylists).to.have.lengthOf(1)
@@ -175,7 +175,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
if (!videoUUID) videoUUID = video1Server2UUID
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)
expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1)
@@ -188,7 +188,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls'
const baseUrlSegment = servers[0].url + '/static/redundancy/hls'
- const video = await servers[0].videosCommand.get({ id: videoUUID })
+ const video = await servers[0].videos.get({ id: videoUUID })
const hlsPlaylist = video.streamingPlaylists[0]
for (const resolution of [ 240, 360, 480, 720 ]) {
@@ -221,7 +221,7 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
statsLength = 2
}
- const data = await servers[0].statsCommand.get()
+ const data = await servers[0].stats.get()
expect(data.videosRedundancy).to.have.lengthOf(statsLength)
const stat = data.videosRedundancy[0]
@@ -248,7 +248,7 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit
}
async function findServerFollows () {
- const body = await servers[0].followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
+ const body = await servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
const follows = body.data
const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
@@ -257,7 +257,7 @@ async function findServerFollows () {
}
async function enableRedundancyOnServer1 () {
- await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: true })
+ await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: true })
const { server2, server3 } = await findServerFollows()
@@ -269,7 +269,7 @@ async function enableRedundancyOnServer1 () {
}
async function disableRedundancyOnServer1 () {
- await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: false })
+ await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: false })
const { server2, server3 } = await findServerFollows()
@@ -305,7 +305,7 @@ describe('Test videos redundancy', function () {
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
@@ -355,7 +355,7 @@ describe('Test videos redundancy', function () {
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
@@ -366,7 +366,7 @@ describe('Test videos redundancy', function () {
it('Should unfollow on server 1 and remove duplicated videos', async function () {
this.timeout(80000)
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].follows.unfollow({ target: servers[1] })
await waitJobs(servers)
await wait(5000)
@@ -416,8 +416,8 @@ describe('Test videos redundancy', function () {
it('Should view 2 times the first video to have > min_views config', async function () {
this.timeout(80000)
- await servers[0].videosCommand.view({ id: video1Server2UUID })
- await servers[2].videosCommand.view({ id: video1Server2UUID })
+ await servers[0].videos.view({ id: video1Server2UUID })
+ await servers[2].videos.view({ id: video1Server2UUID })
await wait(10000)
await waitJobs(servers)
@@ -427,7 +427,7 @@ describe('Test videos redundancy', function () {
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
@@ -438,7 +438,7 @@ describe('Test videos redundancy', function () {
it('Should remove the video and the redundancy files', async function () {
this.timeout(20000)
- await servers[1].videosCommand.remove({ id: video1Server2UUID })
+ await servers[1].videos.remove({ id: video1Server2UUID })
await waitJobs(servers)
@@ -484,14 +484,14 @@ describe('Test videos redundancy', function () {
it('Should have 1 redundancy on the first video', async function () {
this.timeout(160000)
- await servers[0].videosCommand.view({ id: video1Server2UUID })
- await servers[2].videosCommand.view({ id: video1Server2UUID })
+ await servers[0].videos.view({ id: video1Server2UUID })
+ await servers[2].videos.view({ id: video1Server2UUID })
await wait(10000)
await waitJobs(servers)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 1)
+ await servers[0].servers.waitUntilLog('Duplicated ', 1)
await waitJobs(servers)
await check1PlaylistRedundancies()
@@ -501,7 +501,7 @@ describe('Test videos redundancy', function () {
it('Should remove the video and the redundancy files', async function () {
this.timeout(20000)
- await servers[1].videosCommand.remove({ id: video1Server2UUID })
+ await servers[1].videos.remove({ id: video1Server2UUID })
await waitJobs(servers)
@@ -529,14 +529,14 @@ describe('Test videos redundancy', function () {
})
it('Should create a redundancy on first video', async function () {
- await servers[0].redundancyCommand.addVideo({ videoId: video1Server2Id })
+ await servers[0].redundancy.addVideo({ videoId: video1Server2Id })
})
it('Should have 2 webseeds on the first video', async function () {
this.timeout(80000)
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds()
@@ -547,7 +547,7 @@ describe('Test videos redundancy', function () {
it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () {
this.timeout(80000)
- const body = await servers[0].redundancyCommand.listVideos({ target: 'remote-videos' })
+ const body = await servers[0].redundancy.listVideos({ target: 'remote-videos' })
const videos = body.data
expect(videos).to.have.lengthOf(1)
@@ -555,7 +555,7 @@ describe('Test videos redundancy', function () {
const video = videos[0]
for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) {
- await servers[0].redundancyCommand.removeVideo({ redundancyId: r.id })
+ await servers[0].redundancy.removeVideo({ redundancyId: r.id })
}
await waitJobs(servers)
@@ -577,7 +577,7 @@ describe('Test videos redundancy', function () {
async function checkContains (servers: ServerInfo[], str: string) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: video1Server2UUID })
+ const video = await server.videos.get({ id: video1Server2UUID })
for (const f of video.files) {
expect(f.magnetUri).to.contain(str)
@@ -587,7 +587,7 @@ describe('Test videos redundancy', function () {
async function checkNotContains (servers: ServerInfo[], str: string) {
for (const server of servers) {
- const video = await server.videosCommand.get({ id: video1Server2UUID })
+ const video = await server.videos.get({ id: video1Server2UUID })
for (const f of video.files) {
expect(f.magnetUri).to.not.contain(str)
@@ -645,20 +645,20 @@ describe('Test videos redundancy', function () {
await enableRedundancyOnServer1()
await waitJobs(servers)
- await servers[0].serversCommand.waitUntilLog('Duplicated ', 5)
+ await servers[0].servers.waitUntilLog('Duplicated ', 5)
await waitJobs(servers)
await check2Webseeds(video1Server2UUID)
await check1PlaylistRedundancies(video1Server2UUID)
await checkStatsWith1Redundancy(strategy)
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } })
video2Server2UUID = uuid
// Wait transcoding before federation
await waitJobs(servers)
- await servers[1].videosCommand.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } })
+ await servers[1].videos.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } })
})
it('Should cache video 2 webseeds on the first video', async function () {
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index 75794402d..71e9367e5 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -30,34 +30,34 @@ describe('Test ActivityPub video channels search', function () {
await setAccessTokensToServers(servers)
{
- await servers[0].usersCommand.create({ username: 'user1_server1', password: 'password' })
+ await servers[0].users.create({ username: 'user1_server1', password: 'password' })
const channel = {
name: 'channel1_server1',
displayName: 'Channel 1 server 1'
}
- await servers[0].channelsCommand.create({ attributes: channel })
+ await servers[0].channels.create({ attributes: channel })
}
{
const user = { username: 'user1_server2', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
- userServer2Token = await servers[1].loginCommand.getAccessToken(user)
+ await servers[1].users.create({ username: user.username, password: user.password })
+ userServer2Token = await servers[1].login.getAccessToken(user)
const channel = {
name: 'channel1_server2',
displayName: 'Channel 1 server 2'
}
- const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel })
+ const created = await servers[1].channels.create({ token: userServer2Token, attributes: channel })
channelIdServer2 = created.id
const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 }
- const { uuid } = await servers[1].videosCommand.upload({ token: userServer2Token, attributes })
+ const { uuid } = await servers[1].videos.upload({ token: userServer2Token, attributes })
videoServer2UUID = uuid
}
await waitJobs(servers)
- command = servers[0].searchCommand
+ command = servers[0].search
})
it('Should not find a remote video channel', async function () {
@@ -134,7 +134,7 @@ describe('Test ActivityPub video channels search', function () {
})
it('Should not list this remote video channel', async function () {
- const body = await servers[0].channelsCommand.list()
+ const body = await servers[0].channels.list()
expect(body.total).to.equal(3)
expect(body.data).to.have.lengthOf(3)
expect(body.data[0].name).to.equal('channel1_server1')
@@ -147,7 +147,7 @@ describe('Test ActivityPub video channels search', function () {
await waitJobs(servers)
- const { total, data } = await servers[0].videosCommand.listByChannel({
+ const { total, data } = await servers[0].videos.listByChannel({
token: null,
videoChannelName: 'channel1_server2@localhost:' + servers[1].port
})
@@ -156,7 +156,7 @@ describe('Test ActivityPub video channels search', function () {
})
it('Should list video channel videos of server 2 with token', async function () {
- const { total, data } = await servers[0].videosCommand.listByChannel({
+ const { total, data } = await servers[0].videos.listByChannel({
videoChannelName: 'channel1_server2@localhost:' + servers[1].port
})
@@ -167,12 +167,12 @@ describe('Test ActivityPub video channels search', function () {
it('Should update video channel of server 2, and refresh it on server 1', async function () {
this.timeout(60000)
- await servers[1].channelsCommand.update({
+ await servers[1].channels.update({
token: userServer2Token,
channelName: 'channel1_server2',
attributes: { displayName: 'channel updated' }
})
- await servers[1].usersCommand.updateMe({ token: userServer2Token, displayName: 'user updated' })
+ await servers[1].users.updateMe({ token: userServer2Token, displayName: 'user updated' })
await waitJobs(servers)
// Expire video channel
@@ -193,8 +193,8 @@ describe('Test ActivityPub video channels search', function () {
it('Should update and add a video on server 2, and update it on server 1 after a search', async function () {
this.timeout(60000)
- await servers[1].videosCommand.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } })
- await servers[1].videosCommand.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } })
+ await servers[1].videos.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } })
+ await servers[1].videos.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } })
await waitJobs(servers)
@@ -207,7 +207,7 @@ describe('Test ActivityPub video channels search', function () {
await waitJobs(servers)
const videoChannelName = 'channel1_server2@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName, sort: '-createdAt' })
+ const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' })
expect(total).to.equal(2)
expect(data[0].name).to.equal('video 2 server 2')
@@ -217,7 +217,7 @@ describe('Test ActivityPub video channels search', function () {
it('Should delete video channel of server 2, and delete it on server 1', async function () {
this.timeout(60000)
- await servers[1].channelsCommand.delete({ token: userServer2Token, channelName: 'channel1_server2' })
+ await servers[1].channels.delete({ token: userServer2Token, channelName: 'channel1_server2' })
await waitJobs(servers)
// Expire video
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts
index 46105c12c..7c99b954b 100644
--- a/server/tests/api/search/search-activitypub-video-playlists.ts
+++ b/server/tests/api/search/search-activitypub-video-playlists.ts
@@ -33,40 +33,40 @@ describe('Test ActivityPub playlists search', function () {
await setDefaultVideoChannel(servers)
{
- const video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
- const video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
+ const video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid
+ const video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid
const attributes = {
displayName: 'playlist 1 on server 1',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
- const created = await servers[0].playlistsCommand.create({ attributes })
+ const created = await servers[0].playlists.create({ attributes })
playlistServer1UUID = created.uuid
for (const videoId of [ video1, video2 ]) {
- await servers[0].playlistsCommand.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } })
+ await servers[0].playlists.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } })
}
}
{
- const videoId = (await servers[1].videosCommand.quickUpload({ name: 'video 1' })).uuid
- video2Server2 = (await servers[1].videosCommand.quickUpload({ name: 'video 2' })).uuid
+ const videoId = (await servers[1].videos.quickUpload({ name: 'video 1' })).uuid
+ video2Server2 = (await servers[1].videos.quickUpload({ name: 'video 2' })).uuid
const attributes = {
displayName: 'playlist 1 on server 2',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[1].videoChannel.id
+ videoChannelId: servers[1].store.channel.id
}
- const created = await servers[1].playlistsCommand.create({ attributes })
+ const created = await servers[1].playlists.create({ attributes })
playlistServer2UUID = created.uuid
- await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } })
+ await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } })
}
await waitJobs(servers)
- command = servers[0].searchCommand
+ command = servers[0].search
})
it('Should not find a remote playlist', async function () {
@@ -139,7 +139,7 @@ describe('Test ActivityPub playlists search', function () {
})
it('Should not list this remote playlist', async function () {
- const body = await servers[0].playlistsCommand.list({ start: 0, count: 10 })
+ const body = await servers[0].playlists.list({ start: 0, count: 10 })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].displayName).to.equal('playlist 1 on server 1')
@@ -148,7 +148,7 @@ describe('Test ActivityPub playlists search', function () {
it('Should update the playlist of server 2, and refresh it on server 1', async function () {
this.timeout(60000)
- await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } })
+ await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } })
await waitJobs(servers)
// Expire playlist
@@ -172,7 +172,7 @@ describe('Test ActivityPub playlists search', function () {
it('Should delete playlist of server 2, and delete it on server 1', async function () {
this.timeout(60000)
- await servers[1].playlistsCommand.delete({ playlistId: playlistServer2UUID })
+ await servers[1].playlists.delete({ playlistId: playlistServer2UUID })
await waitJobs(servers)
// Expiration
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts
index 19b4d5ed8..0dfc63446 100644
--- a/server/tests/api/search/search-activitypub-videos.ts
+++ b/server/tests/api/search/search-activitypub-videos.ts
@@ -30,18 +30,18 @@ describe('Test ActivityPub videos search', function () {
await setAccessTokensToServers(servers)
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1 on server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1 on server 1' } })
videoServer1UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 on server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 on server 2' } })
videoServer2UUID = uuid
}
await waitJobs(servers)
- command = servers[0].searchCommand
+ command = servers[0].search
})
it('Should not find a remote video', async function () {
@@ -105,7 +105,7 @@ describe('Test ActivityPub videos search', function () {
})
it('Should not list this remote video', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video 1 on server 1')
@@ -118,7 +118,7 @@ describe('Test ActivityPub videos search', function () {
name: 'super_channel',
displayName: 'super channel'
}
- const created = await servers[1].channelsCommand.create({ attributes: channelAttributes })
+ const created = await servers[1].channels.create({ attributes: channelAttributes })
const videoChannelId = created.id
const attributes = {
@@ -127,7 +127,7 @@ describe('Test ActivityPub videos search', function () {
privacy: VideoPrivacy.UNLISTED,
channelId: videoChannelId
}
- await servers[1].videosCommand.update({ id: videoServer2UUID, attributes })
+ await servers[1].videos.update({ id: videoServer2UUID, attributes })
await waitJobs(servers)
// Expire video
@@ -153,7 +153,7 @@ describe('Test ActivityPub videos search', function () {
it('Should delete video of server 2, and delete it on server 1', async function () {
this.timeout(120000)
- await servers[1].videosCommand.remove({ id: videoServer2UUID })
+ await servers[1].videos.remove({ id: videoServer2UUID })
await waitJobs(servers)
// Expire video
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts
index 4d2104708..7035fbd62 100644
--- a/server/tests/api/search/search-channels.ts
+++ b/server/tests/api/search/search-channels.ts
@@ -19,15 +19,15 @@ describe('Test channels search', function () {
await setAccessTokensToServers([ server ])
{
- await server.usersCommand.create({ username: 'user1', password: 'password' })
+ await server.users.create({ username: 'user1', password: 'password' })
const channel = {
name: 'squall_channel',
displayName: 'Squall channel'
}
- await server.channelsCommand.create({ attributes: channel })
+ await server.channels.create({ attributes: channel })
}
- command = server.searchCommand
+ command = server.search
})
it('Should make a simple search and not have results', async function () {
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts
index d5dc40f60..b54c0da22 100644
--- a/server/tests/api/search/search-index.ts
+++ b/server/tests/api/search/search-index.ts
@@ -20,9 +20,9 @@ describe('Test videos search', function () {
await setAccessTokensToServers([ server ])
- await server.videosCommand.upload({ attributes: { name: localVideoName } })
+ await server.videos.upload({ attributes: { name: localVideoName } })
- command = server.searchCommand
+ command = server.search
})
describe('Default search', async function () {
@@ -30,7 +30,7 @@ describe('Test videos search', function () {
it('Should make a local videos search by default', async function () {
this.timeout(10000)
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
@@ -57,7 +57,7 @@ describe('Test videos search', function () {
})
it('Should make an index videos search by default', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
@@ -79,7 +79,7 @@ describe('Test videos search', function () {
})
it('Should make an index videos search if local search is disabled', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
@@ -213,7 +213,7 @@ describe('Test videos search', function () {
let nsfwUUID: string
{
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'display' }
}
@@ -229,7 +229,7 @@ describe('Test videos search', function () {
}
{
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: { defaultNSFWPolicy: 'do_not_list' }
}
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts
index 2e4773ed6..e15128c8e 100644
--- a/server/tests/api/search/search-playlists.ts
+++ b/server/tests/api/search/search-playlists.ts
@@ -26,40 +26,40 @@ describe('Test playlists search', function () {
await setAccessTokensToServers([ server ])
await setDefaultVideoChannel([ server ])
- const videoId = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid
{
const attributes = {
displayName: 'Dr. Kenzo Tenma hospital videos',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
- const created = await server.playlistsCommand.create({ attributes })
+ const created = await server.playlists.create({ attributes })
- await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } })
+ await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
}
{
const attributes = {
displayName: 'Johan & Anna Libert musics',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
- const created = await server.playlistsCommand.create({ attributes })
+ const created = await server.playlists.create({ attributes })
- await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } })
+ await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
}
{
const attributes = {
displayName: 'Inspector Lunge playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
- await server.playlistsCommand.create({ attributes })
+ await server.playlists.create({ attributes })
}
- command = server.searchCommand
+ command = server.search
})
it('Should make a simple search and not have results', async function () {
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 148499d5f..478ebafc9 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -40,24 +40,24 @@ describe('Test videos search', function () {
nsfw: false,
language: 'fr'
}
- await server.videosCommand.upload({ attributes: attributes1 })
+ await server.videos.upload({ attributes: attributes1 })
const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
- await server.videosCommand.upload({ attributes: attributes2 })
+ await server.videos.upload({ attributes: attributes2 })
{
const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
- const { id, uuid } = await server.videosCommand.upload({ attributes: attributes3 })
+ const { id, uuid } = await server.videos.upload({ attributes: attributes3 })
videoUUID = uuid
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: 'en',
videoId: id,
fixture: 'subtitle-good2.vtt',
mimeType: 'application/octet-stream'
})
- await server.captionsCommand.createVideoCaption({
+ await server.captions.createVideoCaption({
language: 'aa',
videoId: id,
fixture: 'subtitle-good2.vtt',
@@ -66,23 +66,23 @@ describe('Test videos search', function () {
}
const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
- await server.videosCommand.upload({ attributes: attributes4 })
+ await server.videos.upload({ attributes: attributes4 })
await wait(1000)
startDate = new Date().toISOString()
const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
- await server.videosCommand.upload({ attributes: attributes5 })
+ await server.videos.upload({ attributes: attributes5 })
const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
- await server.videosCommand.upload({ attributes: attributes6 })
+ await server.videos.upload({ attributes: attributes6 })
const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
- await server.videosCommand.upload({ attributes: attributes7 })
+ await server.videos.upload({ attributes: attributes7 })
const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
- await server.videosCommand.upload({ attributes: attributes8 })
+ await server.videos.upload({ attributes: attributes8 })
}
{
@@ -93,9 +93,9 @@ describe('Test videos search', function () {
licence: 2,
language: 'en'
}
- await server.videosCommand.upload({ attributes: attributes })
+ await server.videos.upload({ attributes: attributes })
- await server.videosCommand.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
+ await server.videos.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
}
{
@@ -106,7 +106,7 @@ describe('Test videos search', function () {
licence: 3,
language: 'pl'
}
- await server.videosCommand.upload({ attributes: attributes })
+ await server.videos.upload({ attributes: attributes })
}
{
@@ -115,11 +115,11 @@ describe('Test videos search', function () {
tags: [ 'aaaa', 'bbbb', 'cccc' ],
category: 1
}
- await server.videosCommand.upload({ attributes: attributes1 })
- await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } })
+ await server.videos.upload({ attributes: attributes1 })
+ await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
- await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
- await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
+ await server.videos.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
+ await server.videos.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
}
{
@@ -127,11 +127,11 @@ describe('Test videos search', function () {
name: 'aaaa 2',
category: 1
}
- await server.videosCommand.upload({ attributes: attributes1 })
- await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } })
+ await server.videos.upload({ attributes: attributes1 })
+ await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
}
- command = server.searchCommand
+ command = server.search
})
it('Should make a simple search and not have results', async function () {
@@ -479,7 +479,7 @@ describe('Test videos search', function () {
},
live: { enabled: true }
}
- await server.configCommand.updateCustomSubConfig({ newConfig })
+ await server.config.updateCustomSubConfig({ newConfig })
}
{
@@ -490,9 +490,9 @@ describe('Test videos search', function () {
}
{
- const liveCommand = server.liveCommand
+ const liveCommand = server.live
- const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id }
+ const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.store.channel.id }
const live = await liveCommand.create({ fields: liveAttributes })
const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id })
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts
index 34c4f6882..e9fb5b4b1 100644
--- a/server/tests/api/server/auto-follows.ts
+++ b/server/tests/api/server/auto-follows.ts
@@ -16,7 +16,7 @@ const expect = chai.expect
async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) {
{
- const body = await following.followsCommand.getFollowers({ start: 0, count: 5, sort: '-createdAt' })
+ const body = await following.follows.getFollowers({ start: 0, count: 5, sort: '-createdAt' })
const follow = body.data.find(f => f.follower.host === follower.host && f.state === 'accepted')
if (exists === true) expect(follow).to.exist
@@ -24,7 +24,7 @@ async function checkFollow (follower: ServerInfo, following: ServerInfo, exists:
}
{
- const body = await follower.followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
+ const body = await follower.follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
const follow = body.data.find(f => f.following.host === following.host && f.state === 'accepted')
if (exists === true) expect(follow).to.exist
@@ -33,15 +33,15 @@ async function checkFollow (follower: ServerInfo, following: ServerInfo, exists:
}
async function server1Follows2 (servers: ServerInfo[]) {
- await servers[0].followsCommand.follow({ targets: [ servers[1].host ] })
+ await servers[0].follows.follow({ targets: [ servers[1].host ] })
await waitJobs(servers)
}
async function resetFollows (servers: ServerInfo[]) {
try {
- await servers[0].followsCommand.unfollow({ target: servers[1] })
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[0].follows.unfollow({ target: servers[1] })
+ await servers[1].follows.unfollow({ target: servers[0] })
} catch { /* empty */
}
@@ -86,7 +86,7 @@ describe('Test auto follows', function () {
}
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
@@ -111,14 +111,14 @@ describe('Test auto follows', function () {
}
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
await server1Follows2(servers)
await checkFollow(servers[0], servers[1], false)
await checkFollow(servers[1], servers[0], false)
- await servers[1].followsCommand.acceptFollower({ follower: 'peertube@' + servers[0].host })
+ await servers[1].follows.acceptFollower({ follower: 'peertube@' + servers[0].host })
await waitJobs(servers)
await checkFollow(servers[0], servers[1], true)
@@ -128,7 +128,7 @@ describe('Test auto follows', function () {
config.followings.instance.autoFollowBack.enabled = false
config.followers.instance.manualApproval = false
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[1].config.updateCustomSubConfig({ newConfig: config })
})
})
@@ -165,7 +165,7 @@ describe('Test auto follows', function () {
}
}
}
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
await wait(5000)
await waitJobs(servers)
diff --git a/server/tests/api/server/bulk.ts b/server/tests/api/server/bulk.ts
index c83bcfb22..acc17092d 100644
--- a/server/tests/api/server/bulk.ts
+++ b/server/tests/api/server/bulk.ts
@@ -34,23 +34,23 @@ describe('Test bulk actions', function () {
{
const user = { username: 'user1', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- user1Token = await servers[0].loginCommand.getAccessToken(user)
+ user1Token = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user2', password: 'password' }
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- user2Token = await servers[0].loginCommand.getAccessToken(user)
+ user2Token = await servers[0].login.getAccessToken(user)
}
{
const user = { username: 'user3', password: 'password' }
- await servers[1].usersCommand.create({ username: user.username, password: user.password })
+ await servers[1].users.create({ username: user.username, password: user.password })
- user3Token = await servers[1].loginCommand.getAccessToken(user)
+ user3Token = await servers[1].login.getAccessToken(user)
}
await doubleFollow(servers[0], servers[1])
@@ -61,11 +61,11 @@ describe('Test bulk actions', function () {
describe('Bulk remove comments', function () {
async function checkInstanceCommentsRemoved () {
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
// Server 1 should not have these comments anymore
for (const video of data) {
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: video.id })
+ const { data } = await servers[0].comments.listThreads({ videoId: video.id })
const comment = data.find(c => c.text === 'comment by user 3')
expect(comment).to.not.exist
@@ -73,11 +73,11 @@ describe('Test bulk actions', function () {
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
// Server 1 should not have these comments on videos of server 1
for (const video of data) {
- const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.id })
+ const { data } = await servers[1].comments.listThreads({ videoId: video.id })
const comment = data.find(c => c.text === 'comment by user 3')
if (video.account.host === 'localhost:' + servers[0].port) {
@@ -92,30 +92,30 @@ describe('Test bulk actions', function () {
before(async function () {
this.timeout(120000)
- await servers[0].videosCommand.upload({ attributes: { name: 'video 1 server 1' } })
- await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } })
- await servers[0].videosCommand.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } })
+ await servers[0].videos.upload({ attributes: { name: 'video 1 server 1' } })
+ await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
+ await servers[0].videos.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } })
- await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } })
+ await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
await waitJobs(servers)
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
for (const video of data) {
- await servers[0].commentsCommand.createThread({ videoId: video.id, text: 'comment by root server 1' })
- await servers[0].commentsCommand.createThread({ token: user1Token, videoId: video.id, text: 'comment by user 1' })
- await servers[0].commentsCommand.createThread({ token: user2Token, videoId: video.id, text: 'comment by user 2' })
+ await servers[0].comments.createThread({ videoId: video.id, text: 'comment by root server 1' })
+ await servers[0].comments.createThread({ token: user1Token, videoId: video.id, text: 'comment by user 1' })
+ await servers[0].comments.createThread({ token: user2Token, videoId: video.id, text: 'comment by user 2' })
}
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
for (const video of data) {
- await servers[1].commentsCommand.createThread({ videoId: video.id, text: 'comment by root server 2' })
+ await servers[1].comments.createThread({ videoId: video.id, text: 'comment by root server 2' })
- const comment = await servers[1].commentsCommand.createThread({ token: user3Token, videoId: video.id, text: 'comment by user 3' })
+ const comment = await servers[1].comments.createThread({ token: user3Token, videoId: video.id, text: 'comment by user 3' })
commentsUser3.push({ videoId: video.id, commentId: comment.id })
}
}
@@ -137,10 +137,10 @@ describe('Test bulk actions', function () {
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
for (const video of data) {
- const { data } = await server.commentsCommand.listThreads({ videoId: video.id })
+ const { data } = await server.comments.listThreads({ videoId: video.id })
const comment = data.find(c => c.text === 'comment by user 2')
if (video.name === 'video 3 server 1') expect(comment).to.not.exist
@@ -168,7 +168,7 @@ describe('Test bulk actions', function () {
this.timeout(60000)
for (const obj of commentsUser3) {
- await servers[1].commentsCommand.addReply({
+ await servers[1].comments.addReply({
token: user3Token,
videoId: obj.videoId,
toCommentId: obj.commentId,
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index c613511ed..479e177a8 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -214,7 +214,7 @@ describe('Test config', function () {
})
it('Should have a correct config on a server with registration enabled', async function () {
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.signup.allowed).to.be.true
})
@@ -223,32 +223,32 @@ describe('Test config', function () {
this.timeout(5000)
await Promise.all([
- server.usersCommand.register({ username: 'user1' }),
- server.usersCommand.register({ username: 'user2' }),
- server.usersCommand.register({ username: 'user3' })
+ server.users.register({ username: 'user1' }),
+ server.users.register({ username: 'user2' }),
+ server.users.register({ username: 'user3' })
])
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.signup.allowed).to.be.false
})
it('Should have the correct video allowed extensions', async function () {
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.video.file.extensions).to.have.lengthOf(3)
expect(data.video.file.extensions).to.contain('.mp4')
expect(data.video.file.extensions).to.contain('.webm')
expect(data.video.file.extensions).to.contain('.ogv')
- await server.videosCommand.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
- await server.videosCommand.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
+ await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
+ await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
expect(data.contactForm.enabled).to.be.true
})
it('Should get the customized configuration', async function () {
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkInitialConfig(server, data)
})
@@ -425,16 +425,16 @@ describe('Test config', function () {
}
}
}
- await server.configCommand.updateCustomConfig({ newCustomConfig })
+ await server.config.updateCustomConfig({ newCustomConfig })
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should have the correct updated video allowed extensions', async function () {
this.timeout(10000)
- const data = await server.configCommand.getConfig()
+ const data = await server.config.getConfig()
expect(data.video.file.extensions).to.have.length.above(4)
expect(data.video.file.extensions).to.contain('.mp4')
@@ -447,8 +447,8 @@ describe('Test config', function () {
expect(data.video.file.extensions).to.contain('.ogg')
expect(data.video.file.extensions).to.contain('.flac')
- await server.videosCommand.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 })
- await server.videosCommand.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 })
+ await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 })
+ await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should have the configuration updated after a restart', async function () {
@@ -458,13 +458,13 @@ describe('Test config', function () {
await reRunServer(server)
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkUpdatedConfig(data)
})
it('Should fetch the about information', async function () {
- const data = await server.configCommand.getAbout()
+ const data = await server.config.getAbout()
expect(data.instance.name).to.equal('PeerTube updated')
expect(data.instance.shortDescription).to.equal('my short description')
@@ -486,9 +486,9 @@ describe('Test config', function () {
it('Should remove the custom configuration', async function () {
this.timeout(10000)
- await server.configCommand.deleteCustomConfig()
+ await server.config.deleteCustomConfig()
- const data = await server.configCommand.getCustomConfig()
+ const data = await server.config.getCustomConfig()
checkInitialConfig(server, data)
})
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts
index 79c4c6748..353fed80a 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -27,7 +27,7 @@ describe('Test contact form', function () {
server = await flushAndRunServer(1, overrideConfig)
await setAccessTokensToServers([ server ])
- command = server.contactFormCommand
+ command = server.contactForm
})
it('Should send a contact form', async function () {
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index aeda5fddb..258e835e7 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -43,15 +43,15 @@ describe('Test emails', function () {
await setAccessTokensToServers([ server ])
{
- const created = await server.usersCommand.create({ username: user.username, password: user.password })
+ const created = await server.users.create({ username: user.username, password: user.password })
userId = created.id
- userAccessToken = await server.loginCommand.getAccessToken(user)
+ userAccessToken = await server.login.getAccessToken(user)
}
{
const attributes = { name: 'my super user video' }
- const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes })
+ const { uuid } = await server.videos.upload({ token: userAccessToken, attributes })
videoUserUUID = uuid
}
@@ -59,7 +59,7 @@ describe('Test emails', function () {
const attributes = {
name: 'my super name'
}
- const { uuid, id } = await server.videosCommand.upload({ attributes })
+ const { uuid, id } = await server.videos.upload({ attributes })
videoUUID = uuid
videoId = id
}
@@ -70,7 +70,7 @@ describe('Test emails', function () {
it('Should ask to reset the password', async function () {
this.timeout(10000)
- await server.usersCommand.askResetPassword({ email: 'user_1@example.com' })
+ await server.users.askResetPassword({ email: 'user_1@example.com' })
await waitJobs(server)
expect(emails).to.have.lengthOf(1)
@@ -96,7 +96,7 @@ describe('Test emails', function () {
})
it('Should not reset the password with an invalid verification string', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId,
verificationString: verificationString + 'b',
password: 'super_password2',
@@ -105,11 +105,11 @@ describe('Test emails', function () {
})
it('Should reset the password', async function () {
- await server.usersCommand.resetPassword({ userId, verificationString, password: 'super_password2' })
+ await server.users.resetPassword({ userId, verificationString, password: 'super_password2' })
})
it('Should not reset the password with the same verification string', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId,
verificationString,
password: 'super_password3',
@@ -120,7 +120,7 @@ describe('Test emails', function () {
it('Should login with this new password', async function () {
user.password = 'super_password2'
- await server.loginCommand.getAccessToken(user)
+ await server.login.getAccessToken(user)
})
})
@@ -129,7 +129,7 @@ describe('Test emails', function () {
it('Should send a create password email', async function () {
this.timeout(10000)
- await server.usersCommand.create({ username: 'create_password', password: '' })
+ await server.users.create({ username: 'create_password', password: '' })
await waitJobs(server)
expect(emails).to.have.lengthOf(2)
@@ -155,7 +155,7 @@ describe('Test emails', function () {
})
it('Should not reset the password with an invalid verification string', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId: userId2,
verificationString: verificationString2 + 'c',
password: 'newly_created_password',
@@ -164,7 +164,7 @@ describe('Test emails', function () {
})
it('Should reset the password', async function () {
- await server.usersCommand.resetPassword({
+ await server.users.resetPassword({
userId: userId2,
verificationString: verificationString2,
password: 'newly_created_password'
@@ -172,7 +172,7 @@ describe('Test emails', function () {
})
it('Should login with this new password', async function () {
- await server.loginCommand.getAccessToken({
+ await server.login.getAccessToken({
username: 'create_password',
password: 'newly_created_password'
})
@@ -184,7 +184,7 @@ describe('Test emails', function () {
this.timeout(10000)
const reason = 'my super bad reason'
- await server.abusesCommand.report({ videoId, reason })
+ await server.abuses.report({ videoId, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(3)
@@ -205,7 +205,7 @@ describe('Test emails', function () {
this.timeout(10000)
const reason = 'my super bad reason'
- await server.usersCommand.banUser({ userId, reason })
+ await server.users.banUser({ userId, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(4)
@@ -223,7 +223,7 @@ describe('Test emails', function () {
it('Should send the notification email when unblocking a user', async function () {
this.timeout(10000)
- await server.usersCommand.unbanUser({ userId })
+ await server.users.unbanUser({ userId })
await waitJobs(server)
expect(emails).to.have.lengthOf(5)
@@ -243,7 +243,7 @@ describe('Test emails', function () {
this.timeout(10000)
const reason = 'my super reason'
- await server.blacklistCommand.add({ videoId: videoUserUUID, reason })
+ await server.blacklist.add({ videoId: videoUserUUID, reason })
await waitJobs(server)
expect(emails).to.have.lengthOf(6)
@@ -261,7 +261,7 @@ describe('Test emails', function () {
it('Should send the notification email', async function () {
this.timeout(10000)
- await server.blacklistCommand.remove({ videoId: videoUserUUID })
+ await server.blacklist.remove({ videoId: videoUserUUID })
await waitJobs(server)
expect(emails).to.have.lengthOf(7)
@@ -286,7 +286,7 @@ describe('Test emails', function () {
it('Should ask to send the verification email', async function () {
this.timeout(10000)
- await server.usersCommand.askSendVerifyEmail({ email: 'user_1@example.com' })
+ await server.users.askSendVerifyEmail({ email: 'user_1@example.com' })
await waitJobs(server)
expect(emails).to.have.lengthOf(8)
@@ -312,7 +312,7 @@ describe('Test emails', function () {
})
it('Should not verify the email with an invalid verification string', async function () {
- await server.usersCommand.verifyEmail({
+ await server.users.verifyEmail({
userId,
verificationString: verificationString + 'b',
isPendingEmail: false,
@@ -321,7 +321,7 @@ describe('Test emails', function () {
})
it('Should verify the email', async function () {
- await server.usersCommand.verifyEmail({ userId, verificationString })
+ await server.users.verifyEmail({ userId, verificationString })
})
})
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index f9014aeee..887e400e9 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -23,11 +23,11 @@ describe('Test follow constraints', function () {
await setAccessTokensToServers(servers)
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
video1UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
video2UUID = uuid
}
@@ -35,8 +35,8 @@ describe('Test follow constraints', function () {
username: 'user1',
password: 'super_password'
}
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
- userToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ username: user.username, password: user.password })
+ userToken = await servers[0].login.getAccessToken(user)
await doubleFollow(servers[0], servers[1])
})
@@ -46,22 +46,22 @@ describe('Test follow constraints', function () {
describe('With an unlogged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.get({ id: video1UUID })
+ await servers[0].videos.get({ id: video1UUID })
})
it('Should get the remote video', async function () {
- await servers[0].videosCommand.get({ id: video2UUID })
+ await servers[0].videos.get({ id: video2UUID })
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -69,7 +69,7 @@ describe('Test follow constraints', function () {
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -77,7 +77,7 @@ describe('Test follow constraints', function () {
it('Should list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -86,22 +86,22 @@ describe('Test follow constraints', function () {
describe('With a logged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video1UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
})
it('Should get the remote video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video2UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -109,7 +109,7 @@ describe('Test follow constraints', function () {
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -117,7 +117,7 @@ describe('Test follow constraints', function () {
it('Should list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -130,17 +130,17 @@ describe('Test follow constraints', function () {
before(async function () {
this.timeout(30000)
- await servers[0].followsCommand.unfollow({ target: servers[1] })
+ await servers[0].follows.unfollow({ target: servers[1] })
})
describe('With an unlogged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.get({ id: video1UUID })
+ await servers[0].videos.get({ id: video1UUID })
})
it('Should not get the remote video', async function () {
- const body = await servers[0].videosCommand.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ const body = await servers[0].videos.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
const error = body as unknown as PeerTubeProblemDocument
const doc = 'https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints'
@@ -156,7 +156,7 @@ describe('Test follow constraints', function () {
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({
+ const { total, data } = await servers[0].videos.listByAccount({
token: undefined,
accountName: 'root@localhost:' + servers[0].port
})
@@ -166,7 +166,7 @@ describe('Test follow constraints', function () {
})
it('Should not list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({
+ const { total, data } = await servers[0].videos.listByAccount({
token: undefined,
accountName: 'root@localhost:' + servers[1].port
})
@@ -177,7 +177,7 @@ describe('Test follow constraints', function () {
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: undefined, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -185,7 +185,7 @@ describe('Test follow constraints', function () {
it('Should not list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: undefined, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
@@ -194,22 +194,22 @@ describe('Test follow constraints', function () {
describe('With a logged user', function () {
it('Should get the local video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video1UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
})
it('Should get the remote video', async function () {
- await servers[0].videosCommand.getWithToken({ token: userToken, id: video2UUID })
+ await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -217,7 +217,7 @@ describe('Test follow constraints', function () {
it('Should list local channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -225,7 +225,7 @@ describe('Test follow constraints', function () {
it('Should list remote channel videos', async function () {
const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName })
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts
index 6d6eca9a8..045024544 100644
--- a/server/tests/api/server/follows-moderation.ts
+++ b/server/tests/api/server/follows-moderation.ts
@@ -15,8 +15,8 @@ const expect = chai.expect
async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
const fns = [
- servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand),
- servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand)
+ servers[0].follows.getFollowings.bind(servers[0].follows),
+ servers[1].follows.getFollowers.bind(servers[1].follows)
]
for (const fn of fns) {
@@ -32,8 +32,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
async function checkNoFollowers (servers: ServerInfo[]) {
const fns = [
- servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand),
- servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand)
+ servers[0].follows.getFollowings.bind(servers[0].follows),
+ servers[1].follows.getFollowers.bind(servers[1].follows)
]
for (const fn of fns) {
@@ -54,7 +54,7 @@ describe('Test follows moderation', function () {
// Get the access tokens
await setAccessTokensToServers(servers)
- commands = servers.map(s => s.followsCommand)
+ commands = servers.map(s => s.follows)
})
it('Should have server 1 following server 2', async function () {
@@ -93,7 +93,7 @@ describe('Test follows moderation', function () {
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
@@ -113,7 +113,7 @@ describe('Test follows moderation', function () {
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
@@ -136,8 +136,8 @@ describe('Test follows moderation', function () {
}
}
- await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig })
- await servers[2].configCommand.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
+ await servers[2].config.updateCustomSubConfig({ newConfig: subConfig })
await commands[0].follow({ targets: [ servers[1].url ] })
await waitJobs(servers)
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 5ce8938fa..d43064689 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -26,7 +26,7 @@ describe('Test follows', function () {
this.timeout(30000)
servers = await flushAndRunMultipleServers(3)
- followsCommands = servers.map(s => s.followsCommand)
+ followsCommands = servers.map(s => s.follows)
// Get the access tokens
await setAccessTokensToServers(servers)
@@ -34,7 +34,7 @@ describe('Test follows', function () {
it('Should not have followers', async function () {
for (const server of servers) {
- const body = await server.followsCommand.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
+ const body = await server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
expect(body.total).to.equal(0)
const follows = body.data
@@ -45,7 +45,7 @@ describe('Test follows', function () {
it('Should not have following', async function () {
for (const server of servers) {
- const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
+ const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
expect(body.total).to.equal(0)
const follows = body.data
@@ -141,7 +141,7 @@ describe('Test follows', function () {
it('Should have 0 followings on server 2 and 3', async function () {
for (const server of [ servers[1], servers[2] ]) {
- const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
+ const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
expect(body.total).to.equal(0)
const follows = body.data
@@ -152,7 +152,7 @@ describe('Test follows', function () {
it('Should have 1 followers on server 2 and 3', async function () {
for (const server of [ servers[1], servers[2] ]) {
- const body = await server.followsCommand.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
+ const body = await server.follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
expect(body.total).to.equal(1)
const follows = body.data
@@ -284,25 +284,25 @@ describe('Test follows', function () {
it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
this.timeout(60000)
- await servers[1].videosCommand.upload({ attributes: { name: 'server2' } })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3' } })
+ await servers[1].videos.upload({ attributes: { name: 'server2' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3' } })
await waitJobs(servers)
{
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('server2')
}
{
- const { total, data } = await servers[1].videosCommand.list()
+ const { total, data } = await servers[1].videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('server2')
}
{
- const { total, data } = await servers[2].videosCommand.list()
+ const { total, data } = await servers[2].videos.list()
expect(total).to.equal(1)
expect(data[0].name).to.equal('server3')
}
@@ -322,60 +322,60 @@ describe('Test follows', function () {
tags: [ 'tag1', 'tag2', 'tag3' ]
}
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-2' } })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-3' } })
- await servers[2].videosCommand.upload({ attributes: video4Attributes })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-5' } })
- await servers[2].videosCommand.upload({ attributes: { name: 'server3-6' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3-2' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3-3' } })
+ await servers[2].videos.upload({ attributes: video4Attributes })
+ await servers[2].videos.upload({ attributes: { name: 'server3-5' } })
+ await servers[2].videos.upload({ attributes: { name: 'server3-6' } })
{
- const userAccessToken = await servers[2].usersCommand.generateUserAndToken('captain')
+ const userAccessToken = await servers[2].users.generateUserAndToken('captain')
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
video4 = data.find(v => v.name === 'server3-4')
{
- await servers[2].videosCommand.rate({ id: video4.id, rating: 'like' })
- await servers[2].videosCommand.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' })
+ await servers[2].videos.rate({ id: video4.id, rating: 'like' })
+ await servers[2].videos.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' })
}
{
{
const text = 'my super first comment'
- const created = await servers[2].commentsCommand.createThread({ videoId: video4.id, text })
+ const created = await servers[2].comments.createThread({ videoId: video4.id, text })
const threadId = created.id
const text1 = 'my super answer to thread 1'
- const childComment = await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
+ const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
const text2 = 'my super answer to answer of thread 1'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 })
const text3 = 'my second answer to thread 1'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 })
}
{
const text = 'will be deleted'
- const created = await servers[2].commentsCommand.createThread({ videoId: video4.id, text })
+ const created = await servers[2].comments.createThread({ videoId: video4.id, text })
const threadId = created.id
const text1 = 'answer to deleted'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
const text2 = 'will also be deleted'
- const childComment = await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 })
+ const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 })
const text3 = 'my second answer to deleted'
- await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 })
+ await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 })
- await servers[2].commentsCommand.delete({ videoId: video4.id, commentId: threadId })
- await servers[2].commentsCommand.delete({ videoId: video4.id, commentId: childComment.id })
+ await servers[2].comments.delete({ videoId: video4.id, commentId: threadId })
+ await servers[2].comments.delete({ videoId: video4.id, commentId: childComment.id })
}
}
{
- await servers[2].captionsCommand.createVideoCaption({
+ await servers[2].captions.createVideoCaption({
language: 'ar',
videoId: video4.id,
fixture: 'subtitle-good2.vtt'
@@ -404,7 +404,7 @@ describe('Test follows', function () {
})
it('Should have propagated videos', async function () {
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(7)
const video2 = data.find(v => v.name === 'server3-2')
@@ -454,7 +454,7 @@ describe('Test follows', function () {
})
it('Should have propagated comments', async function () {
- const { total, data } = await servers[0].commentsCommand.listThreads({ videoId: video4.id, sort: 'createdAt' })
+ const { total, data } = await servers[0].comments.listThreads({ videoId: video4.id, sort: 'createdAt' })
expect(total).to.equal(2)
expect(data).to.be.an('array')
@@ -474,7 +474,7 @@ describe('Test follows', function () {
const threadId = comment.threadId
- const tree = await servers[0].commentsCommand.getThread({ videoId: video4.id, threadId })
+ const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId })
expect(tree.comment.text).equal('my super first comment')
expect(tree.children).to.have.lengthOf(2)
@@ -502,7 +502,7 @@ describe('Test follows', function () {
expect(deletedComment.totalReplies).to.equal(2)
expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
- const tree = await servers[0].commentsCommand.getThread({ videoId: video4.id, threadId: deletedComment.threadId })
+ const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId: deletedComment.threadId })
const [ commentRoot, deletedChildRoot ] = tree.children
expect(deletedChildRoot).to.not.be.undefined
@@ -527,7 +527,7 @@ describe('Test follows', function () {
})
it('Should have propagated captions', async function () {
- const body = await servers[0].captionsCommand.listVideoCaptions({ videoId: video4.id })
+ const body = await servers[0].captions.listVideoCaptions({ videoId: video4.id })
expect(body.total).to.equal(1)
expect(body.data).to.have.lengthOf(1)
@@ -545,7 +545,7 @@ describe('Test follows', function () {
await waitJobs(servers)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
})
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 35b905a8c..de3dee826 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -55,7 +55,7 @@ describe('Test handle downs', function () {
this.timeout(30000)
servers = await flushAndRunMultipleServers(3)
- commentCommands = servers.map(s => s.commentsCommand)
+ commentCommands = servers.map(s => s.comments)
checkAttributes = {
name: 'my super name for server 1',
@@ -99,19 +99,19 @@ describe('Test handle downs', function () {
this.timeout(240000)
// Server 2 and 3 follow server 1
- await servers[1].followsCommand.follow({ targets: [ servers[0].url ] })
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[1].follows.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
// Upload a video to server 1
- await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ await servers[0].videos.upload({ attributes: videoAttributes })
await waitJobs(servers)
// And check all servers have this video
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).to.have.lengthOf(1)
}
@@ -121,7 +121,7 @@ describe('Test handle downs', function () {
// Remove server 2 follower
for (let i = 0; i < 10; i++) {
- await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ await servers[0].videos.upload({ attributes: videoAttributes })
}
await waitJobs([ servers[0], servers[2] ])
@@ -129,12 +129,12 @@ describe('Test handle downs', function () {
// Kill server 3
await killallServers([ servers[2] ])
- missedVideo1 = await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ missedVideo1 = await servers[0].videos.upload({ attributes: videoAttributes })
- missedVideo2 = await servers[0].videosCommand.upload({ attributes: videoAttributes })
+ missedVideo2 = await servers[0].videos.upload({ attributes: videoAttributes })
// Unlisted video
- unlistedVideo = await servers[0].videosCommand.upload({ attributes: unlistedVideoAttributes })
+ unlistedVideo = await servers[0].videos.upload({ attributes: unlistedVideoAttributes })
// Add comments to video 2
{
@@ -153,7 +153,7 @@ describe('Test handle downs', function () {
await wait(11000)
// Only server 3 is still a follower of server 1
- const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
+ const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(1)
expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
@@ -163,7 +163,7 @@ describe('Test handle downs', function () {
const states: JobState[] = [ 'waiting', 'active' ]
for (const state of states) {
- const body = await servers[0].jobsCommand.getJobsList({
+ const body = await servers[0].jobs.getJobsList({
state: state,
start: 0,
count: 50,
@@ -179,14 +179,14 @@ describe('Test handle downs', function () {
await reRunServer(servers[1])
await reRunServer(servers[2])
- await servers[1].followsCommand.unfollow({ target: servers[0] })
+ await servers[1].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- await servers[1].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[1].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
- const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
+ const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
expect(body.data).to.be.an('array')
expect(body.data).to.have.lengthOf(2)
})
@@ -195,25 +195,25 @@ describe('Test handle downs', function () {
this.timeout(15000)
{
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
expect(data).to.be.an('array')
expect(data).to.have.lengthOf(11)
}
- await servers[0].videosCommand.update({ id: missedVideo1.uuid })
- await servers[0].videosCommand.update({ id: unlistedVideo.uuid })
+ await servers[0].videos.update({ id: missedVideo1.uuid })
+ await servers[0].videos.update({ id: unlistedVideo.uuid })
await waitJobs(servers)
{
- const { data } = await servers[2].videosCommand.list()
+ const { data } = await servers[2].videos.list()
expect(data).to.be.an('array')
// 1 video is unlisted
expect(data).to.have.lengthOf(12)
}
// Check unlisted video
- const video = await servers[2].videosCommand.get({ id: unlistedVideo.uuid })
+ const video = await servers[2].videos.get({ id: unlistedVideo.uuid })
await completeVideoCheck(servers[2], video, unlistedCheckAttributes)
})
@@ -224,16 +224,16 @@ describe('Test handle downs', function () {
await waitJobs(servers)
- await servers[2].videosCommand.get({ id: missedVideo2.uuid })
+ await servers[2].videos.get({ id: missedVideo2.uuid })
{
- const { data } = await servers[2].commentsCommand.listThreads({ videoId: missedVideo2.uuid })
+ const { data } = await servers[2].comments.listThreads({ videoId: missedVideo2.uuid })
expect(data).to.be.an('array')
expect(data).to.have.lengthOf(1)
threadIdServer2 = data[0].id
- const tree = await servers[2].commentsCommand.getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer2 })
+ const tree = await servers[2].comments.getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer2 })
expect(tree.comment.text).equal('thread 1')
expect(tree.children).to.have.lengthOf(1)
@@ -256,7 +256,7 @@ describe('Test handle downs', function () {
it('Should correctly reply to the comment', async function () {
this.timeout(15000)
- await servers[2].commentsCommand.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' })
+ await servers[2].comments.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' })
await waitJobs(servers)
@@ -286,24 +286,24 @@ describe('Test handle downs', function () {
this.timeout(120000)
for (let i = 0; i < 10; i++) {
- const uuid = (await servers[0].videosCommand.quickUpload({ name: 'video ' + i })).uuid
+ const uuid = (await servers[0].videos.quickUpload({ name: 'video ' + i })).uuid
videoIdsServer1.push(uuid)
}
await waitJobs(servers)
for (const id of videoIdsServer1) {
- await servers[1].videosCommand.get({ id })
+ await servers[1].videos.get({ id })
}
await waitJobs(servers)
- await servers[1].sqlCommand.setActorFollowScores(20)
+ await servers[1].sql.setActorFollowScores(20)
// Wait video expiration
await wait(11000)
// Refresh video -> score + 10 = 30
- await servers[1].videosCommand.get({ id: videoIdsServer1[0] })
+ await servers[1].videos.get({ id: videoIdsServer1[0] })
await waitJobs(servers)
})
@@ -318,14 +318,14 @@ describe('Test handle downs', function () {
for (let i = 0; i < 5; i++) {
try {
- await servers[1].videosCommand.get({ id: videoIdsServer1[i] })
+ await servers[1].videos.get({ id: videoIdsServer1[i] })
await waitJobs([ servers[1] ])
await wait(1500)
} catch {}
}
for (const id of videoIdsServer1) {
- await servers[1].videosCommand.get({ id, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[1].videos.get({ id, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
}
})
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts
index 18b9edc31..aac075321 100644
--- a/server/tests/api/server/homepage.ts
+++ b/server/tests/api/server/homepage.ts
@@ -16,7 +16,7 @@ import {
const expect = chai.expect
async function getHomepageState (server: ServerInfo) {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
return config.homepage.enabled
}
@@ -31,7 +31,7 @@ describe('Test instance homepage actions', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- command = server.customPageCommand
+ command = server.customPage
})
it('Should not have a homepage', async function () {
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index aa4c7587b..0c44e4dad 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -31,21 +31,21 @@ describe('Test jobs', function () {
it('Should create some jobs', async function () {
this.timeout(120000)
- await servers[1].videosCommand.upload({ attributes: { name: 'video1' } })
- await servers[1].videosCommand.upload({ attributes: { name: 'video2' } })
+ await servers[1].videos.upload({ attributes: { name: 'video1' } })
+ await servers[1].videos.upload({ attributes: { name: 'video2' } })
await waitJobs(servers)
})
it('Should list jobs', async function () {
- const body = await servers[1].jobsCommand.getJobsList({ state: 'completed' })
+ const body = await servers[1].jobs.getJobsList({ state: 'completed' })
expect(body.total).to.be.above(2)
expect(body.data).to.have.length.above(2)
})
it('Should list jobs with sort, pagination and job type', async function () {
{
- const body = await servers[1].jobsCommand.getJobsList({
+ const body = await servers[1].jobs.getJobsList({
state: 'completed',
start: 1,
count: 2,
@@ -66,7 +66,7 @@ describe('Test jobs', function () {
}
{
- const body = await servers[1].jobsCommand.getJobsList({
+ const body = await servers[1].jobs.getJobsList({
state: 'completed',
start: 0,
count: 100,
@@ -82,7 +82,7 @@ describe('Test jobs', function () {
})
it('Should list all jobs', async function () {
- const body = await servers[1].jobsCommand.getJobsList()
+ const body = await servers[1].jobs.getJobsList()
expect(body.total).to.be.above(2)
const jobs = body.data
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts
index e7bef5a4a..2d141fd8c 100644
--- a/server/tests/api/server/logs.ts
+++ b/server/tests/api/server/logs.ts
@@ -25,7 +25,7 @@ describe('Test logs', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- logsCommand = server.logsCommand
+ logsCommand = server.logs
})
describe('With the standard log file', function () {
@@ -33,12 +33,12 @@ describe('Test logs', function () {
it('Should get logs with a start date', async function () {
this.timeout(20000)
- await server.videosCommand.upload({ attributes: { name: 'video 1' } })
+ await server.videos.upload({ attributes: { name: 'video 1' } })
await waitJobs([ server ])
const now = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 2' } })
+ await server.videos.upload({ attributes: { name: 'video 2' } })
await waitJobs([ server ])
const body = await logsCommand.getLogs({ startDate: now })
@@ -51,17 +51,17 @@ describe('Test logs', function () {
it('Should get logs with an end date', async function () {
this.timeout(30000)
- await server.videosCommand.upload({ attributes: { name: 'video 3' } })
+ await server.videos.upload({ attributes: { name: 'video 3' } })
await waitJobs([ server ])
const now1 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 4' } })
+ await server.videos.upload({ attributes: { name: 'video 4' } })
await waitJobs([ server ])
const now2 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 5' } })
+ await server.videos.upload({ attributes: { name: 'video 5' } })
await waitJobs([ server ])
const body = await logsCommand.getLogs({ startDate: now1, endDate: now2 })
@@ -77,7 +77,7 @@ describe('Test logs', function () {
const now = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 6' } })
+ await server.videos.upload({ attributes: { name: 'video 6' } })
await waitJobs([ server ])
{
@@ -100,7 +100,7 @@ describe('Test logs', function () {
const now = new Date()
- await server.serversCommand.ping()
+ await server.servers.ping()
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
const logsString = JSON.stringify(body)
@@ -117,7 +117,7 @@ describe('Test logs', function () {
const now = new Date()
- await server.serversCommand.ping()
+ await server.servers.ping()
const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
const logsString = JSON.stringify(body)
@@ -130,12 +130,12 @@ describe('Test logs', function () {
it('Should get logs with a start date', async function () {
this.timeout(20000)
- await server.videosCommand.upload({ attributes: { name: 'video 7' } })
+ await server.videos.upload({ attributes: { name: 'video 7' } })
await waitJobs([ server ])
const now = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 8' } })
+ await server.videos.upload({ attributes: { name: 'video 8' } })
await waitJobs([ server ])
const body = await logsCommand.getAuditLogs({ startDate: now })
@@ -156,17 +156,17 @@ describe('Test logs', function () {
it('Should get logs with an end date', async function () {
this.timeout(30000)
- await server.videosCommand.upload({ attributes: { name: 'video 9' } })
+ await server.videos.upload({ attributes: { name: 'video 9' } })
await waitJobs([ server ])
const now1 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 10' } })
+ await server.videos.upload({ attributes: { name: 'video 10' } })
await waitJobs([ server ])
const now2 = new Date()
- await server.videosCommand.upload({ attributes: { name: 'video 11' } })
+ await server.videos.upload({ attributes: { name: 'video 11' } })
await waitJobs([ server ])
const body = await logsCommand.getAuditLogs({ startDate: now1, endDate: now2 })
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index 1fd5e613b..45a22e48d 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -33,7 +33,7 @@ describe('Test plugins', function () {
server = await flushAndRunServer(1, configOverride)
await setAccessTokensToServers([ server ])
- command = server.pluginsCommand
+ command = server.plugins
})
it('Should list and search available plugins and themes', async function () {
@@ -97,7 +97,7 @@ describe('Test plugins', function () {
})
it('Should have the plugin loaded in the configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const theme = config.theme.registered.find(r => r.name === 'background-red')
expect(theme).to.not.be.undefined
@@ -107,20 +107,20 @@ describe('Test plugins', function () {
})
it('Should update the default theme in the configuration', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
theme: { default: 'background-red' }
}
})
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
expect(config.theme.default).to.equal('background-red')
})
it('Should update my default theme', async function () {
- await server.usersCommand.updateMe({ theme: 'background-red' })
+ await server.users.updateMe({ theme: 'background-red' })
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
expect(user.theme).to.equal('background-red')
})
@@ -187,7 +187,7 @@ describe('Test plugins', function () {
it('Should have watched settings changes', async function () {
this.timeout(10000)
- await server.serversCommand.waitUntilLog('Settings changed!')
+ await server.servers.waitUntilLog('Settings changed!')
})
it('Should get a plugin and a theme', async function () {
@@ -234,7 +234,7 @@ describe('Test plugins', function () {
await wait(6000)
// Fake update our plugin version
- await server.sqlCommand.setPluginVersion('hello-world', '0.0.1')
+ await server.sql.setPluginVersion('hello-world', '0.0.1')
// Fake update package.json
const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world')
@@ -293,7 +293,7 @@ describe('Test plugins', function () {
})
it('Should have updated the configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
expect(config.theme.default).to.equal('default')
@@ -305,7 +305,7 @@ describe('Test plugins', function () {
})
it('Should have updated the user theme', async function () {
- const user = await server.usersCommand.getMyInfo()
+ const user = await server.users.getMyInfo()
expect(user.theme).to.equal('instance-default')
})
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts
index 5a6491430..de3cf02f2 100644
--- a/server/tests/api/server/reverse-proxy.ts
+++ b/server/tests/api/server/reverse-proxy.ts
@@ -33,59 +33,59 @@ describe('Test application behind a reverse proxy', function () {
server = await flushAndRunServer(1, config)
await setAccessTokensToServers([ server ])
- const { uuid } = await server.videosCommand.upload()
+ const { uuid } = await server.videos.upload()
videoId = uuid
})
it('Should view a video only once with the same IP by default', async function () {
this.timeout(20000)
- 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(1)
})
it('Should view a video 2 times with the X-Forwarded-For header set', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
// 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 view a video only once with the same client IP in the X-Forwarded-For header', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
// 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(4)
})
it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () {
this.timeout(20000)
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
- await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
+ await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
// 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(6)
})
@@ -93,22 +93,22 @@ describe('Test application behind a reverse proxy', function () {
const user = { username: 'root', password: 'fail' }
for (let i = 0; i < 19; i++) {
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
})
it('Should rate limit signup', async function () {
for (let i = 0; i < 10; i++) {
try {
- await server.usersCommand.register({ username: 'test' + i })
+ await server.users.register({ username: 'test' + i })
} catch {
// empty
}
}
- await server.usersCommand.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ await server.users.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
})
it('Should not rate limit failed signup', async function () {
@@ -117,10 +117,10 @@ describe('Test application behind a reverse proxy', function () {
await wait(7000)
for (let i = 0; i < 3; i++) {
- await server.usersCommand.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
+ await server.users.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
}
- await server.usersCommand.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
+ await server.users.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
})
@@ -131,13 +131,13 @@ describe('Test application behind a reverse proxy', function () {
for (let i = 0; i < 100; i++) {
try {
- await server.videosCommand.get({ id: videoId })
+ await server.videos.get({ id: videoId })
} catch {
// don't care if it fails
}
}
- await server.videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
+ await server.videos.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
})
after(async function () {
diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts
index a62fb3939..28f9ae3b6 100644
--- a/server/tests/api/server/services.ts
+++ b/server/tests/api/server/services.ts
@@ -23,25 +23,25 @@ describe('Test services', function () {
{
const attributes = { name: 'my super name' }
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
video = data[0]
}
{
- const created = await server.playlistsCommand.create({
+ const created = await server.playlists.create({
attributes: {
displayName: 'The Life and Times of Scrooge McDuck',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id
+ videoChannelId: server.store.channel.id
}
})
playlistUUID = created.uuid
playlistDisplayName = 'The Life and Times of Scrooge McDuck'
- await server.playlistsCommand.addElement({
+ await server.playlists.addElement({
playlistId: created.id,
attributes: {
videoId: video.id
@@ -54,7 +54,7 @@ describe('Test services', function () {
for (const basePath of [ '/videos/watch/', '/w/' ]) {
const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid
- const res = await server.servicesCommand.getOEmbed({ oembedUrl })
+ const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = ''
@@ -62,7 +62,7 @@ describe('Test services', function () {
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(video.name)
- expect(res.body.author_name).to.equal(server.videoChannel.displayName)
+ expect(res.body.author_name).to.equal(server.store.channel.displayName)
expect(res.body.width).to.equal(560)
expect(res.body.height).to.equal(315)
expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -75,14 +75,14 @@ describe('Test services', function () {
for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) {
const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID
- const res = await server.servicesCommand.getOEmbed({ oembedUrl })
+ const res = await server.services.getOEmbed({ oembedUrl })
const expectedHtml = ''
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck')
- expect(res.body.author_name).to.equal(server.videoChannel.displayName)
+ expect(res.body.author_name).to.equal(server.store.channel.displayName)
expect(res.body.width).to.equal(560)
expect(res.body.height).to.equal(315)
expect(res.body.thumbnail_url).exist
@@ -98,14 +98,14 @@ describe('Test services', function () {
const maxHeight = 50
const maxWidth = 50
- const res = await server.servicesCommand.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
+ const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
const expectedHtml = ''
expect(res.body.html).to.equal(expectedHtml)
expect(res.body.title).to.equal(video.name)
- expect(res.body.author_name).to.equal(server.videoChannel.displayName)
+ expect(res.body.author_name).to.equal(server.store.channel.displayName)
expect(res.body.height).to.equal(50)
expect(res.body.width).to.equal(50)
expect(res.body).to.not.have.property('thumbnail_url')
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index 3eb1efb94..be5abad52 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -32,23 +32,23 @@ describe('Test stats (excluding redundancy)', function () {
await doubleFollow(servers[0], servers[1])
- await servers[0].usersCommand.create({ username: user.username, password: user.password })
+ await servers[0].users.create({ username: user.username, password: user.password })
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { fixture: 'video_short.webm' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } })
- await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' })
+ await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
- await servers[0].videosCommand.view({ id: uuid })
+ await servers[0].videos.view({ id: uuid })
// Wait the video views repeatable job
await wait(8000)
- await servers[2].followsCommand.follow({ targets: [ servers[0].url ] })
+ await servers[2].follows.follow({ targets: [ servers[0].url ] })
await waitJobs(servers)
})
it('Should have the correct stats on instance 1', async function () {
- const data = await servers[0].statsCommand.get()
+ const data = await servers[0].stats.get()
expect(data.totalLocalVideoComments).to.equal(1)
expect(data.totalLocalVideos).to.equal(1)
@@ -63,7 +63,7 @@ describe('Test stats (excluding redundancy)', function () {
})
it('Should have the correct stats on instance 2', async function () {
- const data = await servers[1].statsCommand.get()
+ const data = await servers[1].stats.get()
expect(data.totalLocalVideoComments).to.equal(0)
expect(data.totalLocalVideos).to.equal(0)
@@ -78,7 +78,7 @@ describe('Test stats (excluding redundancy)', function () {
})
it('Should have the correct stats on instance 3', async function () {
- const data = await servers[2].statsCommand.get()
+ const data = await servers[2].stats.get()
expect(data.totalLocalVideoComments).to.equal(0)
expect(data.totalLocalVideos).to.equal(0)
@@ -94,10 +94,10 @@ describe('Test stats (excluding redundancy)', function () {
it('Should have the correct total videos stats after an unfollow', async function () {
this.timeout(15000)
- await servers[2].followsCommand.unfollow({ target: servers[0] })
+ await servers[2].follows.unfollow({ target: servers[0] })
await waitJobs(servers)
- const data = await servers[2].statsCommand.get()
+ const data = await servers[2].stats.get()
expect(data.totalVideos).to.equal(0)
})
@@ -106,7 +106,7 @@ describe('Test stats (excluding redundancy)', function () {
const server = servers[0]
{
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalDailyActiveUsers).to.equal(1)
expect(data.totalWeeklyActiveUsers).to.equal(1)
@@ -114,9 +114,9 @@ describe('Test stats (excluding redundancy)', function () {
}
{
- await server.loginCommand.getAccessToken(user)
+ await server.login.getAccessToken(user)
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalDailyActiveUsers).to.equal(2)
expect(data.totalWeeklyActiveUsers).to.equal(2)
@@ -128,7 +128,7 @@ describe('Test stats (excluding redundancy)', function () {
const server = servers[0]
{
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
@@ -140,10 +140,10 @@ describe('Test stats (excluding redundancy)', function () {
name: 'stats_channel',
displayName: 'My stats channel'
}
- const created = await server.channelsCommand.create({ attributes })
+ const created = await server.channels.create({ attributes })
channelId = created.id
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
@@ -151,9 +151,9 @@ describe('Test stats (excluding redundancy)', function () {
}
{
- await server.videosCommand.upload({ attributes: { fixture: 'video_short.webm', channelId } })
+ await server.videos.upload({ attributes: { fixture: 'video_short.webm', channelId } })
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
@@ -165,12 +165,12 @@ describe('Test stats (excluding redundancy)', function () {
const server = servers[0]
{
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalPlaylists).to.equal(0)
}
{
- await server.playlistsCommand.create({
+ await server.playlists.create({
attributes: {
displayName: 'playlist for count',
privacy: VideoPlaylistPrivacy.PUBLIC,
@@ -178,7 +178,7 @@ describe('Test stats (excluding redundancy)', function () {
}
})
- const data = await server.statsCommand.get()
+ const data = await server.stats.get()
expect(data.totalLocalPlaylists).to.equal(1)
}
})
@@ -186,7 +186,7 @@ describe('Test stats (excluding redundancy)', function () {
it('Should correctly count video file sizes if transcoding is enabled', async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
@@ -210,17 +210,17 @@ describe('Test stats (excluding redundancy)', function () {
}
})
- await servers[0].videosCommand.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } })
+ await servers[0].videos.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } })
await waitJobs(servers)
{
- const data = await servers[1].statsCommand.get()
+ const data = await servers[1].stats.get()
expect(data.totalLocalVideoFilesSize).to.equal(0)
}
{
- const data = await servers[0].statsCommand.get()
+ const data = await servers[0].stats.get()
expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000)
expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000)
}
@@ -229,7 +229,7 @@ describe('Test stats (excluding redundancy)', function () {
it('Should have the correct AP stats', async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
@@ -237,17 +237,17 @@ describe('Test stats (excluding redundancy)', function () {
}
})
- const first = await servers[1].statsCommand.get()
+ const first = await servers[1].stats.get()
for (let i = 0; i < 10; i++) {
- await servers[0].videosCommand.upload({ attributes: { name: 'video' } })
+ await servers[0].videos.upload({ attributes: { name: 'video' } })
}
await waitJobs(servers)
await wait(6000)
- const second = await servers[1].statsCommand.get()
+ const second = await servers[1].stats.get()
expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed)
const apTypes: ActivityType[] = [
@@ -269,7 +269,7 @@ describe('Test stats (excluding redundancy)', function () {
await wait(6000)
- const third = await servers[1].statsCommand.get()
+ const third = await servers[1].stats.get()
expect(third.totalActivityPubMessagesWaiting).to.equal(0)
expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond)
})
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts
index 032012edf..d80362fee 100644
--- a/server/tests/api/server/tracker.ts
+++ b/server/tests/api/server/tracker.ts
@@ -16,8 +16,8 @@ describe('Test tracker', function () {
await setAccessTokensToServers([ server ])
{
- const { uuid } = await server.videosCommand.upload()
- const video = await server.videosCommand.get({ id: uuid })
+ const { uuid } = await server.videos.upload()
+ const video = await server.videos.get({ id: uuid })
goodMagnet = video.files[0].magnetUri
const parsed = magnetUtil.decode(goodMagnet)
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 622cddb7d..1b15a98dc 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -35,26 +35,26 @@ describe('Test users subscriptions', function () {
{
for (const server of servers) {
const user = { username: 'user' + server.serverNumber, password: 'password' }
- await server.usersCommand.create({ username: user.username, password: user.password })
+ await server.users.create({ username: user.username, password: user.password })
- const accessToken = await server.loginCommand.getAccessToken(user)
+ const accessToken = await server.login.getAccessToken(user)
users.push({ accessToken })
const videoName1 = 'video 1-' + server.serverNumber
- await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName1 } })
+ await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } })
const videoName2 = 'video 2-' + server.serverNumber
- await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName2 } })
+ await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } })
}
}
await waitJobs(servers)
- command = servers[0].subscriptionsCommand
+ command = servers[0].subscriptions
})
it('Should display videos of server 2 on server 1', async function () {
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(4)
})
@@ -67,14 +67,14 @@ describe('Test users subscriptions', function () {
await waitJobs(servers)
- const { uuid } = await servers[2].videosCommand.upload({ attributes: { name: 'video server 3 added after follow' } })
+ const { uuid } = await servers[2].videos.upload({ attributes: { name: 'video server 3 added after follow' } })
video3UUID = uuid
await waitJobs(servers)
})
it('Should not display videos of server 3 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(4)
for (const video of data) {
@@ -183,7 +183,7 @@ describe('Test users subscriptions', function () {
this.timeout(60000)
const videoName = 'video server 1 added after follow'
- await servers[0].videosCommand.upload({ attributes: { name: videoName } })
+ await servers[0].videos.upload({ attributes: { name: videoName } })
await waitJobs(servers)
@@ -209,7 +209,7 @@ describe('Test users subscriptions', function () {
}
{
- const { data, total } = await servers[0].videosCommand.list()
+ const { data, total } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
@@ -223,11 +223,11 @@ describe('Test users subscriptions', function () {
it('Should have server 1 follow server 3 and display server 3 videos', async function () {
this.timeout(60000)
- await servers[0].followsCommand.follow({ targets: [ servers[2].url ] })
+ await servers[0].follows.follow({ targets: [ servers[2].url ] })
await waitJobs(servers)
- const { data, total } = await servers[0].videosCommand.list()
+ const { data, total } = await servers[0].videos.list()
expect(total).to.equal(8)
const names = [ '1-3', '2-3', 'video server 3 added after follow' ]
@@ -240,11 +240,11 @@ describe('Test users subscriptions', function () {
it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
this.timeout(60000)
- await servers[0].followsCommand.unfollow({ target: servers[2] })
+ await servers[0].follows.unfollow({ target: servers[2] })
await waitJobs(servers)
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
@@ -280,7 +280,7 @@ describe('Test users subscriptions', function () {
it('Should update a video of server 3 and see the updated video on server 1', async function () {
this.timeout(30000)
- await servers[2].videosCommand.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
+ await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
await waitJobs(servers)
@@ -325,7 +325,7 @@ describe('Test users subscriptions', function () {
})
it('Should correctly display public videos 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(5)
for (const video of data) {
@@ -356,7 +356,7 @@ describe('Test users subscriptions', function () {
}
{
- const { total, data } = await servers[0].videosCommand.list()
+ const { total, data } = await servers[0].videos.list()
expect(total).to.equal(5)
for (const video of data) {
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 3ae105008..f8d7ae88e 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -42,20 +42,20 @@ describe('Test users with multiple servers', function () {
await doubleFollow(servers[1], servers[2])
// The root user of server 1 is propagated to servers 2 and 3
- await servers[0].videosCommand.upload()
+ await servers[0].videos.upload()
{
const user = {
username: 'user1',
password: 'password'
}
- const created = await servers[0].usersCommand.create(user)
+ const created = await servers[0].users.create(user)
userId = created.id
- userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ userAccessToken = await servers[0].login.getAccessToken(user)
}
{
- const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken })
+ const { uuid } = await servers[0].videos.upload({ token: userAccessToken })
videoUUID = uuid
}
@@ -65,9 +65,9 @@ describe('Test users with multiple servers', function () {
it('Should be able to update my display name', async function () {
this.timeout(10000)
- await servers[0].usersCommand.updateMe({ displayName: 'my super display name' })
+ await servers[0].users.updateMe({ displayName: 'my super display name' })
- user = await servers[0].usersCommand.getMyInfo()
+ user = await servers[0].users.getMyInfo()
expect(user.account.displayName).to.equal('my super display name')
await waitJobs(servers)
@@ -76,9 +76,9 @@ describe('Test users with multiple servers', function () {
it('Should be able to update my description', async function () {
this.timeout(10_000)
- await servers[0].usersCommand.updateMe({ description: 'my super description updated' })
+ await servers[0].users.updateMe({ description: 'my super description updated' })
- user = await servers[0].usersCommand.getMyInfo()
+ user = await servers[0].users.getMyInfo()
expect(user.account.displayName).to.equal('my super display name')
expect(user.account.description).to.equal('my super description updated')
@@ -90,9 +90,9 @@ describe('Test users with multiple servers', function () {
const fixture = 'avatar2.png'
- await servers[0].usersCommand.updateMyAvatar({ fixture })
+ await servers[0].users.updateMyAvatar({ fixture })
- user = await servers[0].usersCommand.getMyInfo()
+ user = await servers[0].users.getMyInfo()
userAvatarFilename = user.account.avatar.path
await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
@@ -104,12 +104,12 @@ describe('Test users with multiple servers', function () {
let createdAt: string | Date
for (const server of servers) {
- const body = await server.accountsCommand.list({ sort: '-createdAt' })
+ const body = await server.accounts.list({ sort: '-createdAt' })
const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port)
expect(resList).not.to.be.undefined
- const account = await server.accountsCommand.get({ accountName: resList.name + '@' + resList.host })
+ const account = await server.accounts.get({ accountName: resList.name + '@' + resList.host })
if (!createdAt) createdAt = account.createdAt
@@ -131,7 +131,7 @@ describe('Test users with multiple servers', function () {
it('Should list account videos', async function () {
for (const server of servers) {
- const { total, data } = await server.videosCommand.listByAccount({ accountName: 'user1@localhost:' + servers[0].port })
+ const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.be.an('array')
@@ -143,12 +143,12 @@ describe('Test users with multiple servers', function () {
it('Should search through account videos', async function () {
this.timeout(10_000)
- const created = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } })
+ const created = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } })
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videosCommand.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' })
+ const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' })
expect(total).to.equal(1)
expect(data).to.be.an('array')
@@ -161,27 +161,27 @@ describe('Test users with multiple servers', function () {
this.timeout(10_000)
for (const server of servers) {
- const body = await server.accountsCommand.list({ sort: '-createdAt' })
+ const body = await server.accounts.list({ sort: '-createdAt' })
const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
expect(accountDeleted).not.to.be.undefined
- const { data } = await server.channelsCommand.list()
+ const { data } = await server.channels.list()
const videoChannelDeleted = data.find(a => a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port)
expect(videoChannelDeleted).not.to.be.undefined
}
- await servers[0].usersCommand.remove({ userId })
+ await servers[0].users.remove({ userId })
await waitJobs(servers)
for (const server of servers) {
- const body = await server.accountsCommand.list({ sort: '-createdAt' })
+ const body = await server.accounts.list({ sort: '-createdAt' })
const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
expect(accountDeleted).to.be.undefined
- const { data } = await server.channelsCommand.list()
+ const { data } = await server.channels.list()
const videoChannelDeleted = data.find(a => a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port)
expect(videoChannelDeleted).to.be.undefined
}
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts
index 271aa3c7a..c8c226fa8 100644
--- a/server/tests/api/users/users-verification.ts
+++ b/server/tests/api/users/users-verification.ts
@@ -42,7 +42,7 @@ describe('Test users account verification', function () {
it('Should register user and send verification email if verification required', async function () {
this.timeout(30000)
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
@@ -52,7 +52,7 @@ describe('Test users account verification', function () {
}
})
- await server.usersCommand.register(user1)
+ await server.users.register(user1)
await waitJobs(server)
expectedEmailsLength++
@@ -71,22 +71,22 @@ describe('Test users account verification', function () {
userId = parseInt(userIdMatches[1], 10)
- const body = await server.usersCommand.get({ userId })
+ const body = await server.users.get({ userId })
expect(body.emailVerified).to.be.false
})
it('Should not allow login for user with unverified email', async function () {
- const { detail } = await server.loginCommand.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const { detail } = await server.login.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(detail).to.contain('User email is not verified.')
})
it('Should verify the user via email and allow login', async function () {
- await server.usersCommand.verifyEmail({ userId, verificationString })
+ await server.users.verifyEmail({ userId, verificationString })
- const body = await server.loginCommand.login({ user: user1 })
+ const body = await server.login.login({ user: user1 })
userAccessToken = body.access_token
- const user = await server.usersCommand.get({ userId })
+ const user = await server.users.get({ userId })
expect(user.emailVerified).to.be.true
})
@@ -96,7 +96,7 @@ describe('Test users account verification', function () {
let updateVerificationString: string
{
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userAccessToken,
email: 'updated@example.com',
currentPassword: user1.password
@@ -113,15 +113,15 @@ describe('Test users account verification', function () {
}
{
- const me = await server.usersCommand.getMyInfo({ token: userAccessToken })
+ const me = await server.users.getMyInfo({ token: userAccessToken })
expect(me.email).to.equal('user_1@example.com')
expect(me.pendingEmail).to.equal('updated@example.com')
}
{
- await server.usersCommand.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true })
+ await server.users.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true })
- const me = await server.usersCommand.getMyInfo({ token: userAccessToken })
+ const me = await server.users.getMyInfo({ token: userAccessToken })
expect(me.email).to.equal('updated@example.com')
expect(me.pendingEmail).to.be.null
}
@@ -129,7 +129,7 @@ describe('Test users account verification', function () {
it('Should register user not requiring email verification if setting not enabled', async function () {
this.timeout(5000)
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
@@ -139,19 +139,19 @@ describe('Test users account verification', function () {
}
})
- await server.usersCommand.register(user2)
+ await server.users.register(user2)
await waitJobs(server)
expect(emails).to.have.lengthOf(expectedEmailsLength)
- const accessToken = await server.loginCommand.getAccessToken(user2)
+ const accessToken = await server.login.getAccessToken(user2)
- const user = await server.usersCommand.getMyInfo({ token: accessToken })
+ const user = await server.users.getMyInfo({ token: accessToken })
expect(user.emailVerified).to.be.null
})
it('Should allow login for user with unverified email when setting later enabled', async function () {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
signup: {
enabled: true,
@@ -161,7 +161,7 @@ describe('Test users account verification', function () {
}
})
- await server.loginCommand.getAccessToken(user2)
+ await server.login.getAccessToken(user2)
})
after(async function () {
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6f3873939..310136a37 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -42,7 +42,7 @@ describe('Test users', function () {
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' })
+ await server.plugins.install({ npmName: 'peertube-theme-background-red' })
})
describe('OAuth client', function () {
@@ -53,8 +53,8 @@ describe('Test users', function () {
it('Should remove the last client')
it('Should not login with an invalid client id', async function () {
- const client = { id: 'client', secret: server.client.secret }
- const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const client = { id: 'client', secret: server.store.client.secret }
+ const body = await server.login.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
expect(body.error).to.contain('client is invalid')
@@ -63,8 +63,8 @@ describe('Test users', function () {
})
it('Should not login with an invalid client secret', async function () {
- const client = { id: server.client.id, secret: 'coucou' }
- const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const client = { id: server.store.client.id, secret: 'coucou' }
+ const body = await server.login.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
expect(body.error).to.contain('client is invalid')
@@ -76,8 +76,8 @@ describe('Test users', function () {
describe('Login', function () {
it('Should not login with an invalid username', async function () {
- const user = { username: 'captain crochet', password: server.user.password }
- const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const user = { username: 'captain crochet', password: server.store.user.password }
+ const body = await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
expect(body.error).to.contain('credentials are invalid')
@@ -86,8 +86,8 @@ describe('Test users', function () {
})
it('Should not login with an invalid password', async function () {
- const user = { username: server.user.username, password: 'mew_three' }
- const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ const user = { username: server.store.user.username, password: 'mew_three' }
+ const body = await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
expect(body.error).to.contain('credentials are invalid')
@@ -98,13 +98,13 @@ describe('Test users', function () {
it('Should not be able to upload a video', async function () {
token = 'my_super_token'
- await server.videosCommand.upload({ token, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.videos.upload({ token, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to follow', async function () {
token = 'my_super_token'
- await server.followsCommand.follow({
+ await server.follows.follow({
targets: [ 'http://example.com' ],
token,
expectedStatus: HttpStatusCode.UNAUTHORIZED_401
@@ -114,28 +114,28 @@ describe('Test users', function () {
it('Should not be able to unfollow')
it('Should be able to login', async function () {
- const body = await server.loginCommand.login({ expectedStatus: HttpStatusCode.OK_200 })
+ const body = await server.login.login({ expectedStatus: HttpStatusCode.OK_200 })
token = body.access_token
})
it('Should be able to login with an insensitive username', async function () {
- const user = { username: 'RoOt', password: server.user.password }
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.OK_200 })
+ const user = { username: 'RoOt', password: server.store.user.password }
+ await server.login.login({ user, expectedStatus: HttpStatusCode.OK_200 })
- const user2 = { username: 'rOoT', password: server.user.password }
- await server.loginCommand.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 })
+ const user2 = { username: 'rOoT', password: server.store.user.password }
+ await server.login.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 })
- const user3 = { username: 'ROOt', password: server.user.password }
- await server.loginCommand.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 })
+ const user3 = { username: 'ROOt', password: server.store.user.password }
+ await server.login.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 })
})
})
describe('Upload', function () {
it('Should upload the video with the correct token', async function () {
- await server.videosCommand.upload({ token })
- const { data } = await server.videosCommand.list()
+ await server.videos.upload({ token })
+ const { data } = await server.videos.list()
const video = data[0]
expect(video.account.name).to.equal('root')
@@ -143,24 +143,24 @@ describe('Test users', function () {
})
it('Should upload the video again with the correct token', async function () {
- await server.videosCommand.upload({ token })
+ await server.videos.upload({ token })
})
})
describe('Ratings', function () {
it('Should retrieve a video rating', async function () {
- await server.videosCommand.rate({ id: videoId, rating: 'like' })
- const rating = await server.usersCommand.getMyRating({ token, videoId })
+ await server.videos.rate({ id: videoId, rating: 'like' })
+ const rating = await server.users.getMyRating({ token, videoId })
expect(rating.videoId).to.equal(videoId)
expect(rating.rating).to.equal('like')
})
it('Should retrieve ratings list', async function () {
- await server.videosCommand.rate({ id: videoId, rating: 'like' })
+ await server.videos.rate({ id: videoId, rating: 'like' })
- const body = await server.accountsCommand.listRatings({ accountName: server.user.username })
+ const body = await server.accounts.listRatings({ accountName: server.store.user.username })
expect(body.total).to.equal(1)
expect(body.data[0].video.id).to.equal(videoId)
@@ -169,12 +169,12 @@ describe('Test users', function () {
it('Should retrieve ratings list by rating type', async function () {
{
- const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'like' })
+ const body = await server.accounts.listRatings({ accountName: server.store.user.username, rating: 'like' })
expect(body.data.length).to.equal(1)
}
{
- const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'dislike' })
+ const body = await server.accounts.listRatings({ accountName: server.store.user.username, rating: 'dislike' })
expect(body.data.length).to.equal(0)
}
})
@@ -182,27 +182,27 @@ describe('Test users', function () {
describe('Remove video', function () {
it('Should not be able to remove the video with an incorrect token', async function () {
- await server.videosCommand.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.videos.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to remove the video with the token of another account')
it('Should be able to remove the video with the correct token', async function () {
- await server.videosCommand.remove({ token, id: videoId })
+ await server.videos.remove({ token, id: videoId })
})
})
describe('Logout', function () {
it('Should logout (revoke token)', async function () {
- await server.loginCommand.logout({ token: server.accessToken })
+ await server.login.logout({ token: server.accessToken })
})
it('Should not be able to get the user information', async function () {
- await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to upload a video', async function () {
- await server.videosCommand.upload({ attributes: { name: 'video' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.videos.upload({ attributes: { name: 'video' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to rate a video', async function () {
@@ -222,64 +222,64 @@ describe('Test users', function () {
})
it('Should be able to login again', async function () {
- const body = await server.loginCommand.login()
+ const body = await server.login.login()
server.accessToken = body.access_token
server.refreshToken = body.refresh_token
})
it('Should be able to get my user information again', async function () {
- await server.usersCommand.getMyInfo()
+ await server.users.getMyInfo()
})
it('Should have an expired access token', async function () {
this.timeout(15000)
- await server.sqlCommand.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString())
- await server.sqlCommand.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString())
+ await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString())
+ await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString())
await killallServers([ server ])
await reRunServer(server)
- await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should not be able to refresh an access token with an expired refresh token', async function () {
- await server.loginCommand.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should refresh the token', async function () {
this.timeout(15000)
const futureDate = new Date(new Date().getTime() + 1000 * 60).toISOString()
- await server.sqlCommand.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate)
+ await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate)
await killallServers([ server ])
await reRunServer(server)
- const res = await server.loginCommand.refreshToken({ refreshToken: server.refreshToken })
+ const res = await server.login.refreshToken({ refreshToken: server.refreshToken })
server.accessToken = res.body.access_token
server.refreshToken = res.body.refresh_token
})
it('Should be able to get my user information again', async function () {
- await server.usersCommand.getMyInfo()
+ await server.users.getMyInfo()
})
})
describe('Creating a user', function () {
it('Should be able to create a new user', async function () {
- await server.usersCommand.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST })
+ await server.users.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST })
})
it('Should be able to login with this user', async function () {
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
})
it('Should be able to get user information', async function () {
- const userMe = await server.usersCommand.getMyInfo({ token: userToken })
+ const userMe = await server.users.getMyInfo({ token: userToken })
- const userGet = await server.usersCommand.get({ userId: userMe.id, withStats: true })
+ const userGet = await server.users.get({ userId: userMe.id, withStats: true })
for (const user of [ userMe, userGet ]) {
expect(user.username).to.equal('user_1')
@@ -319,20 +319,20 @@ describe('Test users', function () {
name: 'super user video',
fixture: 'video_short.webm'
}
- await server.videosCommand.upload({ token: userToken, attributes })
+ await server.videos.upload({ token: userToken, attributes })
})
it('Should have video quota updated', async function () {
- const quota = await server.usersCommand.getMyQuotaUsed({ token: userToken })
+ const quota = await server.users.getMyQuotaUsed({ token: userToken })
expect(quota.videoQuotaUsed).to.equal(218910)
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
const tmpUser = data.find(u => u.username === user.username)
expect(tmpUser.videoQuotaUsed).to.equal(218910)
})
it('Should be able to list my videos', async function () {
- const { total, data } = await server.videosCommand.listMyVideos({ token: userToken })
+ const { total, data } = await server.videos.listMyVideos({ token: userToken })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -344,13 +344,13 @@ describe('Test users', function () {
it('Should be able to search in my videos', async function () {
{
- const { total, data } = await server.videosCommand.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })
+ const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
}
{
- const { total, data } = await server.videosCommand.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' })
+ const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' })
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
}
@@ -360,11 +360,11 @@ describe('Test users', function () {
this.timeout(60000)
{
- const config = await server.configCommand.getCustomConfig()
+ const config = await server.config.getCustomConfig()
config.transcoding.webtorrent.enabled = false
config.transcoding.hls.enabled = true
config.transcoding.enabled = true
- await server.configCommand.updateCustomSubConfig({ newConfig: config })
+ await server.config.updateCustomSubConfig({ newConfig: config })
}
{
@@ -372,13 +372,13 @@ describe('Test users', function () {
name: 'super user video 2',
fixture: 'video_short.webm'
}
- await server.videosCommand.upload({ token: userToken, attributes })
+ await server.videos.upload({ token: userToken, attributes })
await waitJobs([ server ])
}
{
- const data = await server.usersCommand.getMyQuotaUsed({ token: userToken })
+ const data = await server.users.getMyQuotaUsed({ token: userToken })
expect(data.videoQuotaUsed).to.be.greaterThan(220000)
}
})
@@ -387,7 +387,7 @@ describe('Test users', function () {
describe('Users listing', function () {
it('Should list all the users', async function () {
- const { data, total } = await server.usersCommand.list()
+ const { data, total } = await server.users.list()
expect(total).to.equal(2)
expect(data).to.be.an('array')
@@ -410,7 +410,7 @@ describe('Test users', function () {
})
it('Should list only the first user by username asc', async function () {
- const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: 'username' })
+ const { total, data } = await server.users.list({ start: 0, count: 1, sort: 'username' })
expect(total).to.equal(2)
expect(data.length).to.equal(1)
@@ -423,7 +423,7 @@ describe('Test users', function () {
})
it('Should list only the first user by username desc', async function () {
- const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: '-username' })
+ const { total, data } = await server.users.list({ start: 0, count: 1, sort: '-username' })
expect(total).to.equal(2)
expect(data.length).to.equal(1)
@@ -435,7 +435,7 @@ describe('Test users', function () {
})
it('Should list only the second user by createdAt desc', async function () {
- const { data, total } = await server.usersCommand.list({ start: 0, count: 1, sort: '-createdAt' })
+ const { data, total } = await server.users.list({ start: 0, count: 1, sort: '-createdAt' })
expect(total).to.equal(2)
expect(data.length).to.equal(1)
@@ -447,7 +447,7 @@ describe('Test users', function () {
})
it('Should list all the users by createdAt asc', async function () {
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt' })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt' })
expect(total).to.equal(2)
expect(data.length).to.equal(2)
@@ -462,7 +462,7 @@ describe('Test users', function () {
})
it('Should search user by username', async function () {
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
expect(data[0].username).to.equal('root')
@@ -470,7 +470,7 @@ describe('Test users', function () {
it('Should search user by email', async function () {
{
- const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' })
+ const { total, data } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
expect(data[0].username).to.equal('user_1')
@@ -478,7 +478,7 @@ describe('Test users', function () {
}
{
- const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' })
+ const { total, data } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' })
expect(total).to.equal(2)
expect(data.length).to.equal(2)
expect(data[0].username).to.equal('root')
@@ -490,23 +490,23 @@ describe('Test users', function () {
describe('Update my account', function () {
it('Should update my password', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
currentPassword: 'super password',
password: 'new password'
})
user.password = 'new password'
- await server.loginCommand.login({ user })
+ await server.login.login({ user })
})
it('Should be able to change the NSFW display attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
nsfwPolicy: 'do_not_list'
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('user_1@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -517,33 +517,33 @@ describe('Test users', function () {
})
it('Should be able to change the autoPlayVideo attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
autoPlayVideo: false
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.autoPlayVideo).to.be.false
})
it('Should be able to change the autoPlayNextVideo attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
autoPlayNextVideo: true
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.autoPlayNextVideo).to.be.true
})
it('Should be able to change the email attribute', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
currentPassword: 'new password',
email: 'updated@example.com'
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -556,9 +556,9 @@ describe('Test users', function () {
it('Should be able to update my avatar with a gif', async function () {
const fixture = 'avatar.gif'
- await server.usersCommand.updateMyAvatar({ token: userToken, fixture })
+ await server.users.updateMyAvatar({ token: userToken, fixture })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif')
})
@@ -566,17 +566,17 @@ describe('Test users', function () {
for (const extension of [ '.png', '.gif' ]) {
const fixture = 'avatar' + extension
- await server.usersCommand.updateMyAvatar({ token: userToken, fixture })
+ await server.users.updateMyAvatar({ token: userToken, fixture })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
await testImage(server.url, 'avatar-resized', user.account.avatar.path, extension)
}
})
it('Should be able to update my display name', async function () {
- await server.usersCommand.updateMe({ token: userToken, displayName: 'new display name' })
+ await server.users.updateMe({ token: userToken, displayName: 'new display name' })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -587,9 +587,9 @@ describe('Test users', function () {
})
it('Should be able to update my description', async function () {
- await server.usersCommand.updateMe({ token: userToken, description: 'my super description updated' })
+ await server.users.updateMe({ token: userToken, description: 'my super description updated' })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated@example.com')
expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -603,21 +603,21 @@ describe('Test users', function () {
it('Should be able to update my theme', async function () {
for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
- await server.usersCommand.updateMe({ token: userToken, theme })
+ await server.users.updateMe({ token: userToken, theme })
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.theme).to.equal(theme)
}
})
it('Should be able to update my modal preferences', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: userToken,
noInstanceConfigWarningModal: true,
noWelcomeModal: true
})
- const user = await server.usersCommand.getMyInfo({ token: userToken })
+ const user = await server.users.getMyInfo({ token: userToken })
expect(user.noWelcomeModal).to.be.true
expect(user.noInstanceConfigWarningModal).to.be.true
})
@@ -625,7 +625,7 @@ describe('Test users', function () {
describe('Updating another user', function () {
it('Should be able to update another user', async function () {
- await server.usersCommand.update({
+ await server.users.update({
userId,
token,
email: 'updated2@example.com',
@@ -636,7 +636,7 @@ describe('Test users', function () {
pluginAuth: 'toto'
})
- const user = await server.usersCommand.get({ token, userId })
+ const user = await server.users.get({ token, userId })
expect(user.username).to.equal('user_1')
expect(user.email).to.equal('updated2@example.com')
@@ -650,47 +650,47 @@ describe('Test users', function () {
})
it('Should reset the auth plugin', async function () {
- await server.usersCommand.update({ userId, token, pluginAuth: null })
+ await server.users.update({ userId, token, pluginAuth: null })
- const user = await server.usersCommand.get({ token, userId })
+ const user = await server.users.get({ token, userId })
expect(user.pluginAuth).to.be.null
})
it('Should have removed the user token', async function () {
- await server.usersCommand.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
})
it('Should be able to update another user password', async function () {
- await server.usersCommand.update({ userId, token, password: 'password updated' })
+ await server.users.update({ userId, token, password: 'password updated' })
- await server.usersCommand.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
user.password = 'password updated'
- userToken = await server.loginCommand.getAccessToken(user)
+ userToken = await server.login.getAccessToken(user)
})
})
describe('Video blacklists', function () {
it('Should be able to list video blacklist by a moderator', async function () {
- await server.blacklistCommand.list({ token: userToken })
+ await server.blacklist.list({ token: userToken })
})
})
describe('Remove a user', function () {
it('Should be able to remove this user', async function () {
- await server.usersCommand.remove({ userId, token })
+ await server.users.remove({ userId, token })
})
it('Should not be able to login with this user', async function () {
- await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not have videos of this user', async function () {
- const { data, total } = await server.videosCommand.list()
+ const { data, total } = await server.videos.list()
expect(total).to.equal(1)
const video = data[0]
@@ -705,7 +705,7 @@ describe('Test users', function () {
const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' }
const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' }
- await server.usersCommand.register({ ...user, channel })
+ await server.users.register({ ...user, channel })
})
it('Should be able to login with this registered user', async function () {
@@ -714,35 +714,35 @@ describe('Test users', function () {
password: 'my super password'
}
- user15AccessToken = await server.loginCommand.getAccessToken(user15)
+ user15AccessToken = await server.login.getAccessToken(user15)
})
it('Should have the correct display name', async function () {
- const user = await server.usersCommand.getMyInfo({ token: user15AccessToken })
+ const user = await server.users.getMyInfo({ token: user15AccessToken })
expect(user.account.displayName).to.equal('super user 15')
})
it('Should have the correct video quota', async function () {
- const user = await server.usersCommand.getMyInfo({ token: user15AccessToken })
+ const user = await server.users.getMyInfo({ token: user15AccessToken })
expect(user.videoQuota).to.equal(5 * 1024 * 1024)
})
it('Should have created the channel', async function () {
- const { displayName } = await server.channelsCommand.get({ channelName: 'my_user_15_channel' })
+ const { displayName } = await server.channels.get({ channelName: 'my_user_15_channel' })
expect(displayName).to.equal('my channel rocks')
})
it('Should remove me', async function () {
{
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
expect(data.find(u => u.username === 'user_15')).to.not.be.undefined
}
- await server.usersCommand.deleteMe({ token: user15AccessToken })
+ await server.users.deleteMe({ token: user15AccessToken })
{
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
expect(data.find(u => u.username === 'user_15')).to.be.undefined
}
})
@@ -757,21 +757,21 @@ describe('Test users', function () {
}
it('Should block a user', async function () {
- const user = await server.usersCommand.create({ ...user16 })
+ const user = await server.users.create({ ...user16 })
user16Id = user.id
- user16AccessToken = await server.loginCommand.getAccessToken(user16)
+ user16AccessToken = await server.login.getAccessToken(user16)
- await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
- await server.usersCommand.banUser({ userId: user16Id })
+ await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
+ await server.users.banUser({ userId: user16Id })
- await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
- await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.login.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should search user by banned status', async function () {
{
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: true })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: true })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
@@ -779,7 +779,7 @@ describe('Test users', function () {
}
{
- const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: false })
+ const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: false })
expect(total).to.equal(1)
expect(data.length).to.equal(1)
@@ -788,9 +788,9 @@ describe('Test users', function () {
})
it('Should unblock a user', async function () {
- await server.usersCommand.unbanUser({ userId: user16Id })
- user16AccessToken = await server.loginCommand.getAccessToken(user16)
- await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
+ await server.users.unbanUser({ userId: user16Id })
+ user16AccessToken = await server.login.getAccessToken(user16)
+ await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -803,12 +803,12 @@ describe('Test users', function () {
username: 'user_17',
password: 'my super password'
}
- const created = await server.usersCommand.create({ ...user17 })
+ const created = await server.users.create({ ...user17 })
user17Id = created.id
- user17AccessToken = await server.loginCommand.getAccessToken(user17)
+ user17AccessToken = await server.login.getAccessToken(user17)
- const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user = await server.users.get({ userId: user17Id, withStats: true })
expect(user.videosCount).to.equal(0)
expect(user.videoCommentsCount).to.equal(0)
expect(user.abusesCount).to.equal(0)
@@ -818,37 +818,37 @@ describe('Test users', function () {
it('Should report correct videos count', async function () {
const attributes = { name: 'video to test user stats' }
- await server.videosCommand.upload({ token: user17AccessToken, attributes })
+ await server.videos.upload({ token: user17AccessToken, attributes })
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
videoId = data.find(video => video.name === attributes.name).id
- const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user = await server.users.get({ userId: user17Id, withStats: true })
expect(user.videosCount).to.equal(1)
})
it('Should report correct video comments for user', async function () {
const text = 'super comment'
- await server.commentsCommand.createThread({ token: user17AccessToken, videoId, text })
+ await server.comments.createThread({ token: user17AccessToken, videoId, text })
- const user = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user = await server.users.get({ userId: user17Id, withStats: true })
expect(user.videoCommentsCount).to.equal(1)
})
it('Should report correct abuses counts', async function () {
const reason = 'my super bad reason'
- await server.abusesCommand.report({ token: user17AccessToken, videoId, reason })
+ await server.abuses.report({ token: user17AccessToken, videoId, reason })
- const body1 = await server.abusesCommand.getAdminList()
+ const body1 = await server.abuses.getAdminList()
const abuseId = body1.data[0].id
- const user2 = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user2 = await server.users.get({ userId: user17Id, withStats: true })
expect(user2.abusesCount).to.equal(1) // number of incriminations
expect(user2.abusesCreatedCount).to.equal(1) // number of reports created
- await server.abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
+ await server.abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
- const user3 = await server.usersCommand.get({ userId: user17Id, withStats: true })
+ const user3 = await server.users.get({ userId: user17Id, withStats: true })
expect(user3.abusesAcceptedCount).to.equal(1) // number of reports created accepted
})
})
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)
}
})
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index b1d9da242..26f4bdc8d 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -35,12 +35,12 @@ describe('Test create import video jobs', function () {
// Upload two videos for our needs
{
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video1' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } })
video1UUID = uuid
}
{
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video2' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video2' } })
video2UUID = uuid
}
@@ -50,16 +50,16 @@ describe('Test create import video jobs', function () {
it('Should run a import job on video 1 with a lower resolution', async function () {
const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`
- await servers[0].cliCommand.execWithEnv(command)
+ await servers[0].cli.execWithEnv(command)
await waitJobs(servers)
for (const server of servers) {
- const { data: videos } = await server.videosCommand.list()
+ const { data: videos } = await server.videos.list()
expect(videos).to.have.lengthOf(2)
const video = videos.find(({ uuid }) => uuid === video1UUID)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(2)
const [ originalVideo, transcodedVideo ] = videoDetails.files
@@ -70,16 +70,16 @@ describe('Test create import video jobs', function () {
it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`
- await servers[1].cliCommand.execWithEnv(command)
+ await servers[1].cli.execWithEnv(command)
await waitJobs(servers)
for (const server of servers) {
- const { data: videos } = await server.videosCommand.list()
+ const { data: videos } = await server.videos.list()
expect(videos).to.have.lengthOf(2)
const video = videos.find(({ uuid }) => uuid === video2UUID)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(4)
const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files
@@ -92,16 +92,16 @@ describe('Test create import video jobs', function () {
it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`
- await servers[0].cliCommand.execWithEnv(command)
+ await servers[0].cli.execWithEnv(command)
await waitJobs(servers)
for (const server of servers) {
- const { data: videos } = await server.videosCommand.list()
+ const { data: videos } = await server.videos.list()
expect(videos).to.have.lengthOf(2)
const video = videos.find(({ uuid }) => uuid === video1UUID)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(2)
const [ video720, video480 ] = videoDetails.files
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index f629306e6..c9bbab802 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -42,12 +42,12 @@ describe('Test create transcoding jobs', function () {
servers = await flushAndRunMultipleServers(2)
await setAccessTokensToServers(servers)
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
await doubleFollow(servers[0], servers[1])
for (let i = 1; i <= 5; i++) {
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' + i } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } })
videosUUID.push(uuid)
}
@@ -58,11 +58,11 @@ describe('Test create transcoding jobs', function () {
this.timeout(30000)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(videosUUID.length)
for (const video of data) {
- const videoDetail = await server.videosCommand.get({ id: video.uuid })
+ const videoDetail = await server.videos.get({ id: video.uuid })
expect(videoDetail.files).to.have.lengthOf(1)
expect(videoDetail.streamingPlaylists).to.have.lengthOf(0)
}
@@ -72,16 +72,16 @@ describe('Test create transcoding jobs', function () {
it('Should run a transcoding job on video 2', async function () {
this.timeout(60000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
let infoHashes: { [id: number]: string }
for (const video of data) {
- const videoDetail = await server.videosCommand.get({ id: video.uuid })
+ const videoDetail = await server.videos.get({ id: video.uuid })
if (video.uuid === videosUUID[1]) {
expect(videoDetail.files).to.have.lengthOf(4)
@@ -110,15 +110,15 @@ describe('Test create transcoding jobs', function () {
it('Should run a transcoding job on video 1 with resolution', async function () {
this.timeout(60000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(videosUUID.length)
- const videoDetails = await server.videosCommand.get({ id: videosUUID[0] })
+ const videoDetails = await server.videos.get({ id: videosUUID[0] })
expect(videoDetails.files).to.have.lengthOf(2)
expect(videoDetails.files[0].resolution.id).to.equal(720)
@@ -131,12 +131,12 @@ describe('Test create transcoding jobs', function () {
it('Should generate an HLS resolution', async function () {
this.timeout(120000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[2] })
+ const videoDetails = await server.videos.get({ id: videosUUID[2] })
expect(videoDetails.files).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -150,12 +150,12 @@ describe('Test create transcoding jobs', function () {
it('Should not duplicate an HLS resolution', async function () {
this.timeout(120000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[2] })
+ const videoDetails = await server.videos.get({ id: videosUUID[2] })
const files = videoDetails.streamingPlaylists[0].files
expect(files).to.have.lengthOf(1)
@@ -166,12 +166,12 @@ describe('Test create transcoding jobs', function () {
it('Should generate all HLS resolutions', async function () {
this.timeout(120000)
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[3] })
+ const videoDetails = await server.videos.get({ id: videosUUID[3] })
expect(videoDetails.files).to.have.lengthOf(1)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -185,14 +185,14 @@ describe('Test create transcoding jobs', function () {
this.timeout(120000)
config.transcoding.hls.enabled = true
- await servers[0].configCommand.updateCustomSubConfig({ newConfig: config })
+ await servers[0].config.updateCustomSubConfig({ newConfig: config })
- await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
+ await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
await waitJobs(servers)
for (const server of servers) {
- const videoDetails = await server.videosCommand.get({ id: videosUUID[4] })
+ const videoDetails = await server.videos.get({ id: videosUUID[4] })
expect(videoDetails.files).to.have.lengthOf(4)
expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index ef8603a33..eefc95a6d 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -41,8 +41,8 @@ describe('Test optimize old videos', function () {
}
// Upload two videos for our needs
- await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
- await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
+ await servers[0].videos.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
+ await servers[0].videos.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
await waitJobs(servers)
})
@@ -51,11 +51,11 @@ describe('Test optimize old videos', function () {
this.timeout(30000)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
for (const video of data) {
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(1)
}
}
@@ -64,29 +64,29 @@ describe('Test optimize old videos', function () {
it('Should run optimize script', async function () {
this.timeout(200000)
- await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos')
+ await servers[0].cli.execWithEnv('npm run optimize-old-videos')
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
for (const video of data) {
- await server.videosCommand.view({ id: video.uuid })
+ await server.videos.view({ id: video.uuid })
// Refresh video
await waitJobs(servers)
await wait(5000)
await waitJobs(servers)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(1)
const file = videoDetails.files[0]
expect(file.size).to.be.below(8000000)
- const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
+ const path = servers[0].servers.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
const bitrate = await getVideoFileBitrate(path)
const fps = await getVideoFileFPS(path)
const resolution = await getVideoFileResolution(path)
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index fe5f63191..a83aa7724 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -30,16 +30,16 @@ describe('Test CLI wrapper', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.usersCommand.create({ username: 'user_1', password: 'super_password' })
+ await server.users.create({ username: 'user_1', password: 'super_password' })
- userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' })
+ userAccessToken = await server.login.getAccessToken({ username: 'user_1', password: 'super_password' })
{
const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
- await server.channelsCommand.create({ token: userAccessToken, attributes })
+ await server.channels.create({ token: userAccessToken, attributes })
}
- cliCommand = server.cliCommand
+ cliCommand = server.cli
})
describe('Authentication and instance selection', function () {
@@ -48,7 +48,7 @@ describe('Test CLI wrapper', function () {
const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`)
const token = stdout.trim()
- const body = await server.usersCommand.getMyInfo({ token })
+ const body = await server.users.getMyInfo({ token })
expect(body.username).to.equal('user_1')
})
@@ -103,10 +103,10 @@ describe('Test CLI wrapper', function () {
})
it('Should have the video uploaded', async function () {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(1)
- const video = await server.videosCommand.get({ id: data[0].uuid })
+ const video = await server.videos.get({ id: data[0].uuid })
expect(video.name).to.equal('test upload')
expect(video.support).to.equal('support_text')
expect(video.channel.name).to.equal('user_channel')
@@ -128,19 +128,19 @@ describe('Test CLI wrapper', function () {
await waitJobs([ server ])
- 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.name === 'small video - youtube')
expect(video).to.not.be.undefined
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.channel.name).to.equal('user_channel')
expect(videoDetails.support).to.equal('super support text')
expect(videoDetails.nsfw).to.be.false
// So we can reimport it
- await server.videosCommand.remove({ token: userAccessToken, id: video.id })
+ await server.videos.remove({ token: userAccessToken, id: video.id })
})
it('Should import and override some imported attributes', async function () {
@@ -155,13 +155,13 @@ describe('Test CLI wrapper', function () {
await waitJobs([ server ])
{
- 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.name === 'toto')
expect(video).to.not.be.undefined
- const videoDetails = await server.videosCommand.get({ id: video.id })
+ const videoDetails = await server.videos.get({ id: video.id })
expect(videoDetails.channel.name).to.equal('user_channel')
expect(videoDetails.support).to.equal('support')
expect(videoDetails.nsfw).to.be.true
@@ -225,10 +225,10 @@ describe('Test CLI wrapper', function () {
servers = [ server, anotherServer ]
await waitJobs(servers)
- const { uuid } = await anotherServer.videosCommand.quickUpload({ name: 'super video' })
+ const { uuid } = await anotherServer.videos.quickUpload({ name: 'super video' })
await waitJobs(servers)
- video1Server2 = await server.videosCommand.getId({ uuid })
+ video1Server2 = await server.videos.getId({ uuid })
})
it('Should add a redundancy', async function () {
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts
index 5344bfc96..178a7a2d9 100644
--- a/server/tests/cli/plugins.ts
+++ b/server/tests/cli/plugins.ts
@@ -27,13 +27,13 @@ describe('Test plugin scripts', function () {
const packagePath = PluginsCommand.getPluginTestPath()
- await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
+ await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
})
it('Should install a theme from stateless CLI', async function () {
this.timeout(60000)
- await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
+ await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
})
it('Should have the theme and the plugin registered when we restart peertube', async function () {
@@ -42,7 +42,7 @@ describe('Test plugin scripts', function () {
await killallServers([ server ])
await reRunServer(server)
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const plugin = config.plugin.registered
.find(p => p.name === 'test')
@@ -56,7 +56,7 @@ describe('Test plugin scripts', function () {
it('Should uninstall a plugin from stateless CLI', async function () {
this.timeout(60000)
- await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
+ await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
})
it('Should have removed the plugin on another peertube restart', async function () {
@@ -65,7 +65,7 @@ describe('Test plugin scripts', function () {
await killallServers([ server ])
await reRunServer(server)
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const plugin = config.plugin.registered
.find(p => p.name === 'test')
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index a4556312b..9912a36e0 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -24,13 +24,13 @@ import { VideoPlaylistPrivacy } from '@shared/models'
const expect = chai.expect
async function countFiles (server: ServerInfo, directory: string) {
- const files = await readdir(server.serversCommand.buildDirectory(directory))
+ const files = await readdir(server.servers.buildDirectory(directory))
return files.length
}
async function assertNotExists (server: ServerInfo, directory: string, substring: string) {
- const files = await readdir(server.serversCommand.buildDirectory(directory))
+ const files = await readdir(server.servers.buildDirectory(directory))
for (const f of files) {
expect(f).to.not.contain(substring)
@@ -68,16 +68,16 @@ describe('Test prune storage scripts', function () {
await setDefaultVideoChannel(servers)
for (const server of servers) {
- await server.videosCommand.upload({ attributes: { name: 'video 1' } })
- await server.videosCommand.upload({ attributes: { name: 'video 2' } })
+ await server.videos.upload({ attributes: { name: 'video 1' } })
+ await server.videos.upload({ attributes: { name: 'video 2' } })
- await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' })
+ await server.users.updateMyAvatar({ fixture: 'avatar.png' })
- await server.playlistsCommand.create({
+ await server.playlists.create({
attributes: {
displayName: 'playlist',
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: server.videoChannel.id,
+ videoChannelId: server.store.channel.id,
thumbnailfile: 'thumbnail.jpg'
}
})
@@ -87,7 +87,7 @@ describe('Test prune storage scripts', function () {
// Lazy load the remote avatar
{
- const account = await servers[0].accountsCommand.get({ accountName: 'root@localhost:' + servers[1].port })
+ const account = await servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port })
await makeGetRequest({
url: servers[0].url,
path: account.avatar.path,
@@ -96,7 +96,7 @@ describe('Test prune storage scripts', function () {
}
{
- const account = await servers[1].accountsCommand.get({ accountName: 'root@localhost:' + servers[0].port })
+ const account = await servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port })
await makeGetRequest({
url: servers[1].url,
path: account.avatar.path,
@@ -119,7 +119,7 @@ describe('Test prune storage scripts', function () {
it('Should create some dirty files', async function () {
for (let i = 0; i < 2; i++) {
{
- const base = servers[0].serversCommand.buildDirectory('videos')
+ const base = servers[0].servers.buildDirectory('videos')
const n1 = buildUUID() + '.mp4'
const n2 = buildUUID() + '.webm'
@@ -131,7 +131,7 @@ describe('Test prune storage scripts', function () {
}
{
- const base = servers[0].serversCommand.buildDirectory('torrents')
+ const base = servers[0].servers.buildDirectory('torrents')
const n1 = buildUUID() + '-240.torrent'
const n2 = buildUUID() + '-480.torrent'
@@ -143,7 +143,7 @@ describe('Test prune storage scripts', function () {
}
{
- const base = servers[0].serversCommand.buildDirectory('thumbnails')
+ const base = servers[0].servers.buildDirectory('thumbnails')
const n1 = buildUUID() + '.jpg'
const n2 = buildUUID() + '.jpg'
@@ -155,7 +155,7 @@ describe('Test prune storage scripts', function () {
}
{
- const base = servers[0].serversCommand.buildDirectory('previews')
+ const base = servers[0].servers.buildDirectory('previews')
const n1 = buildUUID() + '.jpg'
const n2 = buildUUID() + '.jpg'
@@ -167,7 +167,7 @@ describe('Test prune storage scripts', function () {
}
{
- const base = servers[0].serversCommand.buildDirectory('avatars')
+ const base = servers[0].servers.buildDirectory('avatars')
const n1 = buildUUID() + '.png'
const n2 = buildUUID() + '.jpg'
@@ -183,7 +183,7 @@ describe('Test prune storage scripts', function () {
it('Should run prune storage', async function () {
this.timeout(30000)
- const env = servers[0].cliCommand.getEnv()
+ const env = servers[0].cli.getEnv()
await CLICommand.exec(`echo y | ${env} npm run prune-storage`)
})
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index d59520783..2df1a1157 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -15,7 +15,7 @@ import {
} from '../../../shared/extra-utils'
async function testThumbnail (server: ServerInfo, videoId: number | string) {
- const video = await server.videosCommand.get({ id: videoId })
+ const video = await server.videos.get({ id: videoId })
const requests = [
makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200),
@@ -47,22 +47,22 @@ describe('Test regenerate thumbnails script', function () {
await doubleFollow(servers[0], servers[1])
{
- const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
- video1 = await servers[0].videosCommand.get({ id: videoUUID1 })
+ const videoUUID1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid
+ video1 = await servers[0].videos.get({ id: videoUUID1 })
- thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
+ thumbnail1Path = join(servers[0].servers.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
- const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
- video2 = await servers[0].videosCommand.get({ id: videoUUID2 })
+ const videoUUID2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid
+ video2 = await servers[0].videos.get({ id: videoUUID2 })
}
{
- const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid
+ const videoUUID = (await servers[1].videos.quickUpload({ name: 'video 3' })).uuid
await waitJobs(servers)
- remoteVideo = await servers[0].videosCommand.get({ id: videoUUID })
+ remoteVideo = await servers[0].videos.get({ id: videoUUID })
- thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
+ thumbnailRemotePath = join(servers[0].servers.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
}
await writeFile(thumbnail1Path, '')
@@ -89,7 +89,7 @@ describe('Test regenerate thumbnails script', function () {
it('Should regenerate local thumbnails from the CLI', async function () {
this.timeout(15000)
- await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`)
+ await servers[0].cli.execWithEnv(`npm run regenerate-thumbnails`)
})
it('Should have generated new thumbnail files', async function () {
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts
index 5e1e1c2af..e0d6f220a 100644
--- a/server/tests/cli/reset-password.ts
+++ b/server/tests/cli/reset-password.ts
@@ -9,16 +9,16 @@ describe('Test reset password scripts', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.usersCommand.create({ username: 'user_1', password: 'super password' })
+ await server.users.create({ username: 'user_1', password: 'super password' })
})
it('Should change the user password from CLI', async function () {
this.timeout(60000)
- const env = server.cliCommand.getEnv()
+ const env = server.cli.getEnv()
await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
- await server.loginCommand.login({ user: { username: 'user_1', password: 'coucou' } })
+ await server.login.login({ user: { username: 'user_1', password: 'coucou' } })
})
after(async function () {
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index d90b4a64d..d2d196456 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -30,11 +30,11 @@ describe('Test update host scripts', function () {
await setAccessTokensToServers([ server ])
// Upload two videos for our needs
- const { uuid: video1UUID } = await server.videosCommand.upload()
- await server.videosCommand.upload()
+ const { uuid: video1UUID } = await server.videos.upload()
+ await server.videos.upload()
// Create a user
- await server.usersCommand.create({ username: 'toto', password: 'coucou' })
+ await server.users.create({ username: 'toto', password: 'coucou' })
// Create channel
const videoChannel = {
@@ -42,11 +42,11 @@ describe('Test update host scripts', function () {
displayName: 'second video channel',
description: 'super video channel description'
}
- await server.channelsCommand.create({ attributes: videoChannel })
+ await server.channels.create({ attributes: videoChannel })
// Create comments
const text = 'my super first comment'
- await server.commentsCommand.createThread({ videoId: video1UUID, text })
+ await server.comments.createThread({ videoId: video1UUID, text })
await waitJobs(server)
})
@@ -58,11 +58,11 @@ describe('Test update host scripts', function () {
// Run server with standard configuration
await reRunServer(server)
- await server.cliCommand.execWithEnv(`npm run update-host`)
+ await server.cli.execWithEnv(`npm run update-host`)
})
it('Should have updated videos url', async function () {
- const { total, data } = await server.videosCommand.list()
+ const { total, data } = await server.videos.list()
expect(total).to.equal(2)
for (const video of data) {
@@ -70,7 +70,7 @@ describe('Test update host scripts', function () {
expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid)
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.trackerUrls[0]).to.include(server.host)
expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host)
@@ -79,7 +79,7 @@ describe('Test update host scripts', function () {
})
it('Should have updated video channels url', async function () {
- const { data, total } = await server.channelsCommand.list({ sort: '-name' })
+ const { data, total } = await server.channels.list({ sort: '-name' })
expect(total).to.equal(3)
for (const channel of data) {
@@ -90,7 +90,7 @@ describe('Test update host scripts', function () {
})
it('Should have updated accounts url', async function () {
- const body = await server.accountsCommand.list()
+ const body = await server.accounts.list()
expect(body.total).to.equal(3)
for (const account of body.data) {
@@ -104,11 +104,11 @@ describe('Test update host scripts', function () {
it('Should have updated torrent hosts', async function () {
this.timeout(30000)
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
for (const video of data) {
- 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)
diff --git a/server/tests/client.ts b/server/tests/client.ts
index e91d4c671..caf6fb00c 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -59,8 +59,8 @@ describe('Test a client controllers', function () {
await setDefaultVideoChannel(servers)
- await servers[0].channelsCommand.update({
- channelName: servers[0].videoChannel.name,
+ await servers[0].channels.update({
+ channelName: servers[0].store.channel.name,
attributes: { description: channelDescription }
})
@@ -68,13 +68,13 @@ describe('Test a client controllers', function () {
{
const attributes = { name: videoName, description: videoDescription }
- await servers[0].videosCommand.upload({ attributes })
+ await servers[0].videos.upload({ attributes })
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data.length).to.equal(1)
const video = data[0]
- servers[0].video = video
+ servers[0].store.video = video
videoIds = [ video.id, video.uuid, video.shortUUID ]
}
@@ -85,21 +85,21 @@ describe('Test a client controllers', function () {
displayName: playlistName,
description: playlistDescription,
privacy: VideoPlaylistPrivacy.PUBLIC,
- videoChannelId: servers[0].videoChannel.id
+ videoChannelId: servers[0].store.channel.id
}
- playlist = await servers[0].playlistsCommand.create({ attributes })
+ playlist = await servers[0].playlists.create({ attributes })
playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ]
- await servers[0].playlistsCommand.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].video.id } })
+ await servers[0].playlists.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].store.video.id } })
}
// Account
{
- await servers[0].usersCommand.updateMe({ description: 'my account description' })
+ await servers[0].users.updateMe({ description: 'my account description' })
- account = await servers[0].accountsCommand.get({ accountName: `${servers[0].user.username}@${servers[0].host}` })
+ account = await servers[0].accounts.get({ accountName: `${servers[0].store.user.username}@${servers[0].host}` })
}
await waitJobs(servers)
@@ -120,8 +120,8 @@ describe('Test a client controllers', function () {
const port = servers[0].port
const expectedLink = '`
+ `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].store.video.uuid}" ` +
+ `title="${servers[0].store.video.name}" />`
expect(res.text).to.contain(expectedLink)
}
@@ -159,17 +159,17 @@ describe('Test a client controllers', function () {
expect(text).to.contain(``)
expect(text).to.contain(``)
expect(text).to.contain('')
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
}
async function channelPageTest (path: string) {
const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
const text = res.text
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
expect(text).to.contain(``)
expect(text).to.contain('')
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
}
async function watchVideoPageTest (path: string) {
@@ -179,7 +179,7 @@ describe('Test a client controllers', function () {
expect(text).to.contain(``)
expect(text).to.contain(``)
expect(text).to.contain('')
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
}
async function watchPlaylistPageTest (path: string) {
@@ -193,15 +193,15 @@ describe('Test a client controllers', function () {
}
it('Should have valid Open Graph tags on the account page', async function () {
- await accountPageTest('/accounts/' + servers[0].user.username)
- await accountPageTest('/a/' + servers[0].user.username)
- await accountPageTest('/@' + servers[0].user.username)
+ await accountPageTest('/accounts/' + servers[0].store.user.username)
+ await accountPageTest('/a/' + servers[0].store.user.username)
+ await accountPageTest('/@' + servers[0].store.user.username)
})
it('Should have valid Open Graph tags on the channel page', async function () {
- await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
- await channelPageTest('/c/' + servers[0].videoChannel.name)
- await channelPageTest('/@' + servers[0].videoChannel.name)
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
})
it('Should have valid Open Graph tags on the watch page', async function () {
@@ -241,7 +241,7 @@ describe('Test a client controllers', function () {
expect(text).to.contain('')
expect(text).to.contain('')
- expect(text).to.contain(``)
+ expect(text).to.contain(``)
expect(text).to.contain(``)
}
@@ -288,22 +288,22 @@ describe('Test a client controllers', function () {
})
it('Should have valid twitter card on the channel page', async function () {
- await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
- await channelPageTest('/c/' + servers[0].videoChannel.name)
- await channelPageTest('/@' + servers[0].videoChannel.name)
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
})
})
describe('Whitelisted', function () {
before(async function () {
- const config = await servers[0].configCommand.getCustomConfig()
+ const config = await servers[0].config.getCustomConfig()
config.services.twitter = {
username: '@Kuja',
whitelisted: true
}
- await servers[0].configCommand.updateCustomConfig({ newCustomConfig: config })
+ await servers[0].config.updateCustomConfig({ newCustomConfig: config })
})
async function accountPageTest (path: string) {
@@ -361,9 +361,9 @@ describe('Test a client controllers', function () {
})
it('Should have valid twitter card on the channel page', async function () {
- await channelPageTest('/video-channels/' + servers[0].videoChannel.name)
- await channelPageTest('/c/' + servers[0].videoChannel.name)
- await channelPageTest('/@' + servers[0].videoChannel.name)
+ await channelPageTest('/video-channels/' + servers[0].store.channel.name)
+ await channelPageTest('/c/' + servers[0].store.channel.name)
+ await channelPageTest('/@' + servers[0].store.channel.name)
})
})
})
@@ -371,7 +371,7 @@ describe('Test a client controllers', function () {
describe('Index HTML', function () {
it('Should have valid index html tags (title, description...)', async function () {
- const config = await servers[0].configCommand.getConfig()
+ const config = await servers[0].config.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
@@ -379,7 +379,7 @@ describe('Test a client controllers', function () {
})
it('Should update the customized configuration and have the correct index html tags', async function () {
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
instance: {
name: 'PeerTube updated',
@@ -396,14 +396,14 @@ describe('Test a client controllers', function () {
}
})
- const config = await servers[0].configCommand.getConfig()
+ const config = await servers[0].config.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
it('Should have valid index html updated tags (title, description...)', async function () {
- const config = await servers[0].configCommand.getConfig()
+ const config = await servers[0].config.getConfig()
const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
@@ -413,7 +413,7 @@ describe('Test a client controllers', function () {
for (const basePath of watchVideoBasePaths) {
for (const id of videoIds) {
const res = await makeHTMLRequest(servers[1].url, basePath + id)
- expect(res.text).to.contain(``)
+ expect(res.text).to.contain(``)
}
}
})
@@ -451,8 +451,8 @@ describe('Test a client controllers', function () {
describe('Embed HTML', function () {
it('Should have the correct embed html tags', async function () {
- const config = await servers[0].configCommand.getConfig()
- const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath)
+ const config = await servers[0].config.getConfig()
+ const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath)
checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
})
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts
index b626ab2bb..ef624152e 100644
--- a/server/tests/external-plugins/auth-ldap.ts
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -16,15 +16,15 @@ describe('Official plugin auth-ldap', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-auth-ldap' })
+ await server.plugins.install({ npmName: 'peertube-plugin-auth-ldap' })
})
it('Should not login with without LDAP settings', async function () {
- await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not login with bad LDAP settings', async function () {
- await server.pluginsCommand.updateSettings({
+ await server.plugins.updateSettings({
npmName: 'peertube-plugin-auth-ldap',
settings: {
'bind-credentials': 'GoodNewsEveryone',
@@ -38,11 +38,11 @@ describe('Official plugin auth-ldap', function () {
}
})
- await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not login with good LDAP settings but wrong username/password', async function () {
- await server.pluginsCommand.updateSettings({
+ await server.plugins.updateSettings({
npmName: 'peertube-plugin-auth-ldap',
settings: {
'bind-credentials': 'GoodNewsEveryone',
@@ -56,20 +56,20 @@ describe('Official plugin auth-ldap', function () {
}
})
- await server.loginCommand.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.loginCommand.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should login with the appropriate username/password', async function () {
- accessToken = await server.loginCommand.getAccessToken({ username: 'fry', password: 'fry' })
+ accessToken = await server.login.getAccessToken({ username: 'fry', password: 'fry' })
})
it('Should login with the appropriate email/password', async function () {
- accessToken = await server.loginCommand.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
+ accessToken = await server.login.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
})
it('Should login get my profile', async function () {
- const body = await server.usersCommand.getMyInfo({ token: accessToken })
+ const body = await server.users.getMyInfo({ token: accessToken })
expect(body.username).to.equal('fry')
expect(body.email).to.equal('fry@planetexpress.com')
@@ -77,28 +77,28 @@ describe('Official plugin auth-ldap', function () {
})
it('Should upload a video', async function () {
- await server.videosCommand.upload({ token: accessToken, attributes: { name: 'my super video' } })
+ await server.videos.upload({ token: accessToken, attributes: { name: 'my super video' } })
})
it('Should not be able to login if the user is banned', async function () {
- await server.usersCommand.banUser({ userId })
+ await server.users.banUser({ userId })
- await server.loginCommand.login({
+ await server.login.login({
user: { username: 'fry@planetexpress.com', password: 'fry' },
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should be able to login if the user is unbanned', async function () {
- await server.usersCommand.unbanUser({ userId })
+ await server.users.unbanUser({ userId })
- await server.loginCommand.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
+ await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
})
it('Should not login if the plugin is uninstalled', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
- await server.loginCommand.login({
+ await server.login.login({
user: { username: 'fry@planetexpress.com', password: 'fry' },
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts
index 1cce15a2f..3b4b48bf0 100644
--- a/server/tests/external-plugins/auto-block-videos.ts
+++ b/server/tests/external-plugins/auto-block-videos.ts
@@ -16,7 +16,7 @@ import {
import { Video } from '@shared/models'
async function check (server: ServerInfo, videoUUID: string, exists = true) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
const video = data.find(v => v.uuid === videoUUID)
@@ -38,24 +38,24 @@ describe('Official plugin auto-block videos', function () {
await setAccessTokensToServers(servers)
for (const server of servers) {
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-block-videos' })
+ await server.plugins.install({ npmName: 'peertube-plugin-auto-block-videos' })
}
blocklistServer = new MockBlocklist()
port = await blocklistServer.initialize()
- await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
- await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
- await await servers[1].videosCommand.quickUpload({ name: 'video 2 server 2' })
- await await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2' })
+ await await servers[0].videos.quickUpload({ name: 'video server 1' })
+ await await servers[1].videos.quickUpload({ name: 'video server 2' })
+ await await servers[1].videos.quickUpload({ name: 'video 2 server 2' })
+ await await servers[1].videos.quickUpload({ name: 'video 3 server 2' })
{
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid }))
}
{
- const { data } = await servers[1].videosCommand.list()
+ const { data } = await servers[1].videos.list()
server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid }))
}
@@ -63,7 +63,7 @@ describe('Official plugin auto-block videos', function () {
})
it('Should update plugin settings', async function () {
- await servers[0].pluginsCommand.updateSettings({
+ await servers[0].plugins.updateSettings({
npmName: 'peertube-plugin-auto-block-videos',
settings: {
'blocklist-urls': `http://localhost:${port}/blocklist`,
@@ -91,7 +91,7 @@ describe('Official plugin auto-block videos', function () {
})
it('Should have video in blacklists', async function () {
- const body = await servers[0].blacklistCommand.list()
+ const body = await servers[0].blacklist.list()
const videoBlacklists = body.data
expect(videoBlacklists).to.have.lengthOf(1)
@@ -156,7 +156,7 @@ describe('Official plugin auto-block videos', function () {
await check(servers[0], video.uuid, false)
- await servers[0].blacklistCommand.remove({ videoId: video.uuid })
+ await servers[0].blacklist.remove({ videoId: video.uuid })
await check(servers[0], video.uuid, true)
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts
index 81a96744e..25b56a546 100644
--- a/server/tests/external-plugins/auto-mute.ts
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -29,20 +29,20 @@ describe('Official plugin auto-mute', function () {
await setAccessTokensToServers(servers)
for (const server of servers) {
- await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-mute' })
+ await server.plugins.install({ npmName: 'peertube-plugin-auto-mute' })
}
blocklistServer = new MockBlocklist()
port = await blocklistServer.initialize()
- await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
- await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
+ await await servers[0].videos.quickUpload({ name: 'video server 1' })
+ await await servers[1].videos.quickUpload({ name: 'video server 2' })
await doubleFollow(servers[0], servers[1])
})
it('Should update plugin settings', async function () {
- await servers[0].pluginsCommand.updateSettings({
+ await servers[0].plugins.updateSettings({
npmName: 'peertube-plugin-auto-mute',
settings: {
'blocklist-urls': `http://localhost:${port}/blocklist`,
@@ -64,7 +64,7 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
})
@@ -82,7 +82,7 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
})
@@ -99,7 +99,7 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
})
@@ -117,7 +117,7 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
})
@@ -138,14 +138,14 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
{
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(1)
}
- await servers[0].blocklistCommand.removeFromServerBlocklist({ account })
+ await servers[0].blocklist.removeFromServerBlocklist({ account })
{
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
}
@@ -154,7 +154,7 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
{
- const { total } = await servers[0].videosCommand.list()
+ const { total } = await servers[0].videos.list()
expect(total).to.equal(2)
}
})
@@ -168,7 +168,7 @@ describe('Official plugin auto-mute', function () {
})
it('Should enable auto mute list', async function () {
- await servers[0].pluginsCommand.updateSettings({
+ await servers[0].plugins.updateSettings({
npmName: 'peertube-plugin-auto-mute',
settings: {
'blocklist-urls': '',
@@ -187,7 +187,7 @@ describe('Official plugin auto-mute', function () {
it('Should mute an account on server 1, and server 2 auto mutes it', async function () {
this.timeout(20000)
- await servers[1].pluginsCommand.updateSettings({
+ await servers[1].plugins.updateSettings({
npmName: 'peertube-plugin-auto-mute',
settings: {
'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath,
@@ -196,8 +196,8 @@ describe('Official plugin auto-mute', function () {
}
})
- await servers[0].blocklistCommand.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port })
- await servers[0].blocklistCommand.addToMyBlocklist({ server: 'localhost:' + servers[1].port })
+ await servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port })
+ await servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port })
const res = await makeGetRequest({
url: servers[0].url,
@@ -213,7 +213,7 @@ describe('Official plugin auto-mute', function () {
await wait(2000)
for (const server of servers) {
- const { total } = await server.videosCommand.list()
+ const { total } = await server.videos.list()
expect(total).to.equal(1)
}
})
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index c66cdde1b..8bdafc644 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -47,26 +47,26 @@ describe('Test syndication feeds', () => {
await doubleFollow(servers[0], servers[1])
{
- const user = await servers[0].usersCommand.getMyInfo()
+ const user = await servers[0].users.getMyInfo()
rootAccountId = user.account.id
rootChannelId = user.videoChannels[0].id
}
{
const attr = { username: 'john', password: 'password' }
- await servers[0].usersCommand.create({ username: attr.username, password: attr.password })
- userAccessToken = await servers[0].loginCommand.getAccessToken(attr)
+ await servers[0].users.create({ username: attr.username, password: attr.password })
+ userAccessToken = await servers[0].login.getAccessToken(attr)
- const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken })
+ const user = await servers[0].users.getMyInfo({ token: userAccessToken })
userAccountId = user.account.id
userChannelId = user.videoChannels[0].id
- const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken })
+ const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken })
userFeedToken = token.feedToken
}
{
- await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'user video' } })
+ await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'user video' } })
}
{
@@ -75,17 +75,17 @@ describe('Test syndication feeds', () => {
description: 'my super description for server 1',
fixture: 'video_short.webm'
}
- const { id } = await servers[0].videosCommand.upload({ attributes })
+ const { id } = await servers[0].videos.upload({ attributes })
- await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 1' })
- await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 2' })
+ await servers[0].comments.createThread({ videoId: id, text: 'super comment 1' })
+ await servers[0].comments.createThread({ videoId: id, text: 'super comment 2' })
}
{
const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED }
- const { id } = await servers[0].videosCommand.upload({ attributes })
+ const { id } = await servers[0].videos.upload({ attributes })
- await servers[0].commentsCommand.createThread({ videoId: id, text: 'comment on unlisted video' })
+ await servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' })
}
await waitJobs(servers)
@@ -95,17 +95,17 @@ describe('Test syndication feeds', () => {
it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () {
for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) {
- const rss = await servers[0].feedCommand.getXML({ feed })
+ const rss = await servers[0].feed.getXML({ feed })
expect(rss).xml.to.be.valid()
- const atom = await servers[0].feedCommand.getXML({ feed, format: 'atom' })
+ const atom = await servers[0].feed.getXML({ feed, format: 'atom' })
expect(atom).xml.to.be.valid()
}
})
it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () {
for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) {
- const jsonText = await servers[0].feedCommand.getJSON({ feed })
+ const jsonText = await servers[0].feed.getJSON({ feed })
expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' })
}
})
@@ -115,7 +115,7 @@ describe('Test syndication feeds', () => {
it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () {
for (const server of servers) {
- const rss = await server.feedCommand.getXML({ feed: 'videos' })
+ const rss = await server.feed.getXML({ feed: 'videos' })
expect(xmlParser.validate(rss)).to.be.true
const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false })
@@ -130,7 +130,7 @@ describe('Test syndication feeds', () => {
it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () {
for (const server of servers) {
- const json = await server.feedCommand.getJSON({ feed: 'videos' })
+ const json = await server.feed.getJSON({ feed: 'videos' })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
expect(jsonObj.items[0].attachments).to.exist
@@ -143,7 +143,7 @@ describe('Test syndication feeds', () => {
it('Should filter by account', async function () {
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: rootAccountId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
@@ -151,7 +151,7 @@ describe('Test syndication feeds', () => {
}
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: userAccountId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: userAccountId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
@@ -160,14 +160,14 @@ describe('Test syndication feeds', () => {
for (const server of servers) {
{
- const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } })
+ const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
}
{
- const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } })
+ const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
@@ -177,7 +177,7 @@ describe('Test syndication feeds', () => {
it('Should filter by video channel', async function () {
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
@@ -185,7 +185,7 @@ describe('Test syndication feeds', () => {
}
{
- const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } })
+ const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
@@ -195,7 +195,7 @@ describe('Test syndication feeds', () => {
for (const server of servers) {
{
const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port }
- const json = await server.feedCommand.getJSON({ feed: 'videos', query })
+ const json = await server.feed.getJSON({ feed: 'videos', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('my super name for server 1')
@@ -203,7 +203,7 @@ describe('Test syndication feeds', () => {
{
const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port }
- const json = await server.feedCommand.getJSON({ feed: 'videos', query })
+ const json = await server.feed.getJSON({ feed: 'videos', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].title).to.equal('user video')
@@ -214,11 +214,11 @@ describe('Test syndication feeds', () => {
it('Should correctly have videos feed with HLS only', async function () {
this.timeout(120000)
- await serverHLSOnly.videosCommand.upload({ attributes: { name: 'hls only video' } })
+ await serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } })
await waitJobs([ serverHLSOnly ])
- const json = await serverHLSOnly.feedCommand.getJSON({ feed: 'videos' })
+ const json = await serverHLSOnly.feed.getJSON({ feed: 'videos' })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1)
expect(jsonObj.items[0].attachments).to.exist
@@ -236,7 +236,7 @@ describe('Test syndication feeds', () => {
it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () {
for (const server of servers) {
- const json = await server.feedCommand.getJSON({ feed: 'video-comments' })
+ const json = await server.feed.getJSON({ feed: 'video-comments' })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
@@ -250,31 +250,31 @@ describe('Test syndication feeds', () => {
const remoteHandle = 'root@localhost:' + servers[0].port
- await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle })
+ await servers[1].blocklist.addToServerBlocklist({ account: remoteHandle })
{
- const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } })
+ const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 2 } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(0)
}
- await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle })
+ await servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle })
{
- const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid
+ const videoUUID = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid
await waitJobs(servers)
- await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' })
+ await servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' })
await waitJobs(servers)
- const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } })
+ const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 3 } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(3)
}
- await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle })
+ await servers[1].blocklist.addToMyBlocklist({ account: remoteHandle })
{
- const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } })
+ const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 4 } })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2)
}
@@ -287,25 +287,25 @@ describe('Test syndication feeds', () => {
it('Should list no videos for a user with no videos and no subscriptions', async function () {
const attr = { username: 'feeduser', password: 'password' }
- await servers[0].usersCommand.create({ username: attr.username, password: attr.password })
- const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr)
+ await servers[0].users.create({ username: attr.username, password: attr.password })
+ const feeduserAccessToken = await servers[0].login.getAccessToken(attr)
{
- const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken })
+ const user = await servers[0].users.getMyInfo({ token: feeduserAccessToken })
feeduserAccountId = user.account.id
}
{
- const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken })
+ const token = await servers[0].users.getMyScopedTokens({ token: feeduserAccessToken })
feeduserFeedToken = token.feedToken
}
{
- const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken })
expect(body.total).to.equal(0)
const query = { accountId: feeduserAccountId, token: feeduserFeedToken }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos
}
@@ -313,20 +313,20 @@ describe('Test syndication feeds', () => {
it('Should fail with an invalid token', async function () {
const query = { accountId: feeduserAccountId, token: 'toto' }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a token of another user', async function () {
const query = { accountId: feeduserAccountId, token: userFeedToken }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should list no videos for a user with videos but no subscriptions', async function () {
- const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
expect(body.total).to.equal(0)
const query = { accountId: userAccountId, token: userFeedToken }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos
})
@@ -334,16 +334,16 @@ describe('Test syndication feeds', () => {
it('Should list self videos for a user with a subscription to themselves', async function () {
this.timeout(30000)
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port })
await waitJobs(servers)
{
- const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
expect(body.total).to.equal(1)
expect(body.data[0].name).to.equal('user video')
const query = { accountId: userAccountId, token: userFeedToken, version: 1 }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's
}
@@ -352,33 +352,33 @@ describe('Test syndication feeds', () => {
it('Should list videos of a user\'s subscription', async function () {
this.timeout(30000)
- await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
+ await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
await waitJobs(servers)
{
- const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken })
+ const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
expect(body.total).to.equal(2, "there should be 2 videos part of the subscription")
const query = { accountId: userAccountId, token: userFeedToken, version: 2 }
- const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
const jsonObj = JSON.parse(json)
expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's
}
})
it('Should renew the token, and so have an invalid old token', async function () {
- await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken })
+ await servers[0].users.renewMyScopedTokens({ token: userAccessToken })
const query = { accountId: userAccountId, token: userFeedToken, version: 3 }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should succeed with the new token', async function () {
- const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken })
+ const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken })
userFeedToken = token.feedToken
const query = { accountId: userAccountId, token: userFeedToken, version: 4 }
- await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query })
+ await servers[0].feed.getJSON({ feed: 'subscriptions', query })
})
})
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index b5b10bd5e..f7c9e6c26 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -158,15 +158,15 @@ describe('Test misc endpoints', function () {
it('Should add videos, channel and accounts and get sitemap', async function () {
this.timeout(35000)
- await server.videosCommand.upload({ attributes: { name: 'video 1', nsfw: false } })
- await server.videosCommand.upload({ attributes: { name: 'video 2', nsfw: false } })
- await server.videosCommand.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } })
+ await server.videos.upload({ attributes: { name: 'video 1', nsfw: false } })
+ await server.videos.upload({ attributes: { name: 'video 2', nsfw: false } })
+ await server.videos.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } })
- await server.channelsCommand.create({ attributes: { name: 'channel1', displayName: 'channel 1' } })
- await server.channelsCommand.create({ attributes: { name: 'channel2', displayName: 'channel 2' } })
+ await server.channels.create({ attributes: { name: 'channel1', displayName: 'channel 1' } })
+ await server.channels.create({ attributes: { name: 'channel2', displayName: 'channel 2' } })
- await server.usersCommand.create({ username: 'user1', password: 'password' })
- await server.usersCommand.create({ username: 'user2', password: 'password' })
+ await server.users.create({ username: 'user1', password: 'password' })
+ await server.users.create({ username: 'user2', password: 'password' })
const res = await makeGetRequest({
url: server.url,
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 9e12c8aa7..12d5c23c5 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -19,7 +19,7 @@ describe('Test plugin action hooks', function () {
let threadId: number
function checkHook (hook: ServerHookName) {
- return servers[0].serversCommand.waitUntilLog('Run hook ' + hook)
+ return servers[0].servers.waitUntilLog('Run hook ' + hook)
}
before(async function () {
@@ -29,7 +29,7 @@ describe('Test plugin action hooks', function () {
await setAccessTokensToServers(servers)
await setDefaultVideoChannel(servers)
- await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
+ await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
await killallServers([ servers[0] ])
@@ -49,20 +49,20 @@ describe('Test plugin action hooks', function () {
describe('Videos hooks', function () {
it('Should run action:api.video.uploaded', async function () {
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
videoUUID = uuid
await checkHook('action:api.video.uploaded')
})
it('Should run action:api.video.updated', async function () {
- await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video updated' } })
+ await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video updated' } })
await checkHook('action:api.video.updated')
})
it('Should run action:api.video.viewed', async function () {
- await servers[0].videosCommand.view({ id: videoUUID })
+ await servers[0].videos.view({ id: videoUUID })
await checkHook('action:api.video.viewed')
})
@@ -74,10 +74,10 @@ describe('Test plugin action hooks', function () {
const attributes = {
name: 'live',
privacy: VideoPrivacy.PUBLIC,
- channelId: servers[0].videoChannel.id
+ channelId: servers[0].store.channel.id
}
- await servers[0].liveCommand.create({ fields: attributes })
+ await servers[0].live.create({ fields: attributes })
await checkHook('action:api.live-video.created')
})
@@ -85,20 +85,20 @@ describe('Test plugin action hooks', function () {
describe('Comments hooks', function () {
it('Should run action:api.video-thread.created', async function () {
- const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' })
+ const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
threadId = created.id
await checkHook('action:api.video-thread.created')
})
it('Should run action:api.video-comment-reply.created', async function () {
- await servers[0].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' })
+ await servers[0].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' })
await checkHook('action:api.video-comment-reply.created')
})
it('Should run action:api.video-comment.deleted', async function () {
- await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId: threadId })
+ await servers[0].comments.delete({ videoId: videoUUID, commentId: threadId })
await checkHook('action:api.video-comment.deleted')
})
@@ -108,44 +108,44 @@ describe('Test plugin action hooks', function () {
let userId: number
it('Should run action:api.user.registered', async function () {
- await servers[0].usersCommand.register({ username: 'registered_user' })
+ await servers[0].users.register({ username: 'registered_user' })
await checkHook('action:api.user.registered')
})
it('Should run action:api.user.created', async function () {
- const user = await servers[0].usersCommand.create({ username: 'created_user' })
+ const user = await servers[0].users.create({ username: 'created_user' })
userId = user.id
await checkHook('action:api.user.created')
})
it('Should run action:api.user.oauth2-got-token', async function () {
- await servers[0].loginCommand.getAccessToken('created_user', 'super_password')
+ await servers[0].login.getAccessToken('created_user', 'super_password')
await checkHook('action:api.user.oauth2-got-token')
})
it('Should run action:api.user.blocked', async function () {
- await servers[0].usersCommand.banUser({ userId })
+ await servers[0].users.banUser({ userId })
await checkHook('action:api.user.blocked')
})
it('Should run action:api.user.unblocked', async function () {
- await servers[0].usersCommand.unbanUser({ userId })
+ await servers[0].users.unbanUser({ userId })
await checkHook('action:api.user.unblocked')
})
it('Should run action:api.user.updated', async function () {
- await servers[0].usersCommand.update({ userId, videoQuota: 50 })
+ await servers[0].users.update({ userId, videoQuota: 50 })
await checkHook('action:api.user.updated')
})
it('Should run action:api.user.deleted', async function () {
- await servers[0].usersCommand.remove({ userId })
+ await servers[0].users.remove({ userId })
await checkHook('action:api.user.deleted')
})
@@ -157,7 +157,7 @@ describe('Test plugin action hooks', function () {
before(async function () {
{
- const { id } = await servers[0].playlistsCommand.create({
+ const { id } = await servers[0].playlists.create({
attributes: {
displayName: 'My playlist',
privacy: VideoPlaylistPrivacy.PRIVATE
@@ -167,13 +167,13 @@ describe('Test plugin action hooks', function () {
}
{
- const { id } = await servers[0].videosCommand.upload({ attributes: { name: 'my super name' } })
+ const { id } = await servers[0].videos.upload({ attributes: { name: 'my super name' } })
videoId = id
}
})
it('Should run action:api.video-playlist-element.created', async function () {
- await servers[0].playlistsCommand.addElement({ playlistId, attributes: { videoId } })
+ await servers[0].playlists.addElement({ playlistId, attributes: { videoId } })
await checkHook('action:api.video-playlist-element.created')
})
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 3e8305611..48f942f7f 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -23,7 +23,7 @@ async function loginExternal (options: {
statusCodeExpected?: HttpStatusCode
statusCodeExpectedStep2?: HttpStatusCode
}) {
- const res = await options.server.pluginsCommand.getExternalAuth({
+ const res = await options.server.plugins.getExternalAuth({
npmName: options.npmName,
npmVersion: '0.0.1',
authName: options.authName,
@@ -36,7 +36,7 @@ async function loginExternal (options: {
const location = res.header.location
const { externalAuthToken } = decodeQueryString(location)
- const resLogin = await options.server.loginCommand.loginUsingExternalToken({
+ const resLogin = await options.server.login.loginUsingExternalToken({
username: options.username,
externalAuthToken: externalAuthToken as string,
expectedStatus: options.statusCodeExpectedStep2
@@ -63,12 +63,12 @@ describe('Test external auth plugins', function () {
await setAccessTokensToServers([ server ])
for (const suffix of [ 'one', 'two', 'three' ]) {
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
}
})
it('Should display the correct configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(8)
@@ -80,7 +80,7 @@ describe('Test external auth plugins', function () {
})
it('Should redirect for a Cyan login', async function () {
- const res = await server.pluginsCommand.getExternalAuth({
+ const res = await server.plugins.getExternalAuth({
npmName: 'test-external-auth-one',
npmVersion: '0.0.1',
authName: 'external-auth-1',
@@ -102,14 +102,14 @@ describe('Test external auth plugins', function () {
})
it('Should reject auto external login with a missing or invalid token', async function () {
- const command = server.loginCommand
+ const command = server.login
await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: '', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: 'blabla', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should reject auto external login with a missing or invalid username', async function () {
- const command = server.loginCommand
+ const command = server.login
await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -120,13 +120,13 @@ describe('Test external auth plugins', function () {
await wait(5000)
- await server.loginCommand.loginUsingExternalToken({
+ await server.login.loginUsingExternalToken({
username: 'cyan',
externalAuthToken,
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
- await server.serversCommand.waitUntilLog('expired external auth token', 2)
+ await server.servers.waitUntilLog('expired external auth token', 2)
})
it('Should auto login Cyan, create the user and use the token', async function () {
@@ -146,7 +146,7 @@ describe('Test external auth plugins', function () {
}
{
- const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
+ const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.username).to.equal('cyan')
expect(body.account.displayName).to.equal('cyan')
expect(body.email).to.equal('cyan@example.com')
@@ -168,7 +168,7 @@ describe('Test external auth plugins', function () {
}
{
- const body = await server.usersCommand.getMyInfo({ token: kefkaAccessToken })
+ const body = await server.users.getMyInfo({ token: kefkaAccessToken })
expect(body.username).to.equal('kefka')
expect(body.account.displayName).to.equal('Kefka Palazzo')
expect(body.email).to.equal('kefka@example.com')
@@ -178,39 +178,39 @@ describe('Test external auth plugins', function () {
it('Should refresh Cyan token, but not Kefka token', async function () {
{
- const resRefresh = await server.loginCommand.refreshToken({ refreshToken: cyanRefreshToken })
+ const resRefresh = await server.login.refreshToken({ refreshToken: cyanRefreshToken })
cyanAccessToken = resRefresh.body.access_token
cyanRefreshToken = resRefresh.body.refresh_token
- const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
+ const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.username).to.equal('cyan')
}
{
- await server.loginCommand.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
})
it('Should update Cyan profile', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: cyanAccessToken,
displayName: 'Cyan Garamonde',
description: 'Retainer to the king of Doma'
})
- const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
+ const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.account.displayName).to.equal('Cyan Garamonde')
expect(body.account.description).to.equal('Retainer to the king of Doma')
})
it('Should logout Cyan', async function () {
- await server.loginCommand.logout({ token: cyanAccessToken })
+ await server.login.logout({ token: cyanAccessToken })
})
it('Should have logged out Cyan', async function () {
- await server.serversCommand.waitUntilLog('On logout cyan')
+ await server.servers.waitUntilLog('On logout cyan')
- await server.usersCommand.getMyInfo({ token: cyanAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ token: cyanAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should login Cyan and keep the old existing profile', async function () {
@@ -228,7 +228,7 @@ describe('Test external auth plugins', function () {
cyanAccessToken = res.access_token
}
- const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken })
+ const body = await server.users.getMyInfo({ token: cyanAccessToken })
expect(body.username).to.equal('cyan')
expect(body.account.displayName).to.equal('Cyan Garamonde')
expect(body.account.description).to.equal('Retainer to the king of Doma')
@@ -236,7 +236,7 @@ describe('Test external auth plugins', function () {
})
it('Should not update an external auth email', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: cyanAccessToken,
email: 'toto@example.com',
currentPassword: 'toto',
@@ -249,16 +249,16 @@ describe('Test external auth plugins', function () {
await wait(5000)
- await server.usersCommand.getMyInfo({ token: kefkaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ token: kefkaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
- await server.pluginsCommand.updateSettings({
+ await server.plugins.updateSettings({
npmName: 'peertube-plugin-test-external-auth-one',
settings: { disableKefka: true }
})
- await server.loginCommand.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await loginExternal({
server,
@@ -273,7 +273,7 @@ describe('Test external auth plugins', function () {
})
it('Should have disabled this auth', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(7)
@@ -283,7 +283,7 @@ describe('Test external auth plugins', function () {
})
it('Should uninstall the plugin one and do not login Cyan', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
await loginExternal({
server,
@@ -296,9 +296,9 @@ describe('Test external auth plugins', function () {
statusCodeExpected: HttpStatusCode.NOT_FOUND_404
})
- await server.loginCommand.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.loginCommand.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.loginCommand.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not login kefka with another plugin', async function () {
@@ -320,7 +320,7 @@ describe('Test external auth plugins', function () {
})
it('Should not login an existing user', async function () {
- await server.usersCommand.create({ username: 'existing_user', password: 'super_password' })
+ await server.users.create({ username: 'existing_user', password: 'super_password' })
await loginExternal({
server,
@@ -332,7 +332,7 @@ describe('Test external auth plugins', function () {
})
it('Should display the correct configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const auths = config.plugin.registeredExternalAuths
expect(auths).to.have.lengthOf(6)
@@ -353,7 +353,7 @@ describe('Test external auth plugins', function () {
username: 'cid'
})
- const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token })
+ const { redirectUrl } = await server.login.logout({ token: resLogin.access_token })
expect(redirectUrl).to.equal('https://example.com/redirectUrl')
})
@@ -365,7 +365,7 @@ describe('Test external auth plugins', function () {
username: 'cid'
})
- const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token })
+ const { redirectUrl } = await server.login.logout({ token: resLogin.access_token })
expect(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token)
})
})
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index e82aa3bfb..18479dcf5 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -32,17 +32,17 @@ describe('Test plugin filter hooks', function () {
await setDefaultVideoChannel(servers)
await doubleFollow(servers[0], servers[1])
- await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() })
- await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
+ await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
+ await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
for (let i = 0; i < 10; i++) {
- await servers[0].videosCommand.upload({ attributes: { name: 'default video ' + i } })
+ await servers[0].videos.upload({ attributes: { name: 'default video ' + i } })
}
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
videoUUID = data[0].uuid
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
live: { enabled: true },
signup: { enabled: true },
@@ -57,98 +57,98 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.videos.list.params', async function () {
- const { data } = await servers[0].videosCommand.list({ start: 0, count: 2 })
+ const { data } = await servers[0].videos.list({ start: 0, count: 2 })
// 2 plugins do +1 to the count parameter
expect(data).to.have.lengthOf(4)
})
it('Should run filter:api.videos.list.result', async function () {
- const { total } = await servers[0].videosCommand.list({ start: 0, count: 0 })
+ const { total } = await servers[0].videos.list({ start: 0, count: 0 })
// Plugin do +1 to the total result
expect(total).to.equal(11)
})
it('Should run filter:api.accounts.videos.list.params', async function () {
- const { data } = await servers[0].videosCommand.listByAccount({ accountName: 'root', start: 0, count: 2 })
+ const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
// 1 plugin do +1 to the count parameter
expect(data).to.have.lengthOf(3)
})
it('Should run filter:api.accounts.videos.list.result', async function () {
- const { total } = await servers[0].videosCommand.listByAccount({ accountName: 'root', start: 0, count: 2 })
+ const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
// Plugin do +2 to the total result
expect(total).to.equal(12)
})
it('Should run filter:api.video-channels.videos.list.params', async function () {
- const { data } = await servers[0].videosCommand.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
+ const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
// 1 plugin do +3 to the count parameter
expect(data).to.have.lengthOf(5)
})
it('Should run filter:api.video-channels.videos.list.result', async function () {
- const { total } = await servers[0].videosCommand.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
+ const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
// Plugin do +3 to the total result
expect(total).to.equal(13)
})
it('Should run filter:api.user.me.videos.list.params', async function () {
- const { data } = await servers[0].videosCommand.listMyVideos({ start: 0, count: 2 })
+ const { data } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
// 1 plugin do +4 to the count parameter
expect(data).to.have.lengthOf(6)
})
it('Should run filter:api.user.me.videos.list.result', async function () {
- const { total } = await servers[0].videosCommand.listMyVideos({ start: 0, count: 2 })
+ const { total } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
// Plugin do +4 to the total result
expect(total).to.equal(14)
})
it('Should run filter:api.video.get.result', async function () {
- const video = await servers[0].videosCommand.get({ id: videoUUID })
+ const video = await servers[0].videos.get({ id: videoUUID })
expect(video.name).to.contain('<3')
})
it('Should run filter:api.video.upload.accept.result', async function () {
- await servers[0].videosCommand.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.live-video.create.accept.result', async function () {
const attributes = {
name: 'video with bad word',
privacy: VideoPrivacy.PUBLIC,
- channelId: servers[0].videoChannel.id
+ channelId: servers[0].store.channel.id
}
- await servers[0].liveCommand.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].live.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.pre-import-url.accept.result', async function () {
const attributes = {
name: 'normal title',
privacy: VideoPrivacy.PUBLIC,
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad'
}
- await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
const attributes = {
name: 'bad torrent',
privacy: VideoPrivacy.PUBLIC,
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
torrentfile: 'video-720p.torrent' as any
}
- await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should run filter:api.video.post-import-url.accept.result', async function () {
@@ -160,17 +160,17 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
targetUrl: ImportsCommand.getGoodVideoUrl()
}
- const body = await servers[0].importsCommand.importVideo({ attributes })
+ const body = await servers[0].imports.importVideo({ attributes })
videoImportId = body.id
}
await waitJobs(servers)
{
- const body = await servers[0].importsCommand.getMyVideoImports()
+ const body = await servers[0].imports.getMyVideoImports()
const videoImports = body.data
const videoImport = videoImports.find(i => i.id === videoImportId)
@@ -189,17 +189,17 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'title with bad word',
privacy: VideoPrivacy.PUBLIC,
- channelId: servers[0].videoChannel.id,
+ channelId: servers[0].store.channel.id,
torrentfile: 'video-720p.torrent' as any
}
- const body = await servers[0].importsCommand.importVideo({ attributes })
+ const body = await servers[0].imports.importVideo({ attributes })
videoImportId = body.id
}
await waitJobs(servers)
{
- const { data: videoImports } = await servers[0].importsCommand.getMyVideoImports()
+ const { data: videoImports } = await servers[0].imports.getMyVideoImports()
const videoImport = videoImports.find(i => i.id === videoImportId)
@@ -209,7 +209,7 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.video-thread.create.accept.result', async function () {
- await servers[0].commentsCommand.createThread({
+ await servers[0].comments.createThread({
videoId: videoUUID,
text: 'comment with bad word',
expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -217,16 +217,16 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.video-comment-reply.create.accept.result', async function () {
- const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' })
+ const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
threadId = created.id
- await servers[0].commentsCommand.addReply({
+ await servers[0].comments.addReply({
videoId: videoUUID,
toCommentId: threadId,
text: 'comment with bad word',
expectedStatus: HttpStatusCode.FORBIDDEN_403
})
- await servers[0].commentsCommand.addReply({
+ await servers[0].comments.addReply({
videoId: videoUUID,
toCommentId: threadId,
text: 'comment with good word',
@@ -235,14 +235,14 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.video-threads.list.params', async function () {
- const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 })
+ const { data } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
// our plugin do +1 to the count parameter
expect(data).to.have.lengthOf(1)
})
it('Should run filter:api.video-threads.list.result', async function () {
- const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 })
+ const { total } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
// Plugin do +1 to the total result
expect(total).to.equal(2)
@@ -251,7 +251,7 @@ describe('Test plugin filter hooks', function () {
it('Should run filter:api.video-thread-comments.list.params')
it('Should run filter:api.video-thread-comments.list.result', async function () {
- const thread = await servers[0].commentsCommand.getThread({ videoId: videoUUID, threadId })
+ const thread = await servers[0].comments.getThread({ videoId: videoUUID, threadId })
expect(thread.comment.text.endsWith(' <3')).to.be.true
})
@@ -259,12 +259,12 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:video.auto-blacklist.result', function () {
async function checkIsBlacklisted (id: number | string, value: boolean) {
- const video = await servers[0].videosCommand.getWithToken({ id })
+ const video = await servers[0].videos.getWithToken({ id })
expect(video.blacklisted).to.equal(value)
}
it('Should blacklist on upload', async function () {
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video please blacklist me' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } })
await checkIsBlacklisted(uuid, true)
})
@@ -274,24 +274,24 @@ describe('Test plugin filter hooks', function () {
const attributes = {
name: 'video please blacklist me',
targetUrl: ImportsCommand.getGoodVideoUrl(),
- channelId: servers[0].videoChannel.id
+ channelId: servers[0].store.channel.id
}
- const body = await servers[0].importsCommand.importVideo({ attributes })
+ const body = await servers[0].imports.importVideo({ attributes })
await checkIsBlacklisted(body.video.uuid, true)
})
it('Should blacklist on update', async function () {
- const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' } })
+ const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
await checkIsBlacklisted(uuid, false)
- await servers[0].videosCommand.update({ id: uuid, attributes: { name: 'please blacklist me' } })
+ await servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
await checkIsBlacklisted(uuid, true)
})
it('Should blacklist on remote upload', async function () {
this.timeout(120000)
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'remote please blacklist me' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } })
await waitJobs(servers)
await checkIsBlacklisted(uuid, true)
@@ -300,12 +300,12 @@ describe('Test plugin filter hooks', function () {
it('Should blacklist on remote update', async function () {
this.timeout(120000)
- const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video' } })
+ const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video' } })
await waitJobs(servers)
await checkIsBlacklisted(uuid, false)
- await servers[1].videosCommand.update({ id: uuid, attributes: { name: 'please blacklist me' } })
+ await servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
await waitJobs(servers)
await checkIsBlacklisted(uuid, true)
@@ -315,16 +315,16 @@ describe('Test plugin filter hooks', function () {
describe('Should run filter:api.user.signup.allowed.result', function () {
it('Should run on config endpoint', async function () {
- const body = await servers[0].configCommand.getConfig()
+ const body = await servers[0].config.getConfig()
expect(body.signup.allowed).to.be.true
})
it('Should allow a signup', async function () {
- await servers[0].usersCommand.register({ username: 'john', password: 'password' })
+ await servers[0].users.register({ username: 'john', password: 'password' })
})
it('Should not allow a signup', async function () {
- const res = await servers[0].usersCommand.register({
+ const res = await servers[0].users.register({
username: 'jma',
password: 'password',
expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -340,7 +340,7 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(120000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
webtorrent: {
@@ -356,14 +356,14 @@ describe('Test plugin filter hooks', function () {
const uuids: string[] = []
for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) {
- const uuid = (await servers[0].videosCommand.quickUpload({ name: name })).uuid
+ const uuid = (await servers[0].videos.quickUpload({ name: name })).uuid
uuids.push(uuid)
}
await waitJobs(servers)
for (const uuid of uuids) {
- downloadVideos.push(await servers[0].videosCommand.get({ id: uuid }))
+ downloadVideos.push(await servers[0].videos.get({ id: uuid }))
}
})
@@ -403,7 +403,7 @@ describe('Test plugin filter hooks', function () {
before(async function () {
this.timeout(60000)
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: false
@@ -413,15 +413,15 @@ describe('Test plugin filter hooks', function () {
for (const name of [ 'bad embed', 'good embed' ]) {
{
- const uuid = (await servers[0].videosCommand.quickUpload({ name: name })).uuid
- embedVideos.push(await servers[0].videosCommand.get({ id: uuid }))
+ const uuid = (await servers[0].videos.quickUpload({ name: name })).uuid
+ embedVideos.push(await servers[0].videos.get({ id: uuid }))
}
{
- const attributes = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
- const { id } = await servers[0].playlistsCommand.create({ attributes })
+ const attributes = { displayName: name, videoChannelId: servers[0].store.channel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
+ const { id } = await servers[0].playlists.create({ attributes })
- const playlist = await servers[0].playlistsCommand.get({ playlistId: id })
+ const playlist = await servers[0].playlists.get({ playlistId: id })
embedPlaylists.push(playlist)
}
}
@@ -441,7 +441,7 @@ describe('Test plugin filter hooks', function () {
describe('Search filters', function () {
before(async function () {
- await servers[0].configCommand.updateCustomSubConfig({
+ await servers[0].config.updateCustomSubConfig({
newConfig: {
search: {
searchIndex: {
@@ -455,78 +455,78 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.search.videos.local.list.{params,result}', async function () {
- await servers[0].searchCommand.advancedVideoSearch({
+ await servers[0].search.advancedVideoSearch({
search: {
search: 'Sun Quan'
}
})
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
})
it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
- await servers[0].searchCommand.advancedVideoSearch({
+ await servers[0].search.advancedVideoSearch({
search: {
search: 'Sun Quan',
searchTarget: 'search-index'
}
})
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
})
it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
- await servers[0].searchCommand.advancedChannelSearch({
+ await servers[0].search.advancedChannelSearch({
search: {
search: 'Sun Ce'
}
})
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
})
it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
- await servers[0].searchCommand.advancedChannelSearch({
+ await servers[0].search.advancedChannelSearch({
search: {
search: 'Sun Ce',
searchTarget: 'search-index'
}
})
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
})
it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
- await servers[0].searchCommand.advancedPlaylistSearch({
+ await servers[0].search.advancedPlaylistSearch({
search: {
search: 'Sun Jian'
}
})
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
})
it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
- await servers[0].searchCommand.advancedPlaylistSearch({
+ await servers[0].search.advancedPlaylistSearch({
search: {
search: 'Sun Jian',
searchTarget: 'search-index'
}
})
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
- await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
+ await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
})
})
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts
index 80d67ae0e..0cb89f511 100644
--- a/server/tests/plugins/html-injection.ts
+++ b/server/tests/plugins/html-injection.ts
@@ -23,7 +23,7 @@ describe('Test plugins HTML injection', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- command = server.pluginsCommand
+ command = server.plugins
})
it('Should not inject global css file in HTML', async function () {
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index 787080e7c..203996af8 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -22,12 +22,12 @@ describe('Test id and pass auth plugins', function () {
await setAccessTokensToServers([ server ])
for (const suffix of [ 'one', 'two', 'three' ]) {
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
}
})
it('Should display the correct configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(8)
@@ -39,13 +39,13 @@ describe('Test id and pass auth plugins', function () {
})
it('Should not login', async function () {
- await server.loginCommand.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should login Spyro, create the user and use the token', async function () {
- const accessToken = await server.loginCommand.getAccessToken({ username: 'spyro', password: 'spyro password' })
+ const accessToken = await server.login.getAccessToken({ username: 'spyro', password: 'spyro password' })
- const body = await server.usersCommand.getMyInfo({ token: accessToken })
+ const body = await server.users.getMyInfo({ token: accessToken })
expect(body.username).to.equal('spyro')
expect(body.account.displayName).to.equal('Spyro the Dragon')
@@ -54,13 +54,13 @@ describe('Test id and pass auth plugins', function () {
it('Should login Crash, create the user and use the token', async function () {
{
- const body = await server.loginCommand.login({ user: { username: 'crash', password: 'crash password' } })
+ const body = await server.login.login({ user: { username: 'crash', password: 'crash password' } })
crashAccessToken = body.access_token
crashRefreshToken = body.refresh_token
}
{
- const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
+ const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.username).to.equal('crash')
expect(body.account.displayName).to.equal('Crash Bandicoot')
@@ -70,13 +70,13 @@ describe('Test id and pass auth plugins', function () {
it('Should login the first Laguna, create the user and use the token', async function () {
{
- const body = await server.loginCommand.login({ user: { username: 'laguna', password: 'laguna password' } })
+ const body = await server.login.login({ user: { username: 'laguna', password: 'laguna password' } })
lagunaAccessToken = body.access_token
lagunaRefreshToken = body.refresh_token
}
{
- const body = await server.usersCommand.getMyInfo({ token: lagunaAccessToken })
+ const body = await server.users.getMyInfo({ token: lagunaAccessToken })
expect(body.username).to.equal('laguna')
expect(body.account.displayName).to.equal('laguna')
@@ -86,46 +86,46 @@ describe('Test id and pass auth plugins', function () {
it('Should refresh crash token, but not laguna token', async function () {
{
- const resRefresh = await server.loginCommand.refreshToken({ refreshToken: crashRefreshToken })
+ const resRefresh = await server.login.refreshToken({ refreshToken: crashRefreshToken })
crashAccessToken = resRefresh.body.access_token
crashRefreshToken = resRefresh.body.refresh_token
- const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
+ const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.username).to.equal('crash')
}
{
- await server.loginCommand.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.login.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
})
it('Should update Crash profile', async function () {
- await server.usersCommand.updateMe({
+ await server.users.updateMe({
token: crashAccessToken,
displayName: 'Beautiful Crash',
description: 'Mutant eastern barred bandicoot'
})
- const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
+ const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.account.displayName).to.equal('Beautiful Crash')
expect(body.account.description).to.equal('Mutant eastern barred bandicoot')
})
it('Should logout Crash', async function () {
- await server.loginCommand.logout({ token: crashAccessToken })
+ await server.login.logout({ token: crashAccessToken })
})
it('Should have logged out Crash', async function () {
- await server.serversCommand.waitUntilLog('On logout for auth 1 - 2')
+ await server.servers.waitUntilLog('On logout for auth 1 - 2')
- await server.usersCommand.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should login Crash and keep the old existing profile', async function () {
- crashAccessToken = await server.loginCommand.getAccessToken({ username: 'crash', password: 'crash password' })
+ crashAccessToken = await server.login.getAccessToken({ username: 'crash', password: 'crash password' })
- const body = await server.usersCommand.getMyInfo({ token: crashAccessToken })
+ const body = await server.users.getMyInfo({ token: crashAccessToken })
expect(body.username).to.equal('crash')
expect(body.account.displayName).to.equal('Beautiful Crash')
@@ -138,38 +138,38 @@ describe('Test id and pass auth plugins', function () {
await wait(5000)
- await server.usersCommand.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ await server.users.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should reject an invalid username, email, role or display name', async function () {
- const command = server.loginCommand
+ const command = server.login
await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.serversCommand.waitUntilLog('valid username')
+ await server.servers.waitUntilLog('valid username')
await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.serversCommand.waitUntilLog('valid display name')
+ await server.servers.waitUntilLog('valid display name')
await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.serversCommand.waitUntilLog('valid role')
+ await server.servers.waitUntilLog('valid role')
await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- await server.serversCommand.waitUntilLog('valid email')
+ await server.servers.waitUntilLog('valid email')
})
it('Should unregister spyro-auth and do not login existing Spyro', async function () {
- await server.pluginsCommand.updateSettings({
+ await server.plugins.updateSettings({
npmName: 'peertube-plugin-test-id-pass-auth-one',
settings: { disableSpyro: true }
})
- const command = server.loginCommand
+ const command = server.login
await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should have disabled this auth', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(7)
@@ -179,16 +179,16 @@ describe('Test id and pass auth plugins', function () {
})
it('Should uninstall the plugin one and do not login existing Crash', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
- await server.loginCommand.login({
+ await server.login.login({
user: { username: 'crash', password: 'crash password' },
expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should display the correct configuration', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
const auths = config.plugin.registeredIdAndPassAuths
expect(auths).to.have.lengthOf(6)
@@ -198,7 +198,7 @@ describe('Test id and pass auth plugins', function () {
})
it('Should display plugin auth information in users list', async function () {
- const { data } = await server.usersCommand.list()
+ const { data } = await server.users.list()
const root = data.find(u => u.username === 'root')
const crash = data.find(u => u.username === 'crash')
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 509aba13d..cf16aaa9d 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -39,28 +39,28 @@ describe('Test plugin helpers', function () {
await doubleFollow(servers[0], servers[1])
- await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-four') })
+ await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-four') })
})
describe('Logger', function () {
it('Should have logged things', async function () {
- await servers[0].serversCommand.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
- await servers[0].serversCommand.waitUntilLog('Hello world from plugin four', 1)
+ await servers[0].servers.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
+ await servers[0].servers.waitUntilLog('Hello world from plugin four', 1)
})
})
describe('Database', function () {
it('Should have made a query', async function () {
- await servers[0].serversCommand.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
+ await servers[0].servers.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
})
})
describe('Config', function () {
it('Should have the correct webserver url', async function () {
- await servers[0].serversCommand.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
+ await servers[0].servers.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
})
it('Should have the correct config', async function () {
@@ -78,7 +78,7 @@ describe('Test plugin helpers', function () {
describe('Server', function () {
it('Should get the server actor', async function () {
- await servers[0].serversCommand.waitUntilLog('server actor name is peertube')
+ await servers[0].servers.waitUntilLog('server actor name is peertube')
})
})
@@ -140,17 +140,17 @@ describe('Test plugin helpers', function () {
this.timeout(60000)
{
- const res = await await servers[0].videosCommand.quickUpload({ name: 'video server 1' })
+ const res = await await servers[0].videos.quickUpload({ name: 'video server 1' })
videoUUIDServer1 = res.uuid
}
{
- await await servers[1].videosCommand.quickUpload({ name: 'video server 2' })
+ await await servers[1].videos.quickUpload({ name: 'video server 2' })
}
await waitJobs(servers)
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(2)
})
@@ -159,7 +159,7 @@ describe('Test plugin helpers', function () {
this.timeout(10000)
await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` })
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video server 1')
@@ -168,7 +168,7 @@ describe('Test plugin helpers', function () {
it('Should unmute server 2', async function () {
await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` })
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(2)
})
@@ -176,7 +176,7 @@ describe('Test plugin helpers', function () {
it('Should mute account of server 2', async function () {
await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` })
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video server 1')
@@ -185,7 +185,7 @@ describe('Test plugin helpers', function () {
it('Should unmute account of server 2', async function () {
await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` })
- const { data } = await servers[0].videosCommand.list()
+ const { data } = await servers[0].videos.list()
expect(data).to.have.lengthOf(2)
})
@@ -198,7 +198,7 @@ describe('Test plugin helpers', function () {
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(1)
expect(data[0].name).to.equal('video server 2')
@@ -213,7 +213,7 @@ describe('Test plugin helpers', function () {
await waitJobs(servers)
for (const server of servers) {
- const { data } = await server.videosCommand.list()
+ const { data } = await server.videos.list()
expect(data).to.have.lengthOf(2)
}
@@ -224,7 +224,7 @@ describe('Test plugin helpers', function () {
let videoUUID: string
before(async () => {
- const res = await await servers[0].videosCommand.quickUpload({ name: 'video1' })
+ const res = await await servers[0].videos.quickUpload({ name: 'video1' })
videoUUID = res.uuid
})
@@ -232,15 +232,15 @@ describe('Test plugin helpers', function () {
this.timeout(40000)
// Should not throw -> video exists
- await servers[0].videosCommand.get({ id: videoUUID })
+ await servers[0].videos.get({ id: videoUUID })
// Should delete the video
- await servers[0].videosCommand.view({ id: videoUUID })
+ await servers[0].videos.view({ id: videoUUID })
- await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.')
+ await servers[0].servers.waitUntilLog('Video deleted by plugin four.')
try {
// Should throw because the video should have been deleted
- await servers[0].videosCommand.get({ id: videoUUID })
+ await servers[0].videos.get({ id: videoUUID })
throw new Error('Video exists')
} catch (err) {
if (err.message.includes('exists')) throw err
@@ -250,7 +250,7 @@ describe('Test plugin helpers', function () {
})
it('Should have fetched the video by URL', async function () {
- await servers[0].serversCommand.waitUntilLog(`video from DB uuid is ${videoUUID}`)
+ await servers[0].servers.waitUntilLog(`video from DB uuid is ${videoUUID}`)
})
})
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts
index 81e18dabd..1c53dd80c 100644
--- a/server/tests/plugins/plugin-router.ts
+++ b/server/tests/plugins/plugin-router.ts
@@ -26,7 +26,7 @@ describe('Test plugin helpers', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-five') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
})
it('Should answer "pong"', async function () {
@@ -82,7 +82,7 @@ describe('Test plugin helpers', function () {
})
it('Should remove the plugin and remove the routes', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-five' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
for (const path of basePaths) {
await makeGetRequest({
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 9babfc83e..30e231439 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -16,13 +16,13 @@ describe('Test plugin storage', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
})
describe('DB storage', function () {
it('Should correctly store a subkey', async function () {
- await server.serversCommand.waitUntilLog('superkey stored value is toto')
+ await server.servers.waitUntilLog('superkey stored value is toto')
})
})
@@ -38,12 +38,12 @@ describe('Test plugin storage', function () {
}
before(function () {
- dataPath = server.serversCommand.buildDirectory('plugins/data')
+ dataPath = server.servers.buildDirectory('plugins/data')
pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
})
it('Should have created the directory on install', async function () {
- const dataPath = server.serversCommand.buildDirectory('plugins/data')
+ const dataPath = server.servers.buildDirectory('plugins/data')
const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
expect(await pathExists(dataPath)).to.be.true
@@ -64,14 +64,14 @@ describe('Test plugin storage', function () {
})
it('Should still have the file after an uninstallation', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-six' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-six' })
const content = await getFileContent()
expect(content).to.equal('Prince Ali')
})
it('Should still have the file after the reinstallation', async function () {
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
const content = await getFileContent()
expect(content).to.equal('Prince Ali')
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts
index a3613293a..3a03065b0 100644
--- a/server/tests/plugins/plugin-transcoding.ts
+++ b/server/tests/plugins/plugin-transcoding.ts
@@ -19,17 +19,17 @@ import { VideoPrivacy } from '@shared/models'
async function createLiveWrapper (server: ServerInfo) {
const liveAttributes = {
name: 'live video',
- channelId: server.videoChannel.id,
+ channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
- const { uuid } = await server.liveCommand.create({ fields: liveAttributes })
+ const { uuid } = await server.live.create({ fields: liveAttributes })
return uuid
}
function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) {
- return server.configCommand.updateCustomSubConfig({
+ return server.config.updateCustomSubConfig({
newConfig: {
transcoding: {
enabled: true,
@@ -79,7 +79,7 @@ describe('Test transcoding plugins', function () {
describe('When using a plugin adding profiles to existing encoders', function () {
async function checkVideoFPS (uuid: string, type: 'above' | 'below', fps: number) {
- const video = await server.videosCommand.get({ id: uuid })
+ const video = await server.videos.get({ id: uuid })
const files = video.files.concat(...video.streamingPlaylists.map(p => p.files))
for (const file of files) {
@@ -103,11 +103,11 @@ describe('Test transcoding plugins', function () {
}
before(async function () {
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') })
})
it('Should have the appropriate available profiles', async function () {
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ])
expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ])
@@ -116,7 +116,7 @@ describe('Test transcoding plugins', function () {
it('Should not use the plugin profile if not chosen by the admin', async function () {
this.timeout(240000)
- const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'above', 20)
@@ -127,7 +127,7 @@ describe('Test transcoding plugins', function () {
await updateConf(server, 'low-vod', 'default')
- const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'below', 12)
@@ -138,7 +138,7 @@ describe('Test transcoding plugins', function () {
await updateConf(server, 'input-options-vod', 'default')
- const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'below', 6)
@@ -149,11 +149,11 @@ describe('Test transcoding plugins', function () {
await updateConf(server, 'bad-scale-vod', 'default')
- const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
// Transcoding failed
- const video = await server.videosCommand.get({ id: videoUUID })
+ const video = await server.videos.get({ id: videoUUID })
expect(video.files).to.have.lengthOf(1)
expect(video.streamingPlaylists).to.have.lengthOf(0)
})
@@ -163,8 +163,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
- await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
- await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
+ await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
+ await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'above', 20)
@@ -177,8 +177,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
- await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
- await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
+ await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
+ await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'below', 12)
@@ -191,8 +191,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
- await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
- await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
+ await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
+ await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
await checkLiveFPS(liveVideoId, 'below', 6)
@@ -205,21 +205,21 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
- const command = await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
+ const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
await testFfmpegStreamError(command, true)
})
it('Should default to the default profile if the specified profile does not exist', async function () {
this.timeout(240000)
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
- const config = await server.configCommand.getConfig()
+ const config = await server.config.getConfig()
expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])
- const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid
+ const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
await waitJobs([ server ])
await checkVideoFPS(videoUUID, 'above', 20)
@@ -230,7 +230,7 @@ describe('Test transcoding plugins', function () {
describe('When using a plugin adding new encoders', function () {
before(async function () {
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') })
await updateConf(server, 'test-vod-profile', 'test-live-profile')
})
@@ -238,10 +238,10 @@ describe('Test transcoding plugins', function () {
it('Should use the new vod encoders', async function () {
this.timeout(240000)
- const videoUUID = (await server.videosCommand.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid
+ const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid
await waitJobs([ server ])
- const path = server.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4'))
+ const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))
const audioProbe = await getAudioStream(path)
expect(audioProbe.audioStream.codec_name).to.equal('opus')
@@ -254,8 +254,8 @@ describe('Test transcoding plugins', function () {
const liveVideoId = await createLiveWrapper(server)
- await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
- await server.liveCommand.waitUntilPublished({ videoId: liveVideoId })
+ await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
+ await server.live.waitUntilPublished({ videoId: liveVideoId })
await waitJobs([ server ])
const playlistUrl = `${server.url}/static/streaming-playlists/hls/${liveVideoId}/0.m3u8`
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts
index f430f82b8..26a27abca 100644
--- a/server/tests/plugins/plugin-unloading.ts
+++ b/server/tests/plugins/plugin-unloading.ts
@@ -16,7 +16,7 @@ describe('Test plugins module unloading', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
})
it('Should return a numeric value', async function () {
@@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () {
})
it('Should uninstall the plugin and free the route', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
await makeGetRequest({
url: server.url,
@@ -51,7 +51,7 @@ describe('Test plugins module unloading', function () {
})
it('Should return a different numeric value', async function () {
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
const res = await makeGetRequest({
url: server.url,
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts
index 0e11a0b53..d8d878026 100644
--- a/server/tests/plugins/translations.ts
+++ b/server/tests/plugins/translations.ts
@@ -17,7 +17,7 @@ describe('Test plugin translations', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- command = server.pluginsCommand
+ command = server.plugins
await command.install({ path: PluginsCommand.getPluginTestPath() })
await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index 641e37fbb..facc6bbc1 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -17,11 +17,11 @@ describe('Test plugin altering video constants', function () {
server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
- await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
+ await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
})
it('Should have updated languages', async function () {
- const languages = await server.videosCommand.getLanguages()
+ const languages = await server.videos.getLanguages()
expect(languages['en']).to.not.exist
expect(languages['fr']).to.not.exist
@@ -32,7 +32,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated categories', async function () {
- const categories = await server.videosCommand.getCategories()
+ const categories = await server.videos.getCategories()
expect(categories[1]).to.not.exist
expect(categories[2]).to.not.exist
@@ -42,7 +42,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated licences', async function () {
- const licences = await server.videosCommand.getLicences()
+ const licences = await server.videos.getLicences()
expect(licences[1]).to.not.exist
expect(licences[7]).to.not.exist
@@ -52,7 +52,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated video privacies', async function () {
- const privacies = await server.videosCommand.getPrivacies()
+ const privacies = await server.videos.getPrivacies()
expect(privacies[1]).to.exist
expect(privacies[2]).to.not.exist
@@ -61,7 +61,7 @@ describe('Test plugin altering video constants', function () {
})
it('Should have updated playlist privacies', async function () {
- const playlistPrivacies = await server.playlistsCommand.getPrivacies()
+ const playlistPrivacies = await server.playlists.getPrivacies()
expect(playlistPrivacies[1]).to.exist
expect(playlistPrivacies[2]).to.exist
@@ -70,29 +70,29 @@ describe('Test plugin altering video constants', function () {
it('Should not be able to create a video with this privacy', async function () {
const attributes = { name: 'video', privacy: 2 }
- await server.videosCommand.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.videos.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should not be able to create a video with this privacy', async function () {
const attributes = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE }
- await server.playlistsCommand.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.playlists.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should be able to upload a video with these values', async function () {
const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
- const { uuid } = await server.videosCommand.upload({ attributes })
+ const { uuid } = await server.videos.upload({ attributes })
- const video = await server.videosCommand.get({ id: uuid })
+ const video = await server.videos.get({ id: uuid })
expect(video.language.label).to.equal('Al Bhed 2')
expect(video.licence.label).to.equal('Best licence')
expect(video.category.label).to.equal('Best category')
})
it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () {
- await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' })
+ await server.plugins.uninstall({ npmName: 'peertube-plugin-test-video-constants' })
{
- const languages = await server.videosCommand.getLanguages()
+ const languages = await server.videos.getLanguages()
expect(languages['en']).to.equal('English')
expect(languages['fr']).to.equal('French')
@@ -103,7 +103,7 @@ describe('Test plugin altering video constants', function () {
}
{
- const categories = await server.videosCommand.getCategories()
+ const categories = await server.videos.getCategories()
expect(categories[1]).to.equal('Music')
expect(categories[2]).to.equal('Films')
@@ -113,7 +113,7 @@ describe('Test plugin altering video constants', function () {
}
{
- const licences = await server.videosCommand.getLicences()
+ const licences = await server.videos.getLicences()
expect(licences[1]).to.equal('Attribution')
expect(licences[7]).to.equal('Public Domain Dedication')
@@ -123,7 +123,7 @@ describe('Test plugin altering video constants', function () {
}
{
- const privacies = await server.videosCommand.getPrivacies()
+ const privacies = await server.videos.getPrivacies()
expect(privacies[1]).to.exist
expect(privacies[2]).to.exist
@@ -132,7 +132,7 @@ describe('Test plugin altering video constants', function () {
}
{
- const playlistPrivacies = await server.playlistsCommand.getPrivacies()
+ const playlistPrivacies = await server.playlists.getPrivacies()
expect(playlistPrivacies[1]).to.exist
expect(playlistPrivacies[2]).to.exist
diff --git a/server/tools/cli.ts b/server/tools/cli.ts
index 163ed62d1..7d5eb72ed 100644
--- a/server/tools/cli.ts
+++ b/server/tools/cli.ts
@@ -15,8 +15,8 @@ const config = require('application-config')(configName)
const version = require('../../../package.json').version
async function getAdminTokenOrDie (server: ServerInfo, username: string, password: string) {
- const token = await server.loginCommand.getAccessToken(username, password)
- const me = await server.usersCommand.getMyInfo({ token })
+ const token = await server.login.getAccessToken(username, password)
+ const me = await server.users.getMyInfo({ token })
if (me.role !== UserRole.ADMINISTRATOR) {
console.error('You must be an administrator.')
@@ -160,7 +160,7 @@ async function buildVideoAttributesFromCommander (server: ServerInfo, command: C
Object.assign(videoAttributes, booleanAttributes)
if (options.channelName) {
- const videoChannel = await server.channelsCommand.get({ channelName: options.channelName })
+ const videoChannel = await server.channels.get({ channelName: options.channelName })
Object.assign(videoAttributes, { channelId: videoChannel.id })
@@ -187,10 +187,10 @@ function buildServer (url: string): ServerInfo {
}
async function assignToken (server: ServerInfo, username: string, password: string) {
- const bodyClient = await server.loginCommand.getClient()
+ const bodyClient = await server.login.getClient()
const client = { id: bodyClient.client_id, secret: bodyClient.client_secret }
- const body = await server.loginCommand.login({ client, user: { username, password } })
+ const body = await server.login.login({ client, user: { username, password } })
server.accessToken = body.access_token
}
diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts
index fc76735b9..caf1facc7 100644
--- a/server/tools/peertube-import-videos.ts
+++ b/server/tools/peertube-import-videos.ts
@@ -150,7 +150,7 @@ async function processVideo (parameters: {
}
const server = buildServer(url)
- const { data } = await server.searchCommand.advancedVideoSearch({
+ const { data } = await server.search.advancedVideoSearch({
search: {
search: videoInfo.title,
sort: '-match',
@@ -249,14 +249,14 @@ async function uploadVideoOnPeerTube (parameters: {
log.info('\nUploading on PeerTube video "%s".', attributes.name)
try {
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
} catch (err) {
if (err.message.indexOf('401') !== -1) {
log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.')
- server.accessToken = await server.loginCommand.getAccessToken(username, password)
+ server.accessToken = await server.login.getAccessToken(username, password)
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
} else {
exitError(err.message)
}
@@ -277,7 +277,7 @@ async function getCategory (server: ServerInfo, categories: string[]) {
if (categoryString === 'News & Politics') return 11
- const categoriesServer = await server.videosCommand.getCategories()
+ const categoriesServer = await server.videos.getCategories()
for (const key of Object.keys(categoriesServer)) {
const categoryServer = categoriesServer[key]
diff --git a/server/tools/peertube-plugins.ts b/server/tools/peertube-plugins.ts
index 22a09b779..d9c285115 100644
--- a/server/tools/peertube-plugins.ts
+++ b/server/tools/peertube-plugins.ts
@@ -69,7 +69,7 @@ async function pluginsListCLI (command: Command, options: OptionValues) {
if (options.onlyThemes) pluginType = PluginType.THEME
if (options.onlyPlugins) pluginType = PluginType.PLUGIN
- const { data } = await server.pluginsCommand.list({ start: 0, count: 100, sort: 'name', pluginType })
+ const { data } = await server.plugins.list({ start: 0, count: 100, sort: 'name', pluginType })
const table = new CliTable3({
head: [ 'name', 'version', 'homepage' ],
@@ -109,7 +109,7 @@ async function installPluginCLI (command: Command, options: OptionValues) {
await assignToken(server, username, password)
try {
- await server.pluginsCommand.install({ npmName: options.npmName, path: options.path })
+ await server.plugins.install({ npmName: options.npmName, path: options.path })
} catch (err) {
console.error('Cannot install plugin.', err)
process.exit(-1)
@@ -136,7 +136,7 @@ async function updatePluginCLI (command: Command, options: OptionValues) {
await assignToken(server, username, password)
try {
- await server.pluginsCommand.update({ npmName: options.npmName, path: options.path })
+ await server.plugins.update({ npmName: options.npmName, path: options.path })
} catch (err) {
console.error('Cannot update plugin.', err)
process.exit(-1)
@@ -158,7 +158,7 @@ async function uninstallPluginCLI (command: Command, options: OptionValues) {
await assignToken(server, username, password)
try {
- await server.pluginsCommand.uninstall({ npmName: options.npmName })
+ await server.plugins.uninstall({ npmName: options.npmName })
} catch (err) {
console.error('Cannot uninstall plugin.', err)
process.exit(-1)
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts
index 0f6b3086c..5fda68c8e 100644
--- a/server/tools/peertube-redundancy.ts
+++ b/server/tools/peertube-redundancy.ts
@@ -63,7 +63,7 @@ async function listRedundanciesCLI (target: VideoRedundanciesTarget) {
const server = buildServer(url)
await assignToken(server, username, password)
- const { data } = await server.redundancyCommand.listVideos({ start: 0, count: 100, sort: 'name', target })
+ const { data } = await server.redundancy.listVideos({ start: 0, count: 100, sort: 'name', target })
const table = new CliTable3({
head: [ 'video id', 'video name', 'video url', 'files', 'playlists', 'by instances', 'total size' ]
@@ -114,7 +114,7 @@ async function addRedundancyCLI (options: { video: number }, command: Command) {
}
try {
- await server.redundancyCommand.addVideo({ videoId: options.video })
+ await server.redundancy.addVideo({ videoId: options.video })
console.log('Video will be duplicated by your instance!')
@@ -145,11 +145,11 @@ async function removeRedundancyCLI (options: { video: number }, command: Command
const videoId = parseInt(options.video + '', 10)
- const myVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'my-videos' })
+ const myVideoRedundancies = await server.redundancy.listVideos({ target: 'my-videos' })
let videoRedundancy = myVideoRedundancies.data.find(r => videoId === r.id)
if (!videoRedundancy) {
- const remoteVideoRedundancies = await server.redundancyCommand.listVideos({ target: 'remote-videos' })
+ const remoteVideoRedundancies = await server.redundancy.listVideos({ target: 'remote-videos' })
videoRedundancy = remoteVideoRedundancies.data.find(r => videoId === r.id)
}
@@ -164,7 +164,7 @@ async function removeRedundancyCLI (options: { video: number }, command: Command
.map(r => r.id)
for (const id of ids) {
- await server.redundancyCommand.removeVideo({ redundancyId: id })
+ await server.redundancy.removeVideo({ redundancyId: id })
}
console.log('Video redundancy removed!')
diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts
index 597137e4c..01fb1fe8d 100644
--- a/server/tools/peertube-upload.ts
+++ b/server/tools/peertube-upload.ts
@@ -62,7 +62,7 @@ async function run (url: string, username: string, password: string) {
}
try {
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
console.log(`Video ${options.videoName} uploaded.`)
process.exit(0)
} catch (err) {
diff --git a/server/tools/test-live.ts b/server/tools/test-live.ts
index 7004e98e8..bc31b6926 100644
--- a/server/tools/test-live.ts
+++ b/server/tools/test-live.ts
@@ -54,15 +54,15 @@ async function run () {
const attributes: LiveVideoCreate = {
name: 'live',
saveReplay: true,
- channelId: server.videoChannel.id,
+ channelId: server.store.channel.id,
privacy: VideoPrivacy.PUBLIC
}
console.log('Creating live.')
- const { uuid: liveVideoUUID } = await server.liveCommand.create({ fields: attributes })
+ const { uuid: liveVideoUUID } = await server.live.create({ fields: attributes })
- const live = await server.liveCommand.get({ videoId: liveVideoUUID })
+ const live = await server.live.get({ videoId: liveVideoUUID })
console.log('Sending RTMP stream.')
@@ -82,7 +82,7 @@ async function run () {
// ----------------------------------------------------------------------------
async function buildConfig (server: ServerInfo, commandType: CommandType) {
- await server.configCommand.updateCustomSubConfig({
+ await server.config.updateCustomSubConfig({
newConfig: {
instance: {
customizations: {
diff --git a/shared/extra-utils/miscs/checks.ts b/shared/extra-utils/miscs/checks.ts
index 86b861cd2..8f7bdb9b5 100644
--- a/shared/extra-utils/miscs/checks.ts
+++ b/shared/extra-utils/miscs/checks.ts
@@ -34,7 +34,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
}
async function testFileExistsOrNot (server: ServerInfo, directory: string, filePath: string, exist: boolean) {
- const base = server.serversCommand.buildDirectory(directory)
+ const base = server.servers.buildDirectory(directory)
expect(await pathExists(join(base, filePath))).to.equal(exist)
}
diff --git a/shared/extra-utils/miscs/webtorrent.ts b/shared/extra-utils/miscs/webtorrent.ts
index 63e648309..84e390b2a 100644
--- a/shared/extra-utils/miscs/webtorrent.ts
+++ b/shared/extra-utils/miscs/webtorrent.ts
@@ -17,7 +17,7 @@ function webtorrentAdd (torrent: string, refreshWebTorrent = false) {
async function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) {
const torrentName = videoUUID + '-' + resolution + '.torrent'
- const torrentPath = server.serversCommand.buildDirectory(join('torrents', torrentName))
+ const torrentPath = server.servers.buildDirectory(join('torrents', torrentName))
const data = await readFile(torrentPath)
diff --git a/shared/extra-utils/server/follows.ts b/shared/extra-utils/server/follows.ts
index c23cebd81..50ae898cc 100644
--- a/shared/extra-utils/server/follows.ts
+++ b/shared/extra-utils/server/follows.ts
@@ -3,8 +3,8 @@ import { ServerInfo } from './servers'
async function doubleFollow (server1: ServerInfo, server2: ServerInfo) {
await Promise.all([
- server1.followsCommand.follow({ targets: [ server2.url ] }),
- server2.followsCommand.follow({ targets: [ server1.url ] })
+ server1.follows.follow({ targets: [ server2.url ] }),
+ server2.follows.follow({ targets: [ server1.url ] })
])
// Wait request propagation
diff --git a/shared/extra-utils/server/jobs.ts b/shared/extra-utils/server/jobs.ts
index 36ef882b3..754530977 100644
--- a/shared/extra-utils/server/jobs.ts
+++ b/shared/extra-utils/server/jobs.ts
@@ -23,7 +23,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
// Check if each server has pending request
for (const server of servers) {
for (const state of states) {
- const p = server.jobsCommand.getJobsList({
+ const p = server.jobs.getJobsList({
state,
start: 0,
count: 10,
@@ -39,7 +39,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) {
tasks.push(p)
}
- const p = server.debugCommand.getDebug()
+ const p = server.debug.getDebug()
.then(obj => {
if (obj.activityPubMessagesWaiting !== 0) {
pendingRequests = true
diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts
index 5bed51d1a..98049ce19 100644
--- a/shared/extra-utils/server/plugins-command.ts
+++ b/shared/extra-utils/server/plugins-command.ts
@@ -251,6 +251,6 @@ export class PluginsCommand extends AbstractCommand {
}
private getPackageJSONPath (npmName: string) {
- return this.server.serversCommand.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json'))
+ return this.server.servers.buildDirectory(join('plugins', 'node_modules', npmName, 'package.json'))
}
}
diff --git a/shared/extra-utils/server/plugins.ts b/shared/extra-utils/server/plugins.ts
index 1084ea4f4..d1cc7e383 100644
--- a/shared/extra-utils/server/plugins.ts
+++ b/shared/extra-utils/server/plugins.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai'
import { ServerInfo } from '../server/servers'
async function testHelloWorldRegisteredSettings (server: ServerInfo) {
- const body = await server.pluginsCommand.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })
+ const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })
const registeredSettings = body.registeredSettings
expect(registeredSettings).to.have.length.at.least(1)
diff --git a/shared/extra-utils/server/servers-command.ts b/shared/extra-utils/server/servers-command.ts
index 9ef68fede..a7c5a868d 100644
--- a/shared/extra-utils/server/servers-command.ts
+++ b/shared/extra-utils/server/servers-command.ts
@@ -37,7 +37,7 @@ export class ServersCommand extends AbstractCommand {
if (isGithubCI()) {
await ensureDir('artifacts')
- const origin = this.server.serversCommand.buildDirectory('logs/peertube.log')
+ const origin = this.server.servers.buildDirectory('logs/peertube.log')
const destname = `peertube-${this.server.internalServerNumber}.log`
console.log('Saving logs %s.', destname)
@@ -56,7 +56,7 @@ export class ServersCommand extends AbstractCommand {
}
async waitUntilLog (str: string, count = 1, strictCount = true) {
- const logfile = this.server.serversCommand.buildDirectory('logs/peertube.log')
+ const logfile = this.server.servers.buildDirectory('logs/peertube.log')
while (true) {
const buf = await readFile(logfile)
@@ -74,7 +74,7 @@ export class ServersCommand extends AbstractCommand {
}
async getServerFileSize (subPath: string) {
- const path = this.server.serversCommand.buildDirectory(subPath)
+ const path = this.server.servers.buildDirectory(subPath)
return getFileSize(path)
}
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index fda5c3d6d..ea3f19a92 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -53,83 +53,81 @@ interface ServerInfo {
parallel?: boolean
internalServerNumber: number
+
serverNumber?: number
-
- client?: {
- id?: string
- secret?: string
- }
-
- user?: {
- username: string
- password: string
- email?: string
- }
-
customConfigFile?: string
+ store?: {
+ client?: {
+ id?: string
+ secret?: string
+ }
+
+ user?: {
+ username: string
+ password: string
+ email?: string
+ }
+
+ channel?: VideoChannel
+
+ video?: {
+ id: number
+ uuid: string
+ shortUUID: string
+ name?: string
+ url?: string
+
+ account?: {
+ name: string
+ }
+
+ embedPath?: string
+ }
+
+ videos?: { id: number, uuid: string }[]
+ }
+
accessToken?: string
refreshToken?: string
- videoChannel?: VideoChannel
- video?: {
- id: number
- uuid: string
- shortUUID: string
- name?: string
- url?: string
-
- account?: {
- name: string
- }
-
- embedPath?: string
- }
-
- remoteVideo?: {
- id: number
- uuid: string
- }
-
- videos?: { id: number, uuid: string }[]
-
- bulkCommand?: BulkCommand
- cliCommand?: CLICommand
- customPageCommand?: CustomPagesCommand
- feedCommand?: FeedCommand
- logsCommand?: LogsCommand
- abusesCommand?: AbusesCommand
- overviewsCommand?: OverviewsCommand
- searchCommand?: SearchCommand
- contactFormCommand?: ContactFormCommand
- debugCommand?: DebugCommand
- followsCommand?: FollowsCommand
- jobsCommand?: JobsCommand
- pluginsCommand?: PluginsCommand
- redundancyCommand?: RedundancyCommand
- statsCommand?: StatsCommand
- configCommand?: ConfigCommand
- socketIOCommand?: SocketIOCommand
- accountsCommand?: AccountsCommand
- blocklistCommand?: BlocklistCommand
- subscriptionsCommand?: SubscriptionsCommand
- liveCommand?: LiveCommand
- servicesCommand?: ServicesCommand
- blacklistCommand?: BlacklistCommand
- captionsCommand?: CaptionsCommand
- changeOwnershipCommand?: ChangeOwnershipCommand
- playlistsCommand?: PlaylistsCommand
- historyCommand?: HistoryCommand
- importsCommand?: ImportsCommand
- streamingPlaylistsCommand?: StreamingPlaylistsCommand
- channelsCommand?: ChannelsCommand
- commentsCommand?: CommentsCommand
- sqlCommand?: SQLCommand
- notificationsCommand?: NotificationsCommand
- serversCommand?: ServersCommand
- loginCommand?: LoginCommand
- usersCommand?: UsersCommand
- videosCommand?: VideosCommand
+ bulk?: BulkCommand
+ cli?: CLICommand
+ customPage?: CustomPagesCommand
+ feed?: FeedCommand
+ logs?: LogsCommand
+ abuses?: AbusesCommand
+ overviews?: OverviewsCommand
+ search?: SearchCommand
+ contactForm?: ContactFormCommand
+ debug?: DebugCommand
+ follows?: FollowsCommand
+ jobs?: JobsCommand
+ plugins?: PluginsCommand
+ redundancy?: RedundancyCommand
+ stats?: StatsCommand
+ config?: ConfigCommand
+ socketIO?: SocketIOCommand
+ accounts?: AccountsCommand
+ blocklist?: BlocklistCommand
+ subscriptions?: SubscriptionsCommand
+ live?: LiveCommand
+ services?: ServicesCommand
+ blacklist?: BlacklistCommand
+ captions?: CaptionsCommand
+ changeOwnership?: ChangeOwnershipCommand
+ playlists?: PlaylistsCommand
+ history?: HistoryCommand
+ imports?: ImportsCommand
+ streamingPlaylists?: StreamingPlaylistsCommand
+ channels?: ChannelsCommand
+ comments?: CommentsCommand
+ sql?: SQLCommand
+ notifications?: NotificationsCommand
+ servers?: ServersCommand
+ login?: LoginCommand
+ users?: UsersCommand
+ videos?: VideosCommand
}
function flushAndRunMultipleServers (totalServers: number, configOverride?: Object) {
@@ -189,13 +187,15 @@ async function flushAndRunServer (serverNumber: number, configOverride?: Object,
url: `http://localhost:${port}`,
host: `localhost:${port}`,
hostname: 'localhost',
- client: {
- id: null,
- secret: null
- },
- user: {
- username: null,
- password: null
+ store: {
+ client: {
+ id: null,
+ secret: null
+ },
+ user: {
+ username: null,
+ password: null
+ }
}
}
@@ -291,10 +291,10 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
const regexp = regexps[key]
const matches = data.toString().match(regexp)
if (matches !== null) {
- if (key === 'client_id') server.client.id = matches[1]
- else if (key === 'client_secret') server.client.secret = matches[1]
- else if (key === 'user_username') server.user.username = matches[1]
- else if (key === 'user_password') server.user.password = matches[1]
+ if (key === 'client_id') server.store.client.id = matches[1]
+ else if (key === 'client_secret') server.store.client.secret = matches[1]
+ else if (key === 'user_username') server.store.user.username = matches[1]
+ else if (key === 'user_password') server.store.user.password = matches[1]
}
}
@@ -327,43 +327,43 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
}
function assignCommands (server: ServerInfo) {
- server.bulkCommand = new BulkCommand(server)
- server.cliCommand = new CLICommand(server)
- server.customPageCommand = new CustomPagesCommand(server)
- server.feedCommand = new FeedCommand(server)
- server.logsCommand = new LogsCommand(server)
- server.abusesCommand = new AbusesCommand(server)
- server.overviewsCommand = new OverviewsCommand(server)
- server.searchCommand = new SearchCommand(server)
- server.contactFormCommand = new ContactFormCommand(server)
- server.debugCommand = new DebugCommand(server)
- server.followsCommand = new FollowsCommand(server)
- server.jobsCommand = new JobsCommand(server)
- server.pluginsCommand = new PluginsCommand(server)
- server.redundancyCommand = new RedundancyCommand(server)
- server.statsCommand = new StatsCommand(server)
- server.configCommand = new ConfigCommand(server)
- server.socketIOCommand = new SocketIOCommand(server)
- server.accountsCommand = new AccountsCommand(server)
- server.blocklistCommand = new BlocklistCommand(server)
- server.subscriptionsCommand = new SubscriptionsCommand(server)
- server.liveCommand = new LiveCommand(server)
- server.servicesCommand = new ServicesCommand(server)
- server.blacklistCommand = new BlacklistCommand(server)
- server.captionsCommand = new CaptionsCommand(server)
- server.changeOwnershipCommand = new ChangeOwnershipCommand(server)
- server.playlistsCommand = new PlaylistsCommand(server)
- server.historyCommand = new HistoryCommand(server)
- server.importsCommand = new ImportsCommand(server)
- server.streamingPlaylistsCommand = new StreamingPlaylistsCommand(server)
- server.channelsCommand = new ChannelsCommand(server)
- server.commentsCommand = new CommentsCommand(server)
- server.sqlCommand = new SQLCommand(server)
- server.notificationsCommand = new NotificationsCommand(server)
- server.serversCommand = new ServersCommand(server)
- server.loginCommand = new LoginCommand(server)
- server.usersCommand = new UsersCommand(server)
- server.videosCommand = new VideosCommand(server)
+ server.bulk = new BulkCommand(server)
+ server.cli = new CLICommand(server)
+ server.customPage = new CustomPagesCommand(server)
+ server.feed = new FeedCommand(server)
+ server.logs = new LogsCommand(server)
+ server.abuses = new AbusesCommand(server)
+ server.overviews = new OverviewsCommand(server)
+ server.search = new SearchCommand(server)
+ server.contactForm = new ContactFormCommand(server)
+ server.debug = new DebugCommand(server)
+ server.follows = new FollowsCommand(server)
+ server.jobs = new JobsCommand(server)
+ server.plugins = new PluginsCommand(server)
+ server.redundancy = new RedundancyCommand(server)
+ server.stats = new StatsCommand(server)
+ server.config = new ConfigCommand(server)
+ server.socketIO = new SocketIOCommand(server)
+ server.accounts = new AccountsCommand(server)
+ server.blocklist = new BlocklistCommand(server)
+ server.subscriptions = new SubscriptionsCommand(server)
+ server.live = new LiveCommand(server)
+ server.services = new ServicesCommand(server)
+ server.blacklist = new BlacklistCommand(server)
+ server.captions = new CaptionsCommand(server)
+ server.changeOwnership = new ChangeOwnershipCommand(server)
+ server.playlists = new PlaylistsCommand(server)
+ server.history = new HistoryCommand(server)
+ server.imports = new ImportsCommand(server)
+ server.streamingPlaylists = new StreamingPlaylistsCommand(server)
+ server.channels = new ChannelsCommand(server)
+ server.comments = new CommentsCommand(server)
+ server.sql = new SQLCommand(server)
+ server.notifications = new NotificationsCommand(server)
+ server.servers = new ServersCommand(server)
+ server.login = new LoginCommand(server)
+ server.users = new UsersCommand(server)
+ server.videos = new VideosCommand(server)
}
async function reRunServer (server: ServerInfo, configOverride?: any) {
@@ -377,7 +377,7 @@ async function killallServers (servers: ServerInfo[]) {
for (const server of servers) {
if (!server.app) continue
- await server.sqlCommand.cleanup()
+ await server.sql.cleanup()
process.kill(-server.app.pid)
@@ -394,7 +394,7 @@ async function cleanupTests (servers: ServerInfo[]) {
let p: Promise[] = []
for (const server of servers) {
- p = p.concat(server.serversCommand.cleanupTests())
+ p = p.concat(server.servers.cleanupTests())
}
return Promise.all(p)
diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts
index ee94351e8..2c9a4b71c 100644
--- a/shared/extra-utils/users/accounts.ts
+++ b/shared/extra-utils/users/accounts.ts
@@ -14,7 +14,7 @@ async function expectAccountFollows (options: {
}) {
const { server, handle, followers, following } = options
- const body = await server.accountsCommand.list()
+ const body = await server.accounts.list()
const account = body.data.find(a => a.name + '@' + a.host === handle)
const message = `${handle} on ${server.url}`
diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts
index b4e3bb602..10c3db851 100644
--- a/shared/extra-utils/users/login-command.ts
+++ b/shared/extra-utils/users/login-command.ts
@@ -9,7 +9,7 @@ export class LoginCommand extends AbstractCommand {
client?: { id?: string, secret?: string }
user?: { username: string, password?: string }
} = {}) {
- const { client = this.server.client, user = this.server.user } = options
+ const { client = this.server.store.client, user = this.server.store.user } = options
const path = '/api/v1/users/token'
const body = {
@@ -38,7 +38,7 @@ export class LoginCommand extends AbstractCommand {
async getAccessToken (arg1?: { username: string, password?: string } | string, password?: string) {
let user: { username: string, password?: string }
- if (!arg1) user = this.server.user
+ if (!arg1) user = this.server.store.user
else if (typeof arg1 === 'object') user = arg1
else user = { username: arg1, password }
@@ -59,8 +59,8 @@ export class LoginCommand extends AbstractCommand {
const path = '/api/v1/users/token'
const body = {
- client_id: this.server.client.id,
- client_secret: this.server.client.secret,
+ client_id: this.server.store.client.id,
+ client_secret: this.server.store.client.secret,
username: username,
response_type: 'code',
grant_type: 'password',
@@ -100,8 +100,8 @@ export class LoginCommand extends AbstractCommand {
const path = '/api/v1/users/token'
const body = {
- client_id: this.server.client.id,
- client_secret: this.server.client.secret,
+ client_id: this.server.store.client.id,
+ client_secret: this.server.store.client.secret,
refresh_token: options.refreshToken,
response_type: 'code',
grant_type: 'refresh_token'
diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts
index d4ee8e517..d0c26a4f0 100644
--- a/shared/extra-utils/users/login.ts
+++ b/shared/extra-utils/users/login.ts
@@ -4,7 +4,7 @@ function setAccessTokensToServers (servers: ServerInfo[]) {
const tasks: Promise[] = []
for (const server of servers) {
- const p = server.loginCommand.getAccessToken()
+ const p = server.login.getAccessToken()
.then(t => { server.accessToken = t })
tasks.push(p)
}
diff --git a/shared/extra-utils/users/notifications.ts b/shared/extra-utils/users/notifications.ts
index 0af7d8a18..9196f0bf5 100644
--- a/shared/extra-utils/users/notifications.ts
+++ b/shared/extra-utils/users/notifications.ts
@@ -49,7 +49,7 @@ async function checkNotification (
const check = base.check || { web: true, mail: true }
if (check.web) {
- const notification = await base.server.notificationsCommand.getLastest({ token: base.token })
+ const notification = await base.server.notifications.getLastest({ token: base.token })
if (notification || checkType !== 'absence') {
notificationChecker(notification, checkType)
@@ -651,31 +651,31 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an
}
const user = { username: 'user_1', password: 'super password' }
- await servers[0].usersCommand.create({ ...user, videoQuota: 10 * 1000 * 1000 })
- const userAccessToken = await servers[0].loginCommand.getAccessToken(user)
+ await servers[0].users.create({ ...user, videoQuota: 10 * 1000 * 1000 })
+ const userAccessToken = await servers[0].login.getAccessToken(user)
- await servers[0].notificationsCommand.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
- await servers[0].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() })
+ await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() })
+ await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() })
if (serversCount > 1) {
- await servers[1].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() })
+ await servers[1].notifications.updateMySettings({ settings: getAllNotificationsSettings() })
}
{
- const socket = servers[0].socketIOCommand.getUserNotificationSocket({ token: userAccessToken })
+ const socket = servers[0].socketIO.getUserNotificationSocket({ token: userAccessToken })
socket.on('new-notification', n => userNotifications.push(n))
}
{
- const socket = servers[0].socketIOCommand.getUserNotificationSocket()
+ const socket = servers[0].socketIO.getUserNotificationSocket()
socket.on('new-notification', n => adminNotifications.push(n))
}
if (serversCount > 1) {
- const socket = servers[1].socketIOCommand.getUserNotificationSocket()
+ const socket = servers[1].socketIO.getUserNotificationSocket()
socket.on('new-notification', n => adminNotificationsServer2.push(n))
}
- const { videoChannels } = await servers[0].usersCommand.getMyInfo()
+ const { videoChannels } = await servers[0].users.getMyInfo()
const channelId = videoChannels[0].id
return {
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts
index 202528b8d..59dc6d018 100644
--- a/shared/extra-utils/users/users-command.ts
+++ b/shared/extra-utils/users/users-command.ts
@@ -194,7 +194,7 @@ export class UsersCommand extends AbstractCommand {
const password = 'password'
const user = await this.create({ username, password })
- const token = await this.server.loginCommand.getAccessToken({ username, password })
+ const token = await this.server.login.getAccessToken({ username, password })
const me = await this.getMyInfo({ token })
@@ -209,7 +209,7 @@ export class UsersCommand extends AbstractCommand {
const password = 'password'
await this.create({ username, password })
- return this.server.loginCommand.getAccessToken({ username, password })
+ return this.server.login.getAccessToken({ username, password })
}
register (options: OverrideCommandOptions & {
diff --git a/shared/extra-utils/videos/channels.ts b/shared/extra-utils/videos/channels.ts
index 9e7ec565d..81e818094 100644
--- a/shared/extra-utils/videos/channels.ts
+++ b/shared/extra-utils/videos/channels.ts
@@ -4,8 +4,8 @@ function setDefaultVideoChannel (servers: ServerInfo[]) {
const tasks: Promise[] = []
for (const server of servers) {
- const p = server.usersCommand.getMyInfo()
- .then(user => { server.videoChannel = user.videoChannels[0] })
+ const p = server.users.getMyInfo()
+ .then(user => { server.store.channel = user.videoChannels[0] })
tasks.push(p)
}
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts
index 5adf601cc..fd66c9924 100644
--- a/shared/extra-utils/videos/live-command.ts
+++ b/shared/extra-utils/videos/live-command.ts
@@ -114,7 +114,7 @@ export class LiveCommand extends AbstractCommand {
const { resolution, segment, videoUUID } = options
const segmentName = `${resolution}-00000${segment}.ts`
- return this.server.serversCommand.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false)
+ return this.server.servers.waitUntilLog(`${videoUUID}/${segmentName}`, 2, false)
}
async waitUntilSaved (options: OverrideCommandOptions & {
@@ -123,7 +123,7 @@ export class LiveCommand extends AbstractCommand {
let video: VideoDetails
do {
- video = await this.server.videosCommand.getWithToken({ token: options.token, id: options.videoId })
+ video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
await wait(500)
} while (video.isLive === true && video.state.id !== VideoState.PUBLISHED)
@@ -132,7 +132,7 @@ export class LiveCommand extends AbstractCommand {
async countPlaylists (options: OverrideCommandOptions & {
videoUUID: string
}) {
- const basePath = this.server.serversCommand.buildDirectory('streaming-playlists')
+ const basePath = this.server.servers.buildDirectory('streaming-playlists')
const hlsPath = join(basePath, 'hls', options.videoUUID)
const files = await readdir(hlsPath)
@@ -147,7 +147,7 @@ export class LiveCommand extends AbstractCommand {
let video: VideoDetails
do {
- video = await this.server.videosCommand.getWithToken({ token: options.token, id: options.videoId })
+ video = await this.server.videos.getWithToken({ token: options.token, id: options.videoId })
await wait(500)
} while (video.state.id !== options.state)
diff --git a/shared/extra-utils/videos/live.ts b/shared/extra-utils/videos/live.ts
index 0efcc2883..353595811 100644
--- a/shared/extra-utils/videos/live.ts
+++ b/shared/extra-utils/videos/live.ts
@@ -72,12 +72,12 @@ async function stopFfmpeg (command: ffmpeg.FfmpegCommand) {
async function waitUntilLivePublishedOnAllServers (servers: ServerInfo[], videoId: string) {
for (const server of servers) {
- await server.liveCommand.waitUntilPublished({ videoId })
+ await server.live.waitUntilPublished({ videoId })
}
}
async function checkLiveCleanup (server: ServerInfo, videoUUID: string, resolutions: number[] = []) {
- const basePath = server.serversCommand.buildDirectory('streaming-playlists')
+ const basePath = server.servers.buildDirectory('streaming-playlists')
const hlsPath = join(basePath, 'hls', videoUUID)
if (resolutions.length === 0) {
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts
index 75c8f2433..cbfc7e10f 100644
--- a/shared/extra-utils/videos/playlists-command.ts
+++ b/shared/extra-utils/videos/playlists-command.ts
@@ -184,7 +184,7 @@ export class PlaylistsCommand extends AbstractCommand {
const attributes = {
...options.attributes,
- videoId: await this.server.videosCommand.getId({ ...options, uuid: options.attributes.videoId })
+ videoId: await this.server.videos.getId({ ...options, uuid: options.attributes.videoId })
}
const path = '/api/v1/video-playlists/' + options.playlistId + '/videos'
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts
index 0324c739a..e8fd2f232 100644
--- a/shared/extra-utils/videos/streaming-playlists.ts
+++ b/shared/extra-utils/videos/streaming-playlists.ts
@@ -13,7 +13,7 @@ async function checkSegmentHash (options: {
hlsPlaylist: VideoStreamingPlaylist
}) {
const { server, baseUrlPlaylist, baseUrlSegment, videoUUID, resolution, hlsPlaylist } = options
- const command = server.streamingPlaylistsCommand
+ const command = server.streamingPlaylists
const playlist = await command.get({ url: `${baseUrlPlaylist}/${videoUUID}/${resolution}.m3u8` })
@@ -43,7 +43,7 @@ async function checkLiveSegmentHash (options: {
hlsPlaylist: VideoStreamingPlaylist
}) {
const { server, baseUrlSegment, videoUUID, segmentName, hlsPlaylist } = options
- const command = server.streamingPlaylistsCommand
+ const command = server.streamingPlaylists
const segmentBody = await command.getSegment({ url: `${baseUrlSegment}/${videoUUID}/${segmentName}` })
const shaBody = await command.getSegmentSha256({ url: hlsPlaylist.segmentsSha256Url })
@@ -58,7 +58,7 @@ async function checkResolutionsInMasterPlaylist (options: {
}) {
const { server, playlistUrl, resolutions } = options
- const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: playlistUrl })
+ const masterPlaylist = await server.streamingPlaylists.get({ url: playlistUrl })
for (const resolution of resolutions) {
const reg = new RegExp(
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts
index 574705474..5556cddf6 100644
--- a/shared/extra-utils/videos/videos-command.ts
+++ b/shared/extra-utils/videos/videos-command.ts
@@ -336,7 +336,7 @@ export class VideosCommand extends AbstractCommand {
let defaultChannelId = 1
try {
- const { videoChannels } = await this.server.usersCommand.getMyInfo({ token: options.token })
+ const { videoChannels } = await this.server.users.getMyInfo({ token: options.token })
defaultChannelId = videoChannels[0].id
} catch (e) { /* empty */ }
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index 19f0df8b8..86f49384d 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -27,7 +27,7 @@ async function checkVideoFilesWereRemoved (
]
) {
for (const directory of directories) {
- const directoryPath = server.serversCommand.buildDirectory(directory)
+ const directoryPath = server.servers.buildDirectory(directory)
const directoryExists = await pathExists(directoryPath)
if (directoryExists === false) continue
@@ -47,8 +47,8 @@ function checkUploadVideoParam (
mode: 'legacy' | 'resumable' = 'legacy'
) {
return mode === 'legacy'
- ? server.videosCommand.buildLegacyUpload({ token, attributes, expectedStatus })
- : server.videosCommand.buildResumeUpload({ token, attributes, expectedStatus })
+ ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus })
+ : server.videos.buildResumeUpload({ token, attributes, expectedStatus })
}
async function completeVideoCheck (
@@ -131,7 +131,7 @@ async function completeVideoCheck (
expect(video.originallyPublishedAt).to.be.null
}
- const videoDetails = await server.videosCommand.get({ id: video.uuid })
+ const videoDetails = await server.videos.get({ id: video.uuid })
expect(videoDetails.files).to.have.lengthOf(attributes.files.length)
expect(videoDetails.tags).to.deep.equal(attributes.tags)
@@ -202,7 +202,7 @@ async function uploadRandomVideoOnServers (
additionalParams?: VideoEdit & { prefixName?: string }
) {
const server = servers.find(s => s.serverNumber === serverNumber)
- const res = await server.videosCommand.randomUpload({ wait: false, ...additionalParams })
+ const res = await server.videos.randomUpload({ wait: false, ...additionalParams })
await waitJobs(servers)