X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fvideo-comments.ts;h=b6b00230726aa3e419b6472acd05aa6028f770b8;hb=65e6e2602c0d5521f3a6740f7469bb92830ecb53;hp=18a86beadaba8b2fb4fb77c7a2321a0db74139f9;hpb=f1273314593a4a7dc7ec9594ce0c6c3ae8f62b34;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index 18a86bead..b6b002307 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' -import { VideoComment, VideoCommentAdmin, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' +import * as chai from 'chai' +import { VideoComment, VideoCommentAdmin, VideoCommentThreadTree } from '@shared/models' import { cleanupTests, testImage } from '../../../../shared/extra-utils' import { createUser, @@ -22,7 +22,6 @@ import { getVideoCommentThreads, getVideoThreadComments } from '../../../../shared/extra-utils/videos/video-comments' -import { isLocalLiveVideoAccepted } from '@server/lib/moderation' const expect = chai.expect @@ -67,6 +66,7 @@ describe('Test video comments', function () { const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) expect(res.body.total).to.equal(0) + expect(res.body.totalNotDeletedComments).to.equal(0) expect(res.body.data).to.be.an('array') expect(res.body.data).to.have.lengthOf(0) }) @@ -94,6 +94,7 @@ describe('Test video comments', function () { const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5) expect(res.body.total).to.equal(1) + expect(res.body.totalNotDeletedComments).to.equal(1) expect(res.body.data).to.be.an('array') expect(res.body.data).to.have.lengthOf(1) @@ -172,6 +173,7 @@ describe('Test video comments', function () { const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') expect(res.body.total).to.equal(3) + expect(res.body.totalNotDeletedComments).to.equal(6) expect(res.body.data).to.be.an('array') expect(res.body.data).to.have.lengthOf(3) @@ -186,26 +188,35 @@ describe('Test video comments', function () { it('Should delete a reply', async function () { await deleteVideoComment(server.url, server.accessToken, videoId, replyToDeleteId) - const res = await getVideoThreadComments(server.url, videoUUID, threadId) - - const tree: VideoCommentThreadTree = res.body - expect(tree.comment.text).equal('my super first comment') - expect(tree.children).to.have.lengthOf(2) - - const firstChild = tree.children[0] - expect(firstChild.comment.text).to.equal('my super answer to thread 1') - expect(firstChild.children).to.have.lengthOf(1) + { + const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5, 'createdAt') - const childOfFirstChild = firstChild.children[0] - expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') - expect(childOfFirstChild.children).to.have.lengthOf(0) + expect(res.body.total).to.equal(3) + expect(res.body.totalNotDeletedComments).to.equal(5) + } - const deletedChildOfFirstChild = tree.children[1] - expect(deletedChildOfFirstChild.comment.text).to.equal('') - expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true - expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null - expect(deletedChildOfFirstChild.comment.account).to.be.null - expect(deletedChildOfFirstChild.children).to.have.lengthOf(0) + { + const res = await getVideoThreadComments(server.url, videoUUID, threadId) + + const tree: VideoCommentThreadTree = res.body + expect(tree.comment.text).equal('my super first comment') + expect(tree.children).to.have.lengthOf(2) + + const firstChild = tree.children[0] + expect(firstChild.comment.text).to.equal('my super answer to thread 1') + expect(firstChild.children).to.have.lengthOf(1) + + const childOfFirstChild = firstChild.children[0] + expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1') + expect(childOfFirstChild.children).to.have.lengthOf(0) + + const deletedChildOfFirstChild = tree.children[1] + expect(deletedChildOfFirstChild.comment.text).to.equal('') + expect(deletedChildOfFirstChild.comment.isDeleted).to.be.true + expect(deletedChildOfFirstChild.comment.deletedAt).to.not.be.null + expect(deletedChildOfFirstChild.comment.account).to.be.null + expect(deletedChildOfFirstChild.children).to.have.lengthOf(0) + } }) it('Should delete a complete thread', async function () { @@ -220,7 +231,7 @@ describe('Test video comments', function () { expect(res.body.data[0].isDeleted).to.be.true expect(res.body.data[0].deletedAt).to.not.be.null expect(res.body.data[0].account).to.be.null - expect(res.body.data[0].totalReplies).to.equal(3) + expect(res.body.data[0].totalReplies).to.equal(2) expect(res.body.data[1].text).to.equal('super thread 2') expect(res.body.data[1].totalReplies).to.equal(0) expect(res.body.data[2].text).to.equal('super thread 3')