mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Sanitize reason description and test, fix report in 'seed-db.js'
This commit is contained in:
parent
935252a16e
commit
bb73ff43e4
@ -85,7 +85,7 @@ function clean(dirty) {
|
|||||||
return dirty
|
return dirty
|
||||||
}
|
}
|
||||||
|
|
||||||
const fields = ['content', 'contentExcerpt']
|
const fields = ['content', 'contentExcerpt', 'reasonDescription']
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: async (resolve, root, args, context, info) => {
|
Mutation: async (resolve, root, args, context, info) => {
|
||||||
|
|||||||
@ -2,7 +2,12 @@ import uuid from 'uuid/v4'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
Mutation: {
|
Mutation: {
|
||||||
report: async (_parent, { resourceId, reasonCategory, reasonDescription }, { driver, req, user }, _resolveInfo) => {
|
report: async (
|
||||||
|
_parent,
|
||||||
|
{ resourceId, reasonCategory, reasonDescription },
|
||||||
|
{ driver, _req, user },
|
||||||
|
_resolveInfo,
|
||||||
|
) => {
|
||||||
const reportId = uuid()
|
const reportId = uuid()
|
||||||
const session = driver.session()
|
const session = driver.session()
|
||||||
const reportProperties = {
|
const reportProperties = {
|
||||||
|
|||||||
@ -123,11 +123,13 @@ describe('report', () => {
|
|||||||
|
|
||||||
it('returns a date', async () => {
|
it('returns a date', async () => {
|
||||||
returnedObject = '{ createdAt }'
|
returnedObject = '{ createdAt }'
|
||||||
await expect(action()).resolves.toEqual(expect.objectContaining({
|
await expect(action()).resolves.toEqual(
|
||||||
report: {
|
expect.objectContaining({
|
||||||
createdAt: expect.any(String),
|
report: {
|
||||||
},
|
createdAt: expect.any(String),
|
||||||
}))
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the reason category', async () => {
|
it('returns the reason category', async () => {
|
||||||
@ -155,6 +157,19 @@ describe('report', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('sanitize the reason description', async () => {
|
||||||
|
variables = {
|
||||||
|
...variables,
|
||||||
|
reasonDescription: 'My reason <sanitize></sanitize>!',
|
||||||
|
}
|
||||||
|
returnedObject = '{ reasonDescription }'
|
||||||
|
await expect(action()).resolves.toEqual({
|
||||||
|
report: {
|
||||||
|
reasonDescription: 'My reason !',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('reported resource is a post', () => {
|
describe('reported resource is a post', () => {
|
||||||
|
|||||||
@ -649,9 +649,14 @@ import { gql } from '../jest/helpers'
|
|||||||
])
|
])
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
|
|
||||||
|
// There is no error logged or the 'try' fails if this mutation is wrong. Why?
|
||||||
const reportMutation = gql`
|
const reportMutation = gql`
|
||||||
mutation($resourceId: ID!, $reasonDescription: String!) {
|
mutation($resourceId: ID!, $reasonCategory: String!, $reasonDescription: String!) {
|
||||||
report(reasonDescription: $reasonDescription, resourceId: $resourceId) {
|
report(
|
||||||
|
resourceId: $resourceId
|
||||||
|
reasonCategory: $reasonCategory
|
||||||
|
reasonDescription: $reasonDescription
|
||||||
|
) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -661,22 +666,25 @@ import { gql } from '../jest/helpers'
|
|||||||
mutate({
|
mutate({
|
||||||
mutation: reportMutation,
|
mutation: reportMutation,
|
||||||
variables: {
|
variables: {
|
||||||
reasonDescription: 'This comment is bigoted',
|
|
||||||
resourceId: 'c1',
|
resourceId: 'c1',
|
||||||
|
reasonCategory: 'other',
|
||||||
|
reasonDescription: 'This comment is bigoted',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
mutate({
|
mutate({
|
||||||
mutation: reportMutation,
|
mutation: reportMutation,
|
||||||
variables: {
|
variables: {
|
||||||
reasonDescription: 'This post is bigoted',
|
|
||||||
resourceId: 'p1',
|
resourceId: 'p1',
|
||||||
|
reasonCategory: 'discrimination-etc',
|
||||||
|
reasonDescription: 'This post is bigoted',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
mutate({
|
mutate({
|
||||||
mutation: reportMutation,
|
mutation: reportMutation,
|
||||||
variables: {
|
variables: {
|
||||||
reasonDescription: 'This user is harassing me with bigoted remarks',
|
|
||||||
resourceId: 'u1',
|
resourceId: 'u1',
|
||||||
|
reasonCategory: 'doxing',
|
||||||
|
reasonDescription: 'This user is harassing me with bigoted remarks',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user