aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/email.ts48
1 files changed, 47 insertions, 1 deletions
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index 4be013c84..65d6a759f 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -2,7 +2,17 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { askResetPassword, createUser, reportVideoAbuse, resetPassword, runServer, uploadVideo, userLogin, wait } from '../../utils' 5import {
6 askResetPassword,
7 blockUser,
8 createUser,
9 reportVideoAbuse,
10 resetPassword,
11 runServer,
12 unblockUser,
13 uploadVideo,
14 userLogin
15} from '../../utils'
6import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' 16import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index'
7import { mockSmtpServer } from '../../utils/miscs/email' 17import { mockSmtpServer } from '../../utils/miscs/email'
8import { waitJobs } from '../../utils/server/jobs' 18import { waitJobs } from '../../utils/server/jobs'
@@ -112,6 +122,42 @@ describe('Test emails', function () {
112 }) 122 })
113 }) 123 })
114 124
125 describe('When blocking/unblocking user', async function () {
126 it('Should send the notification email when blocking a user', async function () {
127 this.timeout(10000)
128
129 const reason = 'my super bad reason'
130 await blockUser(server.url, userId, server.accessToken, 204, reason)
131
132 await waitJobs(server)
133 expect(emails).to.have.lengthOf(3)
134
135 const email = emails[2]
136
137 expect(email['from'][0]['address']).equal('test-admin@localhost')
138 expect(email['to'][0]['address']).equal('user_1@example.com')
139 expect(email['subject']).contains(' blocked')
140 expect(email['text']).contains(' blocked')
141 expect(email['text']).contains(reason)
142 })
143
144 it('Should send the notification email when unblocking a user', async function () {
145 this.timeout(10000)
146
147 await unblockUser(server.url, userId, server.accessToken, 204)
148
149 await waitJobs(server)
150 expect(emails).to.have.lengthOf(4)
151
152 const email = emails[3]
153
154 expect(email['from'][0]['address']).equal('test-admin@localhost')
155 expect(email['to'][0]['address']).equal('user_1@example.com')
156 expect(email['subject']).contains(' unblocked')
157 expect(email['text']).contains(' unblocked')
158 })
159 })
160
115 after(async function () { 161 after(async function () {
116 killallServers([ server ]) 162 killallServers([ server ])
117 }) 163 })