aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-01 11:08:10 +0100
committerChocobozzz <me@florianbigard.com>2018-02-01 11:08:29 +0100
commitba75d268596bc7b289bacf1cc4cb53493d6ad444 (patch)
treef631ed9a871ce078cd94afb0b4fcfc1e356944ec /server/tests/api
parent09c93c2031ce4d7dee15f247b194f21346c7e615 (diff)
downloadPeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.tar.gz
PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.tar.zst
PeerTube-ba75d268596bc7b289bacf1cc4cb53493d6ad444.zip
Send an email on video abuse report
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/email.ts36
1 files changed, 33 insertions, 3 deletions
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index 8eb9c0fa4..068e820c8 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { askResetPassword, createUser, resetPassword, runServer, userLogin, wait } from '../../utils' 5import { askResetPassword, createUser, reportVideoAbuse, resetPassword, runServer, uploadVideo, userLogin, wait } from '../../utils'
6import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' 6import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index'
7import { mockSmtpServer } from '../../utils/miscs/email' 7import { mockSmtpServer } from '../../utils/miscs/email'
8 8
@@ -11,6 +11,7 @@ const expect = chai.expect
11describe('Test emails', function () { 11describe('Test emails', function () {
12 let server: ServerInfo 12 let server: ServerInfo
13 let userId: number 13 let userId: number
14 let videoUUID: string
14 let verificationString: string 15 let verificationString: string
15 const emails: object[] = [] 16 const emails: object[] = []
16 const user = { 17 const user = {
@@ -35,8 +36,18 @@ describe('Test emails', function () {
35 await wait(5000) 36 await wait(5000)
36 await setAccessTokensToServers([ server ]) 37 await setAccessTokensToServers([ server ])
37 38
38 const res = await createUser(server.url, server.accessToken, user.username, user.password) 39 {
39 userId = res.body.user.id 40 const res = await createUser(server.url, server.accessToken, user.username, user.password)
41 userId = res.body.user.id
42 }
43
44 {
45 const attributes = {
46 name: 'my super name'
47 }
48 const res = await uploadVideo(server.url, server.accessToken, attributes)
49 videoUUID = res.body.video.uuid
50 }
40 }) 51 })
41 52
42 describe('When resetting user password', function () { 53 describe('When resetting user password', function () {
@@ -83,6 +94,25 @@ describe('Test emails', function () {
83 }) 94 })
84 }) 95 })
85 96
97 describe('When creating a video abuse', function () {
98 it('Should send the notification email', async function () {
99 this.timeout(10000)
100
101 const reason = 'my super bad reason'
102 await reportVideoAbuse(server.url, server.accessToken, videoUUID, reason)
103
104 await wait(3000)
105 expect(emails).to.have.lengthOf(2)
106
107 const email = emails[1]
108
109 expect(email['from'][0]['address']).equal('test-admin@localhost')
110 expect(email['to'][0]['address']).equal('admin1@example.com')
111 expect(email['subject']).contains('abuse')
112 expect(email['text']).contains(videoUUID)
113 })
114 })
115
86 after(async function () { 116 after(async function () {
87 killallServers([ server ]) 117 killallServers([ server ])
88 118