X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Femail.ts;h=5929a3adbe6fc004f6d4da0420abb6e356d0a927;hb=fd822c1c699fb89bb1c3218e047e1d842bc1ba1a;hp=f96c57b6636721360a23e2d1145d7fe2602c413b;hpb=89ada4e26ca1df8ff0dd02acda1d1661f121a294;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index f96c57b66..5929a3adb 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts @@ -7,21 +7,21 @@ import { askResetPassword, askSendVerifyEmail, blockUser, - createUser, removeVideoFromBlacklist, + cleanupTests, + createUser, + flushAndRunServer, + removeVideoFromBlacklist, reportVideoAbuse, resetPassword, - runServer, + ServerInfo, + setAccessTokensToServers, unblockUser, uploadVideo, userLogin, - verifyEmail, - flushTests, - killallServers, - ServerInfo, - setAccessTokensToServers -} from '../../../../shared/utils' -import { MockSmtpServer } from '../../../../shared/utils/miscs/email' -import { waitJobs } from '../../../../shared/utils/server/jobs' + verifyEmail +} from '../../../../shared/extra-utils' +import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' +import { waitJobs } from '../../../../shared/extra-utils/server/jobs' const expect = chai.expect @@ -37,24 +37,24 @@ describe('Test emails', function () { username: 'user_1', password: 'super_password' } + let emailPort: number before(async function () { this.timeout(30000) - await MockSmtpServer.Instance.collectEmails(emails) - - await flushTests() + emailPort = await MockSmtpServer.Instance.collectEmails(emails) const overrideConfig = { smtp: { - hostname: 'localhost' + hostname: 'localhost', + port: emailPort } } - server = await runServer(1, overrideConfig) + server = await flushAndRunServer(1, overrideConfig) await setAccessTokensToServers([ server ]) { - const res = await createUser(server.url, server.accessToken, user.username, user.password) + const res = await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password }) userId = res.body.user.id userAccessToken = await userLogin(server, user) @@ -89,6 +89,7 @@ describe('Test emails', function () { const email = emails[0] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('password') @@ -133,14 +134,16 @@ describe('Test emails', function () { const email = emails[1] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') - expect(email['to'][0]['address']).equal('admin1@example.com') + expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com') expect(email['subject']).contains('abuse') expect(email['text']).contains(videoUUID) }) }) - describe('When blocking/unblocking user', async function () { + describe('When blocking/unblocking user', function () { + it('Should send the notification email when blocking a user', async function () { this.timeout(10000) @@ -152,6 +155,7 @@ describe('Test emails', function () { const email = emails[2] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blocked') @@ -169,6 +173,7 @@ describe('Test emails', function () { const email = emails[3] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblocked') @@ -188,6 +193,7 @@ describe('Test emails', function () { const email = emails[4] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blacklisted') @@ -205,6 +211,7 @@ describe('Test emails', function () { const email = emails[5] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblacklisted') @@ -224,6 +231,7 @@ describe('Test emails', function () { const email = emails[6] + expect(email['from'][0]['name']).equal('localhost:' + server.port) expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('Verify') @@ -252,6 +260,7 @@ describe('Test emails', function () { after(async function () { MockSmtpServer.Instance.kill() - killallServers([ server ]) + + await cleanupTests([ server ]) }) })