mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix tests by first report before review
This commit is contained in:
parent
59f53a07c6
commit
7de34d3d55
@ -111,6 +111,27 @@ beforeAll(async () => {
|
||||
mutate = client.mutate
|
||||
|
||||
authenticatedUser = await moderator.toJson()
|
||||
const reportMutation = gql `
|
||||
mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
||||
report(
|
||||
resourceId: $resourceId
|
||||
reasonCategory: $reasonCategory
|
||||
reasonDescription: $reasonDescription
|
||||
) {
|
||||
type
|
||||
}
|
||||
}
|
||||
`
|
||||
const reportVariables = {
|
||||
resourceId: 'undefined-resource',
|
||||
reasonCategory: 'discrimination_etc',
|
||||
reasonDescription: 'I am what I am !!!',
|
||||
}
|
||||
await Promise.all([
|
||||
mutate({ mutation: reportMutation, variables: { ...reportVariables, resourceId: 'c1' } }),
|
||||
mutate({ mutation: reportMutation, variables: { ...reportVariables, resourceId: 'u2' } }),
|
||||
mutate({ mutation: reportMutation, variables: { ...reportVariables, resourceId: 'p2' } }),
|
||||
])
|
||||
const reviewMutation = gql`
|
||||
mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
|
||||
review(resourceId: $resourceId, disable: $disable, closed: $closed) {
|
||||
|
||||
@ -17,6 +17,17 @@ let query,
|
||||
moderator,
|
||||
nonModerator
|
||||
|
||||
const reportMutation = gql `
|
||||
mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
||||
report(
|
||||
resourceId: $resourceId
|
||||
reasonCategory: $reasonCategory
|
||||
reasonDescription: $reasonDescription
|
||||
) {
|
||||
type
|
||||
}
|
||||
}
|
||||
`
|
||||
const reviewMutation = gql`
|
||||
mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
|
||||
review(resourceId: $resourceId, disable: $disable, closed: $closed) {
|
||||
@ -156,6 +167,14 @@ describe('moderate resources', () => {
|
||||
await factory.create('Comment', {
|
||||
id: 'comment-id',
|
||||
})
|
||||
await mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
resourceId: 'comment-id',
|
||||
reasonCategory: 'discrimination_etc',
|
||||
reasonDescription: 'I am what I am !!!',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('returns disabled resource id', async () => {
|
||||
@ -228,6 +247,14 @@ describe('moderate resources', () => {
|
||||
await factory.create('Post', {
|
||||
id: 'sample-post-id',
|
||||
})
|
||||
await mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
resourceId: 'sample-post-id',
|
||||
reasonCategory: 'discrimination_etc',
|
||||
reasonDescription: 'I am what I am !!!',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('returns disabled resource id', async () => {
|
||||
@ -377,6 +404,14 @@ describe('moderate resources', () => {
|
||||
await factory.create('Comment', {
|
||||
id: 'comment-id',
|
||||
})
|
||||
await mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
resourceId: 'comment-id',
|
||||
reasonCategory: 'discrimination_etc',
|
||||
reasonDescription: 'I am what I am !!!',
|
||||
},
|
||||
})
|
||||
await mutate({ mutation: reviewMutation, variables: disableVariables })
|
||||
})
|
||||
|
||||
@ -435,6 +470,14 @@ describe('moderate resources', () => {
|
||||
await factory.create('Post', {
|
||||
id: 'post-id',
|
||||
})
|
||||
await mutate({
|
||||
mutation: reportMutation,
|
||||
variables: {
|
||||
resourceId: 'post-id',
|
||||
reasonCategory: 'discrimination_etc',
|
||||
reasonDescription: 'I am what I am !!!',
|
||||
},
|
||||
})
|
||||
await mutate({ mutation: reviewMutation, variables: disableVariables })
|
||||
})
|
||||
|
||||
|
||||
@ -17,6 +17,24 @@ const disable = async id => {
|
||||
await factory.create('User', { id: 'u2', role: 'moderator' })
|
||||
const moderatorBearerToken = encode({ id: 'u2' })
|
||||
req = { headers: { authorization: `Bearer ${moderatorBearerToken}` } }
|
||||
await mutate({
|
||||
mutation: gql `
|
||||
mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
||||
report(
|
||||
resourceId: $resourceId
|
||||
reasonCategory: $reasonCategory
|
||||
reasonDescription: $reasonDescription
|
||||
) {
|
||||
type
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
resourceId: id,
|
||||
reasonCategory: 'discrimination_etc',
|
||||
reasonDescription: 'I am what I am !!!',
|
||||
},
|
||||
})
|
||||
await mutate({
|
||||
mutation: gql`
|
||||
mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user