mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Refactor 'leaveGroupMutation' to a function that returns GQL
This commit is contained in:
parent
1c040e1549
commit
14824c8b33
@ -122,16 +122,18 @@ export const joinGroupMutation = () => {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
export const leaveGroupMutation = gql`
|
export const leaveGroupMutation = () => {
|
||||||
mutation ($groupId: ID!, $userId: ID!) {
|
return gql`
|
||||||
LeaveGroup(groupId: $groupId, userId: $userId) {
|
mutation ($groupId: ID!, $userId: ID!) {
|
||||||
id
|
LeaveGroup(groupId: $groupId, userId: $userId) {
|
||||||
name
|
id
|
||||||
slug
|
name
|
||||||
myRoleInGroup
|
slug
|
||||||
|
myRoleInGroup
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
`
|
||||||
`
|
}
|
||||||
|
|
||||||
export const changeGroupMemberRoleMutation = gql`
|
export const changeGroupMemberRoleMutation = gql`
|
||||||
mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {
|
mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {
|
||||||
|
|||||||
@ -2411,7 +2411,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: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
groupId: 'not-existing-group',
|
groupId: 'not-existing-group',
|
||||||
userId: 'current-user',
|
userId: 'current-user',
|
||||||
@ -2450,7 +2450,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await pendingMemberUser.toJson()
|
authenticatedUser = await pendingMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: leaveGroupMutation,
|
mutation: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'pending-member-user',
|
userId: 'pending-member-user',
|
||||||
@ -2477,7 +2477,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await usualMemberUser.toJson()
|
authenticatedUser = await usualMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: leaveGroupMutation,
|
mutation: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2504,7 +2504,7 @@ describe('in mode', () => {
|
|||||||
authenticatedUser = await adminMemberUser.toJson()
|
authenticatedUser = await adminMemberUser.toJson()
|
||||||
await expect(
|
await expect(
|
||||||
mutate({
|
mutate({
|
||||||
mutation: leaveGroupMutation,
|
mutation: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
@ -2528,7 +2528,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: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'owner-member-user',
|
userId: 'owner-member-user',
|
||||||
@ -2542,7 +2542,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: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'second-owner-member-user',
|
userId: 'second-owner-member-user',
|
||||||
@ -2556,7 +2556,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: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'none-member-user',
|
userId: 'none-member-user',
|
||||||
@ -2570,7 +2570,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: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'usual-member-user',
|
userId: 'usual-member-user',
|
||||||
@ -2584,7 +2584,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: leaveGroupMutation(),
|
||||||
variables: {
|
variables: {
|
||||||
...variables,
|
...variables,
|
||||||
userId: 'admin-member-user',
|
userId: 'admin-member-user',
|
||||||
|
|||||||
@ -108,7 +108,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async joinLeave() {
|
async joinLeave() {
|
||||||
const join = !this.isMember
|
const join = !this.isMember
|
||||||
const mutation = join ? joinGroupMutation() : leaveGroupMutation
|
const mutation = join ? joinGroupMutation() : leaveGroupMutation()
|
||||||
|
|
||||||
this.hovered = false
|
this.hovered = false
|
||||||
this.$emit('prepare', join)
|
this.$emit('prepare', join)
|
||||||
|
|||||||
@ -113,16 +113,18 @@ export const joinGroupMutation = () => {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
export const leaveGroupMutation = gql`
|
export const leaveGroupMutation = () => {
|
||||||
mutation ($groupId: ID!, $userId: ID!) {
|
return gql`
|
||||||
LeaveGroup(groupId: $groupId, userId: $userId) {
|
mutation ($groupId: ID!, $userId: ID!) {
|
||||||
id
|
LeaveGroup(groupId: $groupId, userId: $userId) {
|
||||||
name
|
id
|
||||||
slug
|
name
|
||||||
myRoleInGroup
|
slug
|
||||||
|
myRoleInGroup
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
`
|
||||||
`
|
}
|
||||||
|
|
||||||
export const changeGroupMemberRoleMutation = gql`
|
export const changeGroupMemberRoleMutation = gql`
|
||||||
mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {
|
mutation ($groupId: ID!, $userId: ID!, $roleInGroup: GroupMemberRole!) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user