createUser,
deleteVideoChannel,
flushTests,
- getAccountVideoChannelsList,
+ getAccountVideoChannelsList, getMyUserInformation,
getVideoChannelsList,
immutableAssign,
killallServers,
} from '../../utils'
import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
import { getAccountsList } from '../../utils/users/accounts'
+import { User } from '../../../../shared/models/users'
const expect = chai.expect
const accountPath = '/api/v1/accounts/'
let server: ServerInfo
let accessTokenUser: string
+ let accountUUID: string
+ let videoChannelUUID: string
// ---------------------------------------------------------------
username: 'fake',
password: 'fake_password'
}
- await createUser(server.url, server.accessToken, user.username, user.password)
- accessTokenUser = await userLogin(server, user)
+
+ {
+ await createUser(server.url, server.accessToken, user.username, user.password)
+ accessTokenUser = await userLogin(server, user)
+ }
+
+ {
+ const res = await getMyUserInformation(server.url, server.accessToken)
+ const user: User = res.body
+ accountUUID = user.account.uuid
+ videoChannelUUID = user.videoChannels[0].uuid
+ }
})
describe('When listing a video channels', function () {
})
describe('When adding a video channel', function () {
- let path: string
-
const baseCorrectParams = {
name: 'hello',
description: 'super description',
support: 'super support text'
}
+ let path: string
before(async function () {
- const res = await getAccountsList(server.url)
- const accountId = res.body.data[0].id
- path = accountPath + accountId + '/video-channels'
+ path = accountPath + accountUUID + '/video-channels'
})
it('Should fail with a non authenticated user', async function () {
})
describe('When updating a video channel', function () {
- let path: string
-
const baseCorrectParams = {
name: 'hello',
description: 'super description'
}
+ let path: string
before(async function () {
- const res1 = await getVideoChannelsList(server.url, 0, 1)
- const videoChannelId = res1.body.data[0].id
-
- const res2 = await getAccountsList(server.url)
- const accountId = res2.body.data[0].id
-
- path = accountPath + accountId + '/video-channels/' + videoChannelId
+ path = accountPath + accountUUID + '/video-channels/' + videoChannelUUID
})
it('Should fail with a non authenticated user', async function () {
describe('When getting a video channel', function () {
let basePath: string
- let videoChannelId: number
before(async function () {
- const res1 = await getVideoChannelsList(server.url, 0, 1)
- videoChannelId = res1.body.data[0].id
-
- const res2 = await getAccountsList(server.url)
- const accountId = res2.body.data[0].id
-
- basePath = accountPath + accountId + '/video-channels'
+ basePath = accountPath + accountUUID + '/video-channels'
})
it('Should return the list of the video channels with nothing', async function () {
it('Should succeed with the correct parameters', async function () {
await makeGetRequest({
url: server.url,
- path: basePath + '/' + videoChannelId,
+ path: basePath + '/' + videoChannelUUID,
statusCodeExpected: 200
})
})
})
describe('When deleting a video channel', function () {
- let videoChannelId: number
- let accountId: number
-
- before(async function () {
- const res1 = await getVideoChannelsList(server.url, 0, 1)
- videoChannelId = res1.body.data[0].id
-
- const res2 = await getAccountsList(server.url)
- accountId = res2.body.data[0].id
- })
-
it('Should fail with a non authenticated user', async function () {
- await deleteVideoChannel(server.url, 'coucou', accountId, videoChannelId, 401)
+ await deleteVideoChannel(server.url, 'coucou', accountUUID, videoChannelUUID, 401)
})
it('Should fail with another authenticated user', async function () {
- await deleteVideoChannel(server.url, accessTokenUser, accountId, videoChannelId, 403)
+ await deleteVideoChannel(server.url, accessTokenUser, accountUUID, videoChannelUUID, 403)
})
it('Should fail with an unknown account id', async function () {
- await deleteVideoChannel(server.url, server.accessToken, 454554,videoChannelId, 404)
+ await deleteVideoChannel(server.url, server.accessToken, 454554,videoChannelUUID, 404)
})
it('Should fail with an unknown video channel id', async function () {
- await deleteVideoChannel(server.url, server.accessToken, accountId,454554, 404)
+ await deleteVideoChannel(server.url, server.accessToken, accountUUID,454554, 404)
})
it('Should succeed with the correct parameters', async function () {
- await deleteVideoChannel(server.url, server.accessToken, accountId, videoChannelId)
+ await deleteVideoChannel(server.url, server.accessToken, accountUUID, videoChannelUUID)
})
it('Should fail to delete the last user video channel', async function () {
const res = await getVideoChannelsList(server.url, 0, 1)
- videoChannelId = res.body.data[0].id
+ const lastVideoChannelUUID = res.body.data[0].uuid
- await deleteVideoChannel(server.url, server.accessToken, accountId, videoChannelId, 409)
+ await deleteVideoChannel(server.url, server.accessToken, accountUUID, lastVideoChannelUUID, 409)
})
})