X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fcontact-form.ts;h=9db442b0be1105713409618ca60ffea9ba8a4364;hb=49f0468d44468528c2fb2c8b0efd19cdaeeec43d;hp=fb30766d90bca1991f0d5ea91448164ffbc8003e;hpb=a9c58393d36d221197b48884a1960e6126ab31d7;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 fb30766d9..9db442b0b 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/server/tests/api/check-params/contact-form.ts @@ -1,12 +1,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, killallServers, MockSmtpServer, reRunServer, ServerInfo } from '@shared/extra-utils' -import { ContactFormCommand } from '@shared/extra-utils/server' +import { MockSmtpServer } from '@server/tests/shared' +import { HttpStatusCode } from '@shared/models' +import { cleanupTests, ContactFormCommand, createSingleServer, killallServers, PeerTubeServer } from '@shared/server-commands' describe('Test contact form API validators', function () { - let server: ServerInfo + let server: PeerTubeServer const emails: object[] = [] const defaultBody = { fromName: 'super name', @@ -25,8 +25,8 @@ describe('Test contact form API validators', function () { emailPort = await MockSmtpServer.Instance.collectEmails(emails) // Email is disabled - server = await flushAndRunServer(1) - command = server.contactFormCommand + server = await createSingleServer(1) + command = server.contactForm }) it('Should not accept a contact form if emails are disabled', async function () { @@ -34,22 +34,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) + this.timeout(25000) - killallServers([ server ]) + await killallServers([ server ]) // Contact form is disabled - await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } }) + await server.run({ smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } }) await command.send({ ...defaultBody, expectedStatus: HttpStatusCode.CONFLICT_409 }) }) it('Should not accept a contact form if from email is invalid', async function () { - this.timeout(10000) + this.timeout(25000) - killallServers([ server ]) + await killallServers([ server ]) // Email & contact form enabled - await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort } }) + await server.run({ smtp: { hostname: 'localhost', port: emailPort } }) await command.send({ ...defaultBody, fromEmail: 'badEmail', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) await command.send({ ...defaultBody, fromEmail: 'badEmail@', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) @@ -69,7 +69,7 @@ describe('Test contact form API validators', function () { }) it('Should accept a contact form with the correct parameters', async function () { - await command.send({ ...defaultBody }) + await command.send(defaultBody) }) after(async function () {