X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Femail.ts;h=164905651f2dd0793b7e63e0636337e6edd3477d;hb=0e9c48c2edbb3871b0ca3ccd6718f2c99f9760b6;hp=713a27143123a6e621ec2b704c40835196540e18;hpb=d9eaee3939bf2e93e5d775d32bce77842201faba;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 713a27143..164905651 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts @@ -14,11 +14,14 @@ import { unblockUser, uploadVideo, userLogin, - verifyEmail -} from '../../utils' -import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' -import { mockSmtpServer } from '../../utils/miscs/email' -import { waitJobs } from '../../utils/server/jobs' + verifyEmail, + flushTests, + killallServers, + ServerInfo, + setAccessTokensToServers +} from '../../../../shared/utils' +import { MockSmtpServer } from '../../../../shared/utils/miscs/email' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect @@ -38,7 +41,7 @@ describe('Test emails', function () { before(async function () { this.timeout(30000) - await mockSmtpServer(emails) + await MockSmtpServer.Instance.collectEmails(emails) await flushTests() @@ -86,6 +89,7 @@ describe('Test emails', function () { const email = emails[0] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('password') @@ -130,6 +134,7 @@ describe('Test emails', function () { const email = emails[1] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('admin1@example.com') expect(email['subject']).contains('abuse') @@ -137,7 +142,8 @@ describe('Test emails', function () { }) }) - 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) @@ -149,6 +155,7 @@ describe('Test emails', function () { const email = emails[2] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blocked') @@ -166,6 +173,7 @@ describe('Test emails', function () { const email = emails[3] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblocked') @@ -185,6 +193,7 @@ describe('Test emails', function () { const email = emails[4] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' blacklisted') @@ -202,6 +211,7 @@ describe('Test emails', function () { const email = emails[5] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains(' unblacklisted') @@ -221,6 +231,7 @@ describe('Test emails', function () { const email = emails[6] + expect(email['from'][0]['name']).equal('localhost:9001') expect(email['from'][0]['address']).equal('test-admin@localhost') expect(email['to'][0]['address']).equal('user_1@example.com') expect(email['subject']).contains('Verify') @@ -248,6 +259,7 @@ describe('Test emails', function () { }) after(async function () { + MockSmtpServer.Instance.kill() killallServers([ server ]) }) })