aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/users')
-rw-r--r--server/tests/api/users/users-multiple-servers.ts37
-rw-r--r--server/tests/api/users/users.ts20
2 files changed, 27 insertions, 30 deletions
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index f60c66e4b..03fbfabeb 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -1,9 +1,9 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import * as chai from 'chai'
4import 'mocha' 3import 'mocha'
5import { Account } from '../../../../shared/models/actors' 4import * as chai from 'chai'
6import { 5import {
6 checkActorFilesWereRemoved,
7 checkTmpIsEmpty, 7 checkTmpIsEmpty,
8 checkVideoFilesWereRemoved, 8 checkVideoFilesWereRemoved,
9 cleanupTests, 9 cleanupTests,
@@ -11,17 +11,19 @@ import {
11 doubleFollow, 11 doubleFollow,
12 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
13 getAccountVideos, 13 getAccountVideos,
14 getMyUserInformation,
14 getVideoChannelsList, 15 getVideoChannelsList,
15 removeUser, 16 removeUser,
17 ServerInfo,
18 setAccessTokensToServers,
19 testImage,
20 updateMyAvatar,
16 updateMyUser, 21 updateMyUser,
17 userLogin 22 uploadVideo,
18} from '../../../../shared/extra-utils' 23 userLogin,
19import { getMyUserInformation, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/extra-utils/index' 24 waitJobs
20import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/extra-utils/users/accounts' 25} from '@shared/extra-utils'
21import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' 26import { User, VideoChannel } from '@shared/models'
22import { User } from '../../../../shared/models/users'
23import { VideoChannel } from '../../../../shared/models/videos'
24import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
25 27
26const expect = chai.expect 28const expect = chai.expect
27 29
@@ -133,13 +135,12 @@ describe('Test users with multiple servers', function () {
133 let createdAt: string | Date 135 let createdAt: string | Date
134 136
135 for (const server of servers) { 137 for (const server of servers) {
136 const resAccounts = await getAccountsList(server.url, '-createdAt') 138 const body = await server.accountsCommand.list({ sort: '-createdAt' })
137 139
138 const resList = resAccounts.body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) as Account 140 const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port)
139 expect(resList).not.to.be.undefined 141 expect(resList).not.to.be.undefined
140 142
141 const resAccount = await getAccount(server.url, resList.name + '@' + resList.host) 143 const account = await server.accountsCommand.get({ accountName: resList.name + '@' + resList.host })
142 const account = resAccount.body as Account
143 144
144 if (!createdAt) createdAt = account.createdAt 145 if (!createdAt) createdAt = account.createdAt
145 146
@@ -193,9 +194,9 @@ describe('Test users with multiple servers', function () {
193 this.timeout(10_000) 194 this.timeout(10_000)
194 195
195 for (const server of servers) { 196 for (const server of servers) {
196 const resAccounts = await getAccountsList(server.url, '-createdAt') 197 const body = await server.accountsCommand.list({ sort: '-createdAt' })
197 198
198 const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account 199 const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
199 expect(accountDeleted).not.to.be.undefined 200 expect(accountDeleted).not.to.be.undefined
200 201
201 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) 202 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
@@ -210,9 +211,9 @@ describe('Test users with multiple servers', function () {
210 await waitJobs(servers) 211 await waitJobs(servers)
211 212
212 for (const server of servers) { 213 for (const server of servers) {
213 const resAccounts = await getAccountsList(server.url, '-createdAt') 214 const body = await server.accountsCommand.list({ sort: '-createdAt' })
214 215
215 const accountDeleted = resAccounts.body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) as Account 216 const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
216 expect(accountDeleted).to.be.undefined 217 expect(accountDeleted).to.be.undefined
217 218
218 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10) 219 const resVideoChannels = await getVideoChannelsList(server.url, 0, 10)
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 33bcc8701..3beea5d50 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -11,7 +11,6 @@ import {
11 createUser, 11 createUser,
12 deleteMe, 12 deleteMe,
13 flushAndRunServer, 13 flushAndRunServer,
14 getAccountRatings,
15 getBlacklistedVideosList, 14 getBlacklistedVideosList,
16 getMyUserInformation, 15 getMyUserInformation,
17 getMyUserVideoQuotaUsed, 16 getMyUserVideoQuotaUsed,
@@ -194,25 +193,22 @@ describe('Test users', function () {
194 it('Should retrieve ratings list', async function () { 193 it('Should retrieve ratings list', async function () {
195 await rateVideo(server.url, accessToken, videoId, 'like') 194 await rateVideo(server.url, accessToken, videoId, 'like')
196 195
197 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, HttpStatusCode.OK_200) 196 const body = await server.accountsCommand.listRatings({ accountName: server.user.username })
198 const ratings = res.body
199 197
200 expect(ratings.total).to.equal(1) 198 expect(body.total).to.equal(1)
201 expect(ratings.data[0].video.id).to.equal(videoId) 199 expect(body.data[0].video.id).to.equal(videoId)
202 expect(ratings.data[0].rating).to.equal('like') 200 expect(body.data[0].rating).to.equal('like')
203 }) 201 })
204 202
205 it('Should retrieve ratings list by rating type', async function () { 203 it('Should retrieve ratings list by rating type', async function () {
206 { 204 {
207 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like') 205 const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'like' })
208 const ratings = res.body 206 expect(body.data.length).to.equal(1)
209 expect(ratings.data.length).to.equal(1)
210 } 207 }
211 208
212 { 209 {
213 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike') 210 const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'dislike' })
214 const ratings = res.body 211 expect(body.data.length).to.equal(0)
215 expect(ratings.data.length).to.equal(0)
216 } 212 }
217 }) 213 })
218 }) 214 })