]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users.ts
Move test functions outside extra-utils
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users.ts
index 1419ae820493e479124c09784cf7bf3340eaf9af..ff9172a82e664ff2ac294458af6d911d221cf3ff 100644 (file)
@@ -2,6 +2,8 @@
 
 import 'mocha'
 import * as chai from 'chai'
+import { testImage } from '@server/tests/shared'
+import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
 import {
   cleanupTests,
   createSingleServer,
@@ -9,10 +11,8 @@ import {
   makePutBodyRequest,
   PeerTubeServer,
   setAccessTokensToServers,
-  testImage,
   waitJobs
-} from '@shared/extra-utils'
-import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
+} from '@shared/server-commands'
 
 const expect = chai.expect
 
@@ -290,7 +290,7 @@ describe('Test users', function () {
         expect(user.account.description).to.be.null
       }
 
-      expect(userMe.adminFlags).to.be.undefined
+      expect(userMe.adminFlags).to.equal(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)
       expect(userGet.adminFlags).to.equal(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)
 
       expect(userMe.specialPlaylists).to.have.lengthOf(1)
@@ -318,6 +318,8 @@ describe('Test users', function () {
         fixture: 'video_short.webm'
       }
       await server.videos.upload({ token: userToken, attributes })
+
+      await server.channels.create({ token: userToken, attributes: { name: 'other_channel' } })
     })
 
     it('Should have video quota updated', async function () {
@@ -340,6 +342,29 @@ describe('Test users', function () {
       expect(video.previewPath).to.not.be.null
     })
 
+    it('Should be able to filter by channel in my videos', async function () {
+      const myInfo = await server.users.getMyInfo({ token: userToken })
+      const mainChannel = myInfo.videoChannels.find(c => c.name !== 'other_channel')
+      const otherChannel = myInfo.videoChannels.find(c => c.name === 'other_channel')
+
+      {
+        const { total, data } = await server.videos.listMyVideos({ token: userToken, channelId: mainChannel.id })
+        expect(total).to.equal(1)
+        expect(data).to.have.lengthOf(1)
+
+        const video: Video = data[0]
+        expect(video.name).to.equal('super user video')
+        expect(video.thumbnailPath).to.not.be.null
+        expect(video.previewPath).to.not.be.null
+      }
+
+      {
+        const { total, data } = await server.videos.listMyVideos({ token: userToken, channelId: otherChannel.id })
+        expect(total).to.equal(0)
+        expect(data).to.have.lengthOf(0)
+      }
+    })
+
     it('Should be able to search in my videos', async function () {
       {
         const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })
@@ -534,6 +559,28 @@ describe('Test users', function () {
       expect(user.autoPlayNextVideo).to.be.true
     })
 
+    it('Should be able to change the p2p attribute', async function () {
+      {
+        await server.users.updateMe({
+          token: userToken,
+          webTorrentEnabled: false
+        })
+
+        const user = await server.users.getMyInfo({ token: userToken })
+        expect(user.p2pEnabled).to.be.false
+      }
+
+      {
+        await server.users.updateMe({
+          token: userToken,
+          p2pEnabled: true
+        })
+
+        const user = await server.users.getMyInfo({ token: userToken })
+        expect(user.p2pEnabled).to.be.true
+      }
+    })
+
     it('Should be able to change the email attribute', async function () {
       await server.users.updateMe({
         token: userToken,
@@ -597,6 +644,7 @@ describe('Test users', function () {
       expect(user.account.description).to.equal('my super description updated')
       expect(user.noWelcomeModal).to.be.false
       expect(user.noInstanceConfigWarningModal).to.be.false
+      expect(user.noAccountSetupWarningModal).to.be.false
     })
 
     it('Should be able to update my theme', async function () {
@@ -612,12 +660,14 @@ describe('Test users', function () {
       await server.users.updateMe({
         token: userToken,
         noInstanceConfigWarningModal: true,
-        noWelcomeModal: true
+        noWelcomeModal: true,
+        noAccountSetupWarningModal: true
       })
 
       const user = await server.users.getMyInfo({ token: userToken })
       expect(user.noWelcomeModal).to.be.true
       expect(user.noInstanceConfigWarningModal).to.be.true
+      expect(user.noAccountSetupWarningModal).to.be.true
     })
   })