diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index d2aab1e45..18fa8d4c6 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -27,7 +27,7 @@ import { TransactionLink } from '@entity/TransactionLink' import { EventProtocolType } from '@/event/EventProtocolType' import { EventProtocol } from '@entity/EventProtocol' -import { logger } from '@test/testSetup' +import { logger, i18n as localization } from '@test/testSetup' import { validate as validateUUID, version as versionUUID } from 'uuid' import { peterLustig } from '@/seeds/users/peter-lustig' import { UserContact } from '@entity/UserContact' @@ -71,7 +71,8 @@ let mutate: any, query: any, con: any let testEnv: any beforeAll(async () => { - testEnv = await testEnvironment(logger) + // Wolle: console.log('beforeAll – localization: ', localization) + testEnv = await testEnvironment(logger, localization) mutate = testEnv.mutate query = testEnv.query con = testEnv.con diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 46a69bf25..c519b0112 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -416,8 +416,11 @@ export class UserResolver { logger.info(`DbUser.findOne(email=${email}) = ${foundUser}`) if (foundUser) { - // ATTENTION: this logger-message will be exactly expected during tests + // ATTENTION: this logger-message will be exactly expected during tests, next line logger.info(`User already exists with this email=${email}`) + logger.info( + `Specified username when trying to register multiple times with this email: firstName=${firstName}, lastName=${lastName}`, + ) // TODO: this is unsecure, but the current implementation of the login server. This way it can be queried if the user with given EMail is existent. const user = new User(communityDbUser) @@ -431,8 +434,8 @@ export class UserResolver { logger.debug('partly faked user=' + user) const emailSent = await sendAccountMultiRegistrationEmail({ - firstName, - lastName, + firstName: foundUser.firstName, // this is the real name of the email owner, but just "firstName" would be the name of the new registrant which shall not be passed to the outside + lastName: foundUser.lastName, // this is the real name of the email owner, but just "lastName" would be the name of the new registrant which shall not be passed to the outside email, language, }) @@ -441,7 +444,9 @@ export class UserResolver { eventProtocol.writeEvent( event.setEventSendConfirmationEmail(eventSendAccountMultiRegistrationEmail), ) - logger.info(`sendAccountMultiRegistrationEmail of ${firstName}.${lastName} to ${email}`) + logger.info( + `sendAccountMultiRegistrationEmail by ${firstName} ${lastName} to ${foundUser.firstName} ${foundUser.lastName} <${email}>`, + ) /* uncomment this, when you need the activation link on the console */ // In case EMails are disabled log the activation link for the user if (!emailSent) { diff --git a/backend/src/server/createServer.ts b/backend/src/server/createServer.ts index e3f9395db..390ff1c6b 100644 --- a/backend/src/server/createServer.ts +++ b/backend/src/server/createServer.ts @@ -37,7 +37,7 @@ const createServer = async ( // eslint-disable-next-line @typescript-eslint/no-explicit-any context: any = serverContext, logger: Logger = apolloLogger, - localization: any = i18n, + localization: i18n.I18n = i18n, ): Promise => { logger.addContext('user', 'unknown') logger.debug('createServer...') diff --git a/backend/src/server/localization.ts b/backend/src/server/localization.ts index 12f76c783..178d4ae08 100644 --- a/backend/src/server/localization.ts +++ b/backend/src/server/localization.ts @@ -2,6 +2,7 @@ import path from 'path' import { backendLogger } from './logger' import i18n from 'i18n' +// Wolle: console.log('i18n – backend/src/server/localization.ts: ', i18n) i18n.configure({ locales: ['en', 'de'], defaultLocale: 'en', diff --git a/backend/test/helpers.ts b/backend/test/helpers.ts index 6e1856b63..69350b2bf 100644 --- a/backend/test/helpers.ts +++ b/backend/test/helpers.ts @@ -25,8 +25,9 @@ export const cleanDB = async () => { } } -export const testEnvironment = async (logger?: any) => { - const server = await createServer(context, logger) +export const testEnvironment = async (logger?: any, localization?: any) => { + // Wolle: console.log('testEnvironment – localization: ', localization) + const server = await createServer(context, logger, localization) const con = server.con const testClient = createTestClient(server.apollo) const mutate = testClient.mutate diff --git a/backend/test/testSetup.ts b/backend/test/testSetup.ts index a43335e55..5c1cd72fd 100644 --- a/backend/test/testSetup.ts +++ b/backend/test/testSetup.ts @@ -1,4 +1,6 @@ import { backendLogger as logger } from '@/server/logger' +// Wolle: import i18n from 'i18n' +import { i18n } from '@/server/localization' jest.setTimeout(1000000) @@ -19,4 +21,18 @@ jest.mock('@/server/logger', () => { } }) -export { logger } +jest.mock('@/server/localization', () => { + const originalModule = jest.requireActual('@/server/localization') + return { + __esModule: true, + ...originalModule, + i18n: { + init: jest.fn(), + // configure: jest.fn(), + // setLocale: jest.fn(), + }, + } +}) + +// Wolle: console.log('testSetup.js – i18n: ', i18n) +export { logger, i18n }