diff options
Diffstat (limited to 'server/tests/api/users')
-rw-r--r-- | server/tests/api/users/users.ts | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index c4465d541..bc069a7be 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -8,6 +8,7 @@ import { | |||
8 | createUser, | 8 | createUser, |
9 | deleteMe, | 9 | deleteMe, |
10 | flushTests, | 10 | flushTests, |
11 | getAccountRatings, | ||
11 | getBlacklistedVideosList, | 12 | getBlacklistedVideosList, |
12 | getMyUserInformation, | 13 | getMyUserInformation, |
13 | getMyUserVideoQuotaUsed, | 14 | getMyUserVideoQuotaUsed, |
@@ -32,7 +33,7 @@ import { | |||
32 | updateUser, | 33 | updateUser, |
33 | uploadVideo, | 34 | uploadVideo, |
34 | userLogin | 35 | userLogin |
35 | } from '../../../../shared/utils/index' | 36 | } from '../../../../shared/utils' |
36 | import { follow } from '../../../../shared/utils/server/follows' | 37 | import { follow } from '../../../../shared/utils/server/follows' |
37 | import { setAccessTokensToServers } from '../../../../shared/utils/users/login' | 38 | import { setAccessTokensToServers } from '../../../../shared/utils/users/login' |
38 | import { getMyVideos } from '../../../../shared/utils/videos/videos' | 39 | import { getMyVideos } from '../../../../shared/utils/videos/videos' |
@@ -137,6 +138,35 @@ describe('Test users', function () { | |||
137 | expect(rating.rating).to.equal('like') | 138 | expect(rating.rating).to.equal('like') |
138 | }) | 139 | }) |
139 | 140 | ||
141 | it('Should retrieve ratings list', async function () { | ||
142 | await rateVideo(server.url, accessToken, videoId, 'like') | ||
143 | const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200) | ||
144 | const ratings = res.body | ||
145 | |||
146 | expect(ratings.data[0].video.id).to.equal(videoId) | ||
147 | expect(ratings.data[0].rating).to.equal('like') | ||
148 | }) | ||
149 | |||
150 | it('Should retrieve ratings list by rating type', async function () { | ||
151 | await rateVideo(server.url, accessToken, videoId, 'like') | ||
152 | let res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200, { rating: 'like' }) | ||
153 | let ratings = res.body | ||
154 | expect(ratings.data.length).to.equal(1) | ||
155 | res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200, { rating: 'dislike' }) | ||
156 | ratings = res.body | ||
157 | expect(ratings.data.length).to.equal(0) | ||
158 | await getAccountRatings(server.url, server.user.username, server.accessToken, 400, { rating: 'invalid' }) | ||
159 | }) | ||
160 | |||
161 | it('Should not access ratings list if not logged with correct user', async function () { | ||
162 | const user = { username: 'anuragh', password: 'passbyme' } | ||
163 | const resUser = await createUser(server.url, server.accessToken, user.username, user.password) | ||
164 | const userId = resUser.body.user.id | ||
165 | const userAccessToken = await userLogin(server, user) | ||
166 | await getAccountRatings(server.url, server.user.username, userAccessToken, 403) | ||
167 | await removeUser(server.url, userId, server.accessToken) | ||
168 | }) | ||
169 | |||
140 | it('Should not be able to remove the video with an incorrect token', async function () { | 170 | it('Should not be able to remove the video with an incorrect token', async function () { |
141 | await removeVideo(server.url, 'bad_token', videoId, 401) | 171 | await removeVideo(server.url, 'bad_token', videoId, 401) |
142 | }) | 172 | }) |