- describe('My videos & quotas', function () {
-
- it('Should be able to upload a video with this user', async function () {
- this.timeout(10000)
-
- const attributes = {
- name: 'super user video',
- 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 () {
- const quota = await server.users.getMyQuotaUsed({ token: userToken })
- expect(quota.videoQuotaUsed).to.equal(218910)
-
- const { data } = await server.users.list()
- const tmpUser = data.find(u => u.username === user.username)
- expect(tmpUser.videoQuotaUsed).to.equal(218910)
- })
-
- it('Should be able to list my videos', async function () {
- const { total, data } = await server.videos.listMyVideos({ token: userToken })
- 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
- })
-
- 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' })
- expect(total).to.equal(1)
- expect(data).to.have.lengthOf(1)
- }
-
- {
- const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' })
- expect(total).to.equal(0)
- expect(data).to.have.lengthOf(0)
- }
- })
-
- it('Should disable webtorrent, enable HLS, and update my quota', async function () {
- this.timeout(160000)
-
- {
- const config = await server.config.getCustomConfig()
- config.transcoding.webtorrent.enabled = false
- config.transcoding.hls.enabled = true
- config.transcoding.enabled = true
- await server.config.updateCustomSubConfig({ newConfig: config })
- }
-
- {
- const attributes = {
- name: 'super user video 2',
- fixture: 'video_short.webm'
- }
- await server.videos.upload({ token: userToken, attributes })
-
- await waitJobs([ server ])
- }
-
- {
- const data = await server.users.getMyQuotaUsed({ token: userToken })
- expect(data.videoQuotaUsed).to.be.greaterThan(220000)
- }
- })
- })
-