mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
refactor(backend): externalize gql queries in backend specs (#8881)
* externalize gql queries in backend specs * externalize all queries & mutations where easily possible missing change * rename old queries & remove unnecessary function call * fix tests - notifications * fix tests - moderation * remove _CreatePostMutation file * remove _filterPosts & _postQuery files
This commit is contained in:
parent
dbae0862f9
commit
74f6c5b329
@ -8,13 +8,13 @@ import sample from 'lodash/sample'
|
|||||||
|
|
||||||
import CONFIG from '@config/index'
|
import CONFIG from '@config/index'
|
||||||
import { categories } from '@constants/categories'
|
import { categories } from '@constants/categories'
|
||||||
import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation'
|
import { ChangeGroupMemberRole } from '@graphql/queries/ChangeGroupMemberRole'
|
||||||
import { createCommentMutation } from '@graphql/queries/createCommentMutation'
|
import { CreateComment } from '@graphql/queries/CreateComment'
|
||||||
import { createGroupMutation } from '@graphql/queries/createGroupMutation'
|
import { CreateGroup } from '@graphql/queries/CreateGroup'
|
||||||
import { CreateMessage } from '@graphql/queries/CreateMessage'
|
import { CreateMessage } from '@graphql/queries/CreateMessage'
|
||||||
import { createPostMutation } from '@graphql/queries/createPostMutation'
|
import { CreatePost } from '@graphql/queries/CreatePost'
|
||||||
import { createRoomMutation } from '@graphql/queries/createRoomMutation'
|
import { CreateRoom } from '@graphql/queries/CreateRoom'
|
||||||
import { joinGroupMutation } from '@graphql/queries/joinGroupMutation'
|
import { JoinGroup } from '@graphql/queries/JoinGroup'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
|
|
||||||
import Factory from './factories'
|
import Factory from './factories'
|
||||||
@ -341,7 +341,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
console.log('seed', 'groups')
|
console.log('seed', 'groups')
|
||||||
authenticatedUser = await peterLustig.toJson()
|
authenticatedUser = await peterLustig.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'g0',
|
id: 'g0',
|
||||||
name: 'Investigative Journalism',
|
name: 'Investigative Journalism',
|
||||||
@ -354,21 +354,21 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
userId: 'u2',
|
userId: 'u2',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
userId: 'u4',
|
userId: 'u4',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
userId: 'u6',
|
userId: 'u6',
|
||||||
@ -376,7 +376,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
userId: 'u2',
|
userId: 'u2',
|
||||||
@ -385,7 +385,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
userId: 'u4',
|
userId: 'u4',
|
||||||
@ -396,7 +396,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.log('seed', 'group posts')
|
console.log('seed', 'group posts')
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p0-g0',
|
id: 'p0-g0',
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
@ -408,7 +408,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
|
|
||||||
authenticatedUser = await bobDerBaumeister.toJson()
|
authenticatedUser = await bobDerBaumeister.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p1-g0',
|
id: 'p1-g0',
|
||||||
groupId: 'g0',
|
groupId: 'g0',
|
||||||
@ -420,7 +420,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
|
|
||||||
authenticatedUser = await jennyRostock.toJson()
|
authenticatedUser = await jennyRostock.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'g1',
|
id: 'g1',
|
||||||
name: 'School For Citizens',
|
name: 'School For Citizens',
|
||||||
@ -433,35 +433,35 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u1',
|
userId: 'u1',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u2',
|
userId: 'u2',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u5',
|
userId: 'u5',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u6',
|
userId: 'u6',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u7',
|
userId: 'u7',
|
||||||
@ -469,7 +469,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u1',
|
userId: 'u1',
|
||||||
@ -477,7 +477,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u5',
|
userId: 'u5',
|
||||||
@ -485,7 +485,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
userId: 'u6',
|
userId: 'u6',
|
||||||
@ -493,7 +493,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p0-g1',
|
id: 'p0-g1',
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
@ -504,7 +504,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
})
|
})
|
||||||
authenticatedUser = await peterLustig.toJson()
|
authenticatedUser = await peterLustig.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p1-g1',
|
id: 'p1-g1',
|
||||||
groupId: 'g1',
|
groupId: 'g1',
|
||||||
@ -516,7 +516,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
|
|
||||||
authenticatedUser = await bobDerBaumeister.toJson()
|
authenticatedUser = await bobDerBaumeister.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'g2',
|
id: 'g2',
|
||||||
name: 'Yoga Practice',
|
name: 'Yoga Practice',
|
||||||
@ -528,35 +528,35 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u3',
|
userId: 'u3',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u4',
|
userId: 'u4',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u5',
|
userId: 'u5',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u6',
|
userId: 'u6',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u7',
|
userId: 'u7',
|
||||||
@ -564,7 +564,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u3',
|
userId: 'u3',
|
||||||
@ -572,7 +572,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u4',
|
userId: 'u4',
|
||||||
@ -580,7 +580,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u5',
|
userId: 'u5',
|
||||||
@ -588,7 +588,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: 'u6',
|
userId: 'u6',
|
||||||
@ -598,7 +598,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
|
|
||||||
authenticatedUser = await louie.toJson()
|
authenticatedUser = await louie.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p0-g2',
|
id: 'p0-g2',
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
@ -614,7 +614,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'e0',
|
id: 'e0',
|
||||||
title: 'Illegaler Kindergeburtstag',
|
title: 'Illegaler Kindergeburtstag',
|
||||||
@ -629,7 +629,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'e1',
|
id: 'e1',
|
||||||
title: 'Wir Schützen den Stuttgarter Schlossgarten',
|
title: 'Wir Schützen den Stuttgarter Schlossgarten',
|
||||||
@ -644,7 +644,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'e2',
|
id: 'e2',
|
||||||
title: 'IT 4 Change Treffen',
|
title: 'IT 4 Change Treffen',
|
||||||
@ -848,7 +848,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
'The new physics of <a class="hashtag" data-hashtag-id="QuantenFlussTheorie" href="/?hashtag=QuantenFlussTheorie">#QuantenFlussTheorie</a> can explain <a class="hashtag" data-hashtag-id="QuantumGravity" href="/?hashtag=QuantumGravity">#QuantumGravity</a>! <a class="mention" data-mention-id="u1" href="/profile/u1">@peter-lustig</a> got that already. ;-)'
|
'The new physics of <a class="hashtag" data-hashtag-id="QuantenFlussTheorie" href="/?hashtag=QuantenFlussTheorie">#QuantenFlussTheorie</a> can explain <a class="hashtag" data-hashtag-id="QuantumGravity" href="/?hashtag=QuantumGravity">#QuantumGravity</a>! <a class="mention" data-mention-id="u1" href="/profile/u1">@peter-lustig</a> got that already. ;-)'
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
title: `Nature Philosophy Yoga`,
|
title: `Nature Philosophy Yoga`,
|
||||||
@ -857,7 +857,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p7',
|
id: 'p7',
|
||||||
title: 'This is post #7',
|
title: 'This is post #7',
|
||||||
@ -866,7 +866,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p8',
|
id: 'p8',
|
||||||
title: `Quantum Flow Theory explains Quantum Gravity`,
|
title: `Quantum Flow Theory explains Quantum Gravity`,
|
||||||
@ -875,7 +875,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p12',
|
id: 'p12',
|
||||||
title: 'This is post #12',
|
title: 'This is post #12',
|
||||||
@ -899,7 +899,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
const mentionInComment2 =
|
const mentionInComment2 =
|
||||||
'Did <a class="mention" data-mention-id="u1" href="/profile/u1">@peter-lustig</a> tell you?'
|
'Did <a class="mention" data-mention-id="u1" href="/profile/u1">@peter-lustig</a> tell you?'
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createCommentMutation,
|
mutation: CreateComment,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'c4',
|
id: 'c4',
|
||||||
postId: 'p2',
|
postId: 'p2',
|
||||||
@ -907,7 +907,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createCommentMutation,
|
mutation: CreateComment,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'c4-1',
|
id: 'c4-1',
|
||||||
postId: 'p2',
|
postId: 'p2',
|
||||||
@ -915,7 +915,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createCommentMutation,
|
mutation: CreateComment,
|
||||||
variables: {
|
variables: {
|
||||||
postId: 'p14',
|
postId: 'p14',
|
||||||
content: faker.lorem.paragraph(),
|
content: faker.lorem.paragraph(),
|
||||||
@ -1223,7 +1223,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
authenticatedUser = userObj
|
authenticatedUser = userObj
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'g2',
|
groupId: 'g2',
|
||||||
userId: userObj.id,
|
userId: userObj.id,
|
||||||
@ -1530,7 +1530,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
console.log('seed', 'chat')
|
console.log('seed', 'chat')
|
||||||
authenticatedUser = await huey.toJson()
|
authenticatedUser = await huey.toJson()
|
||||||
const { data: roomHueyPeter } = await mutate({
|
const { data: roomHueyPeter } = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: (await peterLustig.toJson()).id,
|
userId: (await peterLustig.toJson()).id,
|
||||||
},
|
},
|
||||||
@ -1557,7 +1557,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
|
|
||||||
authenticatedUser = await huey.toJson()
|
authenticatedUser = await huey.toJson()
|
||||||
const { data: roomHueyJenny } = await mutate({
|
const { data: roomHueyJenny } = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: (await jennyRostock.toJson()).id,
|
userId: (await jennyRostock.toJson()).id,
|
||||||
},
|
},
|
||||||
@ -1584,7 +1584,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
|
|||||||
for (const user of additionalUsers.slice(0, 99)) {
|
for (const user of additionalUsers.slice(0, 99)) {
|
||||||
authenticatedUser = await jennyRostock.toJson()
|
authenticatedUser = await jennyRostock.toJson()
|
||||||
const { data: room } = await mutate({
|
const { data: room } = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: (await user.toJson()).id,
|
userId: (await user.toJson()).id,
|
||||||
},
|
},
|
||||||
|
|||||||
11
backend/src/graphql/queries/AddEmailAddress.ts
Normal file
11
backend/src/graphql/queries/AddEmailAddress.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const AddEmailAddress = gql`
|
||||||
|
mutation ($email: String!) {
|
||||||
|
AddEmailAddress(email: $email) {
|
||||||
|
email
|
||||||
|
verifiedAt
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
15
backend/src/graphql/queries/AddPostEmotions.ts
Normal file
15
backend/src/graphql/queries/AddPostEmotions.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const AddPostEmotions = gql`
|
||||||
|
mutation ($to: _PostInput!, $data: _EMOTEDInput!) {
|
||||||
|
AddPostEmotions(to: $to, data: $data) {
|
||||||
|
from {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
emotion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/Category.ts
Normal file
12
backend/src/graphql/queries/Category.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const Category = gql`
|
||||||
|
query {
|
||||||
|
Category {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
icon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/ChangeGroupMemberRole.ts
Normal file
12
backend/src/graphql/queries/ChangeGroupMemberRole.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const ChangeGroupMemberRole = gql`
|
||||||
|
mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {
|
||||||
|
ChangeGroupMemberRole(groupId: $groupId, userId: $userId, roleInGroup: $roleInGroup) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
myRoleInGroup
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,9 +1,13 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const createCommentMutation = gql`
|
export const CreateComment = gql`
|
||||||
mutation ($id: ID, $postId: ID!, $content: String!) {
|
mutation ($id: ID, $postId: ID!, $content: String!) {
|
||||||
CreateComment(id: $id, postId: $postId, content: $content) {
|
CreateComment(id: $id, postId: $postId, content: $content) {
|
||||||
id
|
id
|
||||||
|
content
|
||||||
|
author {
|
||||||
|
name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
53
backend/src/graphql/queries/CreateGroup.ts
Normal file
53
backend/src/graphql/queries/CreateGroup.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const CreateGroup = gql`
|
||||||
|
mutation (
|
||||||
|
$id: ID
|
||||||
|
$name: String!
|
||||||
|
$slug: String
|
||||||
|
$about: String
|
||||||
|
$description: String!
|
||||||
|
$groupType: GroupType!
|
||||||
|
$actionRadius: GroupActionRadius!
|
||||||
|
$categoryIds: [ID]
|
||||||
|
$locationName: String # empty string '' sets it to null
|
||||||
|
) {
|
||||||
|
CreateGroup(
|
||||||
|
id: $id
|
||||||
|
name: $name
|
||||||
|
slug: $slug
|
||||||
|
about: $about
|
||||||
|
description: $description
|
||||||
|
groupType: $groupType
|
||||||
|
actionRadius: $actionRadius
|
||||||
|
categoryIds: $categoryIds
|
||||||
|
locationName: $locationName
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
disabled
|
||||||
|
deleted
|
||||||
|
about
|
||||||
|
description
|
||||||
|
descriptionExcerpt
|
||||||
|
groupType
|
||||||
|
actionRadius
|
||||||
|
categories {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
icon
|
||||||
|
}
|
||||||
|
locationName
|
||||||
|
location {
|
||||||
|
name
|
||||||
|
nameDE
|
||||||
|
nameEN
|
||||||
|
}
|
||||||
|
myRole
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
50
backend/src/graphql/queries/CreatePost.ts
Normal file
50
backend/src/graphql/queries/CreatePost.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const CreatePost = gql`
|
||||||
|
mutation (
|
||||||
|
$id: ID
|
||||||
|
$title: String!
|
||||||
|
$slug: String
|
||||||
|
$content: String!
|
||||||
|
$categoryIds: [ID]
|
||||||
|
$groupId: ID
|
||||||
|
$postType: PostType
|
||||||
|
$eventInput: _EventInput
|
||||||
|
) {
|
||||||
|
CreatePost(
|
||||||
|
id: $id
|
||||||
|
title: $title
|
||||||
|
slug: $slug
|
||||||
|
content: $content
|
||||||
|
categoryIds: $categoryIds
|
||||||
|
groupId: $groupId
|
||||||
|
postType: $postType
|
||||||
|
eventInput: $eventInput
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
title
|
||||||
|
content
|
||||||
|
disabled
|
||||||
|
deleted
|
||||||
|
postType
|
||||||
|
author {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
categories {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
eventStart
|
||||||
|
eventEnd
|
||||||
|
eventLocationName
|
||||||
|
eventVenue
|
||||||
|
eventIsOnline
|
||||||
|
eventLocation {
|
||||||
|
lng
|
||||||
|
lat
|
||||||
|
}
|
||||||
|
isObservedByMe
|
||||||
|
observingUsersCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
22
backend/src/graphql/queries/CreateRoom.ts
Normal file
22
backend/src/graphql/queries/CreateRoom.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const CreateRoom = gql`
|
||||||
|
mutation ($userId: ID!) {
|
||||||
|
CreateRoom(userId: $userId) {
|
||||||
|
id
|
||||||
|
roomId
|
||||||
|
roomName
|
||||||
|
lastMessageAt
|
||||||
|
unreadCount
|
||||||
|
#avatar
|
||||||
|
users {
|
||||||
|
_id
|
||||||
|
id
|
||||||
|
name
|
||||||
|
avatar {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/DeleteComment.ts
Normal file
12
backend/src/graphql/queries/DeleteComment.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const DeleteComment = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
DeleteComment(id: $id) {
|
||||||
|
id
|
||||||
|
content
|
||||||
|
contentExcerpt
|
||||||
|
deleted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
20
backend/src/graphql/queries/DeletePost.ts
Normal file
20
backend/src/graphql/queries/DeletePost.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const DeletePost = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
DeletePost(id: $id) {
|
||||||
|
id
|
||||||
|
deleted
|
||||||
|
content
|
||||||
|
contentExcerpt
|
||||||
|
image {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
comments {
|
||||||
|
deleted
|
||||||
|
content
|
||||||
|
contentExcerpt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
10
backend/src/graphql/queries/DeleteSocialMedia.ts
Normal file
10
backend/src/graphql/queries/DeleteSocialMedia.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const DeleteSocialMedia = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
DeleteSocialMedia(id: $id) {
|
||||||
|
id
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
30
backend/src/graphql/queries/DeleteUser.ts
Normal file
30
backend/src/graphql/queries/DeleteUser.ts
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const DeleteUser = gql`
|
||||||
|
mutation ($id: ID!, $resource: [Deletable]) {
|
||||||
|
DeleteUser(id: $id, resource: $resource) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
about
|
||||||
|
deleted
|
||||||
|
contributions {
|
||||||
|
id
|
||||||
|
content
|
||||||
|
contentExcerpt
|
||||||
|
deleted
|
||||||
|
comments {
|
||||||
|
id
|
||||||
|
content
|
||||||
|
contentExcerpt
|
||||||
|
deleted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
comments {
|
||||||
|
id
|
||||||
|
content
|
||||||
|
contentExcerpt
|
||||||
|
deleted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/Donations.ts
Normal file
12
backend/src/graphql/queries/Donations.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const Donations = gql`
|
||||||
|
query {
|
||||||
|
Donations {
|
||||||
|
id
|
||||||
|
showDonations
|
||||||
|
goal
|
||||||
|
progress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/JoinGroup.ts
Normal file
12
backend/src/graphql/queries/JoinGroup.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const JoinGroup = gql`
|
||||||
|
mutation ($groupId: ID!, $userId: ID!) {
|
||||||
|
JoinGroup(groupId: $groupId, userId: $userId) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
myRoleInGroup
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/LeaveGroup.ts
Normal file
12
backend/src/graphql/queries/LeaveGroup.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const LeaveGroup = gql`
|
||||||
|
mutation ($groupId: ID!, $userId: ID!) {
|
||||||
|
LeaveGroup(groupId: $groupId, userId: $userId) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
myRoleInGroup
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,9 +1,12 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const Post = gql`
|
export const Post = gql`
|
||||||
query ($orderBy: [_PostOrdering]) {
|
query ($id: ID, $filter: _PostFilter, $first: Int, $offset: Int, $orderBy: [_PostOrdering]) {
|
||||||
Post(orderBy: $orderBy) {
|
Post(id: $id, filter: $filter, first: $first, offset: $offset, orderBy: $orderBy) {
|
||||||
id
|
id
|
||||||
|
title
|
||||||
|
content
|
||||||
|
eventStart
|
||||||
pinned
|
pinned
|
||||||
createdAt
|
createdAt
|
||||||
pinnedAt
|
pinnedAt
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const PostsEmotionsByCurrentUser = gql`
|
||||||
|
query ($postId: ID!) {
|
||||||
|
PostsEmotionsByCurrentUser(postId: $postId)
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const PostsEmotionsCountByEmotion = gql`
|
||||||
|
query ($postId: ID!, $data: _EMOTEDInput!) {
|
||||||
|
PostsEmotionsCountByEmotion(postId: $postId, data: $data)
|
||||||
|
}
|
||||||
|
`
|
||||||
15
backend/src/graphql/queries/RemovePostEmotions.ts
Normal file
15
backend/src/graphql/queries/RemovePostEmotions.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const RemovePostEmotions = gql`
|
||||||
|
mutation ($to: _PostInput!, $data: _EMOTEDInput!) {
|
||||||
|
RemovePostEmotions(to: $to, data: $data) {
|
||||||
|
from {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
emotion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/RemoveUserFromGroup.ts
Normal file
12
backend/src/graphql/queries/RemoveUserFromGroup.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const RemoveUserFromGroup = gql`
|
||||||
|
mutation ($groupId: ID!, $userId: ID!) {
|
||||||
|
RemoveUserFromGroup(groupId: $groupId, userId: $userId) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
myRoleInGroup
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
34
backend/src/graphql/queries/Room.ts
Normal file
34
backend/src/graphql/queries/Room.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const Room = gql`
|
||||||
|
query Room($first: Int, $offset: Int, $id: ID) {
|
||||||
|
Room(first: $first, offset: $offset, id: $id, orderBy: lastMessageAt_desc) {
|
||||||
|
id
|
||||||
|
roomId
|
||||||
|
roomName
|
||||||
|
avatar
|
||||||
|
lastMessageAt
|
||||||
|
unreadCount
|
||||||
|
lastMessage {
|
||||||
|
_id
|
||||||
|
id
|
||||||
|
content
|
||||||
|
senderId
|
||||||
|
username
|
||||||
|
avatar
|
||||||
|
date
|
||||||
|
saved
|
||||||
|
distributed
|
||||||
|
seen
|
||||||
|
}
|
||||||
|
users {
|
||||||
|
_id
|
||||||
|
id
|
||||||
|
name
|
||||||
|
avatar {
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
9
backend/src/graphql/queries/Signup.ts
Normal file
9
backend/src/graphql/queries/Signup.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const Signup = gql`
|
||||||
|
mutation ($email: String!, $locale: String!, $inviteCode: String) {
|
||||||
|
Signup(email: $email, locale: $locale, inviteCode: $inviteCode) {
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const signupVerificationMutation = gql`
|
export const SignupVerification = gql`
|
||||||
mutation (
|
mutation (
|
||||||
$password: String!
|
$password: String!
|
||||||
$email: String!
|
$email: String!
|
||||||
7
backend/src/graphql/queries/UnreadRooms.ts
Normal file
7
backend/src/graphql/queries/UnreadRooms.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UnreadRooms = gql`
|
||||||
|
query {
|
||||||
|
UnreadRooms
|
||||||
|
}
|
||||||
|
`
|
||||||
12
backend/src/graphql/queries/UpdateComment.ts
Normal file
12
backend/src/graphql/queries/UpdateComment.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UpdateComment = gql`
|
||||||
|
mutation ($content: String!, $id: ID!) {
|
||||||
|
UpdateComment(content: $content, id: $id) {
|
||||||
|
id
|
||||||
|
content
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
14
backend/src/graphql/queries/UpdateDonations.ts
Normal file
14
backend/src/graphql/queries/UpdateDonations.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UpdateDonations = gql`
|
||||||
|
mutation ($showDonations: Boolean, $goal: Int, $progress: Int) {
|
||||||
|
UpdateDonations(showDonations: $showDonations, goal: $goal, progress: $progress) {
|
||||||
|
id
|
||||||
|
showDonations
|
||||||
|
goal
|
||||||
|
progress
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
54
backend/src/graphql/queries/UpdateGroup.ts
Normal file
54
backend/src/graphql/queries/UpdateGroup.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UpdateGroup = gql`
|
||||||
|
mutation (
|
||||||
|
$id: ID!
|
||||||
|
$name: String
|
||||||
|
$slug: String
|
||||||
|
$about: String
|
||||||
|
$description: String
|
||||||
|
$actionRadius: GroupActionRadius
|
||||||
|
$categoryIds: [ID]
|
||||||
|
$avatar: ImageInput
|
||||||
|
$locationName: String # empty string '' sets it to null
|
||||||
|
) {
|
||||||
|
UpdateGroup(
|
||||||
|
id: $id
|
||||||
|
name: $name
|
||||||
|
slug: $slug
|
||||||
|
about: $about
|
||||||
|
description: $description
|
||||||
|
actionRadius: $actionRadius
|
||||||
|
categoryIds: $categoryIds
|
||||||
|
avatar: $avatar
|
||||||
|
locationName: $locationName
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
disabled
|
||||||
|
deleted
|
||||||
|
about
|
||||||
|
description
|
||||||
|
descriptionExcerpt
|
||||||
|
groupType
|
||||||
|
actionRadius
|
||||||
|
categories {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
icon
|
||||||
|
}
|
||||||
|
# avatar # test this as result
|
||||||
|
locationName
|
||||||
|
location {
|
||||||
|
name
|
||||||
|
nameDE
|
||||||
|
nameEN
|
||||||
|
}
|
||||||
|
myRole
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
10
backend/src/graphql/queries/UpdatePost.ts
Normal file
10
backend/src/graphql/queries/UpdatePost.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UpdatePost = gql`
|
||||||
|
mutation ($id: ID!, $title: String!, $postContent: String!, $categoryIds: [ID]!) {
|
||||||
|
UpdatePost(id: $id, content: $postContent, title: $title, categoryIds: $categoryIds) {
|
||||||
|
title
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
10
backend/src/graphql/queries/UpdateSocialMedia.ts
Normal file
10
backend/src/graphql/queries/UpdateSocialMedia.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UpdateSocialMedia = gql`
|
||||||
|
mutation ($id: ID!, $url: String!) {
|
||||||
|
UpdateSocialMedia(id: $id, url: $url) {
|
||||||
|
id
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
9
backend/src/graphql/queries/UpdateUser.ts
Normal file
9
backend/src/graphql/queries/UpdateUser.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const UpdateUser = gql`
|
||||||
|
mutation ($id: ID!, $name: String) {
|
||||||
|
UpdateUser(id: $id, name: $name) {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
9
backend/src/graphql/queries/User.ts
Normal file
9
backend/src/graphql/queries/User.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const User = gql`
|
||||||
|
query ($name: String) {
|
||||||
|
User(name: $name) {
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
11
backend/src/graphql/queries/VerifyEmailAddress.ts
Normal file
11
backend/src/graphql/queries/VerifyEmailAddress.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const VerifyEmailAddress = gql`
|
||||||
|
mutation ($email: String!, $nonce: String!) {
|
||||||
|
VerifyEmailAddress(email: $email, nonce: $nonce) {
|
||||||
|
email
|
||||||
|
createdAt
|
||||||
|
verifiedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
7
backend/src/graphql/queries/VerifyNonce.ts
Normal file
7
backend/src/graphql/queries/VerifyNonce.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const VerifyNonce = gql`
|
||||||
|
query ($email: String!, $nonce: String!) {
|
||||||
|
VerifyNonce(email: $email, nonce: $nonce)
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const changeGroupMemberRoleMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {
|
|
||||||
ChangeGroupMemberRole(groupId: $groupId, userId: $userId, roleInGroup: $roleInGroup) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
myRoleInGroup
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
7
backend/src/graphql/queries/changePassword.ts
Normal file
7
backend/src/graphql/queries/changePassword.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const changePassword = gql`
|
||||||
|
mutation ($oldPassword: String!, $newPassword: String!) {
|
||||||
|
changePassword(oldPassword: $oldPassword, newPassword: $newPassword)
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,55 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const createGroupMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation (
|
|
||||||
$id: ID
|
|
||||||
$name: String!
|
|
||||||
$slug: String
|
|
||||||
$about: String
|
|
||||||
$description: String!
|
|
||||||
$groupType: GroupType!
|
|
||||||
$actionRadius: GroupActionRadius!
|
|
||||||
$categoryIds: [ID]
|
|
||||||
$locationName: String # empty string '' sets it to null
|
|
||||||
) {
|
|
||||||
CreateGroup(
|
|
||||||
id: $id
|
|
||||||
name: $name
|
|
||||||
slug: $slug
|
|
||||||
about: $about
|
|
||||||
description: $description
|
|
||||||
groupType: $groupType
|
|
||||||
actionRadius: $actionRadius
|
|
||||||
categoryIds: $categoryIds
|
|
||||||
locationName: $locationName
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
disabled
|
|
||||||
deleted
|
|
||||||
about
|
|
||||||
description
|
|
||||||
descriptionExcerpt
|
|
||||||
groupType
|
|
||||||
actionRadius
|
|
||||||
categories {
|
|
||||||
id
|
|
||||||
slug
|
|
||||||
name
|
|
||||||
icon
|
|
||||||
}
|
|
||||||
locationName
|
|
||||||
location {
|
|
||||||
name
|
|
||||||
nameDE
|
|
||||||
nameEN
|
|
||||||
}
|
|
||||||
myRole
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const createPostMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation (
|
|
||||||
$id: ID
|
|
||||||
$title: String!
|
|
||||||
$slug: String
|
|
||||||
$content: String!
|
|
||||||
$categoryIds: [ID]
|
|
||||||
$groupId: ID
|
|
||||||
$postType: PostType
|
|
||||||
$eventInput: _EventInput
|
|
||||||
) {
|
|
||||||
CreatePost(
|
|
||||||
id: $id
|
|
||||||
title: $title
|
|
||||||
slug: $slug
|
|
||||||
content: $content
|
|
||||||
categoryIds: $categoryIds
|
|
||||||
groupId: $groupId
|
|
||||||
postType: $postType
|
|
||||||
eventInput: $eventInput
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
slug
|
|
||||||
title
|
|
||||||
content
|
|
||||||
disabled
|
|
||||||
deleted
|
|
||||||
postType
|
|
||||||
author {
|
|
||||||
name
|
|
||||||
}
|
|
||||||
categories {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
eventStart
|
|
||||||
eventEnd
|
|
||||||
eventLocationName
|
|
||||||
eventVenue
|
|
||||||
eventIsOnline
|
|
||||||
eventLocation {
|
|
||||||
lng
|
|
||||||
lat
|
|
||||||
}
|
|
||||||
isObservedByMe
|
|
||||||
observingUsersCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const createRoomMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation ($userId: ID!) {
|
|
||||||
CreateRoom(userId: $userId) {
|
|
||||||
id
|
|
||||||
roomId
|
|
||||||
roomName
|
|
||||||
lastMessageAt
|
|
||||||
unreadCount
|
|
||||||
#avatar
|
|
||||||
users {
|
|
||||||
_id
|
|
||||||
id
|
|
||||||
name
|
|
||||||
avatar {
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
21
backend/src/graphql/queries/embed.ts
Normal file
21
backend/src/graphql/queries/embed.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const embed = gql`
|
||||||
|
query ($url: String!) {
|
||||||
|
embed(url: $url) {
|
||||||
|
type
|
||||||
|
title
|
||||||
|
author
|
||||||
|
publisher
|
||||||
|
date
|
||||||
|
description
|
||||||
|
url
|
||||||
|
image
|
||||||
|
audio
|
||||||
|
video
|
||||||
|
lang
|
||||||
|
sources
|
||||||
|
html
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
28
backend/src/graphql/queries/fileReport.ts
Normal file
28
backend/src/graphql/queries/fileReport.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const fileReport = gql`
|
||||||
|
mutation ($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
||||||
|
fileReport(
|
||||||
|
resourceId: $resourceId
|
||||||
|
reasonCategory: $reasonCategory
|
||||||
|
reasonDescription: $reasonDescription
|
||||||
|
) {
|
||||||
|
createdAt
|
||||||
|
reasonCategory
|
||||||
|
reasonDescription
|
||||||
|
reportId
|
||||||
|
resource {
|
||||||
|
__typename
|
||||||
|
... on User {
|
||||||
|
name
|
||||||
|
}
|
||||||
|
... on Post {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
... on Comment {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const filterPosts = () => {
|
|
||||||
return gql`
|
|
||||||
query Post($filter: _PostFilter, $first: Int, $offset: Int, $orderBy: [_PostOrdering]) {
|
|
||||||
Post(filter: $filter, first: $first, offset: $offset, orderBy: $orderBy) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
content
|
|
||||||
eventStart
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
14
backend/src/graphql/queries/followUser.ts
Normal file
14
backend/src/graphql/queries/followUser.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const followUser = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
followUser(id: $id) {
|
||||||
|
name
|
||||||
|
followedBy {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
followedByCurrentUser
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const joinGroupMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation ($groupId: ID!, $userId: ID!) {
|
|
||||||
JoinGroup(groupId: $groupId, userId: $userId) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
myRoleInGroup
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const leaveGroupMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation ($groupId: ID!, $userId: ID!) {
|
|
||||||
LeaveGroup(groupId: $groupId, userId: $userId) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
myRoleInGroup
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const loginMutation = gql`
|
export const login = gql`
|
||||||
mutation ($email: String!, $password: String!) {
|
mutation ($email: String!, $password: String!) {
|
||||||
login(email: $email, password: $password)
|
login(email: $email, password: $password)
|
||||||
}
|
}
|
||||||
19
backend/src/graphql/queries/markAllAsRead.ts
Normal file
19
backend/src/graphql/queries/markAllAsRead.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const markAllAsRead = gql`
|
||||||
|
mutation {
|
||||||
|
markAllAsRead {
|
||||||
|
from {
|
||||||
|
__typename
|
||||||
|
... on Post {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
... on Comment {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const markAllAsReadMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation {
|
|
||||||
markAllAsRead {
|
|
||||||
from {
|
|
||||||
__typename
|
|
||||||
... on Post {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
... on Comment {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
read
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
19
backend/src/graphql/queries/markAsRead.ts
Normal file
19
backend/src/graphql/queries/markAsRead.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const markAsRead = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
markAsRead(id: $id) {
|
||||||
|
from {
|
||||||
|
__typename
|
||||||
|
... on Post {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
... on Comment {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const markAsReadMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
markAsRead(id: $id) {
|
|
||||||
from {
|
|
||||||
__typename
|
|
||||||
... on Post {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
... on Comment {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
read
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
10
backend/src/graphql/queries/markTeaserAsViewed.ts
Normal file
10
backend/src/graphql/queries/markTeaserAsViewed.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const markTeaserAsViewed = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
markTeaserAsViewed(id: $id) {
|
||||||
|
id
|
||||||
|
viewedTeaserCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
10
backend/src/graphql/queries/muteGroup.ts
Normal file
10
backend/src/graphql/queries/muteGroup.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const muteGroup = gql`
|
||||||
|
mutation ($groupId: ID!) {
|
||||||
|
muteGroup(groupId: $groupId) {
|
||||||
|
id
|
||||||
|
isMutedByMe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
11
backend/src/graphql/queries/muteUser.ts
Normal file
11
backend/src/graphql/queries/muteUser.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const muteUser = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
muteUser(id: $id) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
isMuted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
11
backend/src/graphql/queries/mutedUsers.ts
Normal file
11
backend/src/graphql/queries/mutedUsers.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const mutedUsers = gql`
|
||||||
|
query {
|
||||||
|
mutedUsers {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
isMuted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,21 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const notificationQuery = () => {
|
|
||||||
return gql`
|
|
||||||
query ($read: Boolean, $orderBy: NotificationOrdering) {
|
|
||||||
notifications(read: $read, orderBy: $orderBy) {
|
|
||||||
from {
|
|
||||||
__typename
|
|
||||||
... on Post {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
... on Comment {
|
|
||||||
content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
read
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
19
backend/src/graphql/queries/notifications.ts
Normal file
19
backend/src/graphql/queries/notifications.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const notifications = gql`
|
||||||
|
query ($read: Boolean, $orderBy: NotificationOrdering) {
|
||||||
|
notifications(read: $read, orderBy: $orderBy) {
|
||||||
|
from {
|
||||||
|
__typename
|
||||||
|
... on Post {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
... on Comment {
|
||||||
|
content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
read
|
||||||
|
createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
24
backend/src/graphql/queries/pinPost.ts
Normal file
24
backend/src/graphql/queries/pinPost.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const pinPost = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
pinPost(id: $id) {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
content
|
||||||
|
author {
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
}
|
||||||
|
pinnedBy {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
role
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
pinnedAt
|
||||||
|
pinned
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,13 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const postQuery = () => {
|
|
||||||
return gql`
|
|
||||||
query Post($id: ID!) {
|
|
||||||
Post(id: $id) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
content
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
@ -1,18 +1,16 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const profilePagePosts = () => {
|
export const profilePagePosts = gql`
|
||||||
return gql`
|
query profilePagePosts(
|
||||||
query profilePagePosts(
|
$filter: _PostFilter
|
||||||
$filter: _PostFilter
|
$first: Int
|
||||||
$first: Int
|
$offset: Int
|
||||||
$offset: Int
|
$orderBy: [_PostOrdering]
|
||||||
$orderBy: [_PostOrdering]
|
) {
|
||||||
) {
|
profilePagePosts(filter: $filter, first: $first, offset: $offset, orderBy: $orderBy) {
|
||||||
profilePagePosts(filter: $filter, first: $first, offset: $offset, orderBy: $orderBy) {
|
id
|
||||||
id
|
title
|
||||||
title
|
content
|
||||||
content
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
}
|
`
|
||||||
|
|||||||
10
backend/src/graphql/queries/queryLocations.ts
Normal file
10
backend/src/graphql/queries/queryLocations.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const queryLocations = gql`
|
||||||
|
query ($place: String!, $lang: String!) {
|
||||||
|
queryLocations(place: $place, lang: $lang) {
|
||||||
|
place_name
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,14 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const removeUserFromGroupMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation ($groupId: ID!, $userId: ID!) {
|
|
||||||
RemoveUserFromGroup(groupId: $groupId, userId: $userId) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
myRoleInGroup
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
34
backend/src/graphql/queries/reports.ts
Normal file
34
backend/src/graphql/queries/reports.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const reports = gql`
|
||||||
|
query ($closed: Boolean) {
|
||||||
|
reports(orderBy: createdAt_desc, closed: $closed) {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
rule
|
||||||
|
disable
|
||||||
|
closed
|
||||||
|
resource {
|
||||||
|
__typename
|
||||||
|
... on User {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
... on Post {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
... on Comment {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
filed {
|
||||||
|
submitter {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
reasonCategory
|
||||||
|
reasonDescription
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
7
backend/src/graphql/queries/requestPasswordReset.ts
Normal file
7
backend/src/graphql/queries/requestPasswordReset.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const requestPasswordReset = gql`
|
||||||
|
mutation ($email: String!, $locale: String!) {
|
||||||
|
requestPasswordReset(email: $email, locale: $locale)
|
||||||
|
}
|
||||||
|
`
|
||||||
7
backend/src/graphql/queries/resetPassword.ts
Normal file
7
backend/src/graphql/queries/resetPassword.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const resetPassword = gql`
|
||||||
|
mutation ($nonce: String!, $email: String!, $newPassword: String!) {
|
||||||
|
resetPassword(nonce: $nonce, email: $email, newPassword: $newPassword)
|
||||||
|
}
|
||||||
|
`
|
||||||
17
backend/src/graphql/queries/resetTrophyBadgesSelected.ts
Normal file
17
backend/src/graphql/queries/resetTrophyBadgesSelected.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const resetTrophyBadgesSelected = gql`
|
||||||
|
mutation {
|
||||||
|
resetTrophyBadgesSelected {
|
||||||
|
badgeTrophiesCount
|
||||||
|
badgeTrophiesSelected {
|
||||||
|
id
|
||||||
|
isDefault
|
||||||
|
}
|
||||||
|
badgeTrophiesUnused {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
badgeTrophiesUnusedCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
37
backend/src/graphql/queries/review.ts
Normal file
37
backend/src/graphql/queries/review.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const review = gql`
|
||||||
|
mutation ($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
|
||||||
|
review(resourceId: $resourceId, disable: $disable, closed: $closed) {
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
resource {
|
||||||
|
__typename
|
||||||
|
... on User {
|
||||||
|
id
|
||||||
|
disabled
|
||||||
|
}
|
||||||
|
... on Post {
|
||||||
|
id
|
||||||
|
disabled
|
||||||
|
}
|
||||||
|
... on Comment {
|
||||||
|
id
|
||||||
|
disabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
report {
|
||||||
|
id
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
closed
|
||||||
|
reviewed {
|
||||||
|
createdAt
|
||||||
|
moderator {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
20
backend/src/graphql/queries/revokeBadge.ts
Normal file
20
backend/src/graphql/queries/revokeBadge.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const revokeBadge = gql`
|
||||||
|
mutation ($badgeId: ID!, $userId: ID!) {
|
||||||
|
revokeBadge(badgeId: $badgeId, userId: $userId) {
|
||||||
|
id
|
||||||
|
badgeTrophies {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
badgeVerification {
|
||||||
|
id
|
||||||
|
isDefault
|
||||||
|
}
|
||||||
|
badgeTrophiesSelected {
|
||||||
|
id
|
||||||
|
isDefault
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,36 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const roomQuery = () => {
|
|
||||||
return gql`
|
|
||||||
query Room($first: Int, $offset: Int, $id: ID) {
|
|
||||||
Room(first: $first, offset: $offset, id: $id, orderBy: lastMessageAt_desc) {
|
|
||||||
id
|
|
||||||
roomId
|
|
||||||
roomName
|
|
||||||
avatar
|
|
||||||
lastMessageAt
|
|
||||||
unreadCount
|
|
||||||
lastMessage {
|
|
||||||
_id
|
|
||||||
id
|
|
||||||
content
|
|
||||||
senderId
|
|
||||||
username
|
|
||||||
avatar
|
|
||||||
date
|
|
||||||
saved
|
|
||||||
distributed
|
|
||||||
seen
|
|
||||||
}
|
|
||||||
users {
|
|
||||||
_id
|
|
||||||
id
|
|
||||||
name
|
|
||||||
avatar {
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
7
backend/src/graphql/queries/saveCategorySettings.ts
Normal file
7
backend/src/graphql/queries/saveCategorySettings.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const saveCategorySettings = gql`
|
||||||
|
mutation ($activeCategories: [String]) {
|
||||||
|
saveCategorySettings(activeCategories: $activeCategories)
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,16 +1,14 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export const searchPosts = () => {
|
export const searchPosts = gql`
|
||||||
return gql`
|
query ($query: String!, $firstPosts: Int, $postsOffset: Int) {
|
||||||
query ($query: String!, $firstPosts: Int, $postsOffset: Int) {
|
searchPosts(query: $query, firstPosts: $firstPosts, postsOffset: $postsOffset) {
|
||||||
searchPosts(query: $query, firstPosts: $firstPosts, postsOffset: $postsOffset) {
|
postCount
|
||||||
postCount
|
posts {
|
||||||
posts {
|
id
|
||||||
id
|
title
|
||||||
title
|
content
|
||||||
content
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
}
|
`
|
||||||
|
|||||||
22
backend/src/graphql/queries/searchResults.ts
Normal file
22
backend/src/graphql/queries/searchResults.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const searchResults = gql`
|
||||||
|
query ($query: String!) {
|
||||||
|
searchResults(query: $query, limit: 5) {
|
||||||
|
__typename
|
||||||
|
... on Post {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
content
|
||||||
|
}
|
||||||
|
... on User {
|
||||||
|
id
|
||||||
|
slug
|
||||||
|
name
|
||||||
|
}
|
||||||
|
... on Tag {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
16
backend/src/graphql/queries/setVerificationBadge.ts
Normal file
16
backend/src/graphql/queries/setVerificationBadge.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const setVerificationBadge = gql`
|
||||||
|
mutation ($badgeId: ID!, $userId: ID!) {
|
||||||
|
setVerificationBadge(badgeId: $badgeId, userId: $userId) {
|
||||||
|
id
|
||||||
|
badgeVerification {
|
||||||
|
id
|
||||||
|
isDefault
|
||||||
|
}
|
||||||
|
badgeTrophies {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
7
backend/src/graphql/queries/shout.ts
Normal file
7
backend/src/graphql/queries/shout.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const shout = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
shout(id: $id, type: Post)
|
||||||
|
}
|
||||||
|
`
|
||||||
13
backend/src/graphql/queries/switchUserRole.ts
Normal file
13
backend/src/graphql/queries/switchUserRole.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const switchUserRole = gql`
|
||||||
|
mutation ($role: UserRole!, $id: ID!) {
|
||||||
|
switchUserRole(role: $role, id: $id) {
|
||||||
|
name
|
||||||
|
role
|
||||||
|
id
|
||||||
|
updatedAt
|
||||||
|
email
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
10
backend/src/graphql/queries/toggleObservePost.ts
Normal file
10
backend/src/graphql/queries/toggleObservePost.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const toggleObservePost = gql`
|
||||||
|
mutation ($id: ID!, $value: Boolean!) {
|
||||||
|
toggleObservePost(id: $id, value: $value) {
|
||||||
|
isObservedByMe
|
||||||
|
observingUsersCount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
14
backend/src/graphql/queries/unfollowUser.ts
Normal file
14
backend/src/graphql/queries/unfollowUser.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const unfollowUser = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
unfollowUser(id: $id) {
|
||||||
|
name
|
||||||
|
followedBy {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
followedByCurrentUser
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
10
backend/src/graphql/queries/unmuteGroup.ts
Normal file
10
backend/src/graphql/queries/unmuteGroup.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const unmuteGroup = gql`
|
||||||
|
mutation ($groupId: ID!) {
|
||||||
|
unmuteGroup(groupId: $groupId) {
|
||||||
|
id
|
||||||
|
isMutedByMe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
11
backend/src/graphql/queries/unmuteUser.ts
Normal file
11
backend/src/graphql/queries/unmuteUser.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const unmuteUser = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
unmuteUser(id: $id) {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
isMuted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
24
backend/src/graphql/queries/unpinPost.ts
Normal file
24
backend/src/graphql/queries/unpinPost.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const unpinPost = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
unpinPost(id: $id) {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
content
|
||||||
|
author {
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
}
|
||||||
|
pinnedBy {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
role
|
||||||
|
}
|
||||||
|
createdAt
|
||||||
|
updatedAt
|
||||||
|
pinned
|
||||||
|
pinnedAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const unreadRoomsQuery = () => {
|
|
||||||
return gql`
|
|
||||||
query {
|
|
||||||
UnreadRooms
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
7
backend/src/graphql/queries/unshout.ts
Normal file
7
backend/src/graphql/queries/unshout.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const unshout = gql`
|
||||||
|
mutation ($id: ID!) {
|
||||||
|
unshout(id: $id, type: Post)
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -1,56 +0,0 @@
|
|||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
export const updateGroupMutation = () => {
|
|
||||||
return gql`
|
|
||||||
mutation (
|
|
||||||
$id: ID!
|
|
||||||
$name: String
|
|
||||||
$slug: String
|
|
||||||
$about: String
|
|
||||||
$description: String
|
|
||||||
$actionRadius: GroupActionRadius
|
|
||||||
$categoryIds: [ID]
|
|
||||||
$avatar: ImageInput
|
|
||||||
$locationName: String # empty string '' sets it to null
|
|
||||||
) {
|
|
||||||
UpdateGroup(
|
|
||||||
id: $id
|
|
||||||
name: $name
|
|
||||||
slug: $slug
|
|
||||||
about: $about
|
|
||||||
description: $description
|
|
||||||
actionRadius: $actionRadius
|
|
||||||
categoryIds: $categoryIds
|
|
||||||
avatar: $avatar
|
|
||||||
locationName: $locationName
|
|
||||||
) {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
disabled
|
|
||||||
deleted
|
|
||||||
about
|
|
||||||
description
|
|
||||||
descriptionExcerpt
|
|
||||||
groupType
|
|
||||||
actionRadius
|
|
||||||
categories {
|
|
||||||
id
|
|
||||||
slug
|
|
||||||
name
|
|
||||||
icon
|
|
||||||
}
|
|
||||||
# avatar # test this as result
|
|
||||||
locationName
|
|
||||||
location {
|
|
||||||
name
|
|
||||||
nameDE
|
|
||||||
nameEN
|
|
||||||
}
|
|
||||||
myRole
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
}
|
|
||||||
7
backend/src/graphql/queries/updateOnlineStatus.ts
Normal file
7
backend/src/graphql/queries/updateOnlineStatus.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const updateOnlineStatus = gql`
|
||||||
|
mutation ($status: OnlineStatus!) {
|
||||||
|
updateOnlineStatus(status: $status)
|
||||||
|
}
|
||||||
|
`
|
||||||
24
backend/src/graphql/queries/userData.ts
Normal file
24
backend/src/graphql/queries/userData.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
export const userData = gql`
|
||||||
|
query ($id: ID!) {
|
||||||
|
userData(id: $id) {
|
||||||
|
user {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
}
|
||||||
|
posts {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
content
|
||||||
|
comments {
|
||||||
|
content
|
||||||
|
author {
|
||||||
|
slug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
@ -13,7 +13,7 @@ import { UserInputError } from 'apollo-server'
|
|||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import File from '@db/models/File'
|
import File from '@db/models/File'
|
||||||
import { CreateMessage } from '@graphql/queries/CreateMessage'
|
import { CreateMessage } from '@graphql/queries/CreateMessage'
|
||||||
import { createRoomMutation } from '@graphql/queries/createRoomMutation'
|
import { CreateRoom } from '@graphql/queries/CreateRoom'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { S3Config } from '@src/config'
|
import type { S3Config } from '@src/config'
|
||||||
@ -93,7 +93,7 @@ describe('delete Attachment', () => {
|
|||||||
|
|
||||||
authenticatedUser = user
|
authenticatedUser = user
|
||||||
const { data: room } = await mutate({
|
const { data: room } = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: chatPartner.id,
|
userId: chatPartner.id,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,8 +5,10 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
import { TROPHY_BADGES_SELECTED_MAX } from '@constants/badges'
|
import { TROPHY_BADGES_SELECTED_MAX } from '@constants/badges'
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
|
import { revokeBadge } from '@graphql/queries/revokeBadge'
|
||||||
import { rewardTrophyBadge } from '@graphql/queries/rewardTrophyBadge'
|
import { rewardTrophyBadge } from '@graphql/queries/rewardTrophyBadge'
|
||||||
import { setTrophyBadgeSelected } from '@graphql/queries/setTrophyBadgeSelected'
|
import { setTrophyBadgeSelected } from '@graphql/queries/setTrophyBadgeSelected'
|
||||||
|
import { setVerificationBadge } from '@graphql/queries/setVerificationBadge'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -93,27 +95,10 @@ describe('Badges', () => {
|
|||||||
userId: 'regular-user-id',
|
userId: 'regular-user-id',
|
||||||
}
|
}
|
||||||
|
|
||||||
const setVerificationBadgeMutation = gql`
|
|
||||||
mutation ($badgeId: ID!, $userId: ID!) {
|
|
||||||
setVerificationBadge(badgeId: $badgeId, userId: $userId) {
|
|
||||||
id
|
|
||||||
badgeVerification {
|
|
||||||
id
|
|
||||||
isDefault
|
|
||||||
}
|
|
||||||
badgeTrophies {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
await expect(
|
await expect(mutate({ mutation: setVerificationBadge, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: setVerificationBadgeMutation, variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: { setVerificationBadge: null },
|
data: { setVerificationBadge: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -128,7 +113,7 @@ describe('Badges', () => {
|
|||||||
describe('rewards badge to user', () => {
|
describe('rewards badge to user', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: setVerificationBadgeMutation, variables }),
|
mutate({ mutation: setVerificationBadge, variables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { setVerificationBadge: null },
|
data: { setVerificationBadge: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
@ -146,7 +131,7 @@ describe('Badges', () => {
|
|||||||
it('rejects with an informative error message', async () => {
|
it('rejects with an informative error message', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables: { userId: 'regular-user-id', badgeId: 'non-existent-badge-id' },
|
variables: { userId: 'regular-user-id', badgeId: 'non-existent-badge-id' },
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -165,7 +150,7 @@ describe('Badges', () => {
|
|||||||
it('rejects with a telling error message', async () => {
|
it('rejects with a telling error message', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables: { userId: 'non-existent-user-id', badgeId: 'verification_moderator' },
|
variables: { userId: 'non-existent-user-id', badgeId: 'verification_moderator' },
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -184,7 +169,7 @@ describe('Badges', () => {
|
|||||||
it('rejects with a telling error message', async () => {
|
it('rejects with a telling error message', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables: { userId: 'regular-user-id', badgeId: 'trophy_rhino' },
|
variables: { userId: 'regular-user-id', badgeId: 'trophy_rhino' },
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -210,9 +195,9 @@ describe('Badges', () => {
|
|||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(mutate({ mutation: setVerificationBadge, variables })).resolves.toMatchObject(
|
||||||
mutate({ mutation: setVerificationBadgeMutation, variables }),
|
expected,
|
||||||
).resolves.toMatchObject(expected)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('overrides the existing verification if a second verification badge is rewarded to the same user', async () => {
|
it('overrides the existing verification if a second verification badge is rewarded to the same user', async () => {
|
||||||
@ -233,7 +218,7 @@ describe('Badges', () => {
|
|||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'regular-user-id',
|
userId: 'regular-user-id',
|
||||||
badgeId: 'verification_moderator',
|
badgeId: 'verification_moderator',
|
||||||
@ -241,7 +226,7 @@ describe('Badges', () => {
|
|||||||
})
|
})
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'regular-user-id',
|
userId: 'regular-user-id',
|
||||||
badgeId: 'verification_admin',
|
badgeId: 'verification_admin',
|
||||||
@ -271,12 +256,12 @@ describe('Badges', () => {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: setVerificationBadgeMutation,
|
mutation: setVerificationBadge,
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'regular-user-2-id',
|
userId: 'regular-user-2-id',
|
||||||
badgeId: 'verification_moderator',
|
badgeId: 'verification_moderator',
|
||||||
@ -812,25 +797,6 @@ describe('Badges', () => {
|
|||||||
await regularUser.relateTo(badge, 'selected', { slot: 6 })
|
await regularUser.relateTo(badge, 'selected', { slot: 6 })
|
||||||
})
|
})
|
||||||
|
|
||||||
const revokeBadgeMutation = gql`
|
|
||||||
mutation ($badgeId: ID!, $userId: ID!) {
|
|
||||||
revokeBadge(badgeId: $badgeId, userId: $userId) {
|
|
||||||
id
|
|
||||||
badgeTrophies {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
badgeVerification {
|
|
||||||
id
|
|
||||||
isDefault
|
|
||||||
}
|
|
||||||
badgeTrophiesSelected {
|
|
||||||
id
|
|
||||||
isDefault
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('check test setup', () => {
|
describe('check test setup', () => {
|
||||||
it('user has one badge and has it selected', async () => {
|
it('user has one badge and has it selected', async () => {
|
||||||
authenticatedUser = await regularUser.toJson()
|
authenticatedUser = await regularUser.toJson()
|
||||||
@ -912,7 +878,7 @@ describe('Badges', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
await expect(mutate({ mutation: revokeBadgeMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: revokeBadge, variables })).resolves.toMatchObject({
|
||||||
data: { revokeBadge: null },
|
data: { revokeBadge: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -926,12 +892,10 @@ describe('Badges', () => {
|
|||||||
|
|
||||||
describe('removes badge from user', () => {
|
describe('removes badge from user', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(mutate({ mutation: revokeBadgeMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: revokeBadge, variables })).resolves.toMatchObject({
|
||||||
{
|
data: { revokeBadge: null },
|
||||||
data: { revokeBadge: null },
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -942,7 +906,7 @@ describe('Badges', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('removes a badge from user', async () => {
|
it('removes a badge from user', async () => {
|
||||||
await expect(mutate({ mutation: revokeBadgeMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: revokeBadge, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
revokeBadge: {
|
revokeBadge: {
|
||||||
id: 'regular-user-id',
|
id: 'regular-user-id',
|
||||||
@ -993,8 +957,8 @@ describe('Badges', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('does not crash when revoking multiple times', async () => {
|
it('does not crash when revoking multiple times', async () => {
|
||||||
await mutate({ mutation: revokeBadgeMutation, variables })
|
await mutate({ mutation: revokeBadge, variables })
|
||||||
await expect(mutate({ mutation: revokeBadgeMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: revokeBadge, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
revokeBadge: {
|
revokeBadge: {
|
||||||
id: 'regular-user-id',
|
id: 'regular-user-id',
|
||||||
@ -1047,7 +1011,7 @@ describe('Badges', () => {
|
|||||||
it('removes a verification from user', async () => {
|
it('removes a verification from user', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: revokeBadgeMutation,
|
mutation: revokeBadge,
|
||||||
variables: {
|
variables: {
|
||||||
badgeId: 'verification_moderator',
|
badgeId: 'verification_moderator',
|
||||||
userId: 'regular-user-id',
|
userId: 'regular-user-id',
|
||||||
@ -1105,7 +1069,7 @@ describe('Badges', () => {
|
|||||||
|
|
||||||
it('does not crash when removing verification multiple times', async () => {
|
it('does not crash when removing verification multiple times', async () => {
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: revokeBadgeMutation,
|
mutation: revokeBadge,
|
||||||
variables: {
|
variables: {
|
||||||
badgeId: 'verification_moderator',
|
badgeId: 'verification_moderator',
|
||||||
userId: 'regular-user-id',
|
userId: 'regular-user-id',
|
||||||
@ -1113,7 +1077,7 @@ describe('Badges', () => {
|
|||||||
})
|
})
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: revokeBadgeMutation,
|
mutation: revokeBadge,
|
||||||
variables: {
|
variables: {
|
||||||
badgeId: 'verification_moderator',
|
badgeId: 'verification_moderator',
|
||||||
userId: 'regular-user-id',
|
userId: 'regular-user-id',
|
||||||
|
|||||||
@ -2,9 +2,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
|
import { CreateComment } from '@graphql/queries/CreateComment'
|
||||||
|
import { DeleteComment } from '@graphql/queries/DeleteComment'
|
||||||
|
import { UpdateComment as updateComment } from '@graphql/queries/UpdateComment'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -46,17 +47,6 @@ afterEach(async () => {
|
|||||||
await cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
const createCommentMutation = gql`
|
|
||||||
mutation ($id: ID, $postId: ID!, $content: String!) {
|
|
||||||
CreateComment(id: $id, postId: $postId, content: $content) {
|
|
||||||
id
|
|
||||||
content
|
|
||||||
author {
|
|
||||||
name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
const setupPostAndComment = async () => {
|
const setupPostAndComment = async () => {
|
||||||
commentAuthor = await Factory.build('user')
|
commentAuthor = await Factory.build('user')
|
||||||
await Factory.build(
|
await Factory.build(
|
||||||
@ -95,7 +85,7 @@ describe('CreateComment', () => {
|
|||||||
postId: 'p1',
|
postId: 'p1',
|
||||||
content: "I'm not authorized to comment",
|
content: "I'm not authorized to comment",
|
||||||
}
|
}
|
||||||
const { errors } = await mutate({ mutation: createCommentMutation, variables })
|
const { errors } = await mutate({ mutation: CreateComment, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -117,44 +107,29 @@ describe('CreateComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('creates a comment', async () => {
|
it('creates a comment', async () => {
|
||||||
await expect(mutate({ mutation: createCommentMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: CreateComment, variables })).resolves.toMatchObject({
|
||||||
{
|
data: { CreateComment: { content: "I'm authorized to comment" } },
|
||||||
data: { CreateComment: { content: "I'm authorized to comment" } },
|
errors: undefined,
|
||||||
errors: undefined,
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('assigns the authenticated user as author', async () => {
|
it('assigns the authenticated user as author', async () => {
|
||||||
await expect(mutate({ mutation: createCommentMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: CreateComment, variables })).resolves.toMatchObject({
|
||||||
{
|
data: { CreateComment: { author: { name: 'Author' } } },
|
||||||
data: { CreateComment: { author: { name: 'Author' } } },
|
errors: undefined,
|
||||||
errors: undefined,
|
})
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('UpdateComment', () => {
|
describe('UpdateComment', () => {
|
||||||
const updateCommentMutation = gql`
|
|
||||||
mutation ($content: String!, $id: ID!) {
|
|
||||||
UpdateComment(content: $content, id: $id) {
|
|
||||||
id
|
|
||||||
content
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('given a post and a comment', () => {
|
describe('given a post and a comment', () => {
|
||||||
beforeEach(setupPostAndComment)
|
beforeEach(setupPostAndComment)
|
||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: updateCommentMutation, variables })
|
const { errors } = await mutate({ mutation: updateComment, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -166,7 +141,7 @@ describe('UpdateComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: updateCommentMutation, variables })
|
const { errors } = await mutate({ mutation: updateComment, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -181,7 +156,7 @@ describe('UpdateComment', () => {
|
|||||||
data: { UpdateComment: { id: 'c456', content: 'The comment is updated' } },
|
data: { UpdateComment: { id: 'c456', content: 'The comment is updated' } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: updateCommentMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: updateComment, variables })).resolves.toMatchObject(
|
||||||
expected,
|
expected,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -197,7 +172,7 @@ describe('UpdateComment', () => {
|
|||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: updateCommentMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: updateComment, variables })).resolves.toMatchObject(
|
||||||
expected,
|
expected,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -206,7 +181,7 @@ describe('UpdateComment', () => {
|
|||||||
newlyCreatedComment = await newlyCreatedComment.toJson()
|
newlyCreatedComment = await newlyCreatedComment.toJson()
|
||||||
const {
|
const {
|
||||||
data: { UpdateComment },
|
data: { UpdateComment },
|
||||||
} = (await mutate({ mutation: updateCommentMutation, variables })) as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
} = (await mutate({ mutation: updateComment, variables })) as any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
expect(newlyCreatedComment.updatedAt).toBeTruthy()
|
expect(newlyCreatedComment.updatedAt).toBeTruthy()
|
||||||
expect(Date.parse(newlyCreatedComment.updatedAt)).toEqual(expect.any(Number))
|
expect(Date.parse(newlyCreatedComment.updatedAt)).toEqual(expect.any(Number))
|
||||||
expect(UpdateComment.updatedAt).toBeTruthy()
|
expect(UpdateComment.updatedAt).toBeTruthy()
|
||||||
@ -220,7 +195,7 @@ describe('UpdateComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns null', async () => {
|
it('returns null', async () => {
|
||||||
const { data, errors } = await mutate({ mutation: updateCommentMutation, variables })
|
const { data, errors } = await mutate({ mutation: updateComment, variables })
|
||||||
expect(data).toMatchObject({ UpdateComment: null })
|
expect(data).toMatchObject({ UpdateComment: null })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
@ -230,23 +205,12 @@ describe('UpdateComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('DeleteComment', () => {
|
describe('DeleteComment', () => {
|
||||||
const deleteCommentMutation = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
DeleteComment(id: $id) {
|
|
||||||
id
|
|
||||||
content
|
|
||||||
contentExcerpt
|
|
||||||
deleted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('given a post and a comment', () => {
|
describe('given a post and a comment', () => {
|
||||||
beforeEach(setupPostAndComment)
|
beforeEach(setupPostAndComment)
|
||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const result = await mutate({ mutation: deleteCommentMutation, variables })
|
const result = await mutate({ mutation: DeleteComment, variables })
|
||||||
expect(result.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(result.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -258,7 +222,7 @@ describe('DeleteComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: deleteCommentMutation, variables })
|
const { errors } = await mutate({ mutation: DeleteComment, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -269,7 +233,7 @@ describe('DeleteComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('marks the comment as deleted and blacks out content', async () => {
|
it('marks the comment as deleted and blacks out content', async () => {
|
||||||
const { data } = await mutate({ mutation: deleteCommentMutation, variables })
|
const { data } = await mutate({ mutation: DeleteComment, variables })
|
||||||
const expected = {
|
const expected = {
|
||||||
DeleteComment: {
|
DeleteComment: {
|
||||||
id: 'c456',
|
id: 'c456',
|
||||||
|
|||||||
@ -3,39 +3,17 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { getNeode, getDriver } from '@db/neo4j'
|
import { getNeode, getDriver } from '@db/neo4j'
|
||||||
|
import { Donations } from '@graphql/queries/Donations'
|
||||||
|
import { UpdateDonations as updateDonations } from '@graphql/queries/UpdateDonations'
|
||||||
import createServer from '@src/server'
|
import createServer from '@src/server'
|
||||||
|
|
||||||
let mutate, query, authenticatedUser, variables
|
let mutate, query, authenticatedUser, variables
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
const updateDonationsMutation = gql`
|
|
||||||
mutation ($showDonations: Boolean, $goal: Int, $progress: Int) {
|
|
||||||
UpdateDonations(showDonations: $showDonations, goal: $goal, progress: $progress) {
|
|
||||||
id
|
|
||||||
showDonations
|
|
||||||
goal
|
|
||||||
progress
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
const donationsQuery = gql`
|
|
||||||
query {
|
|
||||||
Donations {
|
|
||||||
id
|
|
||||||
showDonations
|
|
||||||
goal
|
|
||||||
progress
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
@ -77,7 +55,7 @@ describe('donations', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = undefined
|
authenticatedUser = undefined
|
||||||
await expect(query({ query: donationsQuery, variables })).resolves.toMatchObject({
|
await expect(query({ query: Donations, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -93,7 +71,7 @@ describe('donations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns the current Donations info', async () => {
|
it('returns the current Donations info', async () => {
|
||||||
await expect(query({ query: donationsQuery, variables })).resolves.toMatchObject({
|
await expect(query({ query: Donations, variables })).resolves.toMatchObject({
|
||||||
data: { Donations: { showDonations: true, goal: 15000, progress: 7000 } },
|
data: { Donations: { showDonations: true, goal: 15000, progress: 7000 } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
})
|
})
|
||||||
@ -109,9 +87,7 @@ describe('donations', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = undefined
|
authenticatedUser = undefined
|
||||||
await expect(
|
await expect(mutate({ mutation: updateDonations, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: updateDonationsMutation, variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -128,9 +104,7 @@ describe('donations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(
|
await expect(mutate({ mutation: updateDonations, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: updateDonationsMutation, variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: { UpdateDonations: null },
|
data: { UpdateDonations: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -147,9 +121,7 @@ describe('donations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(
|
await expect(mutate({ mutation: updateDonations, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: updateDonationsMutation, variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: { UpdateDonations: null },
|
data: { UpdateDonations: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -166,9 +138,7 @@ describe('donations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('updates Donations info', async () => {
|
it('updates Donations info', async () => {
|
||||||
await expect(
|
await expect(mutate({ mutation: updateDonations, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: updateDonationsMutation, variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: { UpdateDonations: { showDonations: false, goal: 20000, progress: 3000 } },
|
data: { UpdateDonations: { showDonations: false, goal: 20000, progress: 3000 } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
})
|
})
|
||||||
@ -178,7 +148,7 @@ describe('donations', () => {
|
|||||||
newlyCreatedDonations = await newlyCreatedDonations.toJson()
|
newlyCreatedDonations = await newlyCreatedDonations.toJson()
|
||||||
const {
|
const {
|
||||||
data: { UpdateDonations },
|
data: { UpdateDonations },
|
||||||
} = await mutate({ mutation: updateDonationsMutation, variables })
|
} = await mutate({ mutation: updateDonations, variables })
|
||||||
expect(newlyCreatedDonations.updatedAt).toBeTruthy()
|
expect(newlyCreatedDonations.updatedAt).toBeTruthy()
|
||||||
expect(Date.parse(newlyCreatedDonations.updatedAt)).toEqual(expect.any(Number))
|
expect(Date.parse(newlyCreatedDonations.updatedAt)).toEqual(expect.any(Number))
|
||||||
expect(UpdateDonations.updatedAt).toBeTruthy()
|
expect(UpdateDonations.updatedAt).toBeTruthy()
|
||||||
|
|||||||
@ -4,10 +4,12 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { getDriver, getNeode } from '@db/neo4j'
|
import { getDriver, getNeode } from '@db/neo4j'
|
||||||
|
import { AddEmailAddress } from '@graphql/queries/AddEmailAddress'
|
||||||
|
import { VerifyEmailAddress } from '@graphql/queries/VerifyEmailAddress'
|
||||||
|
import { VerifyNonce } from '@graphql/queries/VerifyNonce'
|
||||||
import createServer from '@src/server'
|
import createServer from '@src/server'
|
||||||
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
@ -49,15 +51,6 @@ afterEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('AddEmailAddress', () => {
|
describe('AddEmailAddress', () => {
|
||||||
const mutation = gql`
|
|
||||||
mutation ($email: String!) {
|
|
||||||
AddEmailAddress(email: $email) {
|
|
||||||
email
|
|
||||||
verifiedAt
|
|
||||||
createdAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = { ...variables, email: 'new-email@example.org' }
|
variables = { ...variables, email: 'new-email@example.org' }
|
||||||
})
|
})
|
||||||
@ -68,7 +61,7 @@ describe('AddEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws AuthorizationError', async () => {
|
it('throws AuthorizationError', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: AddEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: { AddEmailAddress: null },
|
data: { AddEmailAddress: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -87,7 +80,7 @@ describe('AddEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws UserInputError', async () => {
|
it('throws UserInputError', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: AddEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: { AddEmailAddress: null },
|
data: { AddEmailAddress: null },
|
||||||
errors: [{ message: 'must be a valid email' }],
|
errors: [{ message: 'must be a valid email' }],
|
||||||
})
|
})
|
||||||
@ -96,7 +89,7 @@ describe('AddEmailAddress', () => {
|
|||||||
|
|
||||||
describe('email attribute is a valid email', () => {
|
describe('email attribute is a valid email', () => {
|
||||||
it('creates a new unverified `EmailAddress` node', async () => {
|
it('creates a new unverified `EmailAddress` node', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: AddEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
AddEmailAddress: {
|
AddEmailAddress: {
|
||||||
email: 'new-email@example.org',
|
email: 'new-email@example.org',
|
||||||
@ -109,7 +102,7 @@ describe('AddEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('connects `UnverifiedEmailAddress` to the authenticated user', async () => {
|
it('connects `UnverifiedEmailAddress` to the authenticated user', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: AddEmailAddress, variables })
|
||||||
const result = await neode.cypher(
|
const result = await neode.cypher(
|
||||||
`
|
`
|
||||||
MATCH(u:User)-[:PRIMARY_EMAIL]->(:EmailAddress {email: "user@example.org"})
|
MATCH(u:User)-[:PRIMARY_EMAIL]->(:EmailAddress {email: "user@example.org"})
|
||||||
@ -131,7 +124,7 @@ describe('AddEmailAddress', () => {
|
|||||||
createdAt: '2019-09-24T14:00:01.565Z',
|
createdAt: '2019-09-24T14:00:01.565Z',
|
||||||
email: 'new-email@example.org',
|
email: 'new-email@example.org',
|
||||||
})
|
})
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: AddEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
AddEmailAddress: {
|
AddEmailAddress: {
|
||||||
email: 'new-email@example.org',
|
email: 'new-email@example.org',
|
||||||
@ -146,7 +139,7 @@ describe('AddEmailAddress', () => {
|
|||||||
describe('but if another user owns an `EmailAddress` already with that email', () => {
|
describe('but if another user owns an `EmailAddress` already with that email', () => {
|
||||||
it('does not throw UserInputError', async () => {
|
it('does not throw UserInputError', async () => {
|
||||||
await Factory.build('user', {}, { email: 'new-email@example.org' })
|
await Factory.build('user', {}, { email: 'new-email@example.org' })
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: AddEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
AddEmailAddress: {
|
AddEmailAddress: {
|
||||||
createdAt: expect.any(String),
|
createdAt: expect.any(String),
|
||||||
@ -163,16 +156,6 @@ describe('AddEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('VerifyEmailAddress', () => {
|
describe('VerifyEmailAddress', () => {
|
||||||
const mutation = gql`
|
|
||||||
mutation ($email: String!, $nonce: String!) {
|
|
||||||
VerifyEmailAddress(email: $email, nonce: $nonce) {
|
|
||||||
email
|
|
||||||
createdAt
|
|
||||||
verifiedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = { ...variables, email: 'to-be-verified@example.org', nonce: '12345' }
|
variables = { ...variables, email: 'to-be-verified@example.org', nonce: '12345' }
|
||||||
})
|
})
|
||||||
@ -183,7 +166,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws AuthorizationError', async () => {
|
it('throws AuthorizationError', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: VerifyEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: { VerifyEmailAddress: null },
|
data: { VerifyEmailAddress: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -198,7 +181,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
|
|
||||||
describe('if no unverified `EmailAddress` node exists', () => {
|
describe('if no unverified `EmailAddress` node exists', () => {
|
||||||
it('throws UserInputError', async () => {
|
it('throws UserInputError', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: VerifyEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: { VerifyEmailAddress: null },
|
data: { VerifyEmailAddress: null },
|
||||||
errors: [{ message: 'Invalid nonce or no email address found.' }],
|
errors: [{ message: 'Invalid nonce or no email address found.' }],
|
||||||
})
|
})
|
||||||
@ -219,7 +202,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
describe('given invalid nonce', () => {
|
describe('given invalid nonce', () => {
|
||||||
it('throws UserInputError', async () => {
|
it('throws UserInputError', async () => {
|
||||||
variables.nonce = 'asdfgh'
|
variables.nonce = 'asdfgh'
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: VerifyEmailAddress, variables })).resolves.toMatchObject({
|
||||||
data: { VerifyEmailAddress: null },
|
data: { VerifyEmailAddress: null },
|
||||||
errors: [{ message: 'Invalid nonce or no email address found.' }],
|
errors: [{ message: 'Invalid nonce or no email address found.' }],
|
||||||
})
|
})
|
||||||
@ -233,7 +216,9 @@ describe('VerifyEmailAddress', () => {
|
|||||||
|
|
||||||
describe('but the address does not belong to the authenticated user', () => {
|
describe('but the address does not belong to the authenticated user', () => {
|
||||||
it('throws UserInputError', async () => {
|
it('throws UserInputError', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(
|
||||||
|
mutate({ mutation: VerifyEmailAddress, variables }),
|
||||||
|
).resolves.toMatchObject({
|
||||||
data: { VerifyEmailAddress: null },
|
data: { VerifyEmailAddress: null },
|
||||||
errors: [{ message: 'Invalid nonce or no email address found.' }],
|
errors: [{ message: 'Invalid nonce or no email address found.' }],
|
||||||
})
|
})
|
||||||
@ -246,7 +231,9 @@ describe('VerifyEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('adds `verifiedAt`', async () => {
|
it('adds `verifiedAt`', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(
|
||||||
|
mutate({ mutation: VerifyEmailAddress, variables }),
|
||||||
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
VerifyEmailAddress: {
|
VerifyEmailAddress: {
|
||||||
email: 'to-be-verified@example.org',
|
email: 'to-be-verified@example.org',
|
||||||
@ -259,7 +246,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('connects the new `EmailAddress` as PRIMARY', async () => {
|
it('connects the new `EmailAddress` as PRIMARY', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: VerifyEmailAddress, variables })
|
||||||
const result = await neode.cypher(
|
const result = await neode.cypher(
|
||||||
`
|
`
|
||||||
MATCH(u:User {id: "567"})-[:PRIMARY_EMAIL]->(e:EmailAddress {email: "to-be-verified@example.org"})
|
MATCH(u:User {id: "567"})-[:PRIMARY_EMAIL]->(e:EmailAddress {email: "to-be-verified@example.org"})
|
||||||
@ -283,7 +270,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
await expect(email.toJson()).resolves.toMatchObject({
|
await expect(email.toJson()).resolves.toMatchObject({
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
})
|
})
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: VerifyEmailAddress, variables })
|
||||||
result = await neode.cypher(cypherStatement, {})
|
result = await neode.cypher(cypherStatement, {})
|
||||||
email = neode.hydrateFirst(result, 'e', neode.model('EmailAddress'))
|
email = neode.hydrateFirst(result, 'e', neode.model('EmailAddress'))
|
||||||
await expect(email).toBe(false)
|
await expect(email).toBe(false)
|
||||||
@ -299,7 +286,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
await expect(email.toJson()).resolves.toMatchObject({
|
await expect(email.toJson()).resolves.toMatchObject({
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
})
|
})
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: VerifyEmailAddress, variables })
|
||||||
result = await neode.cypher(cypherStatement, {})
|
result = await neode.cypher(cypherStatement, {})
|
||||||
email = neode.hydrateFirst(result, 'e', neode.model('EmailAddress'))
|
email = neode.hydrateFirst(result, 'e', neode.model('EmailAddress'))
|
||||||
await expect(email).toBe(false)
|
await expect(email).toBe(false)
|
||||||
@ -311,7 +298,9 @@ describe('VerifyEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws UserInputError because of unique constraints', async () => {
|
it('throws UserInputError because of unique constraints', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(
|
||||||
|
mutate({ mutation: VerifyEmailAddress, variables }),
|
||||||
|
).resolves.toMatchObject({
|
||||||
data: { VerifyEmailAddress: null },
|
data: { VerifyEmailAddress: null },
|
||||||
errors: [{ message: 'A user account with this email already exists.' }],
|
errors: [{ message: 'A user account with this email already exists.' }],
|
||||||
})
|
})
|
||||||
@ -324,7 +313,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('connects the new `EmailAddress` as PRIMARY', async () => {
|
it('connects the new `EmailAddress` as PRIMARY', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: VerifyEmailAddress, variables })
|
||||||
const result = await neode.cypher(
|
const result = await neode.cypher(
|
||||||
`
|
`
|
||||||
MATCH(u:User {id: "567"})-[:PRIMARY_EMAIL]->(e:EmailAddress {email: "to-be-verified@example.org"})
|
MATCH(u:User {id: "567"})-[:PRIMARY_EMAIL]->(e:EmailAddress {email: "to-be-verified@example.org"})
|
||||||
@ -354,18 +343,12 @@ describe('VerifyNonce', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const verifyNonceQuery = gql`
|
|
||||||
query ($email: String!, $nonce: String!) {
|
|
||||||
VerifyNonce(email: $email, nonce: $nonce)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
it('returns true when nonce and email match', async () => {
|
it('returns true when nonce and email match', async () => {
|
||||||
variables = {
|
variables = {
|
||||||
email: 'to-be-verified@example.org',
|
email: 'to-be-verified@example.org',
|
||||||
nonce: '12345',
|
nonce: '12345',
|
||||||
}
|
}
|
||||||
await expect(query({ query: verifyNonceQuery, variables })).resolves.toMatchObject({
|
await expect(query({ query: VerifyNonce, variables })).resolves.toMatchObject({
|
||||||
data: { VerifyNonce: true },
|
data: { VerifyNonce: true },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -375,7 +358,7 @@ describe('VerifyNonce', () => {
|
|||||||
email: 'to-be-verified@example.org',
|
email: 'to-be-verified@example.org',
|
||||||
nonce: '---',
|
nonce: '---',
|
||||||
}
|
}
|
||||||
await expect(query({ query: verifyNonceQuery, variables })).resolves.toMatchObject({
|
await expect(query({ query: VerifyNonce, variables })).resolves.toMatchObject({
|
||||||
data: { VerifyNonce: false },
|
data: { VerifyNonce: false },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import fs from 'node:fs'
|
|||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import gql from 'graphql-tag'
|
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
|
import { embed } from '@graphql/queries/embed'
|
||||||
import createServer from '@src/server'
|
import createServer from '@src/server'
|
||||||
|
|
||||||
jest.mock('node-fetch')
|
jest.mock('node-fetch')
|
||||||
@ -65,25 +65,6 @@ describe('Query', () => {
|
|||||||
context: () => {},
|
context: () => {},
|
||||||
})
|
})
|
||||||
const { query } = createTestClient(server)
|
const { query } = createTestClient(server)
|
||||||
const embed = gql`
|
|
||||||
query ($url: String!) {
|
|
||||||
embed(url: $url) {
|
|
||||||
type
|
|
||||||
title
|
|
||||||
author
|
|
||||||
publisher
|
|
||||||
date
|
|
||||||
description
|
|
||||||
url
|
|
||||||
image
|
|
||||||
audio
|
|
||||||
video
|
|
||||||
lang
|
|
||||||
sources
|
|
||||||
html
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
return query({ query: embed, variables })
|
return query({ query: embed, variables })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { createPostMutation } from '@graphql/queries/createPostMutation'
|
import { CreatePost } from '@graphql/queries/CreatePost'
|
||||||
import { filterPosts } from '@graphql/queries/filterPosts'
|
import { Post } from '@graphql/queries/Post'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -45,7 +45,7 @@ describe('Filter Posts', () => {
|
|||||||
})
|
})
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'a1',
|
id: 'a1',
|
||||||
title: 'I am an article',
|
title: 'I am an article',
|
||||||
@ -53,7 +53,7 @@ describe('Filter Posts', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'a2',
|
id: 'a2',
|
||||||
title: 'I am anonther article',
|
title: 'I am anonther article',
|
||||||
@ -61,7 +61,7 @@ describe('Filter Posts', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'e1',
|
id: 'e1',
|
||||||
title: 'Illegaler Kindergeburtstag',
|
title: 'Illegaler Kindergeburtstag',
|
||||||
@ -74,7 +74,7 @@ describe('Filter Posts', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'e2',
|
id: 'e2',
|
||||||
title: 'Räuber-Treffen',
|
title: 'Räuber-Treffen',
|
||||||
@ -92,7 +92,7 @@ describe('Filter Posts', () => {
|
|||||||
it('finds all posts', async () => {
|
it('finds all posts', async () => {
|
||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({ query: filterPosts() })) as any
|
} = (await query({ query: Post })) as any
|
||||||
expect(result).toHaveLength(4)
|
expect(result).toHaveLength(4)
|
||||||
expect(result).toEqual(
|
expect(result).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
@ -110,7 +110,7 @@ describe('Filter Posts', () => {
|
|||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({
|
} = (await query({
|
||||||
query: filterPosts(),
|
query: Post,
|
||||||
variables: { filter: { postType_in: ['Article'] } },
|
variables: { filter: { postType_in: ['Article'] } },
|
||||||
})) as any
|
})) as any
|
||||||
expect(result).toHaveLength(2)
|
expect(result).toHaveLength(2)
|
||||||
@ -128,7 +128,7 @@ describe('Filter Posts', () => {
|
|||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({
|
} = (await query({
|
||||||
query: filterPosts(),
|
query: Post,
|
||||||
variables: { filter: { postType_in: ['Event'] } },
|
variables: { filter: { postType_in: ['Event'] } },
|
||||||
})) as any
|
})) as any
|
||||||
expect(result).toHaveLength(2)
|
expect(result).toHaveLength(2)
|
||||||
@ -146,7 +146,7 @@ describe('Filter Posts', () => {
|
|||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({
|
} = (await query({
|
||||||
query: filterPosts(),
|
query: Post,
|
||||||
variables: { filter: { postType_in: ['Article', 'Event'] } },
|
variables: { filter: { postType_in: ['Article', 'Event'] } },
|
||||||
})) as any
|
})) as any
|
||||||
expect(result).toHaveLength(4)
|
expect(result).toHaveLength(4)
|
||||||
@ -166,7 +166,7 @@ describe('Filter Posts', () => {
|
|||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({
|
} = (await query({
|
||||||
query: filterPosts(),
|
query: Post,
|
||||||
variables: { filter: { postType_in: ['Event'] }, orderBy: ['eventStart_desc'] },
|
variables: { filter: { postType_in: ['Event'] }, orderBy: ['eventStart_desc'] },
|
||||||
})) as any
|
})) as any
|
||||||
expect(result).toHaveLength(2)
|
expect(result).toHaveLength(2)
|
||||||
@ -190,7 +190,7 @@ describe('Filter Posts', () => {
|
|||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({
|
} = (await query({
|
||||||
query: filterPosts(),
|
query: Post,
|
||||||
variables: { filter: { postType_in: ['Event'] }, orderBy: ['eventStart_asc'] },
|
variables: { filter: { postType_in: ['Event'] }, orderBy: ['eventStart_asc'] },
|
||||||
})) as any
|
})) as any
|
||||||
expect(result).toHaveLength(2)
|
expect(result).toHaveLength(2)
|
||||||
@ -214,7 +214,7 @@ describe('Filter Posts', () => {
|
|||||||
const {
|
const {
|
||||||
data: { Post: result },
|
data: { Post: result },
|
||||||
} = (await query({
|
} = (await query({
|
||||||
query: filterPosts(),
|
query: Post,
|
||||||
variables: {
|
variables: {
|
||||||
filter: {
|
filter: {
|
||||||
postType_in: ['Event'],
|
postType_in: ['Event'],
|
||||||
|
|||||||
@ -7,6 +7,8 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { getDriver, getNeode } from '@db/neo4j'
|
import { getDriver, getNeode } from '@db/neo4j'
|
||||||
|
import { followUser } from '@graphql/queries/followUser'
|
||||||
|
import { unfollowUser } from '@graphql/queries/unfollowUser'
|
||||||
import createServer from '@src/server'
|
import createServer from '@src/server'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
@ -20,30 +22,6 @@ let user1
|
|||||||
let user2
|
let user2
|
||||||
let variables
|
let variables
|
||||||
|
|
||||||
const mutationFollowUser = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
followUser(id: $id) {
|
|
||||||
name
|
|
||||||
followedBy {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
followedByCurrentUser
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
const mutationUnfollowUser = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
unfollowUser(id: $id) {
|
|
||||||
name
|
|
||||||
followedBy {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
}
|
|
||||||
followedByCurrentUser
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
const userQuery = gql`
|
const userQuery = gql`
|
||||||
query ($id: ID) {
|
query ($id: ID) {
|
||||||
User(id: $id) {
|
User(id: $id) {
|
||||||
@ -119,7 +97,7 @@ describe('follow', () => {
|
|||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: mutationFollowUser,
|
mutation: followUser,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -137,7 +115,7 @@ describe('follow', () => {
|
|||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: mutationFollowUser,
|
mutation: followUser,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -148,7 +126,7 @@ describe('follow', () => {
|
|||||||
|
|
||||||
test('adds `createdAt` to `FOLLOW` relationship', async () => {
|
test('adds `createdAt` to `FOLLOW` relationship', async () => {
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: mutationFollowUser,
|
mutation: followUser,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
const relation = await neode.cypher(
|
const relation = await neode.cypher(
|
||||||
@ -163,7 +141,7 @@ describe('follow', () => {
|
|||||||
|
|
||||||
test('I can`t follow myself', async () => {
|
test('I can`t follow myself', async () => {
|
||||||
variables.id = user1.id
|
variables.id = user1.id
|
||||||
await expect(mutate({ mutation: mutationFollowUser, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: followUser, variables })).resolves.toMatchObject({
|
||||||
data: { followUser: null },
|
data: { followUser: null },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
})
|
})
|
||||||
@ -189,13 +167,13 @@ describe('follow', () => {
|
|||||||
describe('unfollow user', () => {
|
describe('unfollow user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { id: user2.id }
|
variables = { id: user2.id }
|
||||||
await mutate({ mutation: mutationFollowUser, variables })
|
await mutate({ mutation: followUser, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('unauthenticated follow', () => {
|
describe('unauthenticated follow', () => {
|
||||||
test('throws authorization error', async () => {
|
test('throws authorization error', async () => {
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
await expect(mutate({ mutation: mutationUnfollowUser, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: unfollowUser, variables })).resolves.toMatchObject({
|
||||||
data: { unfollowUser: null },
|
data: { unfollowUser: null },
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -208,7 +186,7 @@ describe('follow', () => {
|
|||||||
followedBy: [],
|
followedBy: [],
|
||||||
followedByCurrentUser: false,
|
followedByCurrentUser: false,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: mutationUnfollowUser, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: unfollowUser, variables })).resolves.toMatchObject({
|
||||||
data: { unfollowUser: expectedUser },
|
data: { unfollowUser: expectedUser },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -4,14 +4,14 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { changeGroupMemberRoleMutation } from '@graphql/queries/changeGroupMemberRoleMutation'
|
import { ChangeGroupMemberRole } from '@graphql/queries/ChangeGroupMemberRole'
|
||||||
import { createGroupMutation } from '@graphql/queries/createGroupMutation'
|
import { CreateGroup } from '@graphql/queries/CreateGroup'
|
||||||
import { Group as groupQuery } from '@graphql/queries/Group'
|
import { Group as groupQuery } from '@graphql/queries/Group'
|
||||||
import { GroupMembers as groupMembersQuery } from '@graphql/queries/GroupMembers'
|
import { GroupMembers as groupMembersQuery } from '@graphql/queries/GroupMembers'
|
||||||
import { joinGroupMutation } from '@graphql/queries/joinGroupMutation'
|
import { JoinGroup } from '@graphql/queries/JoinGroup'
|
||||||
import { leaveGroupMutation } from '@graphql/queries/leaveGroupMutation'
|
import { LeaveGroup } from '@graphql/queries/LeaveGroup'
|
||||||
import { removeUserFromGroupMutation } from '@graphql/queries/removeUserFromGroupMutation'
|
import { RemoveUserFromGroup } from '@graphql/queries/RemoveUserFromGroup'
|
||||||
import { updateGroupMutation } from '@graphql/queries/updateGroupMutation'
|
import { UpdateGroup } from '@graphql/queries/UpdateGroup'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -156,7 +156,7 @@ const seedComplexScenarioAndClearAuthentication = async () => {
|
|||||||
// public-group
|
// public-group
|
||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -168,14 +168,14 @@ const seedComplexScenarioAndClearAuthentication = async () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'public-group',
|
groupId: 'public-group',
|
||||||
userId: 'owner-of-closed-group',
|
userId: 'owner-of-closed-group',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'public-group',
|
groupId: 'public-group',
|
||||||
userId: 'owner-of-hidden-group',
|
userId: 'owner-of-hidden-group',
|
||||||
@ -184,7 +184,7 @@ const seedComplexScenarioAndClearAuthentication = async () => {
|
|||||||
// closed-group
|
// closed-group
|
||||||
authenticatedUser = await ownerMemberUser.toJson()
|
authenticatedUser = await ownerMemberUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'closed-group',
|
id: 'closed-group',
|
||||||
name: 'Uninteresting Group',
|
name: 'Uninteresting Group',
|
||||||
@ -197,7 +197,7 @@ const seedComplexScenarioAndClearAuthentication = async () => {
|
|||||||
})
|
})
|
||||||
// hidden-group
|
// hidden-group
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Investigative Journalism Group',
|
name: 'Investigative Journalism Group',
|
||||||
@ -210,7 +210,7 @@ const seedComplexScenarioAndClearAuthentication = async () => {
|
|||||||
})
|
})
|
||||||
// 'JoinGroup' mutation does not work in hidden groups so we join them by 'ChangeGroupMemberRole' through the owner
|
// 'JoinGroup' mutation does not work in hidden groups so we join them by 'ChangeGroupMemberRole' through the owner
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -219,7 +219,7 @@ const seedComplexScenarioAndClearAuthentication = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -274,7 +274,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: createGroupMutation(), variables })
|
const { errors } = await mutate({ mutation: CreateGroup, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -285,9 +285,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('creates a group', async () => {
|
it('creates a group', async () => {
|
||||||
await expect(
|
await expect(mutate({ mutation: CreateGroup, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: createGroupMutation(), variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: {
|
data: {
|
||||||
CreateGroup: {
|
CreateGroup: {
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -310,9 +308,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('assigns the authenticated user as owner', async () => {
|
it('assigns the authenticated user as owner', async () => {
|
||||||
await expect(
|
await expect(mutate({ mutation: CreateGroup, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: createGroupMutation(), variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: {
|
data: {
|
||||||
CreateGroup: {
|
CreateGroup: {
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -324,9 +320,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('has "disabled" and "deleted" default to "false"', async () => {
|
it('has "disabled" and "deleted" default to "false"', async () => {
|
||||||
await expect(
|
await expect(mutate({ mutation: CreateGroup, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: createGroupMutation(), variables }),
|
|
||||||
).resolves.toMatchObject({
|
|
||||||
data: { CreateGroup: { disabled: false, deleted: false } },
|
data: { CreateGroup: { disabled: false, deleted: false } },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -336,7 +330,7 @@ describe('in mode', () => {
|
|||||||
describe('less then 3 chars', () => {
|
describe('less then 3 chars', () => {
|
||||||
it('throws error: "Description too short!"', async () => {
|
it('throws error: "Description too short!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
description:
|
description:
|
||||||
@ -355,7 +349,7 @@ describe('in mode', () => {
|
|||||||
it('has new categories', async () => {
|
it('has new categories', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
categoryIds: ['cat4', 'cat27'],
|
categoryIds: ['cat4', 'cat27'],
|
||||||
@ -380,7 +374,7 @@ describe('in mode', () => {
|
|||||||
describe('by "categoryIds: null"', () => {
|
describe('by "categoryIds: null"', () => {
|
||||||
it('throws error: "Too few categories!"', async () => {
|
it('throws error: "Too few categories!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: { ...variables, categoryIds: null },
|
variables: { ...variables, categoryIds: null },
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Too few categories!')
|
expect(errors?.[0]).toHaveProperty('message', 'Too few categories!')
|
||||||
@ -390,7 +384,7 @@ describe('in mode', () => {
|
|||||||
describe('by "categoryIds: []"', () => {
|
describe('by "categoryIds: []"', () => {
|
||||||
it('throws error: "Too few categories!"', async () => {
|
it('throws error: "Too few categories!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: { ...variables, categoryIds: [] },
|
variables: { ...variables, categoryIds: [] },
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Too few categories!')
|
expect(errors?.[0]).toHaveProperty('message', 'Too few categories!')
|
||||||
@ -401,7 +395,7 @@ describe('in mode', () => {
|
|||||||
describe('four', () => {
|
describe('four', () => {
|
||||||
it('throws error: "Too many categories!"', async () => {
|
it('throws error: "Too many categories!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: { ...variables, categoryIds: ['cat9', 'cat4', 'cat15', 'cat27'] },
|
variables: { ...variables, categoryIds: ['cat9', 'cat4', 'cat15', 'cat27'] },
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Too many categories!')
|
expect(errors?.[0]).toHaveProperty('message', 'Too many categories!')
|
||||||
@ -458,7 +452,7 @@ describe('in mode', () => {
|
|||||||
)
|
)
|
||||||
authenticatedUser = await otherUser.toJson()
|
authenticatedUser = await otherUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'others-group',
|
id: 'others-group',
|
||||||
name: 'Uninteresting Group',
|
name: 'Uninteresting Group',
|
||||||
@ -471,7 +465,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
authenticatedUser = await ownerOfHiddenGroupUser.toJson()
|
authenticatedUser = await ownerOfHiddenGroupUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Investigative Journalism Group',
|
name: 'Investigative Journalism Group',
|
||||||
@ -483,7 +477,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'second-hidden-group',
|
id: 'second-hidden-group',
|
||||||
name: 'Second Investigative Journalism Group',
|
name: 'Second Investigative Journalism Group',
|
||||||
@ -495,7 +489,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'second-hidden-group',
|
groupId: 'second-hidden-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -503,7 +497,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'third-hidden-group',
|
id: 'third-hidden-group',
|
||||||
name: 'Third Investigative Journalism Group',
|
name: 'Third Investigative Journalism Group',
|
||||||
@ -515,7 +509,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'third-hidden-group',
|
groupId: 'third-hidden-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -524,7 +518,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -802,7 +796,7 @@ describe('in mode', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'not-existing-group',
|
groupId: 'not-existing-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -844,7 +838,7 @@ describe('in mode', () => {
|
|||||||
// public-group
|
// public-group
|
||||||
authenticatedUser = await ownerOfClosedGroupUser.toJson()
|
authenticatedUser = await ownerOfClosedGroupUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'closed-group',
|
id: 'closed-group',
|
||||||
name: 'Uninteresting Group',
|
name: 'Uninteresting Group',
|
||||||
@ -857,7 +851,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
authenticatedUser = await ownerOfHiddenGroupUser.toJson()
|
authenticatedUser = await ownerOfHiddenGroupUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Investigative Journalism Group',
|
name: 'Investigative Journalism Group',
|
||||||
@ -870,7 +864,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -888,7 +882,7 @@ describe('in mode', () => {
|
|||||||
it('has "usual" as membership role', async () => {
|
it('has "usual" as membership role', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'public-group',
|
groupId: 'public-group',
|
||||||
userId: 'owner-of-closed-group',
|
userId: 'owner-of-closed-group',
|
||||||
@ -911,7 +905,7 @@ describe('in mode', () => {
|
|||||||
it('has still "owner" as membership role', async () => {
|
it('has still "owner" as membership role', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'public-group',
|
groupId: 'public-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -936,7 +930,7 @@ describe('in mode', () => {
|
|||||||
it('has "pending" as membership role', async () => {
|
it('has "pending" as membership role', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -959,7 +953,7 @@ describe('in mode', () => {
|
|||||||
it('has still "owner" as membership role', async () => {
|
it('has still "owner" as membership role', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'owner-of-closed-group',
|
userId: 'owner-of-closed-group',
|
||||||
@ -983,7 +977,7 @@ describe('in mode', () => {
|
|||||||
describe('joined by "owner-of-closed-group"', () => {
|
describe('joined by "owner-of-closed-group"', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await query({
|
const { errors } = await query({
|
||||||
query: joinGroupMutation(),
|
query: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'owner-of-closed-group',
|
userId: 'owner-of-closed-group',
|
||||||
@ -998,7 +992,7 @@ describe('in mode', () => {
|
|||||||
it('has still "owner" as membership role', async () => {
|
it('has still "owner" as membership role', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'owner-of-hidden-group',
|
userId: 'owner-of-hidden-group',
|
||||||
@ -1095,7 +1089,7 @@ describe('in mode', () => {
|
|||||||
// public-group
|
// public-group
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -1107,14 +1101,14 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'public-group',
|
groupId: 'public-group',
|
||||||
userId: 'owner-of-closed-group',
|
userId: 'owner-of-closed-group',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'public-group',
|
groupId: 'public-group',
|
||||||
userId: 'owner-of-hidden-group',
|
userId: 'owner-of-hidden-group',
|
||||||
@ -1123,7 +1117,7 @@ describe('in mode', () => {
|
|||||||
// closed-group
|
// closed-group
|
||||||
authenticatedUser = await ownerOfClosedGroupUser.toJson()
|
authenticatedUser = await ownerOfClosedGroupUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'closed-group',
|
id: 'closed-group',
|
||||||
name: 'Uninteresting Group',
|
name: 'Uninteresting Group',
|
||||||
@ -1135,14 +1129,14 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'owner-of-hidden-group',
|
userId: 'owner-of-hidden-group',
|
||||||
@ -1152,7 +1146,7 @@ describe('in mode', () => {
|
|||||||
// hidden-group
|
// hidden-group
|
||||||
authenticatedUser = await ownerOfHiddenGroupUser.toJson()
|
authenticatedUser = await ownerOfHiddenGroupUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Investigative Journalism Group',
|
name: 'Investigative Journalism Group',
|
||||||
@ -1165,7 +1159,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
// 'JoinGroup' mutation does not work in hidden groups so we join them by 'ChangeGroupMemberRole' through the owner
|
// 'JoinGroup' mutation does not work in hidden groups so we join them by 'ChangeGroupMemberRole' through the owner
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'pending-user',
|
userId: 'pending-user',
|
||||||
@ -1173,7 +1167,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -1181,7 +1175,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'owner-of-closed-group',
|
userId: 'owner-of-closed-group',
|
||||||
@ -1556,7 +1550,7 @@ describe('in mode', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'not-existing-group',
|
groupId: 'not-existing-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -1600,7 +1594,7 @@ describe('in mode', () => {
|
|||||||
it('has role usual', async () => {
|
it('has role usual', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -1638,7 +1632,7 @@ describe('in mode', () => {
|
|||||||
it('has role admin', async () => {
|
it('has role admin', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -1673,7 +1667,7 @@ describe('in mode', () => {
|
|||||||
it('has role owner', async () => {
|
it('has role owner', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -1715,7 +1709,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1741,7 +1735,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1759,7 +1753,7 @@ describe('in mode', () => {
|
|||||||
it('has role owner still', async () => {
|
it('has role owner still', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -1790,7 +1784,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1813,7 +1807,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1836,7 +1830,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1869,7 +1863,7 @@ describe('in mode', () => {
|
|||||||
it('has role owner', async () => {
|
it('has role owner', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -1894,7 +1888,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1917,7 +1911,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1934,7 +1928,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1957,7 +1951,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1974,7 +1968,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -1997,7 +1991,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2014,7 +2008,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2047,7 +2041,7 @@ describe('in mode', () => {
|
|||||||
it('has role admin', async () => {
|
it('has role admin', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -2073,7 +2067,7 @@ describe('in mode', () => {
|
|||||||
it('has role usual again', async () => {
|
it('has role usual again', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -2104,7 +2098,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2121,7 +2115,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2144,7 +2138,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2161,7 +2155,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2184,7 +2178,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2201,7 +2195,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2234,7 +2228,7 @@ describe('in mode', () => {
|
|||||||
it('has role usual', async () => {
|
it('has role usual', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -2260,7 +2254,7 @@ describe('in mode', () => {
|
|||||||
it('has role usual again', async () => {
|
it('has role usual again', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -2291,7 +2285,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2314,7 +2308,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2337,7 +2331,7 @@ describe('in mode', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2356,7 +2350,7 @@ describe('in mode', () => {
|
|||||||
// closed-group
|
// closed-group
|
||||||
authenticatedUser = await ownerMemberUser.toJson()
|
authenticatedUser = await ownerMemberUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'pending-member-user',
|
userId: 'pending-member-user',
|
||||||
@ -2364,7 +2358,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2372,7 +2366,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -2380,7 +2374,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'second-owner-member-user',
|
userId: 'second-owner-member-user',
|
||||||
@ -2398,7 +2392,7 @@ describe('in mode', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'not-existing-group',
|
groupId: 'not-existing-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -2437,7 +2431,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await pendingMemberUser.toJson()
|
authenticatedUser = await pendingMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'pending-member-user',
|
userId: 'pending-member-user',
|
||||||
@ -2464,7 +2458,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2491,7 +2485,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await adminMemberUser.toJson()
|
authenticatedUser = await adminMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -2515,7 +2509,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await ownerMemberUser.toJson()
|
authenticatedUser = await ownerMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'owner-member-user',
|
userId: 'owner-member-user',
|
||||||
@ -2529,7 +2523,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await secondOwnerMemberUser.toJson()
|
authenticatedUser = await secondOwnerMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'second-owner-member-user',
|
userId: 'second-owner-member-user',
|
||||||
@ -2543,7 +2537,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await noMemberUser.toJson()
|
authenticatedUser = await noMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'none-member-user',
|
userId: 'none-member-user',
|
||||||
@ -2557,7 +2551,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await ownerMemberUser.toJson()
|
authenticatedUser = await ownerMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2571,7 +2565,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: leaveGroupMutation(),
|
mutation: LeaveGroup,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -2597,7 +2591,7 @@ describe('in mode', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
slug: 'my-best-group',
|
slug: 'my-best-group',
|
||||||
@ -2635,7 +2629,7 @@ describe('in mode', () => {
|
|||||||
)
|
)
|
||||||
authenticatedUser = await noMemberUser.toJson()
|
authenticatedUser = await noMemberUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'others-group',
|
id: 'others-group',
|
||||||
name: 'Uninteresting Group',
|
name: 'Uninteresting Group',
|
||||||
@ -2648,7 +2642,7 @@ describe('in mode', () => {
|
|||||||
})
|
})
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
name: 'The Best Group',
|
name: 'The Best Group',
|
||||||
@ -2661,7 +2655,7 @@ describe('in mode', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'my-group',
|
groupId: 'my-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2680,7 +2674,7 @@ describe('in mode', () => {
|
|||||||
it('has updated the settings', async () => {
|
it('has updated the settings', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
name: 'The New Group For Our Country',
|
name: 'The New Group For Our Country',
|
||||||
@ -2715,7 +2709,7 @@ describe('in mode', () => {
|
|||||||
it('has left locaton unchanged as "Berlin"', async () => {
|
it('has left locaton unchanged as "Berlin"', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
},
|
},
|
||||||
@ -2742,7 +2736,7 @@ describe('in mode', () => {
|
|||||||
it('has updated the location to unset location', async () => {
|
it('has updated the location to unset location', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
locationName: null,
|
locationName: null,
|
||||||
@ -2766,7 +2760,7 @@ describe('in mode', () => {
|
|||||||
it('has updated the location to "Paris"', async () => {
|
it('has updated the location to "Paris"', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
locationName: 'Paris, France',
|
locationName: 'Paris, France',
|
||||||
@ -2794,7 +2788,7 @@ describe('in mode', () => {
|
|||||||
it('has updated the location to "Hamburg"', async () => {
|
it('has updated the location to "Hamburg"', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
locationName: 'Hamburg, Germany',
|
locationName: 'Hamburg, Germany',
|
||||||
@ -2822,7 +2816,7 @@ describe('in mode', () => {
|
|||||||
it('has updated the location to unset', async () => {
|
it('has updated the location to unset', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
locationName: '', // empty string '' sets it to null
|
locationName: '', // empty string '' sets it to null
|
||||||
@ -2848,7 +2842,7 @@ describe('in mode', () => {
|
|||||||
describe('less then 3 chars', () => {
|
describe('less then 3 chars', () => {
|
||||||
it('throws error: "Description too short!"', async () => {
|
it('throws error: "Description too short!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
description:
|
description:
|
||||||
@ -2867,7 +2861,7 @@ describe('in mode', () => {
|
|||||||
it('has new categories', async () => {
|
it('has new categories', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
categoryIds: ['cat4', 'cat27'],
|
categoryIds: ['cat4', 'cat27'],
|
||||||
@ -2893,7 +2887,7 @@ describe('in mode', () => {
|
|||||||
describe('by "categoryIds: []"', () => {
|
describe('by "categoryIds: []"', () => {
|
||||||
it('throws error: "Too few categories!"', async () => {
|
it('throws error: "Too few categories!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
categoryIds: [],
|
categoryIds: [],
|
||||||
@ -2907,7 +2901,7 @@ describe('in mode', () => {
|
|||||||
describe('four', () => {
|
describe('four', () => {
|
||||||
it('throws error: "Too many categories!"', async () => {
|
it('throws error: "Too many categories!"', async () => {
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
categoryIds: ['cat9', 'cat4', 'cat15', 'cat27'],
|
categoryIds: ['cat9', 'cat4', 'cat15', 'cat27'],
|
||||||
@ -2923,7 +2917,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
name: 'The New Group For Our Country',
|
name: 'The New Group For Our Country',
|
||||||
@ -2941,7 +2935,7 @@ describe('in mode', () => {
|
|||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = await noMemberUser.toJson()
|
authenticatedUser = await noMemberUser.toJson()
|
||||||
const { errors } = await mutate({
|
const { errors } = await mutate({
|
||||||
mutation: updateGroupMutation(),
|
mutation: UpdateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'my-group',
|
id: 'my-group',
|
||||||
name: 'The New Group For Our Country',
|
name: 'The New Group For Our Country',
|
||||||
@ -2972,7 +2966,7 @@ describe('in mode', () => {
|
|||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2994,7 +2988,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -3018,7 +3012,7 @@ describe('in mode', () => {
|
|||||||
it('removes the user from the group', async () => {
|
it('removes the user from the group', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -3038,7 +3032,7 @@ describe('in mode', () => {
|
|||||||
it('cannot remove self', async () => {
|
it('cannot remove self', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'owner-member-user',
|
userId: 'owner-member-user',
|
||||||
@ -3058,7 +3052,7 @@ describe('in mode', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await adminMemberUser.toJson()
|
authenticatedUser = await adminMemberUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: changeGroupMemberRoleMutation(),
|
mutation: ChangeGroupMemberRole,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -3071,7 +3065,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -3090,7 +3084,7 @@ describe('in mode', () => {
|
|||||||
it('removes the user from the group', async () => {
|
it('removes the user from the group', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -3110,7 +3104,7 @@ describe('in mode', () => {
|
|||||||
it('cannot remove self', async () => {
|
it('cannot remove self', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -3128,7 +3122,7 @@ describe('in mode', () => {
|
|||||||
it('cannot remove owner', async () => {
|
it('cannot remove owner', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removeUserFromGroupMutation(),
|
mutation: RemoveUserFromGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'hidden-group',
|
groupId: 'hidden-group',
|
||||||
userId: 'owner-member-user',
|
userId: 'owner-member-user',
|
||||||
|
|||||||
@ -3,14 +3,14 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { createGroupMutation } from '@graphql/queries/createGroupMutation'
|
import { CreateGroup } from '@graphql/queries/CreateGroup'
|
||||||
import { currentUser } from '@graphql/queries/currentUser'
|
import { currentUser } from '@graphql/queries/currentUser'
|
||||||
import { generateGroupInviteCode } from '@graphql/queries/generateGroupInviteCode'
|
import { generateGroupInviteCode } from '@graphql/queries/generateGroupInviteCode'
|
||||||
import { generatePersonalInviteCode } from '@graphql/queries/generatePersonalInviteCode'
|
import { generatePersonalInviteCode } from '@graphql/queries/generatePersonalInviteCode'
|
||||||
import { Group } from '@graphql/queries/Group'
|
import { Group } from '@graphql/queries/Group'
|
||||||
import { GroupMembers } from '@graphql/queries/GroupMembers'
|
import { GroupMembers } from '@graphql/queries/GroupMembers'
|
||||||
import { invalidateInviteCode } from '@graphql/queries/invalidateInviteCode'
|
import { invalidateInviteCode } from '@graphql/queries/invalidateInviteCode'
|
||||||
import { joinGroupMutation } from '@graphql/queries/joinGroupMutation'
|
import { JoinGroup } from '@graphql/queries/JoinGroup'
|
||||||
import { redeemInviteCode } from '@graphql/queries/redeemInviteCode'
|
import { redeemInviteCode } from '@graphql/queries/redeemInviteCode'
|
||||||
import {
|
import {
|
||||||
authenticatedValidateInviteCode,
|
authenticatedValidateInviteCode,
|
||||||
@ -59,7 +59,7 @@ describe('validateInviteCode', () => {
|
|||||||
|
|
||||||
authenticatedUser = await invitingUser.toJson()
|
authenticatedUser = await invitingUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Hidden Group',
|
name: 'Hidden Group',
|
||||||
@ -73,7 +73,7 @@ describe('validateInviteCode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
name: 'Public Group',
|
name: 'Public Group',
|
||||||
@ -524,7 +524,7 @@ describe('generateGroupInviteCode', () => {
|
|||||||
|
|
||||||
authenticatedUser = await invitingUser.toJson()
|
authenticatedUser = await invitingUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Hidden Group',
|
name: 'Hidden Group',
|
||||||
@ -538,7 +538,7 @@ describe('generateGroupInviteCode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
name: 'Public Group',
|
name: 'Public Group',
|
||||||
@ -551,7 +551,7 @@ describe('generateGroupInviteCode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'closed-group',
|
id: 'closed-group',
|
||||||
name: 'Closed Group',
|
name: 'Closed Group',
|
||||||
@ -564,7 +564,7 @@ describe('generateGroupInviteCode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: joinGroupMutation(),
|
mutation: JoinGroup,
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'closed-group',
|
groupId: 'closed-group',
|
||||||
userId: 'pending-member-user',
|
userId: 'pending-member-user',
|
||||||
@ -920,7 +920,7 @@ describe('redeemInviteCode', () => {
|
|||||||
|
|
||||||
authenticatedUser = await invitingUser.toJson()
|
authenticatedUser = await invitingUser.toJson()
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
name: 'Hidden Group',
|
name: 'Hidden Group',
|
||||||
@ -934,7 +934,7 @@ describe('redeemInviteCode', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
name: 'Public Group',
|
name: 'Public Group',
|
||||||
|
|||||||
@ -10,10 +10,10 @@ import { Upload } from 'graphql-upload/public/index'
|
|||||||
import pubsubContext from '@context/pubsub'
|
import pubsubContext from '@context/pubsub'
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { CreateMessage } from '@graphql/queries/CreateMessage'
|
import { CreateMessage } from '@graphql/queries/CreateMessage'
|
||||||
import { createRoomMutation } from '@graphql/queries/createRoomMutation'
|
import { CreateRoom } from '@graphql/queries/CreateRoom'
|
||||||
import { MarkMessagesAsSeen } from '@graphql/queries/MarkMessagesAsSeen'
|
import { MarkMessagesAsSeen } from '@graphql/queries/MarkMessagesAsSeen'
|
||||||
import { Message } from '@graphql/queries/Message'
|
import { Message } from '@graphql/queries/Message'
|
||||||
import { roomQuery } from '@graphql/queries/roomQuery'
|
import { Room } from '@graphql/queries/Room'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -123,7 +123,7 @@ describe('Message', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await chattingUser.toJson()
|
authenticatedUser = await chattingUser.toJson()
|
||||||
const room = await mutate({
|
const room = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'other-chatting-user',
|
userId: 'other-chatting-user',
|
||||||
},
|
},
|
||||||
@ -171,7 +171,7 @@ describe('Message', () => {
|
|||||||
|
|
||||||
describe('room is updated as well', () => {
|
describe('room is updated as well', () => {
|
||||||
it('has last message set', async () => {
|
it('has last message set', async () => {
|
||||||
const result = await query({ query: roomQuery() })
|
const result = await query({ query: Room })
|
||||||
await expect(result).toMatchObject({
|
await expect(result).toMatchObject({
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
data: {
|
data: {
|
||||||
@ -201,7 +201,7 @@ describe('Message', () => {
|
|||||||
describe('unread count for other user', () => {
|
describe('unread count for other user', () => {
|
||||||
it('has unread count = 1', async () => {
|
it('has unread count = 1', async () => {
|
||||||
authenticatedUser = await otherChattingUser.toJson()
|
authenticatedUser = await otherChattingUser.toJson()
|
||||||
await expect(query({ query: roomQuery() })).resolves.toMatchObject({
|
await expect(query({ query: Room })).resolves.toMatchObject({
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
data: {
|
data: {
|
||||||
Room: [
|
Room: [
|
||||||
@ -405,7 +405,7 @@ describe('Message', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await chattingUser.toJson()
|
authenticatedUser = await chattingUser.toJson()
|
||||||
const room = await mutate({
|
const room = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'other-chatting-user',
|
userId: 'other-chatting-user',
|
||||||
},
|
},
|
||||||
@ -637,7 +637,7 @@ describe('Message', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await chattingUser.toJson()
|
authenticatedUser = await chattingUser.toJson()
|
||||||
const room = await mutate({
|
const room = await mutate({
|
||||||
mutation: createRoomMutation(),
|
mutation: CreateRoom,
|
||||||
variables: {
|
variables: {
|
||||||
userId: 'other-chatting-user',
|
userId: 'other-chatting-user',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { getNeode, getDriver } from '@db/neo4j'
|
import { getNeode, getDriver } from '@db/neo4j'
|
||||||
|
import { review } from '@graphql/queries/review'
|
||||||
import createServer from '@src/server'
|
import createServer from '@src/server'
|
||||||
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
@ -20,42 +20,6 @@ let mutate,
|
|||||||
nonModerator,
|
nonModerator,
|
||||||
closeReportVariables
|
closeReportVariables
|
||||||
|
|
||||||
const reviewMutation = gql`
|
|
||||||
mutation ($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
|
|
||||||
review(resourceId: $resourceId, disable: $disable, closed: $closed) {
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
resource {
|
|
||||||
__typename
|
|
||||||
... on User {
|
|
||||||
id
|
|
||||||
disabled
|
|
||||||
}
|
|
||||||
... on Post {
|
|
||||||
id
|
|
||||||
disabled
|
|
||||||
}
|
|
||||||
... on Comment {
|
|
||||||
id
|
|
||||||
disabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
report {
|
|
||||||
id
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
closed
|
|
||||||
reviewed {
|
|
||||||
createdAt
|
|
||||||
moderator {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('moderate resources', () => {
|
describe('moderate resources', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await cleanDatabase()
|
await cleanDatabase()
|
||||||
@ -124,7 +88,7 @@ describe('moderate resources', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -138,7 +102,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('non-moderator receives an authorization error', async () => {
|
it('non-moderator receives an authorization error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -169,7 +133,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('report can be closed without disabling resource', async () => {
|
it('report can be closed without disabling resource', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: closeReportVariables }),
|
mutate({ mutation: review, variables: closeReportVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -184,11 +148,11 @@ describe('moderate resources', () => {
|
|||||||
it('creates only one review for multiple reviews by the same moderator on same resource', async () => {
|
it('creates only one review for multiple reviews by the same moderator on same resource', async () => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
mutate({
|
mutate({
|
||||||
mutation: reviewMutation,
|
mutation: review,
|
||||||
variables: { ...disableVariables, resourceId: 'should-i-be-disabled' },
|
variables: { ...disableVariables, resourceId: 'should-i-be-disabled' },
|
||||||
}),
|
}),
|
||||||
mutate({
|
mutate({
|
||||||
mutation: reviewMutation,
|
mutation: review,
|
||||||
variables: { ...enableVariables, resourceId: 'should-i-be-disabled' },
|
variables: { ...enableVariables, resourceId: 'should-i-be-disabled' },
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@ -201,11 +165,11 @@ describe('moderate resources', () => {
|
|||||||
it('updates the updatedAt attribute', async () => {
|
it('updates the updatedAt attribute', async () => {
|
||||||
const [firstReview, secondReview] = await Promise.all([
|
const [firstReview, secondReview] = await Promise.all([
|
||||||
mutate({
|
mutate({
|
||||||
mutation: reviewMutation,
|
mutation: review,
|
||||||
variables: { ...disableVariables, resourceId: 'should-i-be-disabled' },
|
variables: { ...disableVariables, resourceId: 'should-i-be-disabled' },
|
||||||
}),
|
}),
|
||||||
mutate({
|
mutate({
|
||||||
mutation: reviewMutation,
|
mutation: review,
|
||||||
variables: { ...enableVariables, resourceId: 'should-i-be-disabled' },
|
variables: { ...enableVariables, resourceId: 'should-i-be-disabled' },
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@ -222,7 +186,7 @@ describe('moderate resources', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -236,7 +200,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('non-moderator receives an authorization error', async () => {
|
it('non-moderator receives an authorization error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -270,7 +234,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns disabled resource id', async () => {
|
it('returns disabled resource id', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'Comment', id: 'comment-id' } } },
|
data: { review: { resource: { __typename: 'Comment', id: 'comment-id' } } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -279,7 +243,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns .reviewed', async () => {
|
it('returns .reviewed', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -298,7 +262,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('updates .disabled on comment', async () => {
|
it('updates .disabled on comment', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: { resource: { __typename: 'Comment', id: 'comment-id', disabled: true } },
|
review: { resource: { __typename: 'Comment', id: 'comment-id', disabled: true } },
|
||||||
@ -313,7 +277,7 @@ describe('moderate resources', () => {
|
|||||||
closed: true,
|
closed: true,
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: closeReportVariables }),
|
mutate({ mutation: review, variables: closeReportVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -348,7 +312,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns disabled resource id', async () => {
|
it('returns disabled resource id', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -361,7 +325,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns .reviewed', async () => {
|
it('returns .reviewed', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -380,7 +344,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('updates .disabled on post', async () => {
|
it('updates .disabled on post', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'Post', id: 'post-id', disabled: true } } },
|
data: { review: { resource: { __typename: 'Post', id: 'post-id', disabled: true } } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -393,7 +357,7 @@ describe('moderate resources', () => {
|
|||||||
closed: true,
|
closed: true,
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: closeReportVariables }),
|
mutate({ mutation: review, variables: closeReportVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -428,7 +392,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns disabled resource id', async () => {
|
it('returns disabled resource id', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'User', id: 'user-id' } } },
|
data: { review: { resource: { __typename: 'User', id: 'user-id' } } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -437,7 +401,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns .reviewed', async () => {
|
it('returns .reviewed', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -456,7 +420,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('updates .disabled on user', async () => {
|
it('updates .disabled on user', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: disableVariables }),
|
mutate({ mutation: review, variables: disableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'User', id: 'user-id', disabled: true } } },
|
data: { review: { resource: { __typename: 'User', id: 'user-id', disabled: true } } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -469,7 +433,7 @@ describe('moderate resources', () => {
|
|||||||
closed: true,
|
closed: true,
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: closeReportVariables }),
|
mutate({ mutation: review, variables: closeReportVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -492,7 +456,7 @@ describe('moderate resources', () => {
|
|||||||
resourceId: 'post-id',
|
resourceId: 'post-id',
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -511,7 +475,7 @@ describe('moderate resources', () => {
|
|||||||
resourceId: 'post-id',
|
resourceId: 'post-id',
|
||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
})
|
})
|
||||||
@ -552,7 +516,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns enabled resource id', async () => {
|
it('returns enabled resource id', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'Comment', id: 'comment-id' } } },
|
data: { review: { resource: { __typename: 'Comment', id: 'comment-id' } } },
|
||||||
})
|
})
|
||||||
@ -560,7 +524,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns .reviewed', async () => {
|
it('returns .reviewed', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -578,7 +542,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('updates .disabled on comment', async () => {
|
it('updates .disabled on comment', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: { resource: { __typename: 'Comment', id: 'comment-id', disabled: false } },
|
review: { resource: { __typename: 'Comment', id: 'comment-id', disabled: false } },
|
||||||
@ -617,7 +581,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns enabled resource id', async () => {
|
it('returns enabled resource id', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'Post', id: 'post-id' } } },
|
data: { review: { resource: { __typename: 'Post', id: 'post-id' } } },
|
||||||
})
|
})
|
||||||
@ -625,7 +589,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns .reviewed', async () => {
|
it('returns .reviewed', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -643,7 +607,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('updates .disabled on post', async () => {
|
it('updates .disabled on post', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: { resource: { __typename: 'Post', id: 'post-id', disabled: false } },
|
review: { resource: { __typename: 'Post', id: 'post-id', disabled: false } },
|
||||||
@ -681,7 +645,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns enabled resource id', async () => {
|
it('returns enabled resource id', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { review: { resource: { __typename: 'User', id: 'user-id' } } },
|
data: { review: { resource: { __typename: 'User', id: 'user-id' } } },
|
||||||
})
|
})
|
||||||
@ -689,7 +653,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('returns .reviewed', async () => {
|
it('returns .reviewed', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: {
|
review: {
|
||||||
@ -707,7 +671,7 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
it('updates .disabled on user', async () => {
|
it('updates .disabled on user', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: reviewMutation, variables: enableVariables }),
|
mutate({ mutation: review, variables: enableVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
review: { resource: { __typename: 'User', id: 'user-id', disabled: false } },
|
review: { resource: { __typename: 'User', id: 'user-id', disabled: false } },
|
||||||
|
|||||||
@ -3,12 +3,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { markAllAsReadMutation } from '@graphql/queries/markAllAsReadMutation'
|
import { DeletePost } from '@graphql/queries/DeletePost'
|
||||||
import { markAsReadMutation } from '@graphql/queries/markAsReadMutation'
|
import { markAllAsRead } from '@graphql/queries/markAllAsRead'
|
||||||
import { notificationQuery } from '@graphql/queries/notificationQuery'
|
import { markAsRead } from '@graphql/queries/markAsRead'
|
||||||
|
import { notifications } from '@graphql/queries/notifications'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -154,7 +153,7 @@ describe('given some notifications', () => {
|
|||||||
describe('notifications', () => {
|
describe('notifications', () => {
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await query({ query: notificationQuery() })
|
const { errors } = await query({ query: notifications })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -201,7 +200,7 @@ describe('given some notifications', () => {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
await expect(query({ query: notificationQuery(), variables })).resolves.toMatchObject({
|
await expect(query({ query: notifications, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
notifications: expect.arrayContaining(expected),
|
notifications: expect.arrayContaining(expected),
|
||||||
},
|
},
|
||||||
@ -235,7 +234,7 @@ describe('given some notifications', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const response = await query({
|
const response = await query({
|
||||||
query: notificationQuery(),
|
query: notifications,
|
||||||
variables: { ...variables, read: false },
|
variables: { ...variables, read: false },
|
||||||
})
|
})
|
||||||
await expect(response).toMatchObject(expected)
|
await expect(response).toMatchObject(expected)
|
||||||
@ -245,16 +244,8 @@ describe('given some notifications', () => {
|
|||||||
describe('if a resource gets deleted', () => {
|
describe('if a resource gets deleted', () => {
|
||||||
const deletePostAction = async () => {
|
const deletePostAction = async () => {
|
||||||
authenticatedUser = await author.toJson()
|
authenticatedUser = await author.toJson()
|
||||||
const deletePostMutation = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
DeletePost(id: $id) {
|
|
||||||
id
|
|
||||||
deleted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: deletePostMutation, variables: { id: 'p3' } }),
|
mutate({ mutation: DeletePost, variables: { id: 'p3' } }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { DeletePost: { id: 'p3', deleted: true } },
|
data: { DeletePost: { id: 'p3', deleted: true } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
@ -264,14 +255,14 @@ describe('given some notifications', () => {
|
|||||||
|
|
||||||
it('reduces notifications list', async () => {
|
it('reduces notifications list', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: notificationQuery(), variables: { ...variables, read: false } }),
|
query({ query: notifications, variables: { ...variables, read: false } }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
data: { notifications: [expect.any(Object), expect.any(Object)] },
|
data: { notifications: [expect.any(Object), expect.any(Object)] },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
})
|
})
|
||||||
await deletePostAction()
|
await deletePostAction()
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: notificationQuery(), variables: { ...variables, read: false } }),
|
query({ query: notifications, variables: { ...variables, read: false } }),
|
||||||
).resolves.toMatchObject({ data: { notifications: [] }, errors: undefined })
|
).resolves.toMatchObject({ data: { notifications: [] }, errors: undefined })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -283,7 +274,7 @@ describe('given some notifications', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const result = await mutate({
|
const result = await mutate({
|
||||||
mutation: markAsReadMutation(),
|
mutation: markAsRead,
|
||||||
variables: { ...variables, id: 'p1' },
|
variables: { ...variables, id: 'p1' },
|
||||||
})
|
})
|
||||||
expect(result.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(result.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -304,7 +295,7 @@ describe('given some notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns null', async () => {
|
it('returns null', async () => {
|
||||||
const response = await mutate({ mutation: markAsReadMutation(), variables })
|
const response = await mutate({ mutation: markAsRead, variables })
|
||||||
expect(response.data?.markAsRead).toEqual(null)
|
expect(response.data?.markAsRead).toEqual(null)
|
||||||
expect(response.errors).toBeUndefined()
|
expect(response.errors).toBeUndefined()
|
||||||
})
|
})
|
||||||
@ -320,7 +311,7 @@ describe('given some notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('updates `read` attribute and returns NOTIFIED relationship', async () => {
|
it('updates `read` attribute and returns NOTIFIED relationship', async () => {
|
||||||
const { data } = await mutate({ mutation: markAsReadMutation(), variables })
|
const { data } = await mutate({ mutation: markAsRead, variables })
|
||||||
expect(data).toEqual({
|
expect(data).toEqual({
|
||||||
markAsRead: {
|
markAsRead: {
|
||||||
from: {
|
from: {
|
||||||
@ -341,7 +332,7 @@ describe('given some notifications', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
it('returns null', async () => {
|
it('returns null', async () => {
|
||||||
const response = await mutate({ mutation: markAsReadMutation(), variables })
|
const response = await mutate({ mutation: markAsRead, variables })
|
||||||
expect(response.data?.markAsRead).toEqual(null)
|
expect(response.data?.markAsRead).toEqual(null)
|
||||||
expect(response.errors).toBeUndefined()
|
expect(response.errors).toBeUndefined()
|
||||||
})
|
})
|
||||||
@ -357,7 +348,7 @@ describe('given some notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('updates `read` attribute and returns NOTIFIED relationship', async () => {
|
it('updates `read` attribute and returns NOTIFIED relationship', async () => {
|
||||||
const { data } = await mutate({ mutation: markAsReadMutation(), variables })
|
const { data } = await mutate({ mutation: markAsRead, variables })
|
||||||
expect(data).toEqual({
|
expect(data).toEqual({
|
||||||
markAsRead: {
|
markAsRead: {
|
||||||
from: {
|
from: {
|
||||||
@ -378,7 +369,7 @@ describe('given some notifications', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const result = await mutate({
|
const result = await mutate({
|
||||||
mutation: markAllAsReadMutation(),
|
mutation: markAllAsRead,
|
||||||
})
|
})
|
||||||
expect(result.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(result.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
@ -397,7 +388,7 @@ describe('given some notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('returns all as read', async () => {
|
it('returns all as read', async () => {
|
||||||
const response = await mutate({ mutation: markAllAsReadMutation(), variables })
|
const response = await mutate({ mutation: markAllAsRead, variables })
|
||||||
expect(response.data?.markAllAsRead).toEqual(
|
expect(response.data?.markAllAsRead).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import { createPostMutation } from '@graphql/queries/createPostMutation'
|
import { CreatePost } from '@graphql/queries/CreatePost'
|
||||||
|
import { toggleObservePost } from '@graphql/queries/toggleObservePost'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
import type { Context } from '@src/context'
|
import type { Context } from '@src/context'
|
||||||
@ -73,7 +74,7 @@ describe('observing posts', () => {
|
|||||||
it('has the author of the post observing the post', async () => {
|
it('has the author of the post observing the post', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
title: 'A post the author should observe',
|
title: 'A post the author should observe',
|
||||||
@ -158,20 +159,11 @@ describe('observing posts', () => {
|
|||||||
authenticatedUser = await otherUser.toJson()
|
authenticatedUser = await otherUser.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
const toggleObservePostMutation = gql`
|
|
||||||
mutation ($id: ID!, $value: Boolean!) {
|
|
||||||
toggleObservePost(id: $id, value: $value) {
|
|
||||||
isObservedByMe
|
|
||||||
observingUsersCount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('switch off observation', () => {
|
describe('switch off observation', () => {
|
||||||
it('does not observe the post anymore', async () => {
|
it('does not observe the post anymore', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: toggleObservePostMutation,
|
mutation: toggleObservePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
value: false,
|
value: false,
|
||||||
@ -232,7 +224,7 @@ describe('observing posts', () => {
|
|||||||
it('does observe the post again', async () => {
|
it('does observe the post again', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: toggleObservePostMutation,
|
mutation: toggleObservePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
value: true,
|
value: true,
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
import gql from 'graphql-tag'
|
|
||||||
|
|
||||||
import registrationConstants from '@constants/registrationBranded'
|
import registrationConstants from '@constants/registrationBranded'
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
|
import { login } from '@graphql/queries/login'
|
||||||
|
import { requestPasswordReset } from '@graphql/queries/requestPasswordReset'
|
||||||
|
import { resetPassword } from '@graphql/queries/resetPassword'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
|
|
||||||
@ -64,25 +65,21 @@ describe('passwordReset', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('requestPasswordReset', () => {
|
describe('requestPasswordReset', () => {
|
||||||
const mutation = gql`
|
|
||||||
mutation ($email: String!, $locale: String!) {
|
|
||||||
requestPasswordReset(email: $email, locale: $locale)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
describe('with invalid email', () => {
|
describe('with invalid email', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = { ...variables, email: 'non-existent@example.org', locale: 'de' }
|
variables = { ...variables, email: 'non-existent@example.org', locale: 'de' }
|
||||||
})
|
})
|
||||||
|
|
||||||
it('resolves anyways', async () => {
|
it('resolves anyways', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(
|
||||||
|
mutate({ mutation: requestPasswordReset, variables }),
|
||||||
|
).resolves.toMatchObject({
|
||||||
data: { requestPasswordReset: true },
|
data: { requestPasswordReset: true },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates no node', async () => {
|
it('creates no node', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: requestPasswordReset, variables })
|
||||||
const resets = await getAllPasswordResets()
|
const resets = await getAllPasswordResets()
|
||||||
expect(resets).toHaveLength(0)
|
expect(resets).toHaveLength(0)
|
||||||
})
|
})
|
||||||
@ -94,7 +91,9 @@ describe('passwordReset', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('resolves', async () => {
|
it('resolves', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(
|
||||||
|
mutate({ mutation: requestPasswordReset, variables }),
|
||||||
|
).resolves.toMatchObject({
|
||||||
data: { requestPasswordReset: true },
|
data: { requestPasswordReset: true },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -102,13 +101,13 @@ describe('passwordReset', () => {
|
|||||||
it('creates node with label `PasswordReset`', async () => {
|
it('creates node with label `PasswordReset`', async () => {
|
||||||
let resets = await getAllPasswordResets()
|
let resets = await getAllPasswordResets()
|
||||||
expect(resets).toHaveLength(0)
|
expect(resets).toHaveLength(0)
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: requestPasswordReset, variables })
|
||||||
resets = await getAllPasswordResets()
|
resets = await getAllPasswordResets()
|
||||||
expect(resets).toHaveLength(1)
|
expect(resets).toHaveLength(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates a reset nonce', async () => {
|
it('creates a reset nonce', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: requestPasswordReset, variables })
|
||||||
const resets = await getAllPasswordResets()
|
const resets = await getAllPasswordResets()
|
||||||
const [reset] = resets
|
const [reset] = resets
|
||||||
const { nonce } = reset.properties
|
const { nonce } = reset.properties
|
||||||
@ -125,12 +124,6 @@ describe('resetPassword', () => {
|
|||||||
const { email = 'user@example.org', issuedAt = new Date(), nonce = '12345' } = options
|
const { email = 'user@example.org', issuedAt = new Date(), nonce = '12345' } = options
|
||||||
await createPasswordReset({ driver: database.driver, email, issuedAt, nonce })
|
await createPasswordReset({ driver: database.driver, email, issuedAt, nonce })
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutation = gql`
|
|
||||||
mutation ($nonce: String!, $email: String!, $newPassword: String!) {
|
|
||||||
resetPassword(nonce: $nonce, email: $email, newPassword: $newPassword)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
variables = { ...variables, newPassword: 'supersecret' }
|
variables = { ...variables, newPassword: 'supersecret' }
|
||||||
})
|
})
|
||||||
@ -153,7 +146,7 @@ describe('resetPassword', () => {
|
|||||||
it('resolves to false', async () => {
|
it('resolves to false', async () => {
|
||||||
await setup()
|
await setup()
|
||||||
variables = { ...variables, email: 'non-existent@example.org', nonce: '12345' }
|
variables = { ...variables, email: 'non-existent@example.org', nonce: '12345' }
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: resetPassword, variables })).resolves.toMatchObject({
|
||||||
data: { resetPassword: false },
|
data: { resetPassword: false },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -171,7 +164,7 @@ describe('resetPassword', () => {
|
|||||||
|
|
||||||
it('resolves to false', async () => {
|
it('resolves to false', async () => {
|
||||||
await setup()
|
await setup()
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: resetPassword, variables })).resolves.toMatchObject({
|
||||||
data: { resetPassword: false },
|
data: { resetPassword: false },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -191,13 +184,13 @@ describe('resetPassword', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('resolves to true', async () => {
|
it('resolves to true', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: resetPassword, variables })).resolves.toMatchObject({
|
||||||
data: { resetPassword: true },
|
data: { resetPassword: true },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates PasswordReset `usedAt` property', async () => {
|
it('updates PasswordReset `usedAt` property', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: resetPassword, variables })
|
||||||
const requests = await getAllPasswordResets()
|
const requests = await getAllPasswordResets()
|
||||||
const [request] = requests
|
const [request] = requests
|
||||||
const { usedAt } = request.properties
|
const { usedAt } = request.properties
|
||||||
@ -205,16 +198,11 @@ describe('resetPassword', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('updates password of the user', async () => {
|
it('updates password of the user', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: resetPassword, variables })
|
||||||
const checkLoginMutation = gql`
|
|
||||||
mutation ($email: String!, $password: String!) {
|
|
||||||
login(email: $email, password: $password)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
variables = { ...variables, email: 'user@example.org', password: 'supersecret' }
|
variables = { ...variables, email: 'user@example.org', password: 'supersecret' }
|
||||||
await expect(
|
await expect(mutate({ mutation: login, variables })).resolves.toMatchObject({
|
||||||
mutate({ mutation: checkLoginMutation, variables }),
|
data: { login: expect.any(String) },
|
||||||
).resolves.toMatchObject({ data: { login: expect.any(String) } })
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -226,13 +214,13 @@ describe('resetPassword', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('resolves to false', async () => {
|
it('resolves to false', async () => {
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: resetPassword, variables })).resolves.toMatchObject({
|
||||||
data: { resetPassword: false },
|
data: { resetPassword: false },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does not update PasswordReset `usedAt` property', async () => {
|
it('does not update PasswordReset `usedAt` property', async () => {
|
||||||
await mutate({ mutation, variables })
|
await mutate({ mutation: resetPassword, variables })
|
||||||
const requests = await getAllPasswordResets()
|
const requests = await getAllPasswordResets()
|
||||||
const [request] = requests
|
const [request] = requests
|
||||||
const { usedAt } = request.properties
|
const { usedAt } = request.properties
|
||||||
|
|||||||
@ -6,10 +6,17 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
import Factory, { cleanDatabase } from '@db/factories'
|
import Factory, { cleanDatabase } from '@db/factories'
|
||||||
import Image from '@db/models/Image'
|
import Image from '@db/models/Image'
|
||||||
import { createGroupMutation } from '@graphql/queries/createGroupMutation'
|
import { AddPostEmotions } from '@graphql/queries/AddPostEmotions'
|
||||||
import { createPostMutation } from '@graphql/queries/createPostMutation'
|
import { CreateGroup } from '@graphql/queries/CreateGroup'
|
||||||
|
import { CreatePost } from '@graphql/queries/CreatePost'
|
||||||
|
import { DeletePost } from '@graphql/queries/DeletePost'
|
||||||
|
import { pinPost } from '@graphql/queries/pinPost'
|
||||||
import { Post } from '@graphql/queries/Post'
|
import { Post } from '@graphql/queries/Post'
|
||||||
|
import { PostsEmotionsByCurrentUser } from '@graphql/queries/PostsEmotionsByCurrentUser'
|
||||||
|
import { PostsEmotionsCountByEmotion } from '@graphql/queries/PostsEmotionsCountByEmotion'
|
||||||
import { pushPost } from '@graphql/queries/pushPost'
|
import { pushPost } from '@graphql/queries/pushPost'
|
||||||
|
import { RemovePostEmotions } from '@graphql/queries/RemovePostEmotions'
|
||||||
|
import { unpinPost } from '@graphql/queries/unpinPost'
|
||||||
import { unpushPost } from '@graphql/queries/unpushPost'
|
import { unpushPost } from '@graphql/queries/unpushPost'
|
||||||
import type { ApolloTestSetup } from '@root/test/helpers'
|
import type { ApolloTestSetup } from '@root/test/helpers'
|
||||||
import { createApolloTestSetup } from '@root/test/helpers'
|
import { createApolloTestSetup } from '@root/test/helpers'
|
||||||
@ -269,7 +276,7 @@ describe('CreatePost', () => {
|
|||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: createPostMutation(), variables })
|
const { errors } = await mutate({ mutation: CreatePost, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -284,9 +291,7 @@ describe('CreatePost', () => {
|
|||||||
data: { CreatePost: { title: 'I am a title', content: 'Some content' } },
|
data: { CreatePost: { title: 'I am a title', content: 'Some content' } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: createPostMutation(), variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: CreatePost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('assigns the authenticated user as author', async () => {
|
it('assigns the authenticated user as author', async () => {
|
||||||
@ -301,20 +306,16 @@ describe('CreatePost', () => {
|
|||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: createPostMutation(), variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: CreatePost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('`disabled` and `deleted` default to `false`', async () => {
|
it('`disabled` and `deleted` default to `false`', async () => {
|
||||||
const expected = { data: { CreatePost: { disabled: false, deleted: false } } }
|
const expected = { data: { CreatePost: { disabled: false, deleted: false } } }
|
||||||
await expect(mutate({ mutation: createPostMutation(), variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: CreatePost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has label "Article" as default', async () => {
|
it('has label "Article" as default', async () => {
|
||||||
await expect(mutate({ mutation: createPostMutation(), variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: CreatePost, variables })).resolves.toMatchObject({
|
||||||
data: { CreatePost: { postType: ['Article'] } },
|
data: { CreatePost: { postType: ['Article'] } },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -323,7 +324,7 @@ describe('CreatePost', () => {
|
|||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: { ...variables, postType: 'not-valid' },
|
variables: { ...variables, postType: 'not-valid' },
|
||||||
}),
|
}),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
@ -342,7 +343,7 @@ describe('CreatePost', () => {
|
|||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -362,7 +363,7 @@ describe('CreatePost', () => {
|
|||||||
it('throws an error', async () => {
|
it('throws an error', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -387,7 +388,7 @@ describe('CreatePost', () => {
|
|||||||
const eventStart = new Date(now.getFullYear(), now.getMonth() - 1).toISOString()
|
const eventStart = new Date(now.getFullYear(), now.getMonth() - 1).toISOString()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -411,7 +412,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -435,7 +436,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -461,7 +462,7 @@ describe('CreatePost', () => {
|
|||||||
const eventEnd = new Date(now.getFullYear(), now.getMonth() + 2).toISOString()
|
const eventEnd = new Date(now.getFullYear(), now.getMonth() + 2).toISOString()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -486,7 +487,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -511,7 +512,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -540,7 +541,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -568,7 +569,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -593,7 +594,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -620,7 +621,7 @@ describe('CreatePost', () => {
|
|||||||
const now = new Date()
|
const now = new Date()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
postType: 'Event',
|
postType: 'Event',
|
||||||
@ -700,7 +701,7 @@ describe('UpdatePost', () => {
|
|||||||
author = await Factory.build('user', { slug: 'the-author' })
|
author = await Factory.build('user', { slug: 'the-author' })
|
||||||
authenticatedUser = await author.toJson()
|
authenticatedUser = await author.toJson()
|
||||||
const { data } = await mutate({
|
const { data } = await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
title: 'Old title',
|
title: 'Old title',
|
||||||
content: 'Old content',
|
content: 'Old content',
|
||||||
@ -1288,28 +1289,6 @@ describe('unpush posts', () => {
|
|||||||
|
|
||||||
describe('pin posts', () => {
|
describe('pin posts', () => {
|
||||||
let author
|
let author
|
||||||
const pinPostMutation = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
pinPost(id: $id) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
content
|
|
||||||
author {
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
}
|
|
||||||
pinnedBy {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
role
|
|
||||||
}
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
pinnedAt
|
|
||||||
pinned
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
author = await Factory.build('user', { slug: 'the-author' })
|
author = await Factory.build('user', { slug: 'the-author' })
|
||||||
await Factory.build(
|
await Factory.build(
|
||||||
@ -1332,7 +1311,7 @@ describe('pin posts', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
data: { pinPost: null },
|
data: { pinPost: null },
|
||||||
})
|
})
|
||||||
@ -1341,7 +1320,7 @@ describe('pin posts', () => {
|
|||||||
|
|
||||||
describe('ordinary users', () => {
|
describe('ordinary users', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
data: { pinPost: null },
|
data: { pinPost: null },
|
||||||
})
|
})
|
||||||
@ -1356,7 +1335,7 @@ describe('pin posts', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
data: { pinPost: null },
|
data: { pinPost: null },
|
||||||
})
|
})
|
||||||
@ -1391,7 +1370,7 @@ describe('pin posts', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws with error that pinning posts is not allowed', async () => {
|
it('throws with error that pinning posts is not allowed', async () => {
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
data: { pinPost: null },
|
data: { pinPost: null },
|
||||||
errors: [{ message: 'Pinned posts are not allowed!' }],
|
errors: [{ message: 'Pinned posts are not allowed!' }],
|
||||||
})
|
})
|
||||||
@ -1435,9 +1414,7 @@ describe('pin posts', () => {
|
|||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets createdAt date for PINNED', async () => {
|
it('sets createdAt date for PINNED', async () => {
|
||||||
@ -1450,9 +1427,7 @@ describe('pin posts', () => {
|
|||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets redundant `pinned` property for performant ordering', async () => {
|
it('sets redundant `pinned` property for performant ordering', async () => {
|
||||||
@ -1461,9 +1436,7 @@ describe('pin posts', () => {
|
|||||||
data: { pinPost: { pinned: true } },
|
data: { pinPost: { pinned: true } },
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1506,9 +1479,7 @@ describe('pin posts', () => {
|
|||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1531,9 +1502,7 @@ describe('pin posts', () => {
|
|||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -1549,7 +1518,7 @@ describe('pin posts', () => {
|
|||||||
author: admin,
|
author: admin,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
await mutate({ mutation: pinPostMutation, variables })
|
await mutate({ mutation: pinPost, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('removes previous `pinned` attribute', async () => {
|
it('removes previous `pinned` attribute', async () => {
|
||||||
@ -1557,14 +1526,14 @@ describe('pin posts', () => {
|
|||||||
pinnedPost = await database.neode.cypher(cypher, {})
|
pinnedPost = await database.neode.cypher(cypher, {})
|
||||||
expect(pinnedPost.records).toHaveLength(1)
|
expect(pinnedPost.records).toHaveLength(1)
|
||||||
variables = { ...variables, id: 'only-pinned-post' }
|
variables = { ...variables, id: 'only-pinned-post' }
|
||||||
await mutate({ mutation: pinPostMutation, variables })
|
await mutate({ mutation: pinPost, variables })
|
||||||
pinnedPost = await database.neode.cypher(cypher, {})
|
pinnedPost = await database.neode.cypher(cypher, {})
|
||||||
expect(pinnedPost.records).toHaveLength(1)
|
expect(pinnedPost.records).toHaveLength(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('removes previous PINNED relationship', async () => {
|
it('removes previous PINNED relationship', async () => {
|
||||||
variables = { ...variables, id: 'only-pinned-post' }
|
variables = { ...variables, id: 'only-pinned-post' }
|
||||||
await mutate({ mutation: pinPostMutation, variables })
|
await mutate({ mutation: pinPost, variables })
|
||||||
pinnedPost = await database.neode.cypher(
|
pinnedPost = await database.neode.cypher(
|
||||||
`MATCH (:User)-[pinned:PINNED]->(post:Post) RETURN post, pinned`,
|
`MATCH (:User)-[pinned:PINNED]->(post:Post) RETURN post, pinned`,
|
||||||
{},
|
{},
|
||||||
@ -1576,7 +1545,7 @@ describe('pin posts', () => {
|
|||||||
describe('post in public group', () => {
|
describe('post in public group', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
name: 'Public Group',
|
name: 'Public Group',
|
||||||
id: 'public-group',
|
id: 'public-group',
|
||||||
@ -1589,7 +1558,7 @@ describe('pin posts', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'public-group-post',
|
id: 'public-group-post',
|
||||||
title: 'Public group post',
|
title: 'Public group post',
|
||||||
@ -1602,7 +1571,7 @@ describe('pin posts', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('can be pinned', async () => {
|
it('can be pinned', async () => {
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
pinPost: {
|
pinPost: {
|
||||||
id: 'public-group-post',
|
id: 'public-group-post',
|
||||||
@ -1624,7 +1593,7 @@ describe('pin posts', () => {
|
|||||||
describe('post in closed group', () => {
|
describe('post in closed group', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
name: 'Closed Group',
|
name: 'Closed Group',
|
||||||
id: 'closed-group',
|
id: 'closed-group',
|
||||||
@ -1637,7 +1606,7 @@ describe('pin posts', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'closed-group-post',
|
id: 'closed-group-post',
|
||||||
title: 'Closed group post',
|
title: 'Closed group post',
|
||||||
@ -1650,7 +1619,7 @@ describe('pin posts', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('can not be pinned', async () => {
|
it('can not be pinned', async () => {
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
pinPost: null,
|
pinPost: null,
|
||||||
},
|
},
|
||||||
@ -1662,7 +1631,7 @@ describe('pin posts', () => {
|
|||||||
describe('post in hidden group', () => {
|
describe('post in hidden group', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createGroupMutation(),
|
mutation: CreateGroup,
|
||||||
variables: {
|
variables: {
|
||||||
name: 'Hidden Group',
|
name: 'Hidden Group',
|
||||||
id: 'hidden-group',
|
id: 'hidden-group',
|
||||||
@ -1675,7 +1644,7 @@ describe('pin posts', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: createPostMutation(),
|
mutation: CreatePost,
|
||||||
variables: {
|
variables: {
|
||||||
id: 'hidden-group-post',
|
id: 'hidden-group-post',
|
||||||
title: 'Hidden group post',
|
title: 'Hidden group post',
|
||||||
@ -1688,7 +1657,7 @@ describe('pin posts', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('can not be pinned', async () => {
|
it('can not be pinned', async () => {
|
||||||
await expect(mutate({ mutation: pinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: pinPost, variables })).resolves.toMatchObject({
|
||||||
data: {
|
data: {
|
||||||
pinPost: null,
|
pinPost: null,
|
||||||
},
|
},
|
||||||
@ -1800,7 +1769,7 @@ describe('pin posts', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { ...variables, id: 'first-post' }
|
variables = { ...variables, id: 'first-post' }
|
||||||
result = await mutate({ mutation: pinPostMutation, variables })
|
result = await mutate({ mutation: pinPost, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('pins the first post', () => {
|
it('pins the first post', () => {
|
||||||
@ -1836,7 +1805,7 @@ describe('pin posts', () => {
|
|||||||
describe('second post', () => {
|
describe('second post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { ...variables, id: 'second-post' }
|
variables = { ...variables, id: 'second-post' }
|
||||||
result = await mutate({ mutation: pinPostMutation, variables })
|
result = await mutate({ mutation: pinPost, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('pins the second post', () => {
|
it('pins the second post', () => {
|
||||||
@ -1872,7 +1841,7 @@ describe('pin posts', () => {
|
|||||||
describe('third post', () => {
|
describe('third post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { ...variables, id: 'third-post' }
|
variables = { ...variables, id: 'third-post' }
|
||||||
result = await mutate({ mutation: pinPostMutation, variables })
|
result = await mutate({ mutation: pinPost, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('pins the second post', () => {
|
it('pins the second post', () => {
|
||||||
@ -1908,7 +1877,7 @@ describe('pin posts', () => {
|
|||||||
describe('another post', () => {
|
describe('another post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { ...variables, id: 'another-post' }
|
variables = { ...variables, id: 'another-post' }
|
||||||
result = await mutate({ mutation: pinPostMutation, variables })
|
result = await mutate({ mutation: pinPost, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws with max pinned posts is reached', () => {
|
it('throws with max pinned posts is reached', () => {
|
||||||
@ -1974,28 +1943,6 @@ describe('pin posts', () => {
|
|||||||
|
|
||||||
describe('unpin posts', () => {
|
describe('unpin posts', () => {
|
||||||
let pinnedPost
|
let pinnedPost
|
||||||
const unpinPostMutation = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
unpinPost(id: $id) {
|
|
||||||
id
|
|
||||||
title
|
|
||||||
content
|
|
||||||
author {
|
|
||||||
name
|
|
||||||
slug
|
|
||||||
}
|
|
||||||
pinnedBy {
|
|
||||||
id
|
|
||||||
name
|
|
||||||
role
|
|
||||||
}
|
|
||||||
createdAt
|
|
||||||
updatedAt
|
|
||||||
pinned
|
|
||||||
pinnedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
pinnedPost = await Factory.build('post', { id: 'post-to-be-unpinned' })
|
pinnedPost = await Factory.build('post', { id: 'post-to-be-unpinned' })
|
||||||
variables = {
|
variables = {
|
||||||
@ -2006,7 +1953,7 @@ describe('unpin posts', () => {
|
|||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
await expect(mutate({ mutation: unpinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: unpinPost, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
data: { unpinPost: null },
|
data: { unpinPost: null },
|
||||||
})
|
})
|
||||||
@ -2015,7 +1962,7 @@ describe('unpin posts', () => {
|
|||||||
|
|
||||||
describe('users cannot unpin posts', () => {
|
describe('users cannot unpin posts', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(mutate({ mutation: unpinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: unpinPost, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
data: { unpinPost: null },
|
data: { unpinPost: null },
|
||||||
})
|
})
|
||||||
@ -2030,7 +1977,7 @@ describe('unpin posts', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
await expect(mutate({ mutation: unpinPostMutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: unpinPost, variables })).resolves.toMatchObject({
|
||||||
errors: [{ message: 'Not Authorized!' }],
|
errors: [{ message: 'Not Authorized!' }],
|
||||||
data: { unpinPost: null },
|
data: { unpinPost: null },
|
||||||
})
|
})
|
||||||
@ -2062,9 +2009,7 @@ describe('unpin posts', () => {
|
|||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(mutate({ mutation: unpinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: unpinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('unsets `pinned` property', async () => {
|
it('unsets `pinned` property', async () => {
|
||||||
@ -2077,33 +2022,13 @@ describe('unpin posts', () => {
|
|||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: unpinPostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: unpinPost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('DeletePost', () => {
|
describe('DeletePost', () => {
|
||||||
let author
|
let author
|
||||||
const deletePostMutation = gql`
|
|
||||||
mutation ($id: ID!) {
|
|
||||||
DeletePost(id: $id) {
|
|
||||||
id
|
|
||||||
deleted
|
|
||||||
content
|
|
||||||
contentExcerpt
|
|
||||||
image {
|
|
||||||
url
|
|
||||||
}
|
|
||||||
comments {
|
|
||||||
deleted
|
|
||||||
content
|
|
||||||
contentExcerpt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
author = await Factory.build('user')
|
author = await Factory.build('user')
|
||||||
@ -2127,7 +2052,7 @@ describe('DeletePost', () => {
|
|||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: deletePostMutation, variables })
|
const { errors } = await mutate({ mutation: DeletePost, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2138,7 +2063,7 @@ describe('DeletePost', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const { errors } = await mutate({ mutation: deletePostMutation, variables })
|
const { errors } = await mutate({ mutation: DeletePost, variables })
|
||||||
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2161,9 +2086,7 @@ describe('DeletePost', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: deletePostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: DeletePost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('if there are comments on the post', () => {
|
describe('if there are comments on the post', () => {
|
||||||
@ -2200,9 +2123,7 @@ describe('DeletePost', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: deletePostMutation, variables })).resolves.toMatchObject(
|
await expect(mutate({ mutation: DeletePost, variables })).resolves.toMatchObject(expected)
|
||||||
expected,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -2251,19 +2172,6 @@ describe('emotions', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('AddPostEmotions', () => {
|
describe('AddPostEmotions', () => {
|
||||||
const addPostEmotionsMutation = gql`
|
|
||||||
mutation ($to: _PostInput!, $data: _EMOTEDInput!) {
|
|
||||||
AddPostEmotions(to: $to, data: $data) {
|
|
||||||
from {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
emotion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
let postsEmotionsQueryVariables
|
let postsEmotionsQueryVariables
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@ -2277,7 +2185,7 @@ describe('emotions', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const addPostEmotions = await mutate({
|
const addPostEmotions = await mutate({
|
||||||
mutation: addPostEmotionsMutation,
|
mutation: AddPostEmotions,
|
||||||
variables,
|
variables,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -2300,7 +2208,7 @@ describe('emotions', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: addPostEmotionsMutation, variables })).resolves.toEqual(
|
await expect(mutate({ mutation: AddPostEmotions, variables })).resolves.toEqual(
|
||||||
expect.objectContaining(expected),
|
expect.objectContaining(expected),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -2315,8 +2223,8 @@ describe('emotions', () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await mutate({ mutation: addPostEmotionsMutation, variables })
|
await mutate({ mutation: AddPostEmotions, variables })
|
||||||
await mutate({ mutation: addPostEmotionsMutation, variables })
|
await mutate({ mutation: AddPostEmotions, variables })
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: PostsEmotionsCountQuery, variables: postsEmotionsQueryVariables }),
|
query({ query: PostsEmotionsCountQuery, variables: postsEmotionsQueryVariables }),
|
||||||
).resolves.toEqual(expect.objectContaining(expected))
|
).resolves.toEqual(expect.objectContaining(expected))
|
||||||
@ -2335,9 +2243,9 @@ describe('emotions', () => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await mutate({ mutation: addPostEmotionsMutation, variables })
|
await mutate({ mutation: AddPostEmotions, variables })
|
||||||
variables = { ...variables, data: { emotion: 'surprised' } }
|
variables = { ...variables, data: { emotion: 'surprised' } }
|
||||||
await mutate({ mutation: addPostEmotionsMutation, variables })
|
await mutate({ mutation: AddPostEmotions, variables })
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: PostsEmotionsQuery, variables: postsEmotionsQueryVariables }),
|
query({ query: PostsEmotionsQuery, variables: postsEmotionsQueryVariables }),
|
||||||
).resolves.toEqual(expect.objectContaining(expected))
|
).resolves.toEqual(expect.objectContaining(expected))
|
||||||
@ -2359,7 +2267,7 @@ describe('emotions', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
await expect(mutate({ mutation: addPostEmotionsMutation, variables })).resolves.toEqual(
|
await expect(mutate({ mutation: AddPostEmotions, variables })).resolves.toEqual(
|
||||||
expect.objectContaining(expected),
|
expect.objectContaining(expected),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -2368,19 +2276,6 @@ describe('emotions', () => {
|
|||||||
|
|
||||||
describe('RemovePostEmotions', () => {
|
describe('RemovePostEmotions', () => {
|
||||||
let removePostEmotionsVariables, postsEmotionsQueryVariables
|
let removePostEmotionsVariables, postsEmotionsQueryVariables
|
||||||
const removePostEmotionsMutation = gql`
|
|
||||||
mutation ($to: _PostInput!, $data: _EMOTEDInput!) {
|
|
||||||
RemovePostEmotions(to: $to, data: $data) {
|
|
||||||
from {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
emotion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await author.relateTo(postToEmote, 'emoted', { emotion: 'happy' })
|
await author.relateTo(postToEmote, 'emoted', { emotion: 'happy' })
|
||||||
await user.relateTo(postToEmote, 'emoted', { emotion: 'cry' })
|
await user.relateTo(postToEmote, 'emoted', { emotion: 'cry' })
|
||||||
@ -2399,7 +2294,7 @@ describe('emotions', () => {
|
|||||||
|
|
||||||
it('throws authorization error', async () => {
|
it('throws authorization error', async () => {
|
||||||
const removePostEmotions = await mutate({
|
const removePostEmotions = await mutate({
|
||||||
mutation: removePostEmotionsMutation,
|
mutation: RemovePostEmotions,
|
||||||
variables: removePostEmotionsVariables,
|
variables: removePostEmotionsVariables,
|
||||||
})
|
})
|
||||||
expect(removePostEmotions.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
expect(removePostEmotions.errors?.[0]).toHaveProperty('message', 'Not Authorized!')
|
||||||
@ -2414,7 +2309,7 @@ describe('emotions', () => {
|
|||||||
|
|
||||||
it('returns null if the emotion could not be found', async () => {
|
it('returns null if the emotion could not be found', async () => {
|
||||||
const removePostEmotions = await mutate({
|
const removePostEmotions = await mutate({
|
||||||
mutation: removePostEmotionsMutation,
|
mutation: RemovePostEmotions,
|
||||||
variables: removePostEmotionsVariables,
|
variables: removePostEmotionsVariables,
|
||||||
})
|
})
|
||||||
expect(removePostEmotions).toEqual(
|
expect(removePostEmotions).toEqual(
|
||||||
@ -2440,7 +2335,7 @@ describe('emotions', () => {
|
|||||||
}
|
}
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: removePostEmotionsMutation,
|
mutation: RemovePostEmotions,
|
||||||
variables: removePostEmotionsVariables,
|
variables: removePostEmotionsVariables,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(expect.objectContaining(expected))
|
).resolves.toEqual(expect.objectContaining(expected))
|
||||||
@ -2452,7 +2347,7 @@ describe('emotions', () => {
|
|||||||
data: { Post: [{ emotions: expect.arrayContaining(expectedEmotions) }] },
|
data: { Post: [{ emotions: expect.arrayContaining(expectedEmotions) }] },
|
||||||
}
|
}
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: removePostEmotionsMutation,
|
mutation: RemovePostEmotions,
|
||||||
variables: removePostEmotionsVariables,
|
variables: removePostEmotionsVariables,
|
||||||
})
|
})
|
||||||
await expect(
|
await expect(
|
||||||
@ -2467,17 +2362,6 @@ describe('emotions', () => {
|
|||||||
let PostsEmotionsCountByEmotionVariables
|
let PostsEmotionsCountByEmotionVariables
|
||||||
let PostsEmotionsByCurrentUserVariables
|
let PostsEmotionsByCurrentUserVariables
|
||||||
|
|
||||||
const PostsEmotionsCountByEmotionQuery = gql`
|
|
||||||
query ($postId: ID!, $data: _EMOTEDInput!) {
|
|
||||||
PostsEmotionsCountByEmotion(postId: $postId, data: $data)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
const PostsEmotionsByCurrentUserQuery = gql`
|
|
||||||
query ($postId: ID!) {
|
|
||||||
PostsEmotionsByCurrentUser(postId: $postId)
|
|
||||||
}
|
|
||||||
`
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await user.relateTo(postToEmote, 'emoted', { emotion: 'cry' })
|
await user.relateTo(postToEmote, 'emoted', { emotion: 'cry' })
|
||||||
|
|
||||||
@ -2493,7 +2377,7 @@ describe('emotions', () => {
|
|||||||
const expectedResponse = { data: { PostsEmotionsCountByEmotion: 1 } }
|
const expectedResponse = { data: { PostsEmotionsCountByEmotion: 1 } }
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
query: PostsEmotionsCountByEmotionQuery,
|
query: PostsEmotionsCountByEmotion,
|
||||||
variables: PostsEmotionsCountByEmotionVariables,
|
variables: PostsEmotionsCountByEmotionVariables,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(expect.objectContaining(expectedResponse))
|
).resolves.toEqual(expect.objectContaining(expectedResponse))
|
||||||
@ -2510,7 +2394,7 @@ describe('emotions', () => {
|
|||||||
const expectedResponse = { data: { PostsEmotionsByCurrentUser: ['cry'] } }
|
const expectedResponse = { data: { PostsEmotionsByCurrentUser: ['cry'] } }
|
||||||
await expect(
|
await expect(
|
||||||
query({
|
query({
|
||||||
query: PostsEmotionsByCurrentUserQuery,
|
query: PostsEmotionsByCurrentUser,
|
||||||
variables: PostsEmotionsByCurrentUserVariables,
|
variables: PostsEmotionsByCurrentUserVariables,
|
||||||
}),
|
}),
|
||||||
).resolves.toEqual(expect.objectContaining(expectedResponse))
|
).resolves.toEqual(expect.objectContaining(expectedResponse))
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user