-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
+import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models'
-} from '@shared/extra-utils'
-import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models'
-
-const expect = chai.expect
+} from '@shared/server-commands'
let abuseServer1: AdminAbuse
let abuseServer2: AdminAbuse
let commands: AbusesCommand[]
let abuseServer1: AdminAbuse
let abuseServer2: AdminAbuse
let commands: AbusesCommand[]
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
// Server 1 and server 2 follow each other
await doubleFollow(servers[0], servers[1])
- servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
- servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
+ servers[0].store.videoCreated = data.find(video => video.name === 'my super name for server 1')
+ servers[1].store.videoCreated = data.find(video => video.name === 'my super name for server 2')
expect(abuse.reporterAccount.name).to.equal('root')
expect(abuse.reporterAccount.host).to.equal(servers[0].host)
expect(abuse.reporterAccount.name).to.equal('root')
expect(abuse.reporterAccount.host).to.equal(servers[0].host)
await commands[0].report({ videoId, reason })
// We wait requests propagation
await commands[0].report({ videoId, reason })
// We wait requests propagation
expect(abuse1.reporterAccount.name).to.equal('root')
expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
expect(abuse1.reporterAccount.name).to.equal('root')
expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
expect(abuse2.reporterAccount.name).to.equal('root')
expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
expect(abuse2.reporterAccount.name).to.equal('root')
expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
- expect(body.total).to.equal(2, "wrong number of videos returned")
- expect(body.data).to.have.lengthOf(2, "wrong number of videos returned")
+ expect(body.total).to.equal(2, 'wrong number of videos returned')
+ expect(body.data).to.have.lengthOf(2, 'wrong number of videos returned')
- expect(abuse.id).to.equal(abuseServer2.id, "wrong origin server id for first video")
- expect(abuse.video.id).to.equal(abuseServer2.video.id, "wrong video id")
+ expect(abuse.id).to.equal(abuseServer2.id, 'wrong origin server id for first video')
+ expect(abuse.video.id).to.equal(abuseServer2.video.id, 'wrong video id')
await commands[0].report({ videoId: video3Id, reason: reason3 })
const reason4 = 'my super bad reason 4'
await commands[0].report({ videoId: video3Id, reason: reason3 })
const reason4 = 'my super bad reason 4'
- await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: reason4 })
+ await commands[0].report({ token: userAccessToken, videoId: servers[0].store.videoCreated.id, reason: reason4 })
const abuseVideo3 = body.data.find(a => a.video.id === video3Id)
expect(abuseVideo3).to.not.be.undefined
const abuseVideo3 = body.data.find(a => a.video.id === video3Id)
expect(abuseVideo3).to.not.be.undefined
- expect(abuseVideo3.video.countReports).to.equal(1, "wrong reports count for video 3")
- expect(abuseVideo3.video.nthReport).to.equal(1, "wrong report position in report list for video 3")
- expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
- expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
+ expect(abuseVideo3.video.countReports).to.equal(1, 'wrong reports count for video 3')
+ expect(abuseVideo3.video.nthReport).to.equal(1, 'wrong report position in report list for video 3')
+ expect(abuseVideo3.countReportsForReportee).to.equal(1, 'wrong reports count for reporter on video 3 abuse')
+ expect(abuseVideo3.countReportsForReporter).to.equal(3, 'wrong reports count for reportee on video 3 abuse')
- const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.video.id)
- expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
+ const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.videoCreated.id)
+ expect(abuseServer1.countReportsForReportee).to.equal(3, 'wrong reports count for reporter on video 1 abuse')
const reason5 = 'my super bad reason 5'
const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
const createRes = await commands[0].report({
const reason5 = 'my super bad reason 5'
const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
const createRes = await commands[0].report({
{
const abuse = body.data.find(a => a.id === createRes.abuse.id)
expect(abuse.reason).to.equals(reason5)
{
const abuse = body.data.find(a => a.id === createRes.abuse.id)
expect(abuse.reason).to.equals(reason5)
expect(abuse.video.startAt).to.equal(1, "starting timestamp doesn't match the one reported")
expect(abuse.video.endAt).to.equal(5, "ending timestamp doesn't match the one reported")
}
expect(abuse.video.startAt).to.equal(1, "starting timestamp doesn't match the one reported")
expect(abuse.video.endAt).to.equal(5, "ending timestamp doesn't match the one reported")
}
- servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
- servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
+ servers[0].store.videoCreated = await servers[0].videos.quickUpload({ name: 'server 1' })
+ servers[1].store.videoCreated = await servers[1].videos.quickUpload({ name: 'server 2' })
- await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
- await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
+ await servers[0].comments.createThread({ videoId: servers[0].store.videoCreated.id, text: 'comment server 1' })
+ await servers[1].comments.createThread({ videoId: servers[1].store.videoCreated.id, text: 'comment server 2' })
const reason = 'it is a bad comment'
await commands[0].report({ commentId: comment.id, reason })
const reason = 'it is a bad comment'
await commands[0].report({ commentId: comment.id, reason })
expect(abuse.comment.id).to.equal(comment.id)
expect(abuse.comment.text).to.equal(comment.text)
expect(abuse.comment.video.name).to.equal('server 1')
expect(abuse.comment.id).to.equal(comment.id)
expect(abuse.comment.text).to.equal(comment.text)
expect(abuse.comment.video.name).to.equal('server 1')
- expect(abuse.comment.video.id).to.equal(servers[0].store.video.id)
- expect(abuse.comment.video.uuid).to.equal(servers[0].store.video.uuid)
+ expect(abuse.comment.video.id).to.equal(servers[0].store.videoCreated.id)
+ expect(abuse.comment.video.uuid).to.equal(servers[0].store.videoCreated.uuid)
const reason = 'it is a really bad comment'
await commands[0].report({ commentId: comment.id, reason })
const reason = 'it is a really bad comment'
await commands[0].report({ commentId: comment.id, reason })
expect(abuse2.comment.id).to.equal(commentServer2.id)
expect(abuse2.comment.text).to.equal(commentServer2.text)
expect(abuse2.comment.video.name).to.equal('server 2')
expect(abuse2.comment.id).to.equal(commentServer2.id)
expect(abuse2.comment.text).to.equal(commentServer2.text)
expect(abuse2.comment.video.name).to.equal('server 2')
- function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
+ function getAccountFromServer (server: PeerTubeServer, targetName: string, targetServer: PeerTubeServer) {
- await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: 'user reason 1' })
+ await commands[0].report({ token: userAccessToken, videoId: servers[0].store.videoCreated.id, reason: 'user reason 1' })
- const body = await commands[0].report({ token: userToken, videoId: servers[0].store.video.id, reason: 'user 43 reason 1' })
+ const body = await commands[0].report({ token: userToken, videoId: servers[0].store.videoCreated.id, reason: 'user 43 reason 1' })