mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Get backend test to work with new properties
This commit is contained in:
parent
5458d6640e
commit
e7fbd169d9
@ -2,19 +2,20 @@ import uuid from 'uuid/v4'
|
||||
|
||||
export default {
|
||||
Mutation: {
|
||||
report: async (parent, { id, description }, { driver, req, user }, resolveInfo) => {
|
||||
report: async (_parent, { id, reasonCategory, description }, { driver, req, user }, _resolveInfo) => {
|
||||
const reportId = uuid()
|
||||
const session = driver.session()
|
||||
const reportData = {
|
||||
const reportProperties = {
|
||||
id: reportId,
|
||||
createdAt: new Date().toISOString(),
|
||||
description: description,
|
||||
reasonCategory,
|
||||
description,
|
||||
}
|
||||
|
||||
const reportQueryRes = await session.run(
|
||||
`
|
||||
match (u:User {id:$submitterId}) -[:REPORTED]->(report)-[:REPORTED]-> (resource {id: $resourceId})
|
||||
return labels(resource)[0] as label
|
||||
MATCH (u:User {id:$submitterId})-[:REPORTED]->(report)-[:REPORTED]->(resource {id: $resourceId})
|
||||
RETURN labels(resource)[0] as label
|
||||
`,
|
||||
{
|
||||
resourceId: id,
|
||||
@ -30,20 +31,21 @@ export default {
|
||||
if (rep) {
|
||||
throw new Error(rep.label)
|
||||
}
|
||||
|
||||
const res = await session.run(
|
||||
`
|
||||
MATCH (submitter:User {id: $userId})
|
||||
MATCH (resource {id: $resourceId})
|
||||
WHERE resource:User OR resource:Comment OR resource:Post
|
||||
MERGE (report:Report {id: {reportData}.id })
|
||||
MERGE (resource)<-[:REPORTED]-(report)
|
||||
MERGE (report)<-[:REPORTED]-(submitter)
|
||||
RETURN report, submitter, resource, labels(resource)[0] as type
|
||||
MATCH (submitter:User {id: $userId})
|
||||
MATCH (resource {id: $resourceId})
|
||||
WHERE resource:User OR resource:Comment OR resource:Post
|
||||
CREATE (report:Report {reportProperties})
|
||||
MERGE (resource)<-[:REPORTED]-(report)
|
||||
MERGE (report)<-[:REPORTED]-(submitter)
|
||||
RETURN report, submitter, resource, labels(resource)[0] as type
|
||||
`,
|
||||
{
|
||||
resourceId: id,
|
||||
userId: user.id,
|
||||
reportData,
|
||||
reportProperties,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@ -121,6 +121,15 @@ describe('report', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('returns a date', async () => {
|
||||
returnedObject = '{ createdAt }'
|
||||
await expect(action()).resolves.toEqual(expect.objectContaining({
|
||||
report: {
|
||||
createdAt: expect.any(String),
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
it('returns the reason category', async () => {
|
||||
variables = {
|
||||
...variables,
|
||||
|
||||
@ -37,11 +37,12 @@ type Mutation {
|
||||
|
||||
type Report {
|
||||
id: ID!
|
||||
createdAt: String!
|
||||
reasonCategory: String!
|
||||
description: String!
|
||||
submitter: User @relation(name: "REPORTED", direction: "IN")
|
||||
description: String
|
||||
type: String!
|
||||
@cypher(statement: "MATCH (resource)<-[:REPORTED]-(this) RETURN labels(resource)[0]")
|
||||
createdAt: String
|
||||
comment: Comment @relation(name: "REPORTED", direction: "OUT")
|
||||
post: Post @relation(name: "REPORTED", direction: "OUT")
|
||||
user: User @relation(name: "REPORTED", direction: "OUT")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user