import * as chai from 'chai'
import 'mocha'
-import { User, UserRole } from '../../../../shared/index'
+import { User, UserRole, Video } from '../../../../shared/index'
import {
blockUser,
+ cleanupTests,
createUser,
deleteMe,
- flushTests,
+ flushAndRunServer,
getAccountRatings,
getBlacklistedVideosList,
getMyUserInformation,
getUserInformation,
getUsersList,
getUsersListPaginationAndSort,
- getVideosList,
- killallServers,
+ getVideoChannel,
+ getVideosList, installPlugin,
login,
makePutBodyRequest,
rateVideo,
- registerUser,
+ registerUserWithChannel,
removeUser,
removeVideo,
- runServer,
ServerInfo,
testImage,
unblockUser,
updateUser,
uploadVideo,
userLogin
-} from '../../../../shared/utils'
-import { follow } from '../../../../shared/utils/server/follows'
-import { setAccessTokensToServers } from '../../../../shared/utils/users/login'
-import { getMyVideos } from '../../../../shared/utils/videos/videos'
+} from '../../../../shared/extra-utils'
+import { follow } from '../../../../shared/extra-utils/server/follows'
+import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
+import { getMyVideos } from '../../../../shared/extra-utils/videos/videos'
import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
const expect = chai.expect
before(async function () {
this.timeout(30000)
-
- await flushTests()
- server = await runServer(1)
+ server = await flushAndRunServer(1)
await setAccessTokensToServers([ server ])
+
+ await installPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-theme-background-red' })
})
describe('OAuth client', 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 () {
const videos = res.body.data
expect(videos).to.have.lengthOf(1)
- expect(videos[ 0 ].name).to.equal('super user video')
+ const video: Video = videos[ 0 ]
+ expect(video.name).to.equal('super user video')
+ expect(video.thumbnailPath).to.not.be.null
+ expect(video.previewPath).to.not.be.null
})
})
const rootUser = users[ 1 ]
expect(rootUser.username).to.equal('root')
- expect(rootUser.email).to.equal('admin1@example.com')
+ expect(rootUser.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(user.nsfwPolicy).to.equal('display')
userId = user.id
const user = users[ 0 ]
expect(user.username).to.equal('root')
- expect(user.email).to.equal('admin1@example.com')
+ expect(user.email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(user.roleLabel).to.equal('Administrator')
expect(user.nsfwPolicy).to.equal('display')
})
expect(users.length).to.equal(2)
expect(users[ 0 ].username).to.equal('root')
- expect(users[ 0 ].email).to.equal('admin1@example.com')
+ expect(users[ 0 ].email).to.equal('admin' + server.internalServerNumber + '@example.com')
expect(users[ 0 ].nsfwPolicy).to.equal('display')
expect(users[ 1 ].username).to.equal('user_1')
url: server.url,
accessToken: accessTokenUser,
currentPassword: 'super password',
- newPassword: 'new password'
+ password: 'new password'
})
user.password = 'new password'
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'
})
})
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')
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
})
})
describe('Registering a new user', function () {
it('Should register a new user', async function () {
- await registerUser(server.url, 'user_15', '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 })
})
it('Should be able to login with this registered user', async 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
expect(user.videoQuota).to.equal(5 * 1024 * 1024)
})
+ it('Should have created the channel', async function () {
+ const res = await getVideoChannel(server.url, 'my_user_15_channel')
+
+ expect(res.body.displayName).to.equal('my channel rocks')
+ })
+
it('Should remove me', async function () {
{
const res = await getUsersList(server.url, server.accessToken)
})
after(async function () {
- killallServers([ server ])
-
- // Keep the logs if the test failed
- if (this[ 'ok' ]) {
- await flushTests()
- }
+ await cleanupTests([ server ])
})
})