diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 8d1a8e2c4..be4f983a9 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -51,7 +51,7 @@ jobs: shell: bash - name: Backend | docker-compose database - run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database + run: docker compose -f docker-compose.yml -f docker-compose.test.yml up --detach --no-deps database mailserver - name: Backend | Unit tests run: cd database && yarn && yarn build && cd ../config && yarn install && cd ../backend && yarn && yarn test diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index f035d3590..c10c76a62 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -7,9 +7,12 @@ import { CONFIG } from '@/config' import { sendEmailTranslated } from './sendEmailTranslated' +const testMailServerHost = 'localhost' +const testMailServerPort = 1025 + CONFIG.EMAIL = false -CONFIG.EMAIL_SMTP_HOST = 'EMAIL_SMTP_HOST' -CONFIG.EMAIL_SMTP_PORT = 1234 +CONFIG.EMAIL_SMTP_HOST = testMailServerHost +CONFIG.EMAIL_SMTP_PORT = testMailServerPort CONFIG.EMAIL_SENDER = 'info@gradido.net' CONFIG.EMAIL_USERNAME = 'user' CONFIG.EMAIL_PASSWORD = 'pwd' @@ -73,8 +76,8 @@ describe('sendEmailTranslated', () => { it('calls the transporter', () => { expect(createTransport).toBeCalledWith({ - host: 'EMAIL_SMTP_HOST', - port: 1234, + host: testMailServerHost, + port: testMailServerPort, secure: false, requireTLS: true, auth: { @@ -87,11 +90,6 @@ describe('sendEmailTranslated', () => { describe('call of "sendEmailTranslated"', () => { it('has expected result', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['receiver@mail.org', 'support@gradido.net'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -135,11 +133,6 @@ describe('sendEmailTranslated', () => { it('call of "sendEmailTranslated" with faked "to"', () => { expect(result).toMatchObject({ - envelope: { - from: CONFIG.EMAIL_SENDER, - to: [CONFIG.EMAIL_TEST_RECEIVER, 'support@gradido.net'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: CONFIG.EMAIL_TEST_RECEIVER, cc: 'support@gradido.net', diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 9a2cb4ce0..712fe3a27 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -26,6 +26,8 @@ import { } from './sendEmailVariants' CONFIG.EMAIL_SENDER = 'info@gradido.net' +CONFIG.EMAIL_SMTP_HOST = 'localhost' +CONFIG.EMAIL_SMTP_PORT = 1025 let con: Connection let testEnv: { @@ -93,11 +95,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -151,11 +148,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -204,11 +196,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -267,11 +254,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -329,11 +311,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -389,11 +366,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('has expected result', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -449,11 +421,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -507,11 +474,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -571,11 +533,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ', @@ -633,11 +590,6 @@ describe('sendEmailVariants', () => { describe('result', () => { it('is the expected object', () => { expect(result).toMatchObject({ - envelope: { - from: 'info@gradido.net', - to: ['peter@lustig.de'], - }, - message: expect.any(String), originalMessage: expect.objectContaining({ to: 'Peter Lustig ', from: 'Gradido (emails.general.doNotAnswer) ',