mirror of https://github.com/Chocobozzz/PeerTube
				
				
				
			Add tests for video-abuse persistence after video deletion
							parent
							
								
									efa012edad
								
							
						
					
					
						commit
						197876ea87
					
				|  | @ -143,7 +143,8 @@ export enum ScopeNames { | |||
|                 'SELECT count(DISTINCT "videoAbuse"."id") ' + | ||||
|                 'FROM "videoAbuse" ' + | ||||
|                 `WHERE CAST("deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) = "Video->VideoChannel"."accountId" ` + | ||||
|                    `OR CAST("deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) = CAST("VideoAbuseModel"."deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) ` + | ||||
|                    `OR CAST("deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) = ` + | ||||
|                       `CAST("VideoAbuseModel"."deletedVideo"->'channel'->'ownerAccount'->>'id' AS INTEGER) ` + | ||||
|               ')' | ||||
|             ), | ||||
|             'countReportsForReportee__deletedVideo' | ||||
|  |  | |||
|  | @ -13,7 +13,8 @@ import { | |||
|   ServerInfo, | ||||
|   setAccessTokensToServers, | ||||
|   updateVideoAbuse, | ||||
|   uploadVideo | ||||
|   uploadVideo, | ||||
|   removeVideo | ||||
| } from '../../../../shared/extra-utils/index' | ||||
| import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | ||||
| import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||||
|  | @ -97,6 +98,11 @@ describe('Test video abuses', function () { | |||
|     expect(abuse.reporterAccount.name).to.equal('root') | ||||
|     expect(abuse.reporterAccount.host).to.equal('localhost:' + servers[0].port) | ||||
|     expect(abuse.video.id).to.equal(servers[0].video.id) | ||||
|     expect(abuse.video.channel).to.exist | ||||
|     expect(abuse.count).to.equal(1) | ||||
|     expect(abuse.nth).to.equal(1) | ||||
|     expect(abuse.countReportsForReporter).to.equal(1) | ||||
|     expect(abuse.countReportsForReportee).to.equal(1) | ||||
| 
 | ||||
|     const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | ||||
|     expect(res2.body.total).to.equal(0) | ||||
|  | @ -128,6 +134,8 @@ describe('Test video abuses', function () { | |||
|     expect(abuse1.state.id).to.equal(VideoAbuseState.PENDING) | ||||
|     expect(abuse1.state.label).to.equal('Pending') | ||||
|     expect(abuse1.moderationComment).to.be.null | ||||
|     expect(abuse1.count).to.equal(1) | ||||
|     expect(abuse1.nth).to.equal(1) | ||||
| 
 | ||||
|     const abuse2: VideoAbuse = res1.body.data[1] | ||||
|     expect(abuse2.reason).to.equal('my super bad reason 2') | ||||
|  | @ -221,6 +229,26 @@ describe('Test video abuses', function () { | |||
|     } | ||||
|   }) | ||||
| 
 | ||||
|   it('Should keep the video abuse when deleting the video', async function () { | ||||
|     this.timeout(10000) | ||||
| 
 | ||||
|     await removeVideo(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid) | ||||
| 
 | ||||
|     await waitJobs(servers) | ||||
| 
 | ||||
|     { | ||||
|       const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | ||||
|       expect(res.body.total).to.equal(2) | ||||
|       expect(res.body.data.length).to.equal(2) | ||||
|       expect(res.body.data[0].id).to.equal(abuseServer2.id) | ||||
| 
 | ||||
|       const abuse: VideoAbuse = res.body.data[1] | ||||
|       expect(abuse.video.deleted).to.be.true | ||||
|       expect(abuse.video.id).to.equal(abuseServer2.video.id) | ||||
|       expect(abuse.video.channel).to.exist | ||||
|     } | ||||
|   }) | ||||
| 
 | ||||
|   it('Should delete the video abuse', async function () { | ||||
|     this.timeout(10000) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Rigel Kent
						Rigel Kent