From e713f65522da23c52447eef3d44963ee84d65f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 5 Sep 2022 09:01:42 +0200 Subject: [PATCH] Refine groups testing --- backend/src/db/graphql/groups.js | 5 +---- backend/src/schema/resolvers/groups.js | 6 +++++- backend/src/schema/resolvers/groups.spec.js | 8 +++++++- backend/src/schema/types/type/Group.gql | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/backend/src/db/graphql/groups.js b/backend/src/db/graphql/groups.js index fe3153fa2..ddf179572 100644 --- a/backend/src/db/graphql/groups.js +++ b/backend/src/db/graphql/groups.js @@ -12,7 +12,6 @@ export const createGroupMutation = gql` $groupType: GroupType! $actionRadius: GroupActionRadius! $categoryIds: [ID] - $avatar: ImageInput $locationName: String ) { CreateGroup( @@ -24,7 +23,6 @@ export const createGroupMutation = gql` groupType: $groupType actionRadius: $actionRadius categoryIds: $categoryIds - avatar: $avatar locationName: $locationName ) { id @@ -45,7 +43,6 @@ export const createGroupMutation = gql` name icon } - # avatar # test this as result # locationName # test this as result myRole } @@ -68,11 +65,11 @@ export const updateGroupMutation = gql` id: $id name: $name slug: $slug - avatar: $avatar about: $about description: $description actionRadius: $actionRadius categoryIds: $categoryIds + avatar: $avatar locationName: $locationName ) { id diff --git a/backend/src/schema/resolvers/groups.js b/backend/src/schema/resolvers/groups.js index 2a3f2fc11..4d97a2c9f 100644 --- a/backend/src/schema/resolvers/groups.js +++ b/backend/src/schema/resolvers/groups.js @@ -5,6 +5,7 @@ import { CATEGORIES_MIN, CATEGORIES_MAX } from '../../constants/categories' import { DESCRIPTION_WITHOUT_HTML_LENGTH_MIN } from '../../constants/groups' import { removeHtmlTags } from '../../middleware/helpers/cleanHtml.js' import Resolver from './helpers/Resolver' +import { mergeImage } from './images/images' export default { Query: { @@ -135,7 +136,7 @@ export default { UpdateGroup: async (_parent, params, context, _resolveInfo) => { // Wolle: console.log('UpdateGroup !!!') const { categoryIds } = params - const { id: groupId } = params + const { id: groupId, avatar: avatarInput } = params // Wolle: console.log('categoryIds: ', categoryIds) // Wolle: console.log('groupId: ', groupId) delete params.categoryIds @@ -191,6 +192,9 @@ export default { params, }) const [group] = await transactionResponse.records.map((record) => record.get('group')) + if (avatarInput) { + await mergeImage(group, 'AVATAR_IMAGE', avatarInput, { transaction }) + } return group }) try { diff --git a/backend/src/schema/resolvers/groups.spec.js b/backend/src/schema/resolvers/groups.spec.js index 2616cd606..068bf5c73 100644 --- a/backend/src/schema/resolvers/groups.spec.js +++ b/backend/src/schema/resolvers/groups.spec.js @@ -17,6 +17,7 @@ const neode = getNeode() let authenticatedUser let user +// Wolle: let groupAvartar const categoryIds = ['cat9', 'cat4', 'cat15'] const descriptionAdditional100 = @@ -73,6 +74,9 @@ const seedBasicsAndClearAuthentication = async () => { icon: 'paw', }), ]) + // Wolle: groupAvartar = await Factory.build('image', { + // url: 'https://s3.amazonaws.com/uifaces/faces/twitter/jimmuirhead/128.jpg', + // }) authenticatedUser = null } @@ -107,7 +111,6 @@ describe('in mode', () => { groupType: 'public', actionRadius: 'regional', categoryIds, - // avatar, // test this as result // locationName, // test this as result } }) @@ -132,6 +135,9 @@ describe('in mode', () => { name: 'The Best Group', slug: 'the-group', about: 'We will change the world!', + description: 'Some description' + descriptionAdditional100, + groupType: 'public', + actionRadius: 'regional', }, }, errors: undefined, diff --git a/backend/src/schema/types/type/Group.gql b/backend/src/schema/types/type/Group.gql index c7473d6ea..c1b097857 100644 --- a/backend/src/schema/types/type/Group.gql +++ b/backend/src/schema/types/type/Group.gql @@ -101,7 +101,7 @@ type Mutation { groupType: GroupType! actionRadius: GroupActionRadius! categoryIds: [ID] - avatar: ImageInput # test this as result + # avatar: ImageInput # a group can not be created with an avatar locationName: String # test this as result ): Group