mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
existing homecommunity with uuid as prerequisit for createUser
This commit is contained in:
parent
3ecd108660
commit
315c082628
@ -11,6 +11,8 @@ import { CONFIG } from '@/config'
|
||||
import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations'
|
||||
import { queryOptIn } from '@/seeds/graphql/queries'
|
||||
|
||||
import { createHomeCommunity } from './util/communities'
|
||||
|
||||
let mutate: ApolloServerTestClient['mutate'],
|
||||
query: ApolloServerTestClient['query'],
|
||||
con: Connection
|
||||
@ -46,6 +48,7 @@ describe('EmailOptinCodes', () => {
|
||||
lastName: 'Lustig',
|
||||
language: 'de',
|
||||
}
|
||||
await createHomeCommunity()
|
||||
const {
|
||||
data: { createUser: user },
|
||||
} = await mutate({ mutation: createUser, variables })
|
||||
|
||||
@ -67,6 +67,8 @@ import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||
import { printTimeDuration } from '@/util/time'
|
||||
import { objectValuesToArray } from '@/util/utilities'
|
||||
|
||||
import { createHomeCommunity } from './util/communities'
|
||||
|
||||
jest.mock('@/emails/sendEmailVariants', () => {
|
||||
const originalModule = jest.requireActual('@/emails/sendEmailVariants')
|
||||
return {
|
||||
@ -125,9 +127,11 @@ describe('UserResolver', () => {
|
||||
let result: any
|
||||
let emailVerificationCode: string
|
||||
let user: User[]
|
||||
let homeCom: DbCommunity
|
||||
|
||||
beforeAll(async () => {
|
||||
jest.clearAllMocks()
|
||||
homeCom = await createHomeCommunity()
|
||||
result = await mutate({ mutation: createUser, variables })
|
||||
})
|
||||
|
||||
@ -172,7 +176,7 @@ describe('UserResolver', () => {
|
||||
referrerId: null,
|
||||
contributionLinkId: null,
|
||||
passwordEncryptionType: PasswordEncryptionType.NO_PASSWORD,
|
||||
communityUuid: null,
|
||||
communityUuid: homeCom.communityUuid,
|
||||
foreign: false,
|
||||
},
|
||||
])
|
||||
@ -542,6 +546,7 @@ describe('UserResolver', () => {
|
||||
let newUser: User
|
||||
|
||||
beforeAll(async () => {
|
||||
await createHomeCommunity()
|
||||
await mutate({ mutation: createUser, variables: createUserVariables })
|
||||
const emailContact = await UserContact.findOneOrFail({
|
||||
where: { email: createUserVariables.email },
|
||||
@ -586,6 +591,7 @@ describe('UserResolver', () => {
|
||||
|
||||
describe('no valid password', () => {
|
||||
beforeAll(async () => {
|
||||
await createHomeCommunity()
|
||||
await mutate({ mutation: createUser, variables: createUserVariables })
|
||||
const emailContact = await UserContact.findOneOrFail({
|
||||
where: { email: createUserVariables.email },
|
||||
|
||||
@ -275,6 +275,10 @@ export class UserResolver {
|
||||
{ id: 0 } as DbUser,
|
||||
)
|
||||
let dbUser = new DbUser()
|
||||
const homeCom = await getHomeCommunity()
|
||||
if (homeCom.communityUuid) {
|
||||
dbUser.communityUuid = homeCom.communityUuid
|
||||
}
|
||||
dbUser.gradidoID = gradidoID
|
||||
dbUser.firstName = firstName
|
||||
dbUser.lastName = lastName
|
||||
|
||||
@ -63,3 +63,23 @@ export async function getCommunity(communityUuid: string): Promise<DbCommunity |
|
||||
where: [{ communityUuid }],
|
||||
})
|
||||
}
|
||||
|
||||
export async function createHomeCommunity(): Promise<DbCommunity> {
|
||||
let homeCom: DbCommunity
|
||||
try {
|
||||
return await getHomeCommunity()
|
||||
} catch (err) {
|
||||
homeCom = DbCommunity.create()
|
||||
homeCom.foreign = false
|
||||
homeCom.url = 'http://localhost/api'
|
||||
homeCom.publicKey = Buffer.from('publicKey-HomeCommunity')
|
||||
homeCom.privateKey = Buffer.from('privateKey-HomeCommunity')
|
||||
homeCom.communityUuid = 'HomeCom-UUID'
|
||||
homeCom.authenticatedAt = new Date()
|
||||
homeCom.name = 'HomeCommunity-name'
|
||||
homeCom.description = 'HomeCommunity-description'
|
||||
homeCom.creationDate = new Date()
|
||||
await DbCommunity.insert(homeCom)
|
||||
return homeCom
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
|
||||
import { RoleNames } from '@enum/RoleNames'
|
||||
|
||||
import { getHomeCommunity } from '@/graphql/resolver/util/communities'
|
||||
import { createHomeCommunity, getHomeCommunity } from '@/graphql/resolver/util/communities'
|
||||
import { setUserRole } from '@/graphql/resolver/util/modifyUserRole'
|
||||
import { createUser, setPassword } from '@/seeds/graphql/mutations'
|
||||
import { UserInterface } from '@/seeds/users/UserInterface'
|
||||
@ -16,6 +16,8 @@ export const userFactory = async (
|
||||
): Promise<User> => {
|
||||
const { mutate } = client
|
||||
|
||||
await createHomeCommunity()
|
||||
|
||||
const {
|
||||
data: {
|
||||
createUser: { id },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user