Add comments federation tests
[oweals/peertube.git] / server / tests / api / users.ts
index 055dade04e0abb481d1f08ffe485b30c075670fa..67e4cc8c6ce7bb223d62b3d7d1652b33f3d6c3da 100644 (file)
@@ -1,4 +1,5 @@
 /* tslint:disable:no-unused-expression */
+
 import * as chai from 'chai'
 import 'mocha'
 import { UserRole } from '../../../shared'
@@ -28,6 +29,7 @@ import {
 } from '../utils'
 import { follow } from '../utils/follows'
 import { getMyVideos } from '../utils/videos'
+import { setAccessTokensToServers } from '../utils/login'
 
 const expect = chai.expect
 
@@ -39,10 +41,12 @@ describe('Test users', function () {
   let userId: number
 
   before(async function () {
-    this.timeout(120000)
+    this.timeout(10000)
 
     await flushTests()
     server = await runServer(1)
+
+    await setAccessTokensToServers([ server ])
   })
 
   it('Should create a new client')
@@ -109,11 +113,11 @@ describe('Test users', function () {
 
   it('Should upload the video with the correct token', async function () {
     const videoAttributes = {}
-    await uploadVideo(server.url, accessToken, videoAttributes, 204)
+    await uploadVideo(server.url, accessToken, videoAttributes)
     const res = await getVideosList(server.url)
     const video = res.body.data[ 0 ]
 
-    expect(video.account)
+    expect(video.accountName)
       .to
       .equal('root')
     videoId = video.id
@@ -121,7 +125,7 @@ describe('Test users', function () {
 
   it('Should upload the video again with the correct token', async function () {
     const videoAttributes = {}
-    await uploadVideo(server.url, accessToken, videoAttributes, 204)
+    await uploadVideo(server.url, accessToken, videoAttributes)
   })
 
   it('Should retrieve a video rating', async function () {
@@ -242,7 +246,7 @@ describe('Test users', function () {
   })
 
   it('Should list all the users', async function () {
-    const res = await getUsersList(server.url)
+    const res = await getUsersList(server.url, server.accessToken)
     const result = res.body
     const total = result.total
     const users = result.data
@@ -280,7 +284,7 @@ describe('Test users', function () {
   })
 
   it('Should list only the first user by username asc', async function () {
-    const res = await getUsersListPaginationAndSort(server.url, 0, 1, 'username')
+    const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, 'username')
 
     const result = res.body
     const total = result.total
@@ -307,7 +311,7 @@ describe('Test users', function () {
   })
 
   it('Should list only the first user by username desc', async function () {
-    const res = await getUsersListPaginationAndSort(server.url, 0, 1, '-username')
+    const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-username')
     const result = res.body
     const total = result.total
     const users = result.data
@@ -330,7 +334,7 @@ describe('Test users', function () {
   })
 
   it('Should list only the second user by createdAt desc', async function () {
-    const res = await getUsersListPaginationAndSort(server.url, 0, 1, '-createdAt')
+    const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-createdAt')
     const result = res.body
     const total = result.total
     const users = result.data
@@ -353,7 +357,7 @@ describe('Test users', function () {
   })
 
   it('Should list all the users by createdAt asc', async function () {
-    const res = await getUsersListPaginationAndSort(server.url, 0, 2, 'createdAt')
+    const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt')
     const result = res.body
     const total = result.total
     const users = result.data
@@ -411,6 +415,15 @@ describe('Test users', function () {
       .a('number')
   })
 
+  it('Should be able to change the autoPlayVideo attribute', async function () {
+    await updateMyUser(server.url, accessTokenUser, undefined, undefined, undefined, false)
+
+    const res = await getMyUserInformation(server.url, accessTokenUser)
+    const user = res.body
+
+    expect(user.autoPlayVideo).to.be.false
+  })
+
   it('Should be able to change the email display attribute', async function () {
     await updateMyUser(server.url, accessTokenUser, undefined, undefined, 'updated@example.com')
 
@@ -483,7 +496,7 @@ describe('Test users', function () {
       .equal(1)
 
     const video = res.body.data[ 0 ]
-    expect(video.account)
+    expect(video.accountName)
       .to
       .equal('root')
   })