import 'mocha'
import { AccountBlock, ServerBlock, Video } from '../../../../shared/index'
import {
+ cleanupTests,
createUser,
doubleFollow,
flushAndRunMultipleServers,
ServerInfo,
uploadVideo,
userLogin
-} from '../../utils/index'
-import { setAccessTokensToServers } from '../../utils/users/login'
-import { getVideosListWithToken } from '../../utils/videos/videos'
+} from '../../../../shared/extra-utils/index'
+import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
+import { getVideosListWithToken, getVideosList } from '../../../../shared/extra-utils/videos/videos'
import {
addVideoCommentReply,
addVideoCommentThread,
getVideoCommentThreads,
getVideoThreadComments
-} from '../../utils/videos/video-comments'
-import { waitJobs } from '../../utils/server/jobs'
+} from '../../../../shared/extra-utils/videos/video-comments'
+import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
import {
addAccountToAccountBlocklist,
removeAccountFromServerBlocklist,
removeServerFromAccountBlocklist,
removeServerFromServerBlocklist
-} from '../../utils/users/blocklist'
+} from '../../../../shared/extra-utils/users/blocklist'
const expect = chai.expect
async function checkAllVideos (url: string, token: string) {
- const res = await getVideosListWithToken(url, token)
+ {
+ const res = await getVideosListWithToken(url, token)
- expect(res.body.data).to.have.lengthOf(4)
+ expect(res.body.data).to.have.lengthOf(4)
+ }
+
+ {
+ const res = await getVideosList(url)
+
+ expect(res.body.data).to.have.lengthOf(4)
+ }
}
async function checkAllComments (url: string, token: string, videoUUID: string) {
before(async function () {
this.timeout(60000)
- await flushTests()
-
servers = await flushAndRunMultipleServers(2)
await setAccessTokensToServers(servers)
{
const user = { username: 'user1', password: 'password' }
- await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
+ await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
userToken1 = await userLogin(servers[0], user)
await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
{
const user = { username: 'moderator', password: 'password' }
- await createUser(servers[0].url, servers[0].accessToken, user.username, user.password)
+ await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
userModeratorToken = await userLogin(servers[0], user)
}
{
const user = { username: 'user2', password: 'password' }
- await createUser(servers[1].url, servers[1].accessToken, user.username, user.password)
+ await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
userToken2 = await userLogin(servers[1], user)
await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
})
it('Should block a remote account', async function () {
- await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002')
+ await addAccountToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
expect(block.byAccount.name).to.equal('root')
expect(block.blockedAccount.displayName).to.equal('user2')
expect(block.blockedAccount.name).to.equal('user2')
- expect(block.blockedAccount.host).to.equal('localhost:9002')
+ expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
}
{
expect(block.byAccount.name).to.equal('root')
expect(block.blockedAccount.displayName).to.equal('user1')
expect(block.blockedAccount.name).to.equal('user1')
- expect(block.blockedAccount.host).to.equal('localhost:9001')
+ expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
}
})
it('Should unblock the remote account', async function () {
- await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002')
+ await removeAccountFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should display its videos', async function () {
})
it('Should block a remote server', async function () {
- await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002')
+ await addServerToAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
const block = blocks[ 0 ]
expect(block.byAccount.displayName).to.equal('root')
expect(block.byAccount.name).to.equal('root')
- expect(block.blockedServer.host).to.equal('localhost:9002')
+ expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
})
it('Should unblock the remote server', async function () {
- await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002')
+ await removeServerFromAccountBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
})
it('Should display its videos', function () {
})
it('Should block a remote account', async function () {
- await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002')
+ await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
expect(block.byAccount.name).to.equal('peertube')
expect(block.blockedAccount.displayName).to.equal('user2')
expect(block.blockedAccount.name).to.equal('user2')
- expect(block.blockedAccount.host).to.equal('localhost:9002')
+ expect(block.blockedAccount.host).to.equal('localhost:' + servers[1].port)
}
{
expect(block.byAccount.name).to.equal('peertube')
expect(block.blockedAccount.displayName).to.equal('user1')
expect(block.blockedAccount.name).to.equal('user1')
- expect(block.blockedAccount.host).to.equal('localhost:9001')
+ expect(block.blockedAccount.host).to.equal('localhost:' + servers[0].port)
}
})
it('Should unblock the remote account', async function () {
- await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:9002')
+ await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'user2@localhost:' + servers[1].port)
})
it('Should display its videos', async function () {
})
it('Should block a remote server', async function () {
- await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002')
+ await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
})
it('Should hide its videos', async function () {
for (const token of [ userModeratorToken, servers[ 0 ].accessToken ]) {
- const res = await getVideosListWithToken(servers[ 0 ].url, token)
+ const res1 = await getVideosList(servers[ 0 ].url)
+ const res2 = await getVideosListWithToken(servers[ 0 ].url, token)
- const videos: Video[] = res.body.data
- expect(videos).to.have.lengthOf(2)
+ for (const res of [ res1, res2 ]) {
+ const videos: Video[] = res.body.data
+ expect(videos).to.have.lengthOf(2)
- const v1 = videos.find(v => v.name === 'video user 2')
- const v2 = videos.find(v => v.name === 'video server 2')
+ const v1 = videos.find(v => v.name === 'video user 2')
+ const v2 = videos.find(v => v.name === 'video server 2')
- expect(v1).to.be.undefined
- expect(v2).to.be.undefined
+ expect(v1).to.be.undefined
+ expect(v2).to.be.undefined
+ }
}
})
const block = blocks[ 0 ]
expect(block.byAccount.displayName).to.equal('peertube')
expect(block.byAccount.name).to.equal('peertube')
- expect(block.blockedServer.host).to.equal('localhost:9002')
+ expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port)
})
it('Should unblock the remote server', async function () {
- await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:9002')
+ await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, 'localhost:' + servers[1].port)
})
it('Should list all videos', async function () {
})
after(async function () {
- killallServers(servers)
-
- // Keep the logs if the test failed
- if (this[ 'ok' ]) {
- await flushTests()
- }
+ await cleanupTests(servers)
})
})