diff options
Diffstat (limited to 'server/tests/api/moderation')
-rw-r--r-- | server/tests/api/moderation/abuses.ts | 12 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist-notification.ts | 8 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 16 | ||||
-rw-r--r-- | server/tests/api/moderation/video-blacklist.ts | 13 |
4 files changed, 24 insertions, 25 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index 97a0d95c4..360b9de35 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts | |||
@@ -6,8 +6,8 @@ import { | |||
6 | AbusesCommand, | 6 | AbusesCommand, |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
9 | flushAndRunMultipleServers, | 9 | createMultipleServers, |
10 | ServerInfo, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/extra-utils' |
@@ -16,7 +16,7 @@ import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, Use | |||
16 | const expect = chai.expect | 16 | const expect = chai.expect |
17 | 17 | ||
18 | describe('Test abuses', function () { | 18 | describe('Test abuses', function () { |
19 | let servers: ServerInfo[] = [] | 19 | let servers: PeerTubeServer[] = [] |
20 | let abuseServer1: AdminAbuse | 20 | let abuseServer1: AdminAbuse |
21 | let abuseServer2: AdminAbuse | 21 | let abuseServer2: AdminAbuse |
22 | let commands: AbusesCommand[] | 22 | let commands: AbusesCommand[] |
@@ -25,7 +25,7 @@ describe('Test abuses', function () { | |||
25 | this.timeout(50000) | 25 | this.timeout(50000) |
26 | 26 | ||
27 | // Run servers | 27 | // Run servers |
28 | servers = await flushAndRunMultipleServers(2) | 28 | servers = await createMultipleServers(2) |
29 | 29 | ||
30 | // Get the access tokens | 30 | // Get the access tokens |
31 | await setAccessTokensToServers(servers) | 31 | await setAccessTokensToServers(servers) |
@@ -389,7 +389,7 @@ describe('Test abuses', function () { | |||
389 | 389 | ||
390 | describe('Comment abuses', function () { | 390 | describe('Comment abuses', function () { |
391 | 391 | ||
392 | async function getComment (server: ServerInfo, videoIdArg: number | string) { | 392 | async function getComment (server: PeerTubeServer, videoIdArg: number | string) { |
393 | const videoId = typeof videoIdArg === 'string' | 393 | const videoId = typeof videoIdArg === 'string' |
394 | ? await server.videos.getId({ uuid: videoIdArg }) | 394 | ? await server.videos.getId({ uuid: videoIdArg }) |
395 | : videoIdArg | 395 | : videoIdArg |
@@ -591,7 +591,7 @@ describe('Test abuses', function () { | |||
591 | 591 | ||
592 | describe('Account abuses', function () { | 592 | describe('Account abuses', function () { |
593 | 593 | ||
594 | function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) { | 594 | function getAccountFromServer (server: PeerTubeServer, targetName: string, targetServer: PeerTubeServer) { |
595 | return server.accounts.get({ accountName: targetName + '@' + targetServer.host }) | 595 | return server.accounts.get({ accountName: targetName + '@' + targetServer.host }) |
596 | } | 596 | } |
597 | 597 | ||
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index 6b56fdd65..fdfbcbced 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -2,12 +2,12 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' |
6 | import { UserNotificationType } from '@shared/models' | 6 | import { UserNotificationType } from '@shared/models' |
7 | 7 | ||
8 | const expect = chai.expect | 8 | const expect = chai.expect |
9 | 9 | ||
10 | async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) { | 10 | async function checkNotifications (server: PeerTubeServer, token: string, expected: UserNotificationType[]) { |
11 | const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true }) | 11 | const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true }) |
12 | expect(data).to.have.lengthOf(expected.length) | 12 | expect(data).to.have.lengthOf(expected.length) |
13 | 13 | ||
@@ -17,7 +17,7 @@ async function checkNotifications (server: ServerInfo, token: string, expected: | |||
17 | } | 17 | } |
18 | 18 | ||
19 | describe('Test blocklist', function () { | 19 | describe('Test blocklist', function () { |
20 | let servers: ServerInfo[] | 20 | let servers: PeerTubeServer[] |
21 | let videoUUID: string | 21 | let videoUUID: string |
22 | 22 | ||
23 | let userToken1: string | 23 | let userToken1: string |
@@ -62,7 +62,7 @@ describe('Test blocklist', function () { | |||
62 | before(async function () { | 62 | before(async function () { |
63 | this.timeout(60000) | 63 | this.timeout(60000) |
64 | 64 | ||
65 | servers = await flushAndRunMultipleServers(2) | 65 | servers = await createMultipleServers(2) |
66 | await setAccessTokensToServers(servers) | 66 | await setAccessTokensToServers(servers) |
67 | 67 | ||
68 | { | 68 | { |
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 9a4a3b3b9..593291e87 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -7,8 +7,8 @@ import { | |||
7 | cleanupTests, | 7 | cleanupTests, |
8 | CommentsCommand, | 8 | CommentsCommand, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | createMultipleServers, |
11 | ServerInfo, | 11 | PeerTubeServer, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | waitJobs | 13 | waitJobs |
14 | } from '@shared/extra-utils' | 14 | } from '@shared/extra-utils' |
@@ -16,7 +16,7 @@ import { UserNotificationType } from '@shared/models' | |||
16 | 16 | ||
17 | const expect = chai.expect | 17 | const expect = chai.expect |
18 | 18 | ||
19 | async function checkAllVideos (server: ServerInfo, token: string) { | 19 | async function checkAllVideos (server: PeerTubeServer, token: string) { |
20 | { | 20 | { |
21 | const { data } = await server.videos.listWithToken({ token }) | 21 | const { data } = await server.videos.listWithToken({ token }) |
22 | expect(data).to.have.lengthOf(5) | 22 | expect(data).to.have.lengthOf(5) |
@@ -28,7 +28,7 @@ async function checkAllVideos (server: ServerInfo, token: string) { | |||
28 | } | 28 | } |
29 | } | 29 | } |
30 | 30 | ||
31 | async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) { | 31 | async function checkAllComments (server: PeerTubeServer, token: string, videoUUID: string) { |
32 | const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token }) | 32 | const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token }) |
33 | 33 | ||
34 | const threads = data.filter(t => t.isDeleted === false) | 34 | const threads = data.filter(t => t.isDeleted === false) |
@@ -41,8 +41,8 @@ async function checkAllComments (server: ServerInfo, token: string, videoUUID: s | |||
41 | } | 41 | } |
42 | 42 | ||
43 | async function checkCommentNotification ( | 43 | async function checkCommentNotification ( |
44 | mainServer: ServerInfo, | 44 | mainServer: PeerTubeServer, |
45 | comment: { server: ServerInfo, token: string, videoUUID: string, text: string }, | 45 | comment: { server: PeerTubeServer, token: string, videoUUID: string, text: string }, |
46 | check: 'presence' | 'absence' | 46 | check: 'presence' | 'absence' |
47 | ) { | 47 | ) { |
48 | const command = comment.server.comments | 48 | const command = comment.server.comments |
@@ -63,7 +63,7 @@ async function checkCommentNotification ( | |||
63 | } | 63 | } |
64 | 64 | ||
65 | describe('Test blocklist', function () { | 65 | describe('Test blocklist', function () { |
66 | let servers: ServerInfo[] | 66 | let servers: PeerTubeServer[] |
67 | let videoUUID1: string | 67 | let videoUUID1: string |
68 | let videoUUID2: string | 68 | let videoUUID2: string |
69 | let videoUUID3: string | 69 | let videoUUID3: string |
@@ -77,7 +77,7 @@ describe('Test blocklist', function () { | |||
77 | before(async function () { | 77 | before(async function () { |
78 | this.timeout(120000) | 78 | this.timeout(120000) |
79 | 79 | ||
80 | servers = await flushAndRunMultipleServers(3) | 80 | servers = await createMultipleServers(3) |
81 | await setAccessTokensToServers(servers) | 81 | await setAccessTokensToServers(servers) |
82 | 82 | ||
83 | command = servers[0].blocklist | 83 | command = servers[0].blocklist |
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts index d23d23bcb..62cbf2e07 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/server/tests/api/moderation/video-blacklist.ts | |||
@@ -7,11 +7,10 @@ import { | |||
7 | BlacklistCommand, | 7 | BlacklistCommand, |
8 | cleanupTests, | 8 | cleanupTests, |
9 | doubleFollow, | 9 | doubleFollow, |
10 | flushAndRunMultipleServers, | 10 | createMultipleServers, |
11 | ImportsCommand, | 11 | ImportsCommand, |
12 | killallServers, | 12 | killallServers, |
13 | reRunServer, | 13 | PeerTubeServer, |
14 | ServerInfo, | ||
15 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
16 | waitJobs | 15 | waitJobs |
17 | } from '@shared/extra-utils' | 16 | } from '@shared/extra-utils' |
@@ -20,11 +19,11 @@ import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@sh | |||
20 | const expect = chai.expect | 19 | const expect = chai.expect |
21 | 20 | ||
22 | describe('Test video blacklist', function () { | 21 | describe('Test video blacklist', function () { |
23 | let servers: ServerInfo[] = [] | 22 | let servers: PeerTubeServer[] = [] |
24 | let videoId: number | 23 | let videoId: number |
25 | let command: BlacklistCommand | 24 | let command: BlacklistCommand |
26 | 25 | ||
27 | async function blacklistVideosOnServer (server: ServerInfo) { | 26 | async function blacklistVideosOnServer (server: PeerTubeServer) { |
28 | const { data } = await server.videos.list() | 27 | const { data } = await server.videos.list() |
29 | 28 | ||
30 | for (const video of data) { | 29 | for (const video of data) { |
@@ -36,7 +35,7 @@ describe('Test video blacklist', function () { | |||
36 | this.timeout(50000) | 35 | this.timeout(50000) |
37 | 36 | ||
38 | // Run servers | 37 | // Run servers |
39 | servers = await flushAndRunMultipleServers(2) | 38 | servers = await createMultipleServers(2) |
40 | 39 | ||
41 | // Get the access tokens | 40 | // Get the access tokens |
42 | await setAccessTokensToServers(servers) | 41 | await setAccessTokensToServers(servers) |
@@ -344,7 +343,7 @@ describe('Test video blacklist', function () { | |||
344 | } | 343 | } |
345 | } | 344 | } |
346 | } | 345 | } |
347 | await reRunServer(servers[0], config) | 346 | await servers[0].run(config) |
348 | 347 | ||
349 | { | 348 | { |
350 | const user = { username: 'user_without_flag', password: 'password' } | 349 | const user = { username: 'user_without_flag', password: 'password' } |