update test

This commit is contained in:
einhornimmond 2024-02-20 13:22:32 +01:00
parent 4255c1fdfa
commit e5e22c394d
4 changed files with 30 additions and 8 deletions

View File

@ -17,7 +17,7 @@ import { logger, i18n as localization } from '@test/testSetup'
import { userFactory } from '@/seeds/factory/user'
import { login, updateHomeCommunityQuery } from '@/seeds/graphql/mutations'
import { getCommunities, communitiesQuery, getCommunityByUuidQuery } from '@/seeds/graphql/queries'
import { getCommunities, communitiesQuery, getCommunityQuery } from '@/seeds/graphql/queries'
import { peterLustig } from '@/seeds/users/peter-lustig'
import { getCommunity } from './util/communities'
@ -487,10 +487,10 @@ describe('CommunityResolver', () => {
await DbCommunity.insert(foreignCom2)
})
it('finds the home-community', async () => {
it('finds the home-community by uuid', async () => {
await expect(
query({
query: getCommunityByUuidQuery,
query: getCommunityQuery,
variables: { communityIdentifier: homeCom?.communityUuid },
}),
).resolves.toMatchObject({
@ -509,6 +509,28 @@ describe('CommunityResolver', () => {
})
})
it('finds the home-community by foreign', async () => {
await expect(
query({
query: getCommunityQuery,
variables: { foreign: false },
}),
).resolves.toMatchObject({
data: {
community: {
id: homeCom?.id,
foreign: homeCom?.foreign,
name: homeCom?.name,
description: homeCom?.description,
url: homeCom?.url,
creationDate: homeCom?.creationDate?.toISOString(),
uuid: homeCom?.communityUuid,
authenticatedAt: homeCom?.authenticatedAt,
},
},
})
})
it('updates the home-community gmsApiKey', async () => {
await expect(
mutate({

View File

@ -42,7 +42,7 @@ export class CommunityResolver {
return dbCommunities.map((dbCom: DbCommunity) => new Community(dbCom))
}
@Authorized([RIGHTS.COMMUNITIES])
@Authorized([RIGHTS.COMMUNITY_BY_IDENTIFIER])
@Query(() => Community)
async community(@Args() communityArgs: CommunityArgs): Promise<Community> {
const community = await getCommunity(communityArgs)

View File

@ -134,9 +134,9 @@ export const communitiesQuery = gql`
}
`
export const getCommunityByUuidQuery = gql`
query ($communityIdentifier: String!) {
community(communityIdentifier: $communityIdentifier) {
export const getCommunityQuery = gql`
query ($communityIdentifier: String, $foreign: Boolean) {
community(communityIdentifier: $communityIdentifier, foreign: $foreign) {
id
foreign
name

View File

@ -1,12 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { gql, GraphQLClient } from 'graphql-request'
import { SignJWT } from 'jose'
import { CONFIG } from '@/config'
import { CommunityDraft } from '@/graphql/input/CommunityDraft'
import { logger } from '@/logging/logger'
import { LogError } from '@/server/LogError'
import { SignJWT } from 'jose'
const communityByForeign = gql`
query ($foreign: Boolean) {