aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/users/users.ts13
-rw-r--r--server/tests/utils/users/users.ts12
2 files changed, 23 insertions, 2 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index f7e5972d3..b788637e7 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -4,7 +4,8 @@ import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { UserRole } from '../../../../shared/index' 5import { UserRole } from '../../../../shared/index'
6import { 6import {
7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoRating, getUserInformation, getUsersList, 7 createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, getUserInformation,
8 getUsersList,
8 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo, 9 getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo,
9 runServer, ServerInfo, serverLogin, testVideoImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo 10 runServer, ServerInfo, serverLogin, testVideoImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo
10} from '../../utils/index' 11} from '../../utils/index'
@@ -179,11 +180,19 @@ describe('Test users', function () {
179 this.timeout(5000) 180 this.timeout(5000)
180 181
181 const videoAttributes = { 182 const videoAttributes = {
182 name: 'super user video' 183 name: 'super user video',
184 fixture: 'video_short.webm'
183 } 185 }
184 await uploadVideo(server.url, accessTokenUser, videoAttributes) 186 await uploadVideo(server.url, accessTokenUser, videoAttributes)
185 }) 187 })
186 188
189 it('Should have video quota updated', async function () {
190 const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser)
191 const data = res.body
192
193 expect(data.videoQuotaUsed).to.equal(218910)
194 })
195
187 it('Should be able to list my videos', async function () { 196 it('Should be able to list my videos', async function () {
188 const res = await getMyVideos(server.url, accessTokenUser, 0, 5) 197 const res = await getMyVideos(server.url, accessTokenUser, 0, 5)
189 expect(res.body.total).to.equal(1) 198 expect(res.body.total).to.equal(1)
diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts
index 90b1ca0a6..12945a805 100644
--- a/server/tests/utils/users/users.ts
+++ b/server/tests/utils/users/users.ts
@@ -56,6 +56,17 @@ function getMyUserInformation (url: string, accessToken: string, specialStatus =
56 .expect('Content-Type', /json/) 56 .expect('Content-Type', /json/)
57} 57}
58 58
59function getMyUserVideoQuotaUsed (url: string, accessToken: string, specialStatus = 200) {
60 const path = '/api/v1/users/me/video-quota-used'
61
62 return request(url)
63 .get(path)
64 .set('Accept', 'application/json')
65 .set('Authorization', 'Bearer ' + accessToken)
66 .expect(specialStatus)
67 .expect('Content-Type', /json/)
68}
69
59function getUserInformation (url: string, accessToken: string, userId: number) { 70function getUserInformation (url: string, accessToken: string, userId: number) {
60 const path = '/api/v1/users/' + userId 71 const path = '/api/v1/users/' + userId
61 72
@@ -192,6 +203,7 @@ export {
192 registerUser, 203 registerUser,
193 getMyUserInformation, 204 getMyUserInformation,
194 getMyUserVideoRating, 205 getMyUserVideoRating,
206 getMyUserVideoQuotaUsed,
195 getUsersList, 207 getUsersList,
196 getUsersListPaginationAndSort, 208 getUsersListPaginationAndSort,
197 removeUser, 209 removeUser,