diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/moderation/blocklist-notification.ts | 10 | ||||
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 10 | ||||
-rw-r--r-- | server/tests/api/notifications/notifications-api.ts | 19 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 42 | ||||
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 144 |
5 files changed, 99 insertions, 126 deletions
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index 99da64a2d..5b9699816 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -3,7 +3,6 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addUserSubscription, | ||
7 | addVideoCommentThread, | 6 | addVideoCommentThread, |
8 | cleanupTests, | 7 | cleanupTests, |
9 | createUser, | 8 | createUser, |
@@ -11,7 +10,6 @@ import { | |||
11 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
12 | getUserNotifications, | 11 | getUserNotifications, |
13 | markAsReadAllNotifications, | 12 | markAsReadAllNotifications, |
14 | removeUserSubscription, | ||
15 | ServerInfo, | 13 | ServerInfo, |
16 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
17 | uploadVideo, | 15 | uploadVideo, |
@@ -44,8 +42,8 @@ describe('Test blocklist', function () { | |||
44 | 42 | ||
45 | async function resetState () { | 43 | async function resetState () { |
46 | try { | 44 | try { |
47 | await removeUserSubscription(servers[1].url, remoteUserToken, 'user1_channel@' + servers[0].host) | 45 | await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host }) |
48 | await removeUserSubscription(servers[1].url, remoteUserToken, 'user2_channel@' + servers[0].host) | 46 | await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host }) |
49 | } catch {} | 47 | } catch {} |
50 | 48 | ||
51 | await waitJobs(servers) | 49 | await waitJobs(servers) |
@@ -66,8 +64,8 @@ describe('Test blocklist', function () { | |||
66 | 64 | ||
67 | { | 65 | { |
68 | 66 | ||
69 | await addUserSubscription(servers[1].url, remoteUserToken, 'user1_channel@' + servers[0].host) | 67 | await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host }) |
70 | await addUserSubscription(servers[1].url, remoteUserToken, 'user2_channel@' + servers[0].host) | 68 | await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host }) |
71 | } | 69 | } |
72 | 70 | ||
73 | await waitJobs(servers) | 71 | await waitJobs(servers) |
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 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { buildUUID } from '@server/helpers/uuid' | 4 | import { buildUUID } from '@server/helpers/uuid' |
5 | import { | 5 | import { |
6 | addUserSubscription, | ||
7 | addVideoCommentThread, | 6 | addVideoCommentThread, |
8 | addVideoToBlacklist, | 7 | addVideoToBlacklist, |
9 | checkAbuseStateChange, | 8 | checkAbuseStateChange, |
@@ -29,7 +28,6 @@ import { | |||
29 | MockSmtpServer, | 28 | MockSmtpServer, |
30 | prepareNotificationsTest, | 29 | prepareNotificationsTest, |
31 | registerUser, | 30 | registerUser, |
32 | removeUserSubscription, | ||
33 | removeVideoFromBlacklist, | 31 | removeVideoFromBlacklist, |
34 | ServerInfo, | 32 | ServerInfo, |
35 | uploadVideo, | 33 | uploadVideo, |
@@ -488,8 +486,8 @@ describe('Test moderation notifications', function () { | |||
488 | autoBlacklistTestsCustomConfig.transcoding.enabled = true | 486 | autoBlacklistTestsCustomConfig.transcoding.enabled = true |
489 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) | 487 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) |
490 | 488 | ||
491 | await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 489 | await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) |
492 | await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 490 | await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) |
493 | 491 | ||
494 | }) | 492 | }) |
495 | 493 | ||
@@ -611,8 +609,8 @@ describe('Test moderation notifications', function () { | |||
611 | after(async () => { | 609 | after(async () => { |
612 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) | 610 | await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) |
613 | 611 | ||
614 | await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 612 | await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) |
615 | await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 613 | await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) |
616 | }) | 614 | }) |
617 | }) | 615 | }) |
618 | 616 | ||
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 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { addUserSubscription } from '@shared/extra-utils/users/user-subscriptions' | ||
6 | import { cleanupTests, getMyUserInformation, immutableAssign, uploadRandomVideo, waitJobs } from '../../../../shared/extra-utils' | ||
7 | import { ServerInfo } from '../../../../shared/extra-utils/index' | ||
8 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | ||
9 | import { | 5 | import { |
10 | CheckerBaseParams, | 6 | CheckerBaseParams, |
11 | checkNewVideoFromSubscription, | 7 | checkNewVideoFromSubscription, |
8 | cleanupTests, | ||
12 | getAllNotificationsSettings, | 9 | getAllNotificationsSettings, |
10 | getMyUserInformation, | ||
13 | getUserNotifications, | 11 | getUserNotifications, |
12 | immutableAssign, | ||
14 | markAsReadAllNotifications, | 13 | markAsReadAllNotifications, |
15 | markAsReadNotifications, | 14 | markAsReadNotifications, |
15 | MockSmtpServer, | ||
16 | prepareNotificationsTest, | 16 | prepareNotificationsTest, |
17 | updateMyNotificationSettings | 17 | ServerInfo, |
18 | } from '../../../../shared/extra-utils/users/user-notifications' | 18 | updateMyNotificationSettings, |
19 | import { User, UserNotification, UserNotificationSettingValue } from '../../../../shared/models/users' | 19 | uploadRandomVideo, |
20 | waitJobs | ||
21 | } from '@shared/extra-utils' | ||
22 | import { User, UserNotification, UserNotificationSettingValue } from '@shared/models' | ||
20 | 23 | ||
21 | const expect = chai.expect | 24 | const expect = chai.expect |
22 | 25 | ||
@@ -35,7 +38,7 @@ describe('Test notifications API', function () { | |||
35 | userNotifications = res.userNotifications | 38 | userNotifications = res.userNotifications |
36 | server = res.servers[0] | 39 | server = res.servers[0] |
37 | 40 | ||
38 | await addUserSubscription(server.url, userAccessToken, 'root_channel@localhost:' + server.port) | 41 | await server.subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + server.port }) |
39 | 42 | ||
40 | for (let i = 0; i < 10; i++) { | 43 | for (let i = 0; i < 10; i++) { |
41 | await uploadRandomVideo(server, false) | 44 | 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 | |||
@@ -4,29 +4,25 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { buildUUID } from '@server/helpers/uuid' | 5 | import { buildUUID } from '@server/helpers/uuid' |
6 | import { | 6 | import { |
7 | cleanupTests, | ||
8 | updateMyUser, | ||
9 | updateVideo, | ||
10 | updateVideoChannel, | ||
11 | uploadRandomVideoOnServers, | ||
12 | wait | ||
13 | } from '../../../../shared/extra-utils' | ||
14 | import { ServerInfo } from '../../../../shared/extra-utils/index' | ||
15 | import { MockSmtpServer } from '../../../../shared/extra-utils/mock-servers/mock-email' | ||
16 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
17 | import { | ||
18 | CheckerBaseParams, | 7 | CheckerBaseParams, |
19 | checkMyVideoImportIsFinished, | 8 | checkMyVideoImportIsFinished, |
20 | checkNewActorFollow, | 9 | checkNewActorFollow, |
21 | checkNewVideoFromSubscription, | 10 | checkNewVideoFromSubscription, |
22 | checkVideoIsPublished, | 11 | checkVideoIsPublished, |
12 | cleanupTests, | ||
23 | getLastNotification, | 13 | getLastNotification, |
24 | prepareNotificationsTest | 14 | MockSmtpServer, |
25 | } from '../../../../shared/extra-utils/users/user-notifications' | 15 | prepareNotificationsTest, |
26 | import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' | 16 | ServerInfo, |
27 | import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 17 | updateMyUser, |
28 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' | 18 | updateVideo, |
29 | import { VideoPrivacy } from '../../../../shared/models/videos' | 19 | updateVideoChannel, |
20 | uploadRandomVideoOnServers, | ||
21 | wait, | ||
22 | waitJobs | ||
23 | } from '@shared/extra-utils' | ||
24 | import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '@shared/extra-utils/videos/video-imports' | ||
25 | import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models' | ||
30 | 26 | ||
31 | const expect = chai.expect | 27 | const expect = chai.expect |
32 | 28 | ||
@@ -79,7 +75,7 @@ describe('Test user notifications', function () { | |||
79 | it('Should send a new video notification if the user follows the local video publisher', async function () { | 75 | it('Should send a new video notification if the user follows the local video publisher', async function () { |
80 | this.timeout(15000) | 76 | this.timeout(15000) |
81 | 77 | ||
82 | await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[0].port) | 78 | await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) |
83 | await waitJobs(servers) | 79 | await waitJobs(servers) |
84 | 80 | ||
85 | const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) | 81 | const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) |
@@ -89,7 +85,7 @@ describe('Test user notifications', function () { | |||
89 | it('Should send a new video notification from a remote account', async function () { | 85 | it('Should send a new video notification from a remote account', async function () { |
90 | this.timeout(150000) // Server 2 has transcoding enabled | 86 | this.timeout(150000) // Server 2 has transcoding enabled |
91 | 87 | ||
92 | await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:' + servers[1].port) | 88 | await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port }) |
93 | await waitJobs(servers) | 89 | await waitJobs(servers) |
94 | 90 | ||
95 | const { name, uuid } = await uploadRandomVideoOnServers(servers, 2) | 91 | const { name, uuid } = await uploadRandomVideoOnServers(servers, 2) |
@@ -418,23 +414,23 @@ describe('Test user notifications', function () { | |||
418 | it('Should notify when a local channel is following one of our channel', async function () { | 414 | it('Should notify when a local channel is following one of our channel', async function () { |
419 | this.timeout(50000) | 415 | this.timeout(50000) |
420 | 416 | ||
421 | await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 417 | await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) |
422 | await waitJobs(servers) | 418 | await waitJobs(servers) |
423 | 419 | ||
424 | await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') | 420 | await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') |
425 | 421 | ||
426 | await removeUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 422 | await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) |
427 | }) | 423 | }) |
428 | 424 | ||
429 | it('Should notify when a remote channel is following one of our channel', async function () { | 425 | it('Should notify when a remote channel is following one of our channel', async function () { |
430 | this.timeout(50000) | 426 | this.timeout(50000) |
431 | 427 | ||
432 | await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 428 | await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) |
433 | await waitJobs(servers) | 429 | await waitJobs(servers) |
434 | 430 | ||
435 | await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') | 431 | await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') |
436 | 432 | ||
437 | await removeUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:' + servers[0].port) | 433 | await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) |
438 | }) | 434 | }) |
439 | 435 | ||
440 | // PeerTube does not support accout -> account follows | 436 | // PeerTube does not support accout -> account follows |
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 7e365d797..c119622ad 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -3,25 +3,19 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | addUserSubscription, | ||
7 | areSubscriptionsExist, | ||
8 | cleanupTests, | 6 | cleanupTests, |
9 | createUser, | 7 | createUser, |
10 | doubleFollow, | 8 | doubleFollow, |
11 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
12 | getUserSubscription, | ||
13 | getVideosList, | 10 | getVideosList, |
14 | listUserSubscriptions, | ||
15 | listUserSubscriptionVideos, | ||
16 | removeUserSubscription, | ||
17 | ServerInfo, | 11 | ServerInfo, |
18 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
13 | SubscriptionsCommand, | ||
19 | updateVideo, | 14 | updateVideo, |
20 | uploadVideo, | 15 | uploadVideo, |
21 | userLogin, | 16 | userLogin, |
22 | waitJobs | 17 | waitJobs |
23 | } from '@shared/extra-utils' | 18 | } from '@shared/extra-utils' |
24 | import { Video, VideoChannel } from '@shared/models' | ||
25 | 19 | ||
26 | const expect = chai.expect | 20 | const expect = chai.expect |
27 | 21 | ||
@@ -30,6 +24,8 @@ describe('Test users subscriptions', function () { | |||
30 | const users: { accessToken: string }[] = [] | 24 | const users: { accessToken: string }[] = [] |
31 | let video3UUID: string | 25 | let video3UUID: string |
32 | 26 | ||
27 | let command: SubscriptionsCommand | ||
28 | |||
33 | before(async function () { | 29 | before(async function () { |
34 | this.timeout(120000) | 30 | this.timeout(120000) |
35 | 31 | ||
@@ -58,6 +54,8 @@ describe('Test users subscriptions', function () { | |||
58 | } | 54 | } |
59 | 55 | ||
60 | await waitJobs(servers) | 56 | await waitJobs(servers) |
57 | |||
58 | command = servers[0].subscriptionsCommand | ||
61 | }) | 59 | }) |
62 | 60 | ||
63 | it('Should display videos of server 2 on server 1', async function () { | 61 | it('Should display videos of server 2 on server 1', async function () { |
@@ -69,8 +67,8 @@ describe('Test users subscriptions', function () { | |||
69 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { | 67 | it('User of server 1 should follow user of server 3 and root of server 1', async function () { |
70 | this.timeout(60000) | 68 | this.timeout(60000) |
71 | 69 | ||
72 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) | 70 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) |
73 | await addUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) | 71 | await command.add({ token: users[0].accessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) |
74 | 72 | ||
75 | await waitJobs(servers) | 73 | await waitJobs(servers) |
76 | 74 | ||
@@ -93,17 +91,17 @@ describe('Test users subscriptions', function () { | |||
93 | 91 | ||
94 | it('Should list subscriptions', async function () { | 92 | it('Should list subscriptions', async function () { |
95 | { | 93 | { |
96 | const res = await listUserSubscriptions({ url: servers[0].url, token: servers[0].accessToken }) | 94 | const body = await command.list() |
97 | expect(res.body.total).to.equal(0) | 95 | expect(body.total).to.equal(0) |
98 | expect(res.body.data).to.be.an('array') | 96 | expect(body.data).to.be.an('array') |
99 | expect(res.body.data).to.have.lengthOf(0) | 97 | expect(body.data).to.have.lengthOf(0) |
100 | } | 98 | } |
101 | 99 | ||
102 | { | 100 | { |
103 | const res = await listUserSubscriptions({ url: servers[0].url, token: users[0].accessToken, sort: 'createdAt' }) | 101 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) |
104 | expect(res.body.total).to.equal(2) | 102 | expect(body.total).to.equal(2) |
105 | 103 | ||
106 | const subscriptions: VideoChannel[] = res.body.data | 104 | const subscriptions = body.data |
107 | expect(subscriptions).to.be.an('array') | 105 | expect(subscriptions).to.be.an('array') |
108 | expect(subscriptions).to.have.lengthOf(2) | 106 | expect(subscriptions).to.have.lengthOf(2) |
109 | 107 | ||
@@ -114,8 +112,7 @@ describe('Test users subscriptions', function () { | |||
114 | 112 | ||
115 | it('Should get subscription', async function () { | 113 | it('Should get subscription', async function () { |
116 | { | 114 | { |
117 | const res = await getUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) | 115 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) |
118 | const videoChannel: VideoChannel = res.body | ||
119 | 116 | ||
120 | expect(videoChannel.name).to.equal('user3_channel') | 117 | expect(videoChannel.name).to.equal('user3_channel') |
121 | expect(videoChannel.host).to.equal('localhost:' + servers[2].port) | 118 | expect(videoChannel.host).to.equal('localhost:' + servers[2].port) |
@@ -125,8 +122,7 @@ describe('Test users subscriptions', function () { | |||
125 | } | 122 | } |
126 | 123 | ||
127 | { | 124 | { |
128 | const res = await getUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) | 125 | const videoChannel = await command.get({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) |
129 | const videoChannel: VideoChannel = res.body | ||
130 | 126 | ||
131 | expect(videoChannel.name).to.equal('root_channel') | 127 | expect(videoChannel.name).to.equal('root_channel') |
132 | expect(videoChannel.host).to.equal('localhost:' + servers[0].port) | 128 | expect(videoChannel.host).to.equal('localhost:' + servers[0].port) |
@@ -144,8 +140,7 @@ describe('Test users subscriptions', function () { | |||
144 | 'user3_channel@localhost:' + servers[0].port | 140 | 'user3_channel@localhost:' + servers[0].port |
145 | ] | 141 | ] |
146 | 142 | ||
147 | const res = await areSubscriptionsExist(servers[0].url, users[0].accessToken, uris) | 143 | const body = await command.exist({ token: users[0].accessToken, uris }) |
148 | const body = res.body | ||
149 | 144 | ||
150 | expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true | 145 | expect(body['user3_channel@localhost:' + servers[2].port]).to.be.true |
151 | expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false | 146 | expect(body['root2_channel@localhost:' + servers[0].port]).to.be.false |
@@ -155,45 +150,31 @@ describe('Test users subscriptions', function () { | |||
155 | 150 | ||
156 | it('Should search among subscriptions', async function () { | 151 | it('Should search among subscriptions', async function () { |
157 | { | 152 | { |
158 | const res = await listUserSubscriptions({ | 153 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'user3_channel' }) |
159 | url: servers[0].url, | 154 | expect(body.total).to.equal(1) |
160 | token: users[0].accessToken, | 155 | expect(body.data).to.have.lengthOf(1) |
161 | sort: '-createdAt', | ||
162 | search: 'user3_channel' | ||
163 | }) | ||
164 | expect(res.body.total).to.equal(1) | ||
165 | |||
166 | const subscriptions = res.body.data | ||
167 | expect(subscriptions).to.have.lengthOf(1) | ||
168 | } | 156 | } |
169 | 157 | ||
170 | { | 158 | { |
171 | const res = await listUserSubscriptions({ | 159 | const body = await command.list({ token: users[0].accessToken, sort: '-createdAt', search: 'toto' }) |
172 | url: servers[0].url, | 160 | expect(body.total).to.equal(0) |
173 | token: users[0].accessToken, | 161 | expect(body.data).to.have.lengthOf(0) |
174 | sort: '-createdAt', | ||
175 | search: 'toto' | ||
176 | }) | ||
177 | expect(res.body.total).to.equal(0) | ||
178 | |||
179 | const subscriptions = res.body.data | ||
180 | expect(subscriptions).to.have.lengthOf(0) | ||
181 | } | 162 | } |
182 | }) | 163 | }) |
183 | 164 | ||
184 | it('Should list subscription videos', async function () { | 165 | it('Should list subscription videos', async function () { |
185 | { | 166 | { |
186 | const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) | 167 | const body = await command.listVideos() |
187 | expect(res.body.total).to.equal(0) | 168 | expect(body.total).to.equal(0) |
188 | expect(res.body.data).to.be.an('array') | 169 | expect(body.data).to.be.an('array') |
189 | expect(res.body.data).to.have.lengthOf(0) | 170 | expect(body.data).to.have.lengthOf(0) |
190 | } | 171 | } |
191 | 172 | ||
192 | { | 173 | { |
193 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 174 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
194 | expect(res.body.total).to.equal(3) | 175 | expect(body.total).to.equal(3) |
195 | 176 | ||
196 | const videos: Video[] = res.body.data | 177 | const videos = body.data |
197 | expect(videos).to.be.an('array') | 178 | expect(videos).to.be.an('array') |
198 | expect(videos).to.have.lengthOf(3) | 179 | expect(videos).to.have.lengthOf(3) |
199 | 180 | ||
@@ -212,17 +193,17 @@ describe('Test users subscriptions', function () { | |||
212 | await waitJobs(servers) | 193 | await waitJobs(servers) |
213 | 194 | ||
214 | { | 195 | { |
215 | const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) | 196 | const body = await command.listVideos() |
216 | expect(res.body.total).to.equal(0) | 197 | expect(body.total).to.equal(0) |
217 | expect(res.body.data).to.be.an('array') | 198 | expect(body.data).to.be.an('array') |
218 | expect(res.body.data).to.have.lengthOf(0) | 199 | expect(body.data).to.have.lengthOf(0) |
219 | } | 200 | } |
220 | 201 | ||
221 | { | 202 | { |
222 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 203 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
223 | expect(res.body.total).to.equal(4) | 204 | expect(body.total).to.equal(4) |
224 | 205 | ||
225 | const videos: Video[] = res.body.data | 206 | const videos = body.data |
226 | expect(videos).to.be.an('array') | 207 | expect(videos).to.be.an('array') |
227 | expect(videos).to.have.lengthOf(4) | 208 | expect(videos).to.have.lengthOf(4) |
228 | 209 | ||
@@ -281,17 +262,17 @@ describe('Test users subscriptions', function () { | |||
281 | 262 | ||
282 | it('Should still list subscription videos', async function () { | 263 | it('Should still list subscription videos', async function () { |
283 | { | 264 | { |
284 | const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) | 265 | const body = await command.listVideos() |
285 | expect(res.body.total).to.equal(0) | 266 | expect(body.total).to.equal(0) |
286 | expect(res.body.data).to.be.an('array') | 267 | expect(body.data).to.be.an('array') |
287 | expect(res.body.data).to.have.lengthOf(0) | 268 | expect(body.data).to.have.lengthOf(0) |
288 | } | 269 | } |
289 | 270 | ||
290 | { | 271 | { |
291 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 272 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
292 | expect(res.body.total).to.equal(4) | 273 | expect(body.total).to.equal(4) |
293 | 274 | ||
294 | const videos: Video[] = res.body.data | 275 | const videos = body.data |
295 | expect(videos).to.be.an('array') | 276 | expect(videos).to.be.an('array') |
296 | expect(videos).to.have.lengthOf(4) | 277 | expect(videos).to.have.lengthOf(4) |
297 | 278 | ||
@@ -309,44 +290,41 @@ describe('Test users subscriptions', function () { | |||
309 | 290 | ||
310 | await waitJobs(servers) | 291 | await waitJobs(servers) |
311 | 292 | ||
312 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 293 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
313 | const videos: Video[] = res.body.data | 294 | expect(body.data[2].name).to.equal('video server 3 added after follow updated') |
314 | expect(videos[2].name).to.equal('video server 3 added after follow updated') | ||
315 | }) | 295 | }) |
316 | 296 | ||
317 | it('Should remove user of server 3 subscription', async function () { | 297 | it('Should remove user of server 3 subscription', async function () { |
318 | this.timeout(30000) | 298 | this.timeout(30000) |
319 | 299 | ||
320 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) | 300 | await command.remove({ token: users[0].accessToken, uri: 'user3_channel@localhost:' + servers[2].port }) |
321 | 301 | ||
322 | await waitJobs(servers) | 302 | await waitJobs(servers) |
323 | }) | 303 | }) |
324 | 304 | ||
325 | it('Should not display its videos anymore', async function () { | 305 | it('Should not display its videos anymore', async function () { |
326 | { | 306 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
327 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 307 | expect(body.total).to.equal(1) |
328 | expect(res.body.total).to.equal(1) | ||
329 | 308 | ||
330 | const videos: Video[] = res.body.data | 309 | const videos = body.data |
331 | expect(videos).to.be.an('array') | 310 | expect(videos).to.be.an('array') |
332 | expect(videos).to.have.lengthOf(1) | 311 | expect(videos).to.have.lengthOf(1) |
333 | 312 | ||
334 | expect(videos[0].name).to.equal('video server 1 added after follow') | 313 | expect(videos[0].name).to.equal('video server 1 added after follow') |
335 | } | ||
336 | }) | 314 | }) |
337 | 315 | ||
338 | it('Should remove the root subscription and not display the videos anymore', async function () { | 316 | it('Should remove the root subscription and not display the videos anymore', async function () { |
339 | this.timeout(30000) | 317 | this.timeout(30000) |
340 | 318 | ||
341 | await removeUserSubscription(servers[0].url, users[0].accessToken, 'root_channel@localhost:' + servers[0].port) | 319 | await command.remove({ token: users[0].accessToken, uri: 'root_channel@localhost:' + servers[0].port }) |
342 | 320 | ||
343 | await waitJobs(servers) | 321 | await waitJobs(servers) |
344 | 322 | ||
345 | { | 323 | { |
346 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 324 | const body = await command.list({ token: users[0].accessToken, sort: 'createdAt' }) |
347 | expect(res.body.total).to.equal(0) | 325 | expect(body.total).to.equal(0) |
348 | 326 | ||
349 | const videos: Video[] = res.body.data | 327 | const videos = body.data |
350 | expect(videos).to.be.an('array') | 328 | expect(videos).to.be.an('array') |
351 | expect(videos).to.have.lengthOf(0) | 329 | expect(videos).to.have.lengthOf(0) |
352 | } | 330 | } |
@@ -366,15 +344,15 @@ describe('Test users subscriptions', function () { | |||
366 | it('Should follow user of server 3 again', async function () { | 344 | it('Should follow user of server 3 again', async function () { |
367 | this.timeout(60000) | 345 | this.timeout(60000) |
368 | 346 | ||
369 | await addUserSubscription(servers[0].url, users[0].accessToken, 'user3_channel@localhost:' + servers[2].port) | 347 | await command.add({ token: users[0].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) |
370 | 348 | ||
371 | await waitJobs(servers) | 349 | await waitJobs(servers) |
372 | 350 | ||
373 | { | 351 | { |
374 | const res = await listUserSubscriptionVideos(servers[0].url, users[0].accessToken, 'createdAt') | 352 | const body = await command.listVideos({ token: users[0].accessToken, sort: 'createdAt' }) |
375 | expect(res.body.total).to.equal(3) | 353 | expect(body.total).to.equal(3) |
376 | 354 | ||
377 | const videos: Video[] = res.body.data | 355 | const videos = body.data |
378 | expect(videos).to.be.an('array') | 356 | expect(videos).to.be.an('array') |
379 | expect(videos).to.have.lengthOf(3) | 357 | expect(videos).to.have.lengthOf(3) |
380 | 358 | ||