]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users.ts
Correctly fix octet stream fallback for video ext
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users.ts
index 6fc2a070f324bd72805171890f282b73ab3c605a..24203a7317dd888d6a964585df986a8cba119f65 100644 (file)
@@ -2,7 +2,7 @@
 
 import * as chai from 'chai'
 import 'mocha'
-import { User, UserRole, Video } from '../../../../shared/index'
+import { User, UserRole, Video, MyUser, VideoPlaylistType } from '../../../../shared/index'
 import {
   blockUser,
   cleanupTests,
@@ -18,7 +18,7 @@ import {
   getUsersList,
   getUsersListPaginationAndSort,
   getVideoChannel,
-  getVideosList,
+  getVideosList, installPlugin,
   login,
   makePutBodyRequest,
   rateVideo,
@@ -57,6 +57,8 @@ describe('Test users', function () {
     server = await flushAndRunServer(1)
 
     await setAccessTokensToServers([ server ])
+
+    await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-theme-background-red' })
   })
 
   describe('OAuth client', function () {
@@ -249,7 +251,7 @@ describe('Test users', function () {
 
     it('Should be able to get user information', async function () {
       const res1 = await getMyUserInformation(server.url, accessTokenUser)
-      const userMe: User = res1.body
+      const userMe: MyUser = res1.body
 
       const res2 = await getUserInformation(server.url, server.accessToken, userMe.id)
       const userGet: User = res2.body
@@ -267,6 +269,9 @@ describe('Test users', function () {
 
       expect(userMe.adminFlags).to.be.undefined
       expect(userGet.adminFlags).to.equal(UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST)
+
+      expect(userMe.specialPlaylists).to.have.lengthOf(1)
+      expect(userMe.specialPlaylists[0].type).to.equal(VideoPlaylistType.WATCH_LATER)
     })
   })
 
@@ -307,6 +312,24 @@ describe('Test users', function () {
       expect(video.thumbnailPath).to.not.be.null
       expect(video.previewPath).to.not.be.null
     })
+
+    it('Should be able to search in my videos', async function () {
+      {
+        const res = await getMyVideos(server.url, accessTokenUser, 0, 5, '-createdAt', 'user video')
+        expect(res.body.total).to.equal(1)
+
+        const videos = res.body.data
+        expect(videos).to.have.lengthOf(1)
+      }
+
+      {
+        const res = await getMyVideos(server.url, accessTokenUser, 0, 5, '-createdAt', 'toto')
+        expect(res.body.total).to.equal(0)
+
+        const videos = res.body.data
+        expect(videos).to.have.lengthOf(0)
+      }
+    })
   })
 
   describe('Users listing', function () {
@@ -440,7 +463,7 @@ describe('Test users', function () {
         url: server.url,
         accessToken: accessTokenUser,
         currentPassword: 'super password',
-        newPassword: 'new password'
+        password: 'new password'
       })
       user.password = 'new password'
 
@@ -479,6 +502,19 @@ describe('Test users', function () {
       expect(user.autoPlayVideo).to.be.false
     })
 
+    it('Should be able to change the autoPlayNextVideo attribute', async function () {
+      await updateMyUser({
+        url: server.url,
+        accessToken: accessTokenUser,
+        autoPlayNextVideo: true
+      })
+
+      const res = await getMyUserInformation(server.url, accessTokenUser)
+      const user = res.body
+
+      expect(user.autoPlayNextVideo).to.be.true
+    })
+
     it('Should be able to change the email attribute', async function () {
       await updateMyUser({
         url: server.url,
@@ -541,7 +577,7 @@ describe('Test users', function () {
       })
 
       const res = await getMyUserInformation(server.url, accessTokenUser)
-      const user = res.body
+      const user: User = res.body
 
       expect(user.username).to.equal('user_1')
       expect(user.email).to.equal('updated@example.com')
@@ -550,6 +586,38 @@ describe('Test users', function () {
       expect(user.id).to.be.a('number')
       expect(user.account.displayName).to.equal('new display name')
       expect(user.account.description).to.equal('my super description updated')
+      expect(user.noWelcomeModal).to.be.false
+      expect(user.noInstanceConfigWarningModal).to.be.false
+    })
+
+    it('Should be able to update my theme', async function () {
+      for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
+        await updateMyUser({
+          url: server.url,
+          accessToken: accessTokenUser,
+          theme
+        })
+
+        const res = await getMyUserInformation(server.url, accessTokenUser)
+        const body: User = res.body
+
+        expect(body.theme).to.equal(theme)
+      }
+    })
+
+    it('Should be able to update my modal preferences', async function () {
+      await updateMyUser({
+        url: server.url,
+        accessToken: accessTokenUser,
+        noInstanceConfigWarningModal: true,
+        noWelcomeModal: true
+      })
+
+      const res = await getMyUserInformation(server.url, accessTokenUser)
+      const user: User = res.body
+
+      expect(user.noWelcomeModal).to.be.true
+      expect(user.noInstanceConfigWarningModal).to.be.true
     })
   })