mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Test email template 'sendAccountMultiRegistrationEmail' in english
This commit is contained in:
parent
c187b33a4d
commit
17e0cbb15c
@ -78,26 +78,24 @@ describe('sendEmailTranslated', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('has "sendEmailTranslated" with result not(!) "null"', () => {
|
||||
expect(result).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has "sendEmailTranslated" with result', () => {
|
||||
expect(result).toMatchObject({
|
||||
envelope: {
|
||||
from: 'info@gradido.net',
|
||||
to: ['stage1@gradido.net', 'support@gradido.net'],
|
||||
},
|
||||
message: expect.any(String),
|
||||
originalMessage: expect.objectContaining({
|
||||
to: 'stage1@gradido.net',
|
||||
cc: 'support@gradido.net',
|
||||
from: 'Gradido (nicht antworten) <info@gradido.net>',
|
||||
attachments: [],
|
||||
subject: 'Gradido: Try To Register Again With Your Email',
|
||||
html: expect.stringContaining('Gradido: Try To Register Again With Your Email'),
|
||||
text: expect.stringContaining('GRADIDO: TRY TO REGISTER AGAIN WITH YOUR EMAIL'),
|
||||
}),
|
||||
describe('call of "sendEmailTranslated"', () => {
|
||||
it('has result', () => {
|
||||
expect(result).toMatchObject({
|
||||
envelope: {
|
||||
from: 'info@gradido.net',
|
||||
to: ['stage1@gradido.net', 'support@gradido.net'],
|
||||
},
|
||||
message: expect.any(String),
|
||||
originalMessage: expect.objectContaining({
|
||||
to: 'stage1@gradido.net',
|
||||
cc: 'support@gradido.net',
|
||||
from: 'Gradido (nicht antworten) <info@gradido.net>',
|
||||
attachments: [],
|
||||
subject: 'Gradido: Try To Register Again With Your Email',
|
||||
html: expect.stringContaining('Gradido: Try To Register Again With Your Email'),
|
||||
text: expect.stringContaining('GRADIDO: TRY TO REGISTER AGAIN WITH YOUR EMAIL'),
|
||||
}),
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -32,7 +32,8 @@ export const sendEmailTranslated = async (params: {
|
||||
logger.info(`Emails are disabled via config...`)
|
||||
return null
|
||||
}
|
||||
if (CONFIG.EMAIL_TEST_MODUS) {
|
||||
// because 'CONFIG.EMAIL_TEST_MODUS' can be boolean 'true' or string '`false`'
|
||||
if (CONFIG.EMAIL_TEST_MODUS === true) {
|
||||
logger.info(
|
||||
`Testmodus=ON: change receiver from ${params.receiver.to} to ${CONFIG.EMAIL_TEST_RECEIVER}`,
|
||||
)
|
||||
|
||||
88
backend/src/emails/sendEmailVariants.test.ts
Normal file
88
backend/src/emails/sendEmailVariants.test.ts
Normal file
@ -0,0 +1,88 @@
|
||||
import CONFIG from '@/config'
|
||||
import { sendAccountMultiRegistrationEmail } from './sendEmailVariants'
|
||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||
|
||||
CONFIG.EMAIL = true
|
||||
CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL'
|
||||
CONFIG.EMAIL_SMTP_PORT = '1234'
|
||||
CONFIG.EMAIL_USERNAME = 'user'
|
||||
CONFIG.EMAIL_PASSWORD = 'pwd'
|
||||
|
||||
jest.mock('./sendEmailTranslated', () => {
|
||||
const originalModule = jest.requireActual('./sendEmailTranslated')
|
||||
return {
|
||||
__esModule: true,
|
||||
sendEmailTranslated: jest.fn((a) => originalModule.sendEmailTranslated(a)),
|
||||
}
|
||||
})
|
||||
|
||||
describe('sendEmailVariants', () => {
|
||||
let result: Record<string, unknown> | null
|
||||
|
||||
describe('sendAccountMultiRegistrationEmail', () => {
|
||||
beforeAll(async () => {
|
||||
result = await sendAccountMultiRegistrationEmail({
|
||||
firstName: 'Peter',
|
||||
lastName: 'Lustig',
|
||||
email: 'peter@lustig.de',
|
||||
language: 'en',
|
||||
})
|
||||
})
|
||||
|
||||
describe('calls "sendEmailTranslated"', () => {
|
||||
it('with expected parameters', () => {
|
||||
expect(sendEmailTranslated).toBeCalledWith({
|
||||
receiver: {
|
||||
to: 'Peter Lustig <peter@lustig.de>',
|
||||
},
|
||||
template: 'accountMultiRegistration',
|
||||
locals: {
|
||||
firstName: 'Peter',
|
||||
lastName: 'Lustig',
|
||||
locale: 'en',
|
||||
resendLink: CONFIG.EMAIL_LINK_FORGOTPASSWORD,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
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 <peter@lustig.de>',
|
||||
from: 'Gradido (nicht antworten) <info@gradido.net>',
|
||||
attachments: [],
|
||||
subject: 'Gradido: Try To Register Again With Your Email',
|
||||
html:
|
||||
expect.stringContaining(
|
||||
'<title>Gradido: Try To Register Again With Your Email</title>',
|
||||
) &&
|
||||
expect.stringContaining('>Gradido: Try To Register Again With Your Email</h1>') &&
|
||||
expect.stringContaining(
|
||||
'Your email address has just been used again to register an account with Gradido.',
|
||||
) &&
|
||||
expect.stringContaining(
|
||||
'However, an account already exists for your email address.',
|
||||
) &&
|
||||
expect.stringContaining(
|
||||
'Please click on the following link if you have forgotten your password:',
|
||||
) &&
|
||||
expect.stringContaining(
|
||||
`<a href="${CONFIG.EMAIL_LINK_FORGOTPASSWORD}">${CONFIG.EMAIL_LINK_FORGOTPASSWORD}</a>`,
|
||||
) &&
|
||||
expect.stringContaining('or copy the link above into your browser window.') &&
|
||||
expect.stringContaining(
|
||||
'If you are not the one who tried to register again, please contact our support:',
|
||||
) &&
|
||||
expect.stringContaining('Sincerely yours,<br><span>your Gradido team'),
|
||||
text: expect.stringContaining('GRADIDO: TRY TO REGISTER AGAIN WITH YOUR EMAIL'),
|
||||
}),
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -1,12 +1,12 @@
|
||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||
import CONFIG from '@/config'
|
||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||
|
||||
export const sendAccountMultiRegistrationEmail = (data: {
|
||||
firstName: string
|
||||
lastName: string
|
||||
email: string
|
||||
language: string
|
||||
}): Promise<boolean> => {
|
||||
}): Promise<Record<string, unknown> | null> => {
|
||||
return sendEmailTranslated({
|
||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||
template: 'accountMultiRegistration',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user