Merge branch 'master' into 2602-Text-changes-on-Community

This commit is contained in:
mahula 2023-02-01 11:49:42 +01:00 committed by GitHub
commit 5287656423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 26 deletions

View File

@ -96,7 +96,7 @@ describe('EmailOptinCodes', () => {
mutate({ mutation: forgotPassword, variables: { email: 'peter@lustig.de' } }),
).resolves.toMatchObject({
data: null,
errors: [new GraphQLError('email already sent less than 10 minutes minutes ago')],
errors: [new GraphQLError('email already sent less than 10 minutes ago')],
})
})

View File

@ -830,7 +830,7 @@ describe('UserResolver', () => {
new GraphQLError(
`email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} minutes ago`,
)} ago`,
),
],
}),
@ -870,13 +870,13 @@ describe('UserResolver', () => {
CONFIG.EMAIL_CODE_REQUEST_TIME = emailCodeRequestTime
await expect(mutate({ mutation: forgotPassword, variables })).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('email already sent less than 10 minutes minutes ago')],
errors: [new GraphQLError('email already sent less than 10 minutes ago')],
}),
)
})
it('logs the error found', () => {
expect(logger.error).toBeCalledWith(`email already sent less than 10 minutes minutes ago`)
expect(logger.error).toBeCalledWith(`email already sent less than 10 minutes ago`)
})
})
})

View File

@ -392,16 +392,11 @@ export class UserResolver {
}
if (!canEmailResend(user.emailContact.updatedAt || user.emailContact.createdAt)) {
logger.error(
`email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} minutes ago`,
)
throw new Error(
`email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} minutes ago`,
)
const errorMessage = `email already sent less than ${printTimeDuration(
CONFIG.EMAIL_CODE_REQUEST_TIME,
)} ago`
logger.error(errorMessage)
throw new Error(errorMessage)
}
user.emailContact.updatedAt = new Date()

View File

@ -62,7 +62,7 @@ describe('util/creation', () => {
amount: 160.0,
memo: 'Admin contribution for the last month',
creationDate: contributionDateFormatter(
new Date(now.getFullYear(), now.getMonth() - 1, now.getDate()),
new Date(now.getFullYear(), now.getMonth() - 1, 1),
),
},
})
@ -73,7 +73,7 @@ describe('util/creation', () => {
amount: 450.0,
memo: 'Admin contribution for two months ago',
creationDate: contributionDateFormatter(
new Date(now.getFullYear(), now.getMonth() - 2, now.getDate()),
new Date(now.getFullYear(), now.getMonth() - 2, 1),
),
},
})
@ -95,7 +95,7 @@ describe('util/creation', () => {
amount: 500.0,
memo: 'Contribution for the last month',
creationDate: contributionDateFormatter(
new Date(now.getFullYear(), now.getMonth() - 1, now.getDate()),
new Date(now.getFullYear(), now.getMonth() - 1, 1),
),
},
})
@ -114,9 +114,7 @@ describe('util/creation', () => {
}),
expect.objectContaining({
userId: user.id,
contributionDate: setZeroHours(
new Date(now.getFullYear(), now.getMonth() - 1, now.getDate()),
),
contributionDate: setZeroHours(new Date(now.getFullYear(), now.getMonth() - 1, 1)),
amount: expect.decimalEqual(160),
memo: 'Admin contribution for the last month',
moderatorId: admin.id,
@ -125,9 +123,7 @@ describe('util/creation', () => {
}),
expect.objectContaining({
userId: user.id,
contributionDate: setZeroHours(
new Date(now.getFullYear(), now.getMonth() - 2, now.getDate()),
),
contributionDate: setZeroHours(new Date(now.getFullYear(), now.getMonth() - 2, 1)),
amount: expect.decimalEqual(450),
memo: 'Admin contribution for two months ago',
moderatorId: admin.id,
@ -145,9 +141,7 @@ describe('util/creation', () => {
}),
expect.objectContaining({
userId: user.id,
contributionDate: setZeroHours(
new Date(now.getFullYear(), now.getMonth() - 1, now.getDate()),
),
contributionDate: setZeroHours(new Date(now.getFullYear(), now.getMonth() - 1, 1)),
amount: expect.decimalEqual(500),
memo: 'Contribution for the last month',
moderatorId: null,