]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/server/contact-form.ts
Merge branch 'feature/SO035' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / api / server / contact-form.ts
index f0905bb3b1e7b87f046691eb4635023c5965de5d..3252180085da206670ecae5cd763b796a79d064c 100644 (file)
@@ -1,20 +1,17 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { expect } from 'chai'
+import { MockSmtpServer } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
 import {
   cleanupTests,
   ContactFormCommand,
   createSingleServer,
-  MockSmtpServer,
   PeerTubeServer,
   setAccessTokensToServers,
-  wait,
   waitJobs
-} from '@shared/extra-utils'
-
-const expect = chai.expect
+} from '@shared/server-commands'
 
 describe('Test contact form', function () {
   let server: PeerTubeServer
@@ -28,7 +25,7 @@ describe('Test contact form', function () {
 
     const overrideConfig = {
       smtp: {
-        hostname: 'localhost',
+        hostname: '127.0.0.1',
         port
       }
     }
@@ -54,13 +51,20 @@ describe('Test contact form', function () {
 
     const email = emails[0]
 
-    expect(email['from'][0]['address']).equal('test-admin@localhost')
+    expect(email['from'][0]['address']).equal('test-admin@127.0.0.1')
     expect(email['replyTo'][0]['address']).equal('toto@example.com')
     expect(email['to'][0]['address']).equal('admin' + server.internalServerNumber + '@example.com')
     expect(email['subject']).contains('my subject')
     expect(email['text']).contains('my super message')
   })
 
+  it('Should not have duplicated email address in text message', async function () {
+    const text = emails[0]['text'] as string
+
+    const matches = text.match(/toto@example.com/g)
+    expect(matches).to.have.lengthOf(1)
+  })
+
   it('Should not be able to send another contact form because of the anti spam checker', async function () {
     this.timeout(10000)