X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Fcontact-form.ts;h=3252180085da206670ecae5cd763b796a79d064c;hb=0a8a79552cf59c800011c9f63eaa8658230acddc;hp=c555661adce5ae137bd3f0c295b317fb0c2eadc7;hpb=ac27887774e63d99f4e227fbe18846f143cc4b3c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index c555661ad..325218008 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts @@ -1,20 +1,17 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' -import * as chai from 'chai' +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' -import { HttpStatusCode } from '@shared/models' - -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)