]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users.ts
Add welcome modal
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users.ts
index 9d2ef786f1da14303ce6f43fd6ca3146f81053d3..95b1bb62603357324217039ab2306bddb00ed7e7 100644 (file)
@@ -17,11 +17,12 @@ import {
   getUserInformation,
   getUsersList,
   getUsersListPaginationAndSort,
-  getVideosList,
+  getVideoChannel,
+  getVideosList, installPlugin,
   login,
   makePutBodyRequest,
   rateVideo,
-  registerUser,
+  registerUserWithChannel,
   removeUser,
   removeVideo,
   ServerInfo,
@@ -31,8 +32,7 @@ import {
   updateMyUser,
   updateUser,
   uploadVideo,
-  userLogin,
-  registerUserWithChannel, getVideoChannel
+  userLogin
 } from '../../../../shared/extra-utils'
 import { follow } from '../../../../shared/extra-utils/server/follows'
 import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
@@ -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 () {
@@ -116,6 +118,17 @@ describe('Test users', function () {
 
       accessToken = res.body.access_token
     })
+
+    it('Should be able to login with an insensitive username', async function () {
+      const user = { username: 'RoOt', password: server.user.password }
+      const res = await login(server.url, server.client, user, 200)
+
+      const user2 = { username: 'rOoT', password: server.user.password }
+      const res2 = await login(server.url, server.client, user2, 200)
+
+      const user3 = { username: 'ROOt', password: server.user.password }
+      const res3 = await login(server.url, server.client, user3, 200)
+    })
   })
 
   describe('Upload', function () {
@@ -429,7 +442,7 @@ describe('Test users', function () {
         url: server.url,
         accessToken: accessTokenUser,
         currentPassword: 'super password',
-        newPassword: 'new password'
+        password: 'new password'
       })
       user.password = 'new password'
 
@@ -468,10 +481,11 @@ describe('Test users', function () {
       expect(user.autoPlayVideo).to.be.false
     })
 
-    it('Should be able to change the email display attribute', async function () {
+    it('Should be able to change the email attribute', async function () {
       await updateMyUser({
         url: server.url,
         accessToken: accessTokenUser,
+        currentPassword: 'new password',
         email: 'updated@example.com'
       })
 
@@ -529,7 +543,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')
@@ -538,6 +552,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
     })
   })
 
@@ -618,7 +664,7 @@ describe('Test users', function () {
 
   describe('Registering a new user', function () {
     it('Should register a new user', async function () {
-      const user = { username: 'user_15', password: 'my super password' }
+      const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' }
       const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' }
 
       await registerUserWithChannel({ url: server.url, user, channel })
@@ -633,6 +679,13 @@ describe('Test users', function () {
       accessToken = await userLogin(server, user15)
     })
 
+    it('Should have the correct display name', async function () {
+      const res = await getMyUserInformation(server.url, accessToken)
+      const user: User = res.body
+
+      expect(user.account.displayName).to.equal('super user 15')
+    })
+
     it('Should have the correct video quota', async function () {
       const res = await getMyUserInformation(server.url, accessToken)
       const user = res.body