mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
more tests and a potential bug
This commit is contained in:
parent
702a39af9a
commit
d0d45aaf6a
@ -675,9 +675,82 @@ describe('UserResolver', () => {
|
|||||||
describe('user is in database but deleted', () => {
|
describe('user is in database but deleted', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
|
await userFactory(testEnv, stephenHawking)
|
||||||
|
const variables = {
|
||||||
|
email: stephenHawking.email,
|
||||||
|
password: 'Aa12345_',
|
||||||
|
publisherId: 1234,
|
||||||
|
}
|
||||||
|
result = await mutate({ mutation: login, variables })
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await cleanDB()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns an error', () => {
|
||||||
|
expect(result).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
errors: [
|
||||||
|
new GraphQLError('This user was permanently deleted. Contact support for questions'),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('logs the error thrown', () => {
|
||||||
|
expect(logger.error).toBeCalledWith(
|
||||||
|
'This user was permanently deleted. Contact support for questions',
|
||||||
|
expect.objectContaining({
|
||||||
|
firstName: stephenHawking.firstName,
|
||||||
|
lastName: stephenHawking.lastName,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('user is in database but email not confirmed', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
await userFactory(testEnv, garrickOllivander)
|
||||||
|
const variables = {
|
||||||
|
email: garrickOllivander.email,
|
||||||
|
password: 'Aa12345_',
|
||||||
|
publisherId: 1234,
|
||||||
|
}
|
||||||
|
result = await mutate({ mutation: login, variables })
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await cleanDB()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns an error', () => {
|
||||||
|
expect(result).toEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
errors: [new GraphQLError('The Users email is not validate yet')],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('logs the error thrown', () => {
|
||||||
|
expect(logger.error).toBeCalledWith(
|
||||||
|
'The Users email is not validate yet',
|
||||||
|
expect.objectContaining({
|
||||||
|
firstName: garrickOllivander.firstName,
|
||||||
|
lastName: garrickOllivander.lastName,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe.skip('user is in database but password is not set', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
// TODO: we need an user without password set
|
||||||
const user = await userFactory(testEnv, bibiBloxberg)
|
const user = await userFactory(testEnv, bibiBloxberg)
|
||||||
// Hint: softRemove does not soft-delete the email contact of this user
|
user.password = BigInt(0)
|
||||||
await user.softRemove()
|
await user.save()
|
||||||
result = await mutate({ mutation: login, variables })
|
result = await mutate({ mutation: login, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -140,6 +140,7 @@ export class UserResolver {
|
|||||||
if (!dbUser.emailContact.emailChecked) {
|
if (!dbUser.emailContact.emailChecked) {
|
||||||
throw new LogError('The Users email is not validate yet', dbUser)
|
throw new LogError('The Users email is not validate yet', dbUser)
|
||||||
}
|
}
|
||||||
|
// TODO: at least in test this does not work since `dbUser.password = 0` and `BigInto(0) = 0n`
|
||||||
if (dbUser.password === BigInt(0)) {
|
if (dbUser.password === BigInt(0)) {
|
||||||
// TODO we want to catch this on the frontend and ask the user to check his emails or resend code
|
// TODO we want to catch this on the frontend and ask the user to check his emails or resend code
|
||||||
throw new LogError('The User has not set a password yet', dbUser)
|
throw new LogError('The User has not set a password yet', dbUser)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user