Seed reported comments, posts and users

This commit is contained in:
Robert Schäfer 2019-02-20 11:23:03 +01:00
parent 3532b473ee
commit ba26c0e188
5 changed files with 32 additions and 47 deletions

View File

@ -31,7 +31,7 @@ const permissions = shield({
CreatePost: isAuthenticated,
// TODO UpdatePost: isOwner,
// TODO DeletePost: isOwner,
report: isAuthenticated,
report: isAuthenticated
// addFruitToBasket: isAuthenticated
// CreateUser: allow,
},

View File

@ -1,45 +0,0 @@
export default function (data) {
return `
mutation {
r1: CreateReport(id: "r1", type: contribution, description: "Bad Stuff") {
id
}
r2: CreateReport(id: "r2", type: comment, description: "Please remove this sh**") {
id
}
r3: CreateReport(id: "r3", type: user, description: "The user have misbehaved!") {
id
}
ra1: AddReportReporter(from: { id: "u1" }, to: { id: "r1" }) {
from {
id
}
}
ra2: AddReportReporter(from: { id: "u2" }, to: { id: "r2" }) {
from {
id
}
}
ra3: AddReportReporter(from: { id: "u3" }, to: { id: "r3" }) {
from {
id
}
}
rc1: AddReportContribution(from: { id: "r1" }, to: { id: "p2" }) {
from {
id
}
}
rc2: AddReportComment(from: { id: "r2" }, to: { id: "c2" }) {
from {
id
}
}
rc3: AddReportUser(from: { id: "r3" }, to: { id: "u4" }) {
from {
id
}
}
}
`
}

View File

@ -15,7 +15,8 @@ const builders = {
'post': require('./posts.js').default,
'comment': require('./comments.js').default,
'category': require('./categories.js').default,
'tag': require('./tags.js').default
'tag': require('./tags.js').default,
'report': require('./reports.js').default
}
const relationBuilders = {

View File

@ -0,0 +1,23 @@
import faker from 'faker'
export default function create (params) {
const {
description = faker.lorem.sentence(),
resource: { id: resourceId, type }
} = params
return `
mutation {
report(
description: "${description}",
resource: {
id: "${resourceId}",
type: ${type}
}
) {
id,
createdAt
}
}
`
}

View File

@ -169,6 +169,12 @@ import { authenticatedHeaders } from '../jest/helpers.js'
relate('comment', 'Post', { from: 'c7', to: 'p2' })
])
await Promise.all([
create('report', { description: 'I don\'t like this comment', resource: { id: 'c1', type: 'comment' } }, { headers: headers[3] }),
create('report', { description: 'I don\'t like this post', resource: { id: 'p1', type: 'contribution' } }, { headers: headers[4] }),
create('report', { description: 'I don\'t like this user', resource: { id: 'u1', type: 'user' } }, { headers: headers[5] })
])
await Promise.all([
create('organization', { id: 'o1', name: 'Democracy Deutschland', description: 'Description for democracy-deutschland.' }),
create('organization', { id: 'o2', name: 'Human-Connection', description: 'Description for human-connection.' }),