]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/check-params/contact-form.ts
Fix theater mode
[github/Chocobozzz/PeerTube.git] / server / tests / api / check-params / contact-form.ts
index 6c7781f13c0e2727e8475a24f1cdcf289f585447..b2126b9b09981b7d80771d409a1ea743d86a2f83 100644 (file)
@@ -1,22 +1,8 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 
-import {
-  flushTests,
-  immutableAssign,
-  killallServers,
-  reRunServer,
-  flushAndRunServer,
-  ServerInfo,
-  setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import {
-  checkBadCountPagination,
-  checkBadSortPagination,
-  checkBadStartPagination
-} from '../../../../shared/extra-utils/requests/check-api-params'
-import { getAccount } from '../../../../shared/extra-utils/users/accounts'
+import { cleanupTests, flushAndRunServer, immutableAssign, killallServers, reRunServer, ServerInfo } from '../../../../shared/extra-utils'
 import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'
 import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
 
@@ -26,15 +12,17 @@ describe('Test contact form API validators', function () {
   const defaultBody = {
     fromName: 'super name',
     fromEmail: 'toto@example.com',
+    subject: 'my subject',
     body: 'Hello, how are you?'
   }
+  let emailPort: number
 
   // ---------------------------------------------------------------
 
   before(async function () {
     this.timeout(60000)
 
-    await MockSmtpServer.Instance.collectEmails(emails)
+    emailPort = await MockSmtpServer.Instance.collectEmails(emails)
 
     // Email is disabled
     server = await flushAndRunServer(1)
@@ -50,7 +38,7 @@ describe('Test contact form API validators', function () {
     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 }))
   })
 
@@ -60,7 +48,7 @@ describe('Test contact form API validators', function () {
     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@' }))
@@ -83,8 +71,9 @@ describe('Test contact form API validators', function () {
     await sendContactForm(immutableAssign(defaultBody, { url: server.url }))
   })
 
-  after(function () {
+  after(async function () {
     MockSmtpServer.Instance.kill()
-    killallServers([ server ])
+
+    await cleanupTests([ server ])
   })
 })