X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fmoderation%2Fabuses.ts;h=d9c164c439a3ef356b0d4f486f0c309e74ebd36e;hb=863477173efa82a4412d2e522aa46462249f9199;hp=0c3bed3e7e01dc472f9cccb1f255f2960b67a929;hpb=f332d502d5d6a6c7ab62199c8b45f24e488f48e7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index 0c3bed3e7..d9c164c43 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' +import { expect } from 'chai' +import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' import { AbusesCommand, cleanupTests, @@ -9,11 +9,10 @@ import { doubleFollow, PeerTubeServer, setAccessTokensToServers, + setDefaultAccountAvatar, + setDefaultChannelAvatar, waitJobs } from '@shared/server-commands' -import { AbuseMessage, AbusePredefinedReasonsString, AbuseState, AdminAbuse, UserAbuse } from '@shared/models' - -const expect = chai.expect describe('Test abuses', function () { let servers: PeerTubeServer[] = [] @@ -27,8 +26,9 @@ describe('Test abuses', function () { // Run servers servers = await createMultipleServers(2) - // Get the access tokens await setAccessTokensToServers(servers) + await setDefaultChannelAvatar(servers) + await setDefaultAccountAvatar(servers) // Server 1 and server 2 follow each other await doubleFollow(servers[0], servers[1]) @@ -165,7 +165,7 @@ describe('Test abuses', function () { expect(abuse2.reporterAccount.name).to.equal('root') expect(abuse2.reporterAccount.host).to.equal(servers[0].host) - expect(abuse2.video.id).to.equal(servers[1].store.videoCreated.id) + expect(abuse2.video.uuid).to.equal(servers[1].store.videoCreated.uuid) expect(abuse2.comment).to.be.null @@ -257,12 +257,12 @@ describe('Test abuses', function () { await waitJobs(servers) const body = await commands[1].getAdminList() - 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') const abuse = body.data[0] - 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') expect(abuse.video.channel).to.exist expect(abuse.video.deleted).to.be.true }) @@ -296,13 +296,13 @@ describe('Test abuses', function () { 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.videoCreated.id) - expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") + expect(abuseServer1.countReportsForReportee).to.equal(3, 'wrong reports count for reporter on video 1 abuse') } }) @@ -324,7 +324,7 @@ describe('Test abuses', function () { { const abuse = body.data.find(a => a.id === createRes.abuse.id) expect(abuse.reason).to.equals(reason5) - expect(abuse.predefinedReasons).to.deep.equals(predefinedReasons5, "predefined reasons do not match the one reported") + expect(abuse.predefinedReasons).to.deep.equals(predefinedReasons5, 'predefined reasons do not 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") } @@ -527,7 +527,7 @@ describe('Test abuses', function () { it('Should keep the comment abuse when deleting the comment', async function () { this.timeout(10000) - const commentServer2 = await getComment(servers[0], servers[1].store.videoCreated.id) + const commentServer2 = await getComment(servers[0], servers[1].store.videoCreated.uuid) await servers[0].comments.delete({ videoId: servers[1].store.videoCreated.uuid, commentId: commentServer2.id })