From c8fc9b47188b33cfc33184b1ee7e680a093244f1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 10:35:35 +0200 Subject: Rename mock server files --- server/tests/api/notifications/admin-notifications.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index cfe0bd2bb..170aa4532 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { MockJoinPeerTubeVersions } from '@shared/extra-utils/mock-servers/joinpeertube-versions' +import { MockJoinPeerTubeVersions } from '@shared/extra-utils' import { PluginType } from '@shared/models' import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils' import { ServerInfo } from '../../../../shared/extra-utils/index' -- cgit v1.2.3 From 8ef9457fdee7812b1a8cc3b3bdeff94130819003 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 10:36:54 +0200 Subject: Correctly export misc files --- server/tests/api/notifications/admin-notifications.ts | 2 +- server/tests/api/notifications/moderation-notifications.ts | 2 +- server/tests/api/notifications/notifications-api.ts | 2 +- server/tests/api/notifications/user-notifications.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index 170aa4532..91681c9d6 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -6,7 +6,7 @@ import { MockJoinPeerTubeVersions } from '@shared/extra-utils' import { PluginType } from '@shared/models' import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils' import { ServerInfo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' +import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' import { CheckerBaseParams, checkNewPeerTubeVersion, diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 3425480ae..a7671696f 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -27,7 +27,7 @@ import { wait } from '../../../../shared/extra-utils' import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' +import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { checkAbuseStateChange, diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index b81995449..19f9dbbab 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -5,7 +5,7 @@ import * as chai from 'chai' import { addUserSubscription } from '@shared/extra-utils/users/user-subscriptions' import { cleanupTests, getMyUserInformation, immutableAssign, uploadRandomVideo, waitJobs } from '../../../../shared/extra-utils' import { ServerInfo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' +import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' import { CheckerBaseParams, checkNewVideoFromSubscription, diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index e981c1718..ace7e48c7 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -12,7 +12,7 @@ import { wait } from '../../../../shared/extra-utils' import { ServerInfo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' +import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { CheckerBaseParams, -- cgit v1.2.3 From 0c1a77e9ccf915184c431145a8b326d4ce271b46 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 12:01:59 +0200 Subject: Introduce abuse command --- .../api/notifications/moderation-notifications.ts | 88 ++++++++++------------ 1 file changed, 41 insertions(+), 47 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index a7671696f..f77719c68 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -2,11 +2,23 @@ import 'mocha' import { buildUUID } from '@server/helpers/uuid' -import { AbuseState } from '@shared/models' import { - addAbuseMessage, + addUserSubscription, addVideoCommentThread, addVideoToBlacklist, + checkAbuseStateChange, + checkAutoInstanceFollowing, + CheckerBaseParams, + checkNewAbuseMessage, + checkNewAccountAbuseForModerators, + checkNewBlacklistOnMyVideo, + checkNewCommentAbuseForModerators, + checkNewInstanceFollower, + checkNewVideoAbuseForModerators, + checkNewVideoFromSubscription, + checkUserRegistered, + checkVideoAutoBlacklistForModerators, + checkVideoIsPublished, cleanupTests, createUser, follow, @@ -17,38 +29,20 @@ import { getVideoIdFromUUID, immutableAssign, MockInstancesIndex, + MockSmtpServer, + prepareNotificationsTest, registerUser, + removeUserSubscription, removeVideoFromBlacklist, - reportAbuse, + ServerInfo, unfollow, - updateAbuse, updateCustomConfig, updateCustomSubConfig, - wait -} from '../../../../shared/extra-utils' -import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' -import { - checkAbuseStateChange, - checkAutoInstanceFollowing, - CheckerBaseParams, - checkNewAbuseMessage, - checkNewAccountAbuseForModerators, - checkNewBlacklistOnMyVideo, - checkNewCommentAbuseForModerators, - checkNewInstanceFollower, - checkNewVideoAbuseForModerators, - checkNewVideoFromSubscription, - checkUserRegistered, - checkVideoAutoBlacklistForModerators, - checkVideoIsPublished, - prepareNotificationsTest -} from '../../../../shared/extra-utils/users/user-notifications' -import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' -import { CustomConfig } from '../../../../shared/models/server' -import { UserNotification } from '../../../../shared/models/users' -import { VideoPrivacy } from '../../../../shared/models/videos' + uploadVideo, + wait, + waitJobs +} from '@shared/extra-utils' +import { AbuseState, CustomConfig, UserNotification, VideoPrivacy } from '@shared/models' describe('Test moderation notifications', function () { let servers: ServerInfo[] = [] @@ -89,7 +83,7 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video - await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, videoId: video.id, reason: 'super reason' }) + await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' }) await waitJobs(servers) await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') @@ -105,7 +99,7 @@ describe('Test moderation notifications', function () { await waitJobs(servers) const videoId = await getVideoIdFromUUID(servers[1].url, video.uuid) - await reportAbuse({ url: servers[1].url, token: servers[1].accessToken, videoId, reason: 'super reason' }) + await servers[1].abusesCommand.report({ videoId, reason: 'super reason' }) await waitJobs(servers) await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') @@ -122,7 +116,7 @@ describe('Test moderation notifications', function () { await waitJobs(servers) - await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, commentId: comment.id, reason: 'super reason' }) + await servers[0].abusesCommand.report({ commentId: comment.id, reason: 'super reason' }) await waitJobs(servers) await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') @@ -140,7 +134,7 @@ describe('Test moderation notifications', function () { const resComments = await getVideoCommentThreads(servers[1].url, video.uuid, 0, 5) const commentId = resComments.body.data[0].id - await reportAbuse({ url: servers[1].url, token: servers[1].accessToken, commentId, reason: 'super reason' }) + await servers[1].abusesCommand.report({ commentId, reason: 'super reason' }) await waitJobs(servers) await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') @@ -153,7 +147,7 @@ describe('Test moderation notifications', function () { const resUser = await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username, password: 'donald' }) const accountId = resUser.body.user.account.id - await reportAbuse({ url: servers[0].url, token: servers[0].accessToken, accountId, reason: 'super reason' }) + await servers[0].abusesCommand.report({ accountId, reason: 'super reason' }) await waitJobs(servers) await checkNewAccountAbuseForModerators(baseParams, username, 'presence') @@ -169,7 +163,7 @@ describe('Test moderation notifications', function () { await waitJobs(servers) const resAccount = await getAccount(servers[1].url, username + '@' + servers[0].host) - await reportAbuse({ url: servers[1].url, token: servers[1].accessToken, accountId: resAccount.body.id, reason: 'super reason' }) + await servers[1].abusesCommand.report({ accountId: resAccount.body.id, reason: 'super reason' }) await waitJobs(servers) await checkNewAccountAbuseForModerators(baseParams, username, 'presence') @@ -192,14 +186,14 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video - const res = await reportAbuse({ url: servers[0].url, token: userAccessToken, videoId: video.id, reason: 'super reason' }) - abuseId = res.body.abuse.id + const body = await servers[0].abusesCommand.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 updateAbuse(servers[0].url, servers[0].accessToken, abuseId, { state: AbuseState.ACCEPTED }) + await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } }) await waitJobs(servers) await checkAbuseStateChange(baseParams, abuseId, AbuseState.ACCEPTED, 'presence') @@ -208,7 +202,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 updateAbuse(servers[0].url, servers[0].accessToken, abuseId, { state: AbuseState.REJECTED }) + await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.REJECTED } }) await waitJobs(servers) await checkAbuseStateChange(baseParams, abuseId, AbuseState.REJECTED, 'presence') @@ -241,13 +235,13 @@ describe('Test moderation notifications', function () { const video = resVideo.body.video { - const res = await reportAbuse({ url: servers[0].url, token: userAccessToken, videoId: video.id, reason: 'super reason' }) - abuseId = res.body.abuse.id + const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) + abuseId = body.abuse.id } { - const res = await reportAbuse({ url: servers[0].url, token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) - abuseId2 = res.body.abuse.id + const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) + abuseId2 = body.abuse.id } }) @@ -255,7 +249,7 @@ describe('Test moderation notifications', function () { this.timeout(10000) const message = 'my super message to users' - await addAbuseMessage(servers[0].url, servers[0].accessToken, abuseId, message) + await servers[0].abusesCommand.addMessage({ abuseId, message }) await waitJobs(servers) await checkNewAbuseMessage(baseParamsUser, abuseId, message, 'user_1@example.com', 'presence') @@ -265,7 +259,7 @@ describe('Test moderation notifications', function () { this.timeout(10000) const message = 'my super message that should not be sent to the admin' - await addAbuseMessage(servers[0].url, servers[0].accessToken, abuseId, message) + await servers[0].abusesCommand.addMessage({ abuseId, message }) await waitJobs(servers) await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence') @@ -275,7 +269,7 @@ describe('Test moderation notifications', function () { this.timeout(10000) const message = 'my super message to moderators' - await addAbuseMessage(servers[0].url, userAccessToken, abuseId2, message) + await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) await waitJobs(servers) await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence') @@ -285,7 +279,7 @@ describe('Test moderation notifications', function () { this.timeout(10000) const message = 'my super message that should not be sent to reporter' - await addAbuseMessage(servers[0].url, userAccessToken, abuseId2, message) + await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) await waitJobs(servers) await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence') -- cgit v1.2.3 From 2d1ad5b96063d1e430ca99128a15e2e56cb614e0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 15:33:39 +0200 Subject: Move AP request in requests file --- server/tests/api/notifications/moderation-notifications.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index f77719c68..c4f63200a 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -235,7 +235,7 @@ describe('Test moderation notifications', function () { const video = resVideo.body.video { - const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) + const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) abuseId = body.abuse.id } -- cgit v1.2.3 From c3d29f694bf8c910f917be655626d0f80871124f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 09:16:40 +0200 Subject: Introduce follows command --- .../tests/api/notifications/moderation-notifications.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index c4f63200a..9a93ce401 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -21,7 +21,6 @@ import { checkVideoIsPublished, cleanupTests, createUser, - follow, generateUserAccessToken, getAccount, getCustomConfig, @@ -35,7 +34,6 @@ import { removeUserSubscription, removeVideoFromBlacklist, ServerInfo, - unfollow, updateCustomConfig, updateCustomSubConfig, uploadVideo, @@ -386,7 +384,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 follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) + await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) await waitJobs(servers) @@ -399,7 +397,7 @@ describe('Test moderation notifications', function () { it('Should send a notification on auto follow back', async function () { this.timeout(40000) - await unfollow(servers[2].url, servers[2].accessToken, servers[0]) + await servers[2].followsCommand.unfollow({ target: servers[0] }) await waitJobs(servers) const config = { @@ -411,7 +409,7 @@ describe('Test moderation notifications', function () { } await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) - await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) + await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) await waitJobs(servers) @@ -424,13 +422,13 @@ describe('Test moderation notifications', function () { config.followings.instance.autoFollowBack.enabled = false await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) - await unfollow(servers[0].url, servers[0].accessToken, servers[2]) - await unfollow(servers[2].url, servers[2].accessToken, servers[0]) + await servers[0].followsCommand.unfollow({ target: servers[2] }) + await servers[2].followsCommand.unfollow({ target: servers[0] }) }) it('Should send a notification on auto instances index follow', async function () { this.timeout(30000) - await unfollow(servers[0].url, servers[0].accessToken, servers[1]) + await servers[0].followsCommand.unfollow({ target: servers[1] }) await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) @@ -443,7 +441,7 @@ describe('Test moderation notifications', function () { config.followings.instance.autoFollowIndex.enabled = false await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) - await unfollow(servers[0].url, servers[0].accessToken, servers[1]) + await servers[0].followsCommand.unfollow({ target: servers[1] }) }) }) -- cgit v1.2.3 From ae2abfd3aed3e75d39a316b49b914d187faa7475 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 10:33:49 +0200 Subject: Introduce plugins command --- .../tests/api/notifications/admin-notifications.ts | 31 +++++++++------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index 91681c9d6..da9767b74 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -2,18 +2,20 @@ import 'mocha' import { expect } from 'chai' -import { MockJoinPeerTubeVersions } from '@shared/extra-utils' -import { PluginType } from '@shared/models' -import { cleanupTests, installPlugin, setPluginLatestVersion, setPluginVersion, wait } from '../../../../shared/extra-utils' -import { ServerInfo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' import { CheckerBaseParams, checkNewPeerTubeVersion, checkNewPluginVersion, - prepareNotificationsTest -} from '../../../../shared/extra-utils/users/user-notifications' -import { UserNotification, UserNotificationType } from '../../../../shared/models/users' + cleanupTests, + MockJoinPeerTubeVersions, + MockSmtpServer, + prepareNotificationsTest, + ServerInfo, + setPluginLatestVersion, + setPluginVersion, + wait +} from '@shared/extra-utils' +import { PluginType, UserNotification, UserNotificationType } from '@shared/models' describe('Test admin notifications', function () { let server: ServerInfo @@ -58,17 +60,8 @@ describe('Test admin notifications', function () { token: server.accessToken } - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-plugin-hello-world' - }) - - await installPlugin({ - url: server.url, - accessToken: server.accessToken, - npmName: 'peertube-theme-background-red' - }) + await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' }) + await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' }) }) describe('Latest PeerTube version notification', function () { -- cgit v1.2.3 From 65e6e2602c0d5521f3a6740f7469bb92830ecb53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:51:09 +0200 Subject: Introduce config command --- .../api/notifications/moderation-notifications.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 9a93ce401..3e66e7517 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -23,7 +23,6 @@ import { createUser, generateUserAccessToken, getAccount, - getCustomConfig, getVideoCommentThreads, getVideoIdFromUUID, immutableAssign, @@ -34,8 +33,6 @@ import { removeUserSubscription, removeVideoFromBlacklist, ServerInfo, - updateCustomConfig, - updateCustomSubConfig, uploadVideo, wait, waitJobs @@ -407,7 +404,7 @@ describe('Test moderation notifications', function () { } } } - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) + await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) @@ -421,7 +418,7 @@ describe('Test moderation notifications', function () { await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence') config.followings.instance.autoFollowBack.enabled = false - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) + await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) await servers[0].followsCommand.unfollow({ target: servers[2] }) await servers[2].followsCommand.unfollow({ target: servers[0] }) }) @@ -430,7 +427,7 @@ describe('Test moderation notifications', function () { this.timeout(30000) await servers[0].followsCommand.unfollow({ target: servers[1] }) - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) + await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) await wait(5000) await waitJobs(servers) @@ -440,7 +437,7 @@ describe('Test moderation notifications', function () { await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') config.followings.instance.autoFollowIndex.enabled = false - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) + await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) await servers[0].followsCommand.unfollow({ target: servers[1] }) }) }) @@ -476,8 +473,8 @@ describe('Test moderation notifications', function () { token: userAccessToken } - const resCustomConfig = await getCustomConfig(servers[0].url, servers[0].accessToken) - currentCustomConfig = resCustomConfig.body + currentCustomConfig = await servers[0].configCommand.getCustomConfig() + const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, { autoBlacklist: { videos: { @@ -487,9 +484,10 @@ describe('Test moderation notifications', function () { } } }) + // enable transcoding otherwise own publish notification after transcoding not expected autoBlacklistTestsCustomConfig.transcoding.enabled = true - await updateCustomConfig(servers[0].url, servers[0].accessToken, autoBlacklistTestsCustomConfig) + await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) @@ -612,7 +610,7 @@ describe('Test moderation notifications', function () { }) after(async () => { - await updateCustomConfig(servers[0].url, servers[0].accessToken, currentCustomConfig) + await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) -- cgit v1.2.3 From 9fff08cf83f34339df7ed4ac770e1dee536adf9d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 13:38:26 +0200 Subject: Introduce accounts command --- server/tests/api/notifications/moderation-notifications.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 3e66e7517..e90640ad6 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -22,7 +22,6 @@ import { cleanupTests, createUser, generateUserAccessToken, - getAccount, getVideoCommentThreads, getVideoIdFromUUID, immutableAssign, @@ -157,8 +156,8 @@ describe('Test moderation notifications', function () { await waitJobs(servers) - const resAccount = await getAccount(servers[1].url, username + '@' + servers[0].host) - await servers[1].abusesCommand.report({ accountId: resAccount.body.id, reason: 'super reason' }) + const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host }) + await servers[1].abusesCommand.report({ accountId: account.id, reason: 'super reason' }) await waitJobs(servers) await checkNewAccountAbuseForModerators(baseParams, username, 'presence') -- cgit v1.2.3 From 5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 16:02:46 +0200 Subject: Introduce blocklist command --- server/tests/api/notifications/comments-notifications.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index d2badf237..13fcee843 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -3,7 +3,6 @@ import 'mocha' import * as chai from 'chai' import { - addAccountToAccountBlocklist, addVideoCommentReply, addVideoCommentThread, checkCommentMention, @@ -14,7 +13,6 @@ import { getVideoThreadComments, MockSmtpServer, prepareNotificationsTest, - removeAccountFromAccountBlocklist, ServerInfo, updateMyUser, uploadVideo, @@ -86,7 +84,7 @@ describe('Test comments notifications', function () { it('Should not send a new comment notification if the account is muted', async function () { this.timeout(20000) - await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root') + await servers[0].blocklistCommand.addToMyBlocklist({ token: userAccessToken, account: 'root' }) const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid @@ -97,7 +95,7 @@ describe('Test comments notifications', function () { await waitJobs(servers) await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') - await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root') + await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userAccessToken, account: 'root' }) }) it('Should send a new comment notification after a local comment on my video', async function () { @@ -244,7 +242,7 @@ describe('Test comments notifications', function () { it('Should not send a new mention notification if the account is muted', async function () { this.timeout(10000) - await addAccountToAccountBlocklist(servers[0].url, userAccessToken, 'root') + await servers[0].blocklistCommand.addToMyBlocklist({ token: userAccessToken, account: 'root' }) const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid @@ -255,7 +253,7 @@ describe('Test comments notifications', function () { await waitJobs(servers) await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') - await removeAccountFromAccountBlocklist(servers[0].url, userAccessToken, 'root') + await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userAccessToken, account: 'root' }) }) it('Should not send a new mention notification if the remote account mention a local account', async function () { -- cgit v1.2.3 From 2c27e70471120c92e0bc8c8114141fbb31ff98ac Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 16:40:49 +0200 Subject: Introduce subscriptions command --- .../api/notifications/moderation-notifications.ts | 10 +++--- .../tests/api/notifications/notifications-api.ts | 19 +++++----- .../tests/api/notifications/user-notifications.ts | 42 ++++++++++------------ 3 files changed, 34 insertions(+), 37 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index e90640ad6..605b41947 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -3,7 +3,6 @@ import 'mocha' import { buildUUID } from '@server/helpers/uuid' import { - addUserSubscription, addVideoCommentThread, addVideoToBlacklist, checkAbuseStateChange, @@ -29,7 +28,6 @@ import { MockSmtpServer, prepareNotificationsTest, registerUser, - removeUserSubscription, removeVideoFromBlacklist, ServerInfo, uploadVideo, @@ -488,8 +486,8 @@ describe('Test moderation notifications', function () { autoBlacklistTestsCustomConfig.transcoding.enabled = true await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) - await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) - await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) + 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 }) }) @@ -611,8 +609,8 @@ describe('Test moderation notifications', function () { after(async () => { await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) - await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) - await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) + 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 }) }) }) diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 19f9dbbab..1ed98ae7a 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -2,21 +2,24 @@ import 'mocha' import * as chai from 'chai' -import { addUserSubscription } from '@shared/extra-utils/users/user-subscriptions' -import { cleanupTests, getMyUserInformation, immutableAssign, uploadRandomVideo, waitJobs } from '../../../../shared/extra-utils' -import { ServerInfo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' import { CheckerBaseParams, checkNewVideoFromSubscription, + cleanupTests, getAllNotificationsSettings, + getMyUserInformation, getUserNotifications, + immutableAssign, markAsReadAllNotifications, markAsReadNotifications, + MockSmtpServer, prepareNotificationsTest, - updateMyNotificationSettings -} from '../../../../shared/extra-utils/users/user-notifications' -import { User, UserNotification, UserNotificationSettingValue } from '../../../../shared/models/users' + ServerInfo, + updateMyNotificationSettings, + uploadRandomVideo, + waitJobs +} from '@shared/extra-utils' +import { User, UserNotification, UserNotificationSettingValue } from '@shared/models' const expect = chai.expect @@ -35,7 +38,7 @@ describe('Test notifications API', function () { userNotifications = res.userNotifications server = res.servers[0] - await addUserSubscription(server.url, userAccessToken, 'root_channel@localhost:' + server.port) + await server.subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + server.port }) for (let i = 0; i < 10; i++) { await uploadRandomVideo(server, false) diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index ace7e48c7..15be983f2 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -3,30 +3,26 @@ import 'mocha' import * as chai from 'chai' import { buildUUID } from '@server/helpers/uuid' -import { - cleanupTests, - updateMyUser, - updateVideo, - updateVideoChannel, - uploadRandomVideoOnServers, - wait -} from '../../../../shared/extra-utils' -import { ServerInfo } from '../../../../shared/extra-utils/index' -import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' -import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { CheckerBaseParams, checkMyVideoImportIsFinished, checkNewActorFollow, checkNewVideoFromSubscription, checkVideoIsPublished, + cleanupTests, getLastNotification, - prepareNotificationsTest -} from '../../../../shared/extra-utils/users/user-notifications' -import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' -import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' -import { UserNotification, UserNotificationType } from '../../../../shared/models/users' -import { VideoPrivacy } from '../../../../shared/models/videos' + MockSmtpServer, + prepareNotificationsTest, + ServerInfo, + updateMyUser, + updateVideo, + updateVideoChannel, + uploadRandomVideoOnServers, + wait, + waitJobs +} from '@shared/extra-utils' +import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports' +import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -79,7 +75,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 addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port) + await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) await waitJobs(servers) const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) @@ -89,7 +85,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 addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[1].port) + await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port }) await waitJobs(servers) const { name, uuid } = await uploadRandomVideoOnServers(servers, 2) @@ -418,23 +414,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 addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) + await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) await waitJobs(servers) await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') - await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) + await servers[0].subscriptionsCommand.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 addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) + await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) await waitJobs(servers) await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') - await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) + await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) }) // PeerTube does not support accout -> account follows -- cgit v1.2.3 From e3d15a6a9aed97a004d9dac1b7a6499d794e080a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 11:17:55 +0200 Subject: Introduce blacklist command --- server/tests/api/notifications/moderation-notifications.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 605b41947..52ade0548 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -4,7 +4,6 @@ import 'mocha' import { buildUUID } from '@server/helpers/uuid' import { addVideoCommentThread, - addVideoToBlacklist, checkAbuseStateChange, checkAutoInstanceFollowing, CheckerBaseParams, @@ -28,7 +27,6 @@ import { MockSmtpServer, prepareNotificationsTest, registerUser, - removeVideoFromBlacklist, ServerInfo, uploadVideo, wait, @@ -297,7 +295,7 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const uuid = resVideo.body.video.uuid - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.add({ videoId: uuid }) await waitJobs(servers) await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist') @@ -310,10 +308,10 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const uuid = resVideo.body.video.uuid - await addVideoToBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.add({ videoId: uuid }) await waitJobs(servers) - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.remove({ videoId: uuid }) await waitJobs(servers) await wait(500) @@ -517,7 +515,7 @@ describe('Test moderation notifications', function () { it('Should send video published and unblacklist after video unblacklisted', async function () { this.timeout(40000) - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoUUID) + await servers[0].blacklistCommand.remove({ videoId: videoUUID }) await waitJobs(servers) @@ -554,7 +552,7 @@ describe('Test moderation notifications', function () { const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) const uuid = resVideo.body.video.uuid - await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, uuid) + await servers[0].blacklistCommand.remove({ videoId: uuid }) await waitJobs(servers) await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist') -- cgit v1.2.3 From 6910f20f114b5bd020258a3a9a3f2117819a60c2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 16:49:51 +0200 Subject: Introduce import command --- .../tests/api/notifications/user-notifications.ts | 30 ++++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 15be983f2..a9315c818 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -11,6 +11,7 @@ import { checkVideoIsPublished, cleanupTests, getLastNotification, + ImportsCommand, MockSmtpServer, prepareNotificationsTest, ServerInfo, @@ -21,7 +22,6 @@ import { wait, waitJobs } from '@shared/extra-utils' -import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports' import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -209,14 +209,13 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PUBLIC, - targetUrl: getGoodVideoUrl() + targetUrl: ImportsCommand.getGoodVideoUrl() } - const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) - const uuid = res.body.video.uuid + const { video } = await servers[0].importsCommand.importVideo({ attributes }) await waitJobs(servers) - await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') + await checkNewVideoFromSubscription(baseParams, name, video.uuid, 'presence') }) }) @@ -280,14 +279,13 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PUBLIC, - targetUrl: getGoodVideoUrl(), + targetUrl: ImportsCommand.getGoodVideoUrl(), waitTranscoding: true } - const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) - const uuid = res.body.video.uuid + const { video } = await servers[1].importsCommand.importVideo({ attributes }) await waitJobs(servers) - await checkVideoIsPublished(baseParams, name, uuid, 'presence') + await checkVideoIsPublished(baseParams, name, video.uuid, 'presence') }) it('Should send a notification when the scheduled update has been proceeded', async function () { @@ -349,13 +347,12 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PRIVATE, - targetUrl: getBadVideoUrl() + targetUrl: ImportsCommand.getBadVideoUrl() } - const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) - const uuid = res.body.video.uuid + const { video } = await servers[0].importsCommand.importVideo({ attributes }) await waitJobs(servers) - await checkMyVideoImportIsFinished(baseParams, name, uuid, getBadVideoUrl(), false, 'presence') + await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence') }) it('Should send a notification when the video import succeeded', async function () { @@ -367,13 +364,12 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PRIVATE, - targetUrl: getGoodVideoUrl() + targetUrl: ImportsCommand.getGoodVideoUrl() } - const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) - const uuid = res.body.video.uuid + const { video } = await servers[0].importsCommand.importVideo({ attributes }) await waitJobs(servers) - await checkMyVideoImportIsFinished(baseParams, name, uuid, getGoodVideoUrl(), true, 'presence') + await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence') }) }) -- cgit v1.2.3 From a54618880c394ad7571f3f3222dc96ec2dd10d9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 11:21:30 +0200 Subject: Introduce channels command --- server/tests/api/notifications/user-notifications.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index a9315c818..1d159c48f 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -17,7 +17,6 @@ import { ServerInfo, updateMyUser, updateVideo, - updateVideoChannel, uploadRandomVideoOnServers, wait, waitJobs @@ -404,7 +403,11 @@ describe('Test user notifications', function () { displayName: 'super root 2 name' }) - await updateVideoChannel(servers[0].url, userAccessToken, 'user_1_channel', { displayName: myChannelName }) + await servers[0].channelsCommand.update({ + token: userAccessToken, + channelName: 'user_1_channel', + attributes: { displayName: myChannelName } + }) }) it('Should notify when a local channel is following one of our channel', async function () { -- cgit v1.2.3 From 12edc1495a36b2199f1bf1ba37f50c7b694be382 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 14:15:11 +0200 Subject: Introduce comments command --- .../api/notifications/comments-notifications.ts | 123 +++++++++------------ .../api/notifications/moderation-notifications.ts | 20 ++-- 2 files changed, 67 insertions(+), 76 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index 13fcee843..ea6055386 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -3,14 +3,10 @@ import 'mocha' import * as chai from 'chai' import { - addVideoCommentReply, - addVideoCommentThread, checkCommentMention, CheckerBaseParams, checkNewCommentOnMyVideo, cleanupTests, - getVideoCommentThreads, - getVideoThreadComments, MockSmtpServer, prepareNotificationsTest, ServerInfo, @@ -18,13 +14,13 @@ import { uploadVideo, waitJobs } from '@shared/extra-utils' -import { UserNotification, VideoCommentThreadTree } from '@shared/models' +import { UserNotification } from '@shared/models' const expect = chai.expect describe('Test comments notifications', function () { let servers: ServerInfo[] = [] - let userAccessToken: string + let userToken: string let userNotifications: UserNotification[] = [] let emails: object[] = [] @@ -38,7 +34,7 @@ describe('Test comments notifications', function () { const res = await prepareNotificationsTest(2) emails = res.emails - userAccessToken = res.userAccessToken + userToken = res.userAccessToken servers = res.servers userNotifications = res.userNotifications }) @@ -51,7 +47,7 @@ describe('Test comments notifications', function () { server: servers[0], emails, socketNotifications: userNotifications, - token: userAccessToken + token: userToken } }) @@ -61,8 +57,8 @@ describe('Test comments notifications', function () { const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') - const commentId = resComment.body.comment.id + const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) + const commentId = created.id await waitJobs(servers) await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') @@ -71,11 +67,11 @@ 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 resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, 'comment') - const commentId = resComment.body.comment.id + const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' }) + const commentId = created.id await waitJobs(servers) await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') @@ -84,28 +80,28 @@ 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: userAccessToken, account: 'root' }) + await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') - const commentId = resComment.body.comment.id + const created = await servers[0].commentsCommand.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: userAccessToken, account: 'root' }) + await servers[0].blocklistCommand.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 resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') - const commentId = resComment.body.comment.id + const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) + const commentId = created.id await waitJobs(servers) await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') @@ -114,33 +110,31 @@ 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 resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid await waitJobs(servers) - await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment') + await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) await waitJobs(servers) - const resComment = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) - expect(resComment.body.data).to.have.lengthOf(1) - const commentId = resComment.body.data[0].id + const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) + expect(data).to.have.lengthOf(1) + const commentId = data[0].id await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'presence') }) it('Should send a new comment notification after a local reply on my video', async function () { this.timeout(20000) - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, 'comment') - const threadId = resThread.body.comment.id + const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) - const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'reply') - const commentId = resComment.body.comment.id + const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) await waitJobs(servers) await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') @@ -149,24 +143,23 @@ 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 resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid await waitJobs(servers) { - const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, 'comment') - const threadId = resThread.body.comment.id - await addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, threadId, 'reply') + const created = await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) + const threadId = created.id + await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) } await waitJobs(servers) - const resThread = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) - expect(resThread.body.data).to.have.lengthOf(1) - const threadId = resThread.body.data[0].id + const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) + expect(data).to.have.lengthOf(1) - const resComments = await getVideoThreadComments(servers[0].url, uuid, threadId) - const tree = resComments.body as VideoCommentThreadTree + const threadId = data[0].id + const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId }) expect(tree.children).to.have.lengthOf(1) const commentId = tree.children[0].comment.id @@ -177,10 +170,10 @@ describe('Test comments notifications', function () { it('Should convert markdown in comment to html', async function () { this.timeout(20000) - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'cool video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'cool video' }) const uuid = resVideo.body.video.uuid - await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, commentText) + await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText }) await waitJobs(servers) @@ -197,7 +190,7 @@ describe('Test comments notifications', function () { server: servers[0], emails, socketNotifications: userNotifications, - token: userAccessToken + token: userToken } await updateMyUser({ @@ -216,11 +209,10 @@ describe('Test comments notifications', function () { it('Should not send a new mention comment notification if I mention the video owner', async function () { this.timeout(10000) - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: 'super video' }) + const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello') - const commentId = resComment.body.comment.id + const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) await waitJobs(servers) await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') @@ -232,8 +224,7 @@ describe('Test comments notifications', function () { const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, uuid, '@user_1 hello') - const commentId = resComment.body.comment.id + const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) await waitJobs(servers) await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') @@ -242,18 +233,17 @@ 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: userAccessToken, account: 'root' }) + await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resComment = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello') - const commentId = resComment.body.comment.id + const { id: commentId } = await servers[0].commentsCommand.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: userAccessToken, account: 'root' }) + await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' }) }) it('Should not send a new mention notification if the remote account mention a local account', async function () { @@ -263,8 +253,7 @@ describe('Test comments notifications', function () { const uuid = resVideo.body.video.uuid await waitJobs(servers) - const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, '@user_1 hello') - const threadId = resThread.body.comment.id + const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) await waitJobs(servers) await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') @@ -276,14 +265,12 @@ describe('Test comments notifications', function () { const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1') - const threadId = resThread.body.comment.id + const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) await waitJobs(servers) await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') - const resComment = await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, 'hello 2 @user_1') - const commentId = resComment.body.comment.id + const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }) await waitJobs(servers) await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') @@ -298,23 +285,22 @@ describe('Test comments notifications', function () { await waitJobs(servers) const text1 = `hello @user_1@localhost:${servers[0].port} 1` - const resThread = await addVideoCommentThread(servers[1].url, servers[1].accessToken, uuid, text1) - const server2ThreadId = resThread.body.comment.id + const { id: server2ThreadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: text1 }) await waitJobs(servers) - const resThread2 = await getVideoCommentThreads(servers[0].url, uuid, 0, 5) - expect(resThread2.body.data).to.have.lengthOf(1) - const server1ThreadId = resThread2.body.data[0].id + const { data } = await servers[0].commentsCommand.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 addVideoCommentReply(servers[1].url, servers[1].accessToken, uuid, server2ThreadId, text2) + await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) await waitJobs(servers) - const resComments = await getVideoThreadComments(servers[0].url, uuid, server1ThreadId) - const tree = resComments.body as VideoCommentThreadTree + const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId: server1ThreadId }) expect(tree.children).to.have.lengthOf(1) const commentId = tree.children[0].comment.id @@ -328,10 +314,9 @@ describe('Test comments notifications', function () { const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) const uuid = resVideo.body.video.uuid - const resThread = await addVideoCommentThread(servers[0].url, servers[0].accessToken, uuid, '@user_1 hello 1') - const threadId = resThread.body.comment.id + const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' }) - await addVideoCommentReply(servers[0].url, servers[0].accessToken, uuid, threadId, '@user_1 ' + commentText) + await servers[0].commentsCommand.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 52ade0548..229f78811 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -3,7 +3,6 @@ import 'mocha' import { buildUUID } from '@server/helpers/uuid' import { - addVideoCommentThread, checkAbuseStateChange, checkAutoInstanceFollowing, CheckerBaseParams, @@ -20,7 +19,6 @@ import { cleanupTests, createUser, generateUserAccessToken, - getVideoCommentThreads, getVideoIdFromUUID, immutableAssign, MockInstancesIndex, @@ -101,8 +99,11 @@ describe('Test moderation notifications', function () { const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video - const resComment = await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) - const comment = resComment.body.comment + const comment = await servers[0].commentsCommand.createThread({ + token: userAccessToken, + videoId: video.id, + text: 'comment abuse ' + buildUUID() + }) await waitJobs(servers) @@ -118,12 +119,17 @@ describe('Test moderation notifications', function () { const name = 'video for abuse ' + buildUUID() const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) const video = resVideo.body.video - await addVideoCommentThread(servers[0].url, userAccessToken, video.id, 'comment abuse ' + buildUUID()) + + await servers[0].commentsCommand.createThread({ + token: userAccessToken, + videoId: video.id, + text: 'comment abuse ' + buildUUID() + }) await waitJobs(servers) - const resComments = await getVideoCommentThreads(servers[1].url, video.uuid, 0, 5) - const commentId = resComments.body.data[0].id + const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid }) + const commentId = data[0].id await servers[1].abusesCommand.report({ commentId, reason: 'super reason' }) await waitJobs(servers) -- cgit v1.2.3 From 9293139fde7091e9badcafa9b570b83cea9a10ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 15:37:43 +0200 Subject: Introduce sql command --- server/tests/api/notifications/admin-notifications.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index da9767b74..03fbe0b70 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -11,8 +11,6 @@ import { MockSmtpServer, prepareNotificationsTest, ServerInfo, - setPluginLatestVersion, - setPluginVersion, wait } from '@shared/extra-utils' import { PluginType, UserNotification, UserNotificationType } from '@shared/models' @@ -120,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 setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1') - await setPluginLatestVersion(server.internalServerNumber, 'hello-world', '0.0.1') + await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') + await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1') await wait(6000) await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence') @@ -142,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 setPluginVersion(server.internalServerNumber, 'hello-world', '0.0.1') - await setPluginLatestVersion(server.internalServerNumber, 'hello-world', '0.0.1') + await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') + await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1') await wait(6000) expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) -- cgit v1.2.3 From dd0ebb715123dfa126a82d4e4fe3a04064ae77b8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 16:23:01 +0200 Subject: Introduce notifications command --- .../tests/api/notifications/notifications-api.ts | 92 +++++++++++----------- .../tests/api/notifications/user-notifications.ts | 5 +- 2 files changed, 48 insertions(+), 49 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 1ed98ae7a..447492c5f 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -8,14 +8,10 @@ import { cleanupTests, getAllNotificationsSettings, getMyUserInformation, - getUserNotifications, immutableAssign, - markAsReadAllNotifications, - markAsReadNotifications, MockSmtpServer, prepareNotificationsTest, ServerInfo, - updateMyNotificationSettings, uploadRandomVideo, waitJobs } from '@shared/extra-utils' @@ -26,7 +22,7 @@ const expect = chai.expect describe('Test notifications API', function () { let server: ServerInfo let userNotifications: UserNotification[] = [] - let userAccessToken: string + let userToken: string let emails: object[] = [] before(async function () { @@ -34,11 +30,11 @@ describe('Test notifications API', function () { const res = await prepareNotificationsTest(1) emails = res.emails - userAccessToken = res.userAccessToken + userToken = res.userAccessToken userNotifications = res.userNotifications server = res.servers[0] - await server.subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + server.port }) + await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port }) for (let i = 0; i < 10; i++) { await uploadRandomVideo(server, false) @@ -50,49 +46,46 @@ describe('Test notifications API', function () { describe('Mark as read', function () { it('Should mark as read some notifications', async function () { - const res = await getUserNotifications(server.url, userAccessToken, 2, 3) - const ids = res.body.data.map(n => n.id) + const { data } = await server.notificationsCommand.list({ token: userToken, start: 2, count: 3 }) + const ids = data.map(n => n.id) - await markAsReadNotifications(server.url, userAccessToken, ids) + await server.notificationsCommand.markAsRead({ token: userToken, ids }) }) it('Should have the notifications marked as read', async function () { - const res = await getUserNotifications(server.url, userAccessToken, 0, 10) - - const notifications = res.body.data as UserNotification[] - expect(notifications[0].read).to.be.false - expect(notifications[1].read).to.be.false - expect(notifications[2].read).to.be.true - expect(notifications[3].read).to.be.true - expect(notifications[4].read).to.be.true - expect(notifications[5].read).to.be.false + const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10 }) + + expect(data[0].read).to.be.false + expect(data[1].read).to.be.false + expect(data[2].read).to.be.true + expect(data[3].read).to.be.true + expect(data[4].read).to.be.true + expect(data[5].read).to.be.false }) it('Should only list read notifications', async function () { - const res = await getUserNotifications(server.url, userAccessToken, 0, 10, false) + const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: false }) - const notifications = res.body.data as UserNotification[] - for (const notification of notifications) { + for (const notification of data) { expect(notification.read).to.be.true } }) it('Should only list unread notifications', async function () { - const res = await getUserNotifications(server.url, userAccessToken, 0, 10, true) + const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true }) - const notifications = res.body.data as UserNotification[] - for (const notification of notifications) { + for (const notification of data) { expect(notification.read).to.be.false } }) it('Should mark as read all notifications', async function () { - await markAsReadAllNotifications(server.url, userAccessToken) + await server.notificationsCommand.markAsReadAll({ token: userToken }) - const res = await getUserNotifications(server.url, userAccessToken, 0, 10, true) + const body = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true }) - expect(res.body.total).to.equal(0) - expect(res.body.data).to.have.lengthOf(0) + expect(body.total).to.equal(0) + expect(body.data).to.have.lengthOf(0) }) }) @@ -104,19 +97,20 @@ describe('Test notifications API', function () { server: server, emails, socketNotifications: userNotifications, - token: userAccessToken + token: userToken } }) it('Should not have notifications', async function () { this.timeout(20000) - await updateMyNotificationSettings(server.url, userAccessToken, immutableAssign(getAllNotificationsSettings(), { - newVideoFromSubscription: UserNotificationSettingValue.NONE - })) + await server.notificationsCommand.updateMySettings({ + token: userToken, + settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE } + }) { - const res = await getMyUserInformation(server.url, userAccessToken) + const res = await getMyUserInformation(server.url, userToken) const info = res.body as User expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) } @@ -130,12 +124,13 @@ describe('Test notifications API', function () { it('Should only have web notifications', async function () { this.timeout(20000) - await updateMyNotificationSettings(server.url, userAccessToken, immutableAssign(getAllNotificationsSettings(), { - newVideoFromSubscription: UserNotificationSettingValue.WEB - })) + await server.notificationsCommand.updateMySettings({ + token: userToken, + settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB } + }) { - const res = await getMyUserInformation(server.url, userAccessToken) + const res = await getMyUserInformation(server.url, userToken) const info = res.body as User expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) } @@ -156,12 +151,13 @@ describe('Test notifications API', function () { it('Should only have mail notifications', async function () { this.timeout(20000) - await updateMyNotificationSettings(server.url, userAccessToken, immutableAssign(getAllNotificationsSettings(), { - newVideoFromSubscription: UserNotificationSettingValue.EMAIL - })) + await server.notificationsCommand.updateMySettings({ + token: userToken, + settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL } + }) { - const res = await getMyUserInformation(server.url, userAccessToken) + const res = await getMyUserInformation(server.url, userToken) const info = res.body as User expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) } @@ -182,12 +178,16 @@ describe('Test notifications API', function () { it('Should have email and web notifications', async function () { this.timeout(20000) - await updateMyNotificationSettings(server.url, userAccessToken, immutableAssign(getAllNotificationsSettings(), { - newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL - })) + await server.notificationsCommand.updateMySettings({ + token: userToken, + settings: { + ...getAllNotificationsSettings(), + newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL + } + }) { - const res = await getMyUserInformation(server.url, userAccessToken) + const res = await getMyUserInformation(server.url, userToken) const info = res.body as User expect(info.notificationSettings.newVideoFromSubscription).to.equal( UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 1d159c48f..4b31edf25 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -10,7 +10,6 @@ import { checkNewVideoFromSubscription, checkVideoIsPublished, cleanupTests, - getLastNotification, ImportsCommand, MockSmtpServer, prepareNotificationsTest, @@ -64,7 +63,7 @@ describe('Test user notifications', function () { await uploadRandomVideoOnServers(servers, 1) - const notification = await getLastNotification(servers[0].url, userAccessToken) + const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken }) expect(notification).to.be.undefined expect(emails).to.have.lengthOf(0) @@ -245,7 +244,7 @@ describe('Test user notifications', function () { await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false }) await waitJobs(servers) - const notification = await getLastNotification(servers[0].url, userAccessToken) + const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken }) if (notification) { expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED) } -- cgit v1.2.3 From 6c5065a011b099618681a37bd77eaa7bd3db752e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 09:43:59 +0200 Subject: Introduce server commands --- server/tests/api/notifications/moderation-notifications.ts | 13 +++++++------ server/tests/api/notifications/notifications-api.ts | 11 +++++------ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 229f78811..99b434606 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -20,7 +20,6 @@ import { createUser, generateUserAccessToken, getVideoIdFromUUID, - immutableAssign, MockInstancesIndex, MockSmtpServer, prepareNotificationsTest, @@ -347,7 +346,7 @@ describe('Test moderation notifications', function () { await checkUserRegistered(baseParams, 'user_45', 'presence') const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } - await checkUserRegistered(immutableAssign(baseParams, userOverride), 'user_45', 'absence') + await checkUserRegistered({ ...baseParams, ...userOverride }, 'user_45', 'absence') }) }) @@ -389,7 +388,7 @@ describe('Test moderation notifications', function () { await checkNewInstanceFollower(baseParams, 'localhost:' + servers[2].port, 'presence') const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } - await checkNewInstanceFollower(immutableAssign(baseParams, userOverride), 'localhost:' + servers[2].port, 'absence') + await checkNewInstanceFollower({ ...baseParams, ...userOverride }, 'localhost:' + servers[2].port, 'absence') }) it('Should send a notification on auto follow back', async function () { @@ -416,7 +415,7 @@ describe('Test moderation notifications', function () { await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } - await checkAutoInstanceFollowing(immutableAssign(baseParams, userOverride), followerHost, followingHost, 'absence') + await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence') config.followings.instance.autoFollowBack.enabled = false await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) @@ -476,7 +475,9 @@ describe('Test moderation notifications', function () { currentCustomConfig = await servers[0].configCommand.getCustomConfig() - const autoBlacklistTestsCustomConfig = immutableAssign(currentCustomConfig, { + const autoBlacklistTestsCustomConfig = { + ...currentCustomConfig, + autoBlacklist: { videos: { ofUsers: { @@ -484,7 +485,7 @@ describe('Test moderation notifications', function () { } } } - }) + } // enable transcoding otherwise own publish notification after transcoding not expected autoBlacklistTestsCustomConfig.transcoding.enabled = true diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 447492c5f..e5864f1c2 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -8,7 +8,6 @@ import { cleanupTests, getAllNotificationsSettings, getMyUserInformation, - immutableAssign, MockSmtpServer, prepareNotificationsTest, ServerInfo, @@ -118,7 +117,7 @@ describe('Test notifications API', function () { const { name, uuid } = await uploadRandomVideo(server) const check = { web: true, mail: true } - await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') }) it('Should only have web notifications', async function () { @@ -139,12 +138,12 @@ describe('Test notifications API', function () { { const check = { mail: true, web: false } - await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') } { const check = { mail: false, web: true } - await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence') } }) @@ -166,12 +165,12 @@ describe('Test notifications API', function () { { const check = { mail: false, web: true } - await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') } { const check = { mail: true, web: false } - await checkNewVideoFromSubscription(immutableAssign(baseParams, { check }), name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence') } }) -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- .../api/notifications/comments-notifications.ts | 14 ++---------- .../api/notifications/moderation-notifications.ts | 11 ++++------ .../tests/api/notifications/notifications-api.ts | 25 +++++++++------------- .../tests/api/notifications/user-notifications.ts | 18 ++++------------ 4 files changed, 20 insertions(+), 48 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index ea6055386..62569f810 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -10,7 +10,6 @@ import { MockSmtpServer, prepareNotificationsTest, ServerInfo, - updateMyUser, uploadVideo, waitJobs } from '@shared/extra-utils' @@ -193,17 +192,8 @@ describe('Test comments notifications', function () { token: userToken } - await updateMyUser({ - url: servers[0].url, - accessToken: servers[0].accessToken, - displayName: 'super root name' - }) - - await updateMyUser({ - url: servers[1].url, - accessToken: servers[1].accessToken, - displayName: 'super root 2 name' - }) + await servers[0].usersCommand.updateMe({ displayName: 'super root name' }) + await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' }) }) it('Should not send a new mention comment notification if I mention the video owner', async function () { diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 99b434606..0269124c5 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -17,13 +17,10 @@ import { checkVideoAutoBlacklistForModerators, checkVideoIsPublished, cleanupTests, - createUser, - generateUserAccessToken, getVideoIdFromUUID, MockInstancesIndex, MockSmtpServer, prepareNotificationsTest, - registerUser, ServerInfo, uploadVideo, wait, @@ -139,8 +136,8 @@ describe('Test moderation notifications', function () { this.timeout(20000) const username = 'user' + new Date().getTime() - const resUser = await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username, password: 'donald' }) - const accountId = resUser.body.user.account.id + const { account } = await servers[0].usersCommand.create({ username, password: 'donald' }) + const accountId = account.id await servers[0].abusesCommand.report({ accountId, reason: 'super reason' }) @@ -152,7 +149,7 @@ describe('Test moderation notifications', function () { this.timeout(20000) const username = 'user' + new Date().getTime() - const tmpToken = await generateUserAccessToken(servers[0], username) + const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) await uploadVideo(servers[0].url, tmpToken, { name: 'super video' }) await waitJobs(servers) @@ -339,7 +336,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 registerUser(servers[0].url, 'user_45', 'password') + await servers[0].usersCommand.register({ username: 'user_45' }) await waitJobs(servers) diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index e5864f1c2..f33d8e64d 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -7,14 +7,13 @@ import { checkNewVideoFromSubscription, cleanupTests, getAllNotificationsSettings, - getMyUserInformation, MockSmtpServer, prepareNotificationsTest, ServerInfo, uploadRandomVideo, waitJobs } from '@shared/extra-utils' -import { User, UserNotification, UserNotificationSettingValue } from '@shared/models' +import { UserNotification, UserNotificationSettingValue } from '@shared/models' const expect = chai.expect @@ -109,15 +108,14 @@ describe('Test notifications API', function () { }) { - const res = await getMyUserInformation(server.url, userToken) - const info = res.body as User + const info = await server.usersCommand.getMyInfo({ token: userToken }) expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) } const { name, uuid } = await uploadRandomVideo(server) const check = { web: true, mail: true } - await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') }) it('Should only have web notifications', async function () { @@ -129,8 +127,7 @@ describe('Test notifications API', function () { }) { - const res = await getMyUserInformation(server.url, userToken) - const info = res.body as User + const info = await server.usersCommand.getMyInfo({ token: userToken }) expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) } @@ -138,12 +135,12 @@ describe('Test notifications API', function () { { const check = { mail: true, web: false } - await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') } { const check = { mail: false, web: true } - await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence') } }) @@ -156,8 +153,7 @@ describe('Test notifications API', function () { }) { - const res = await getMyUserInformation(server.url, userToken) - const info = res.body as User + const info = await server.usersCommand.getMyInfo({ token: userToken }) expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) } @@ -165,12 +161,12 @@ describe('Test notifications API', function () { { const check = { mail: false, web: true } - await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'absence') + await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') } { const check = { mail: true, web: false } - await checkNewVideoFromSubscription({ ...baseParams, ...check }, name, uuid, 'presence') + await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'presence') } }) @@ -186,8 +182,7 @@ describe('Test notifications API', function () { }) { - const res = await getMyUserInformation(server.url, userToken) - const info = res.body as User + const info = await server.usersCommand.getMyInfo({ token: userToken }) expect(info.notificationSettings.newVideoFromSubscription).to.equal( UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL ) diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 4b31edf25..465349fb9 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -14,7 +14,6 @@ import { MockSmtpServer, prepareNotificationsTest, ServerInfo, - updateMyUser, updateVideo, uploadRandomVideoOnServers, wait, @@ -384,23 +383,14 @@ describe('Test user notifications', function () { token: userAccessToken } - await updateMyUser({ - url: servers[0].url, - accessToken: servers[0].accessToken, - displayName: 'super root name' - }) + await servers[0].usersCommand.updateMe({ displayName: 'super root name' }) - await updateMyUser({ - url: servers[0].url, - accessToken: userAccessToken, + await servers[0].usersCommand.updateMe({ + token: userAccessToken, displayName: myUserName }) - await updateMyUser({ - url: servers[1].url, - accessToken: servers[1].accessToken, - displayName: 'super root 2 name' - }) + await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' }) await servers[0].channelsCommand.update({ token: userAccessToken, -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- .../api/notifications/comments-notifications.ts | 46 +++++++------------ .../api/notifications/moderation-notifications.ts | 51 ++++++++-------------- .../tests/api/notifications/notifications-api.ts | 11 +++-- .../tests/api/notifications/user-notifications.ts | 19 ++++---- 4 files changed, 48 insertions(+), 79 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index 62569f810..a74b38e8a 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -10,7 +10,6 @@ import { MockSmtpServer, prepareNotificationsTest, ServerInfo, - uploadVideo, waitJobs } from '@shared/extra-utils' import { UserNotification } from '@shared/models' @@ -53,8 +52,7 @@ 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 resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) const commentId = created.id @@ -66,8 +64,7 @@ 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 resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' }) const commentId = created.id @@ -81,8 +78,7 @@ describe('Test comments notifications', function () { await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) - const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) const commentId = created.id @@ -96,8 +92,7 @@ describe('Test comments notifications', function () { it('Should send a new comment notification after a local comment on my video', async function () { this.timeout(20000) - const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) const commentId = created.id @@ -109,8 +104,7 @@ 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 resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) await waitJobs(servers) @@ -128,8 +122,7 @@ 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 resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) @@ -142,8 +135,7 @@ 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 resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) await waitJobs(servers) { @@ -169,8 +161,7 @@ describe('Test comments notifications', function () { it('Should convert markdown in comment to html', async function () { this.timeout(20000) - const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'cool video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'cool video' } }) await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText }) @@ -199,8 +190,7 @@ describe('Test comments notifications', function () { it('Should not send a new mention comment notification if I mention the video owner', async function () { this.timeout(10000) - const resVideo = await uploadVideo(servers[0].url, userToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) @@ -211,8 +201,7 @@ describe('Test comments notifications', function () { it('Should not send a new mention comment notification if I mention myself', async function () { this.timeout(10000) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) @@ -225,8 +214,7 @@ describe('Test comments notifications', function () { await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) @@ -239,8 +227,7 @@ describe('Test comments notifications', function () { it('Should not send a new mention notification if the remote account mention a local account', async function () { this.timeout(20000) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) await waitJobs(servers) const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) @@ -252,8 +239,7 @@ describe('Test comments notifications', function () { it('Should send a new mention notification after local comments', async function () { this.timeout(10000) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) @@ -269,8 +255,7 @@ describe('Test comments notifications', function () { it('Should send a new mention notification after remote comments', async function () { this.timeout(20000) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) await waitJobs(servers) @@ -301,8 +286,7 @@ describe('Test comments notifications', function () { it('Should convert markdown in comment to html', async function () { this.timeout(10000) - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'super video' }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' }) diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 0269124c5..91a2b4fa5 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -17,12 +17,10 @@ import { checkVideoAutoBlacklistForModerators, checkVideoIsPublished, cleanupTests, - getVideoIdFromUUID, MockInstancesIndex, MockSmtpServer, prepareNotificationsTest, ServerInfo, - uploadVideo, wait, waitJobs } from '@shared/extra-utils' @@ -64,8 +62,7 @@ describe('Test moderation notifications', function () { this.timeout(20000) const name = 'video for abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const video = resVideo.body.video + const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' }) @@ -77,12 +74,11 @@ describe('Test moderation notifications', function () { this.timeout(20000) const name = 'video for abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const video = resVideo.body.video + const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) await waitJobs(servers) - const videoId = await getVideoIdFromUUID(servers[1].url, video.uuid) + const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid }) await servers[1].abusesCommand.report({ videoId, reason: 'super reason' }) await waitJobs(servers) @@ -93,8 +89,7 @@ describe('Test moderation notifications', function () { this.timeout(20000) const name = 'video for abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const video = resVideo.body.video + const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) const comment = await servers[0].commentsCommand.createThread({ token: userAccessToken, videoId: video.id, @@ -113,8 +108,7 @@ describe('Test moderation notifications', function () { this.timeout(20000) const name = 'video for abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const video = resVideo.body.video + const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) await servers[0].commentsCommand.createThread({ token: userAccessToken, @@ -150,7 +144,7 @@ describe('Test moderation notifications', function () { const username = 'user' + new Date().getTime() const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) - await uploadVideo(servers[0].url, tmpToken, { name: 'super video' }) + await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } }) await waitJobs(servers) @@ -175,8 +169,7 @@ describe('Test moderation notifications', function () { } const name = 'abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const video = resVideo.body.video + const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) abuseId = body.abuse.id @@ -223,8 +216,7 @@ describe('Test moderation notifications', function () { } const name = 'abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const video = resVideo.body.video + const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) { const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) @@ -294,8 +286,7 @@ describe('Test moderation notifications', function () { this.timeout(10000) const name = 'video for abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) await servers[0].blacklistCommand.add({ videoId: uuid }) @@ -307,8 +298,7 @@ describe('Test moderation notifications', function () { this.timeout(10000) const name = 'video for abuse ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) await servers[0].blacklistCommand.add({ videoId: uuid }) @@ -497,8 +487,8 @@ describe('Test moderation notifications', function () { this.timeout(40000) videoName = 'video with auto-blacklist ' + buildUUID() - const resVideo = await uploadVideo(servers[0].url, userAccessToken, { name: videoName }) - videoUUID = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } }) + videoUUID = uuid await waitJobs(servers) await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, videoUUID, videoName, 'presence') @@ -544,17 +534,16 @@ describe('Test moderation notifications', function () { const name = 'video with auto-blacklist and future schedule ' + buildUUID() - const data = { + const attributes = { name, privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } - const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) await servers[0].blacklistCommand.remove({ videoId: uuid }) @@ -577,17 +566,16 @@ describe('Test moderation notifications', function () { const name = 'video with schedule done and still auto-blacklisted ' + buildUUID() - const data = { + const attributes = { name, privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } - const resVideo = await uploadVideo(servers[0].url, userAccessToken, data) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) await wait(6000) await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') @@ -601,8 +589,7 @@ describe('Test moderation notifications', function () { const name = 'video without auto-blacklist ' + buildUUID() // admin with blacklist right will not be auto-blacklisted - const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { name }) - const uuid = resVideo.body.video.uuid + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } }) await waitJobs(servers) await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index f33d8e64d..41e1b8015 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -10,7 +10,6 @@ import { MockSmtpServer, prepareNotificationsTest, ServerInfo, - uploadRandomVideo, waitJobs } from '@shared/extra-utils' import { UserNotification, UserNotificationSettingValue } from '@shared/models' @@ -35,7 +34,7 @@ describe('Test notifications API', function () { await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port }) for (let i = 0; i < 10; i++) { - await uploadRandomVideo(server, false) + await server.videosCommand.randomUpload({ wait: false }) } await waitJobs([ server ]) @@ -112,7 +111,7 @@ describe('Test notifications API', function () { expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) } - const { name, uuid } = await uploadRandomVideo(server) + const { name, uuid } = await server.videosCommand.randomUpload() const check = { web: true, mail: true } await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') @@ -131,7 +130,7 @@ describe('Test notifications API', function () { expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) } - const { name, uuid } = await uploadRandomVideo(server) + const { name, uuid } = await server.videosCommand.randomUpload() { const check = { mail: true, web: false } @@ -157,7 +156,7 @@ describe('Test notifications API', function () { expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) } - const { name, uuid } = await uploadRandomVideo(server) + const { name, uuid } = await server.videosCommand.randomUpload() { const check = { mail: false, web: true } @@ -188,7 +187,7 @@ describe('Test notifications API', function () { ) } - const { name, uuid } = await uploadRandomVideo(server) + const { name, uuid } = await server.videosCommand.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 465349fb9..4db8c1576 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -14,7 +14,6 @@ import { MockSmtpServer, prepareNotificationsTest, ServerInfo, - updateVideo, uploadRandomVideoOnServers, wait, waitJobs @@ -99,7 +98,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) @@ -118,7 +117,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) @@ -137,7 +136,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) @@ -154,7 +153,7 @@ describe('Test user notifications', function () { await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') - await updateVideo(servers[0].url, servers[0].accessToken, uuid, { privacy: VideoPrivacy.PUBLIC }) + await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) await waitJobs(servers) await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') @@ -168,7 +167,7 @@ describe('Test user notifications', function () { await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') - await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.PUBLIC }) + await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) await waitJobs(servers) await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') @@ -180,7 +179,7 @@ describe('Test user notifications', function () { const data = { privacy: VideoPrivacy.PRIVATE } const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) - await updateVideo(servers[0].url, servers[0].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED }) + await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') }) @@ -191,7 +190,7 @@ describe('Test user notifications', function () { const data = { privacy: VideoPrivacy.PRIVATE } const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) - await updateVideo(servers[1].url, servers[1].accessToken, uuid, { privacy: VideoPrivacy.UNLISTED }) + await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) await waitJobs(servers) await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') @@ -295,7 +294,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) @@ -313,7 +312,7 @@ describe('Test user notifications', function () { privacy: VideoPrivacy.PRIVATE, scheduleUpdate: { updateAt: updateAt.toISOString(), - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC as VideoPrivacy.PUBLIC } } const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- .../tests/api/notifications/admin-notifications.ts | 12 +-- .../api/notifications/comments-notifications.ts | 92 ++++++++-------- .../api/notifications/moderation-notifications.ts | 118 ++++++++++----------- .../tests/api/notifications/notifications-api.ts | 42 ++++---- .../tests/api/notifications/user-notifications.ts | 40 +++---- 5 files changed, 152 insertions(+), 152 deletions(-) (limited to 'server/tests/api/notifications') 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 -- cgit v1.2.3 From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/notifications/admin-notifications.ts | 4 ++-- server/tests/api/notifications/comments-notifications.ts | 4 ++-- server/tests/api/notifications/moderation-notifications.ts | 4 ++-- server/tests/api/notifications/notifications-api.ts | 4 ++-- server/tests/api/notifications/user-notifications.ts | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index 5a5bdb0c8..d65551f0a 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -10,13 +10,13 @@ import { MockJoinPeerTubeVersions, MockSmtpServer, prepareNotificationsTest, - ServerInfo, + PeerTubeServer, wait } from '@shared/extra-utils' import { PluginType, UserNotification, UserNotificationType } from '@shared/models' describe('Test admin notifications', function () { - let server: ServerInfo + let server: PeerTubeServer let userNotifications: UserNotification[] = [] let adminNotifications: UserNotification[] = [] let emails: object[] = [] diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index 133b6340f..d54819aaa 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -9,7 +9,7 @@ import { cleanupTests, MockSmtpServer, prepareNotificationsTest, - ServerInfo, + PeerTubeServer, waitJobs } from '@shared/extra-utils' import { UserNotification } from '@shared/models' @@ -17,7 +17,7 @@ import { UserNotification } from '@shared/models' const expect = chai.expect describe('Test comments notifications', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let userToken: string let userNotifications: UserNotification[] = [] let emails: object[] = [] diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index e7c5badd2..3a294192b 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -20,14 +20,14 @@ import { MockInstancesIndex, MockSmtpServer, prepareNotificationsTest, - ServerInfo, + PeerTubeServer, wait, waitJobs } from '@shared/extra-utils' import { AbuseState, CustomConfig, UserNotification, VideoPrivacy } from '@shared/models' describe('Test moderation notifications', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let userAccessToken: string let userNotifications: UserNotification[] = [] let adminNotifications: UserNotification[] = [] diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 647d783b5..178b20687 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -9,7 +9,7 @@ import { getAllNotificationsSettings, MockSmtpServer, prepareNotificationsTest, - ServerInfo, + PeerTubeServer, waitJobs } from '@shared/extra-utils' import { UserNotification, UserNotificationSettingValue } from '@shared/models' @@ -17,7 +17,7 @@ import { UserNotification, UserNotificationSettingValue } from '@shared/models' const expect = chai.expect describe('Test notifications API', function () { - let server: ServerInfo + let server: PeerTubeServer let userNotifications: UserNotification[] = [] let userToken: string let emails: object[] = [] diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 53f8c7594..b7c22d118 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -13,7 +13,7 @@ import { ImportsCommand, MockSmtpServer, prepareNotificationsTest, - ServerInfo, + PeerTubeServer, uploadRandomVideoOnServers, wait, waitJobs @@ -23,7 +23,7 @@ import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/mo const expect = chai.expect describe('Test user notifications', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let userAccessToken: string let userNotifications: UserNotification[] = [] let adminNotifications: UserNotification[] = [] -- cgit v1.2.3 From 59bbcced37005dd511daca9bd58ae2998cb931b1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:19:16 +0200 Subject: Centralize test URLs --- server/tests/api/notifications/user-notifications.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index b7c22d118..ca592d466 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts @@ -10,10 +10,10 @@ import { checkNewVideoFromSubscription, checkVideoIsPublished, cleanupTests, - ImportsCommand, + FIXTURE_URLS, MockSmtpServer, - prepareNotificationsTest, PeerTubeServer, + prepareNotificationsTest, uploadRandomVideoOnServers, wait, waitJobs @@ -205,7 +205,7 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PUBLIC, - targetUrl: ImportsCommand.getGoodVideoUrl() + targetUrl: FIXTURE_URLS.goodVideo } const { video } = await servers[0].imports.importVideo({ attributes }) @@ -275,7 +275,7 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PUBLIC, - targetUrl: ImportsCommand.getGoodVideoUrl(), + targetUrl: FIXTURE_URLS.goodVideo, waitTranscoding: true } const { video } = await servers[1].imports.importVideo({ attributes }) @@ -343,12 +343,12 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PRIVATE, - targetUrl: ImportsCommand.getBadVideoUrl() + targetUrl: FIXTURE_URLS.badVideo } const { video } = await servers[0].imports.importVideo({ attributes }) await waitJobs(servers) - await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence') + await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.badVideo, false, 'presence') }) it('Should send a notification when the video import succeeded', async function () { @@ -360,12 +360,12 @@ describe('Test user notifications', function () { name, channelId, privacy: VideoPrivacy.PRIVATE, - targetUrl: ImportsCommand.getGoodVideoUrl() + targetUrl: FIXTURE_URLS.goodVideo } const { video } = await servers[0].imports.importVideo({ attributes }) await waitJobs(servers) - await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence') + await checkMyVideoImportIsFinished(baseParams, name, video.uuid, FIXTURE_URLS.goodVideo, true, 'presence') }) }) -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/api/notifications/admin-notifications.ts | 2 +- server/tests/api/notifications/comments-notifications.ts | 2 +- server/tests/api/notifications/moderation-notifications.ts | 2 +- server/tests/api/notifications/notifications-api.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts index d65551f0a..b36ba11a9 100644 --- a/server/tests/api/notifications/admin-notifications.ts +++ b/server/tests/api/notifications/admin-notifications.ts @@ -9,8 +9,8 @@ import { cleanupTests, MockJoinPeerTubeVersions, MockSmtpServer, - prepareNotificationsTest, PeerTubeServer, + prepareNotificationsTest, wait } from '@shared/extra-utils' import { PluginType, UserNotification, UserNotificationType } from '@shared/models' diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts index d54819aaa..cbb46e510 100644 --- a/server/tests/api/notifications/comments-notifications.ts +++ b/server/tests/api/notifications/comments-notifications.ts @@ -8,8 +8,8 @@ import { checkNewCommentOnMyVideo, cleanupTests, MockSmtpServer, - prepareNotificationsTest, PeerTubeServer, + prepareNotificationsTest, waitJobs } from '@shared/extra-utils' import { UserNotification } from '@shared/models' diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 3a294192b..6e8f8a2b4 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -19,8 +19,8 @@ import { cleanupTests, MockInstancesIndex, MockSmtpServer, - prepareNotificationsTest, PeerTubeServer, + prepareNotificationsTest, wait, waitJobs } from '@shared/extra-utils' diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts index 178b20687..fa4b53db6 100644 --- a/server/tests/api/notifications/notifications-api.ts +++ b/server/tests/api/notifications/notifications-api.ts @@ -8,8 +8,8 @@ import { cleanupTests, getAllNotificationsSettings, MockSmtpServer, - prepareNotificationsTest, PeerTubeServer, + prepareNotificationsTest, waitJobs } from '@shared/extra-utils' import { UserNotification, UserNotificationSettingValue } from '@shared/models' -- cgit v1.2.3 From 4d029ef8ec3d5274eeaa3ee6d808eb7035e7faef Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Jul 2021 14:15:15 +0200 Subject: Add ability for instances to follow any actor --- server/tests/api/notifications/moderation-notifications.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/api/notifications') diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index 6e8f8a2b4..6f74709b3 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -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].follows.follow({ targets: [ servers[0].url ] }) + await servers[2].follows.follow({ hosts: [ servers[0].url ] }) await waitJobs(servers) @@ -393,7 +393,7 @@ describe('Test moderation notifications', function () { } await servers[0].config.updateCustomSubConfig({ newConfig: config }) - await servers[2].follows.follow({ targets: [ servers[0].url ] }) + await servers[2].follows.follow({ hosts: [ servers[0].url ] }) await waitJobs(servers) -- cgit v1.2.3