From ce5496d6a31b9617aba67970f5dc135e73335234 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 8 Jan 2018 12:53:09 +0100 Subject: Support video quota on client --- server/tests/api/users/users.ts | 13 +++++++++++-- server/tests/utils/users/users.ts | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'server/tests') 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' import 'mocha' import { UserRole } from '../../../../shared/index' import { - createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoRating, getUserInformation, getUsersList, + createUser, flushTests, getBlacklistedVideosList, getMyUserInformation, getMyUserVideoQuotaUsed, getMyUserVideoRating, getUserInformation, + getUsersList, getUsersListPaginationAndSort, getVideosList, killallServers, login, makePutBodyRequest, rateVideo, registerUser, removeUser, removeVideo, runServer, ServerInfo, serverLogin, testVideoImage, updateMyAvatar, updateMyUser, updateUser, uploadVideo } from '../../utils/index' @@ -179,11 +180,19 @@ describe('Test users', function () { this.timeout(5000) const videoAttributes = { - name: 'super user video' + name: 'super user video', + fixture: 'video_short.webm' } await uploadVideo(server.url, accessTokenUser, videoAttributes) }) + it('Should have video quota updated', async function () { + const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser) + const data = res.body + + expect(data.videoQuotaUsed).to.equal(218910) + }) + it('Should be able to list my videos', async function () { const res = await getMyVideos(server.url, accessTokenUser, 0, 5) 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 = .expect('Content-Type', /json/) } +function getMyUserVideoQuotaUsed (url: string, accessToken: string, specialStatus = 200) { + const path = '/api/v1/users/me/video-quota-used' + + return request(url) + .get(path) + .set('Accept', 'application/json') + .set('Authorization', 'Bearer ' + accessToken) + .expect(specialStatus) + .expect('Content-Type', /json/) +} + function getUserInformation (url: string, accessToken: string, userId: number) { const path = '/api/v1/users/' + userId @@ -192,6 +203,7 @@ export { registerUser, getMyUserInformation, getMyUserVideoRating, + getMyUserVideoQuotaUsed, getUsersList, getUsersListPaginationAndSort, removeUser, -- cgit v1.2.3