diff --git a/backend/src/models/Group.js b/backend/src/models/Group.js index 25149e9c3..a75ad518f 100644 --- a/backend/src/models/Group.js +++ b/backend/src/models/Group.js @@ -37,8 +37,6 @@ export default { locationName: { type: 'string', allow: [null] }, - wasSeeded: 'boolean', // Wolle: used or needed? - isIn: { type: 'relationship', relationship: 'IS_IN', diff --git a/backend/src/schema/resolvers/groups.js b/backend/src/schema/resolvers/groups.js index dadbcd2a1..d1af98513 100644 --- a/backend/src/schema/resolvers/groups.js +++ b/backend/src/schema/resolvers/groups.js @@ -52,17 +52,17 @@ export default { const { categoryIds } = params delete params.categoryIds if (!categoryIds || categoryIds.length < CATEGORIES_MIN) { - throw new UserInputError('To Less Categories!') + throw new UserInputError('Too view categories!') } if (categoryIds && categoryIds.length > CATEGORIES_MAX) { - throw new UserInputError('To Many Categories!') + throw new UserInputError('Too many categories!') } if ( params.description === undefined || params.description === null || removeHtmlTags(params.description).length < DESCRIPTION_WITHOUT_HTML_LENGTH_MIN ) { - throw new UserInputError('To Short Description!') + throw new UserInputError('Description too short!') } params.id = params.id || uuid() const session = context.driver.session() diff --git a/backend/src/schema/resolvers/groups.spec.js b/backend/src/schema/resolvers/groups.spec.js index bae530c61..5354f5ebe 100644 --- a/backend/src/schema/resolvers/groups.spec.js +++ b/backend/src/schema/resolvers/groups.spec.js @@ -120,7 +120,7 @@ describe('Group', () => { about: 'We will change nothing!', description: 'We love it like it is!?' + descriptionAddition100, groupType: 'closed', - actionRadius: 'international', + actionRadius: 'global', categoryIds, }, }) @@ -139,62 +139,68 @@ describe('Group', () => { }) }) - describe('can find', () => { - it('all', async () => { - const expected = { - data: { - Group: expect.arrayContaining([ - expect.objectContaining({ - id: 'my-group', - slug: 'the-best-group', - myRole: 'owner', - }), - expect.objectContaining({ - id: 'others-group', - slug: 'uninteresting-group', - myRole: null, - }), - ]), - }, - errors: undefined, - } - await expect(query({ query: groupQuery, variables: {} })).resolves.toMatchObject(expected) + describe('query groups', () => { + describe('without any filters', () => { + it('finds all groups', async () => { + const expected = { + data: { + Group: expect.arrayContaining([ + expect.objectContaining({ + id: 'my-group', + slug: 'the-best-group', + myRole: 'owner', + }), + expect.objectContaining({ + id: 'others-group', + slug: 'uninteresting-group', + myRole: null, + }), + ]), + }, + errors: undefined, + } + await expect(query({ query: groupQuery, variables: {} })).resolves.toMatchObject(expected) + }) }) - it('where user is member (or owner in this case)', async () => { - const expected = { - data: { - Group: [ - { - id: 'my-group', - slug: 'the-best-group', - myRole: 'owner', - }, - ], - }, - errors: undefined, - } - await expect( - query({ query: groupQuery, variables: { isMember: true } }), - ).resolves.toMatchObject(expected) + describe('isMember = true', () => { + it('finds only groups where user is member', async () => { + const expected = { + data: { + Group: [ + { + id: 'my-group', + slug: 'the-best-group', + myRole: 'owner', + }, + ], + }, + errors: undefined, + } + await expect( + query({ query: groupQuery, variables: { isMember: true } }), + ).resolves.toMatchObject(expected) + }) }) - it('where user is not(!) member', async () => { - const expected = { - data: { - Group: expect.arrayContaining([ - expect.objectContaining({ - id: 'others-group', - slug: 'uninteresting-group', - myRole: null, - }), - ]), - }, - errors: undefined, - } - await expect( - query({ query: groupQuery, variables: { isMember: false } }), - ).resolves.toMatchObject(expected) + describe('isMember = false', () => { + it('finds only groups where user is not(!) member', async () => { + const expected = { + data: { + Group: expect.arrayContaining([ + expect.objectContaining({ + id: 'others-group', + slug: 'uninteresting-group', + myRole: null, + }), + ]), + }, + errors: undefined, + } + await expect( + query({ query: groupQuery, variables: { isMember: false } }), + ).resolves.toMatchObject(expected) + }) }) }) }) @@ -258,7 +264,7 @@ describe('CreateGroup', () => { ) }) - it('"disabled" and "deleted" default to "false"', async () => { + it('has "disabled" and "deleted" default to "false"', async () => { const expected = { data: { CreateGroup: { disabled: false, deleted: false } } } await expect(mutate({ mutation: createGroupMutation, variables })).resolves.toMatchObject( expected, @@ -268,7 +274,7 @@ describe('CreateGroup', () => { describe('description', () => { describe('length without HTML', () => { describe('less then 100 chars', () => { - it('throws error: "To Less Categories!"', async () => { + it('throws error: "Too view categories!"', async () => { const { errors } = await mutate({ mutation: createGroupMutation, variables: { @@ -278,7 +284,7 @@ describe('CreateGroup', () => { '0123456789', }, }) - expect(errors[0]).toHaveProperty('message', 'To Short Description!') + expect(errors[0]).toHaveProperty('message', 'Description too short!') }) }) }) @@ -286,22 +292,22 @@ describe('CreateGroup', () => { describe('categories', () => { describe('not even one', () => { - it('throws error: "To Less Categories!"', async () => { + it('throws error: "Too view categories!"', async () => { const { errors } = await mutate({ mutation: createGroupMutation, variables: { ...variables, categoryIds: null }, }) - expect(errors[0]).toHaveProperty('message', 'To Less Categories!') + expect(errors[0]).toHaveProperty('message', 'Too view categories!') }) }) describe('four', () => { - it('throws error: "To Many Categories!"', async () => { + it('throws error: "Too many categories!"', async () => { const { errors } = await mutate({ mutation: createGroupMutation, variables: { ...variables, categoryIds: ['cat9', 'cat4', 'cat15', 'cat27'] }, }) - expect(errors[0]).toHaveProperty('message', 'To Many Categories!') + expect(errors[0]).toHaveProperty('message', 'Too many categories!') }) }) }) diff --git a/backend/src/schema/types/enum/GroupActionRadius.gql b/backend/src/schema/types/enum/GroupActionRadius.gql index afc421133..221ed7f87 100644 --- a/backend/src/schema/types/enum/GroupActionRadius.gql +++ b/backend/src/schema/types/enum/GroupActionRadius.gql @@ -2,5 +2,6 @@ enum GroupActionRadius { regional national continental - international + global + interplanetary }