X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fcontact-form.ts;h=55004020fc256f445c94d6a26f13d3e096c2e84b;hb=9ce3d3027ed7253fbd4fe46787eda58c51549444;hp=2407ac0b50d9ac69ee8f441eebb1d60529ca7d8a;hpb=a4101923e699e49ceb9ff36e971c75417fafc9f0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts index 2407ac0b5..55004020f 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/server/tests/api/check-params/contact-form.ts @@ -7,18 +7,18 @@ import { immutableAssign, killallServers, reRunServer, - runServer, + flushAndRunServer, ServerInfo, - setAccessTokensToServers -} from '../../../../shared/utils' + setAccessTokensToServers, cleanupTests +} from '../../../../shared/extra-utils' import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination -} from '../../../../shared/utils/requests/check-api-params' -import { getAccount } from '../../../../shared/utils/users/accounts' -import { sendContactForm } from '../../../../shared/utils/server/contact-form' -import { MockSmtpServer } from '../../../../shared/utils/miscs/email' +} from '../../../../shared/extra-utils/requests/check-api-params' +import { getAccount } from '../../../../shared/extra-utils/users/accounts' +import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form' +import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' describe('Test contact form API validators', function () { let server: ServerInfo @@ -28,17 +28,17 @@ describe('Test contact form API validators', function () { fromEmail: 'toto@example.com', body: 'Hello, how are you?' } + let emailPort: number // --------------------------------------------------------------- before(async function () { this.timeout(60000) - await flushTests() - await MockSmtpServer.Instance.collectEmails(emails) + emailPort = await MockSmtpServer.Instance.collectEmails(emails) // Email is disabled - server = await runServer(1) + server = await flushAndRunServer(1) }) it('Should not accept a contact form if emails are disabled', async function () { @@ -46,18 +46,22 @@ describe('Test contact form API validators', function () { }) it('Should not accept a contact form if it is disabled in the configuration', async function () { + this.timeout(10000) + killallServers([ server ]) // Contact form is disabled - await reRunServer(server, { smtp: { hostname: 'localhost' }, contact_form: { enabled: false } }) + await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } }) await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 409 })) }) it('Should not accept a contact form if from email is invalid', async function () { + this.timeout(10000) + killallServers([ server ]) // Email & contact form enabled - await reRunServer(server, { smtp: { hostname: 'localhost' } }) + await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort } }) await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail' })) await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail@' })) @@ -82,11 +86,7 @@ describe('Test contact form API validators', function () { after(async function () { MockSmtpServer.Instance.kill() - killallServers([ server ]) - // Keep the logs if the test failed - if (this['ok']) { - await flushTests() - } + // await cleanupTests([ server ]) }) })