mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge pull request #207 from Human-Connection/27_disable_posts
Disable posts
This commit is contained in:
commit
2d24fc9945
@ -4,6 +4,7 @@ import userManagement from './resolvers/user_management.js'
|
|||||||
import statistics from './resolvers/statistics.js'
|
import statistics from './resolvers/statistics.js'
|
||||||
import reports from './resolvers/reports.js'
|
import reports from './resolvers/reports.js'
|
||||||
import posts from './resolvers/posts.js'
|
import posts from './resolvers/posts.js'
|
||||||
|
import moderation from './resolvers/moderation.js'
|
||||||
|
|
||||||
export const typeDefs =
|
export const typeDefs =
|
||||||
fs.readFileSync(process.env.GRAPHQL_SCHEMA || path.join(__dirname, 'schema.graphql'))
|
fs.readFileSync(process.env.GRAPHQL_SCHEMA || path.join(__dirname, 'schema.graphql'))
|
||||||
@ -17,6 +18,7 @@ export const resolvers = {
|
|||||||
Mutation: {
|
Mutation: {
|
||||||
...userManagement.Mutation,
|
...userManagement.Mutation,
|
||||||
...reports.Mutation,
|
...reports.Mutation,
|
||||||
|
...moderation.Mutation,
|
||||||
...posts.Mutation
|
...posts.Mutation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,10 @@ const permissions = shield({
|
|||||||
report: isAuthenticated,
|
report: isAuthenticated,
|
||||||
CreateBadge: isAdmin,
|
CreateBadge: isAdmin,
|
||||||
UpdateBadge: isAdmin,
|
UpdateBadge: isAdmin,
|
||||||
DeleteBadge: isAdmin
|
DeleteBadge: isAdmin,
|
||||||
|
|
||||||
|
enable: isModerator,
|
||||||
|
disable: isModerator
|
||||||
// addFruitToBasket: isAuthenticated
|
// addFruitToBasket: isAuthenticated
|
||||||
// CreateUser: allow,
|
// CreateUser: allow,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -10,14 +10,25 @@ let action
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.create('User', { role: 'user', email: 'user@example.org', password: '1234' }),
|
factory.create('User', { role: 'user', email: 'user@example.org', password: '1234' }),
|
||||||
factory.create('User', { role: 'moderator', email: 'moderator@example.org', password: '1234' })
|
factory.create('User', { id: 'm1', role: 'moderator', email: 'moderator@example.org', password: '1234' })
|
||||||
])
|
])
|
||||||
await factory.authenticateAs({ email: 'user@example.org', password: '1234' })
|
await factory.authenticateAs({ email: 'user@example.org', password: '1234' })
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.create('Post', { title: 'Deleted post', deleted: true, disabled: false }),
|
factory.create('Post', { title: 'Deleted post', deleted: true }),
|
||||||
factory.create('Post', { title: 'Disabled post', deleted: false, disabled: true }),
|
factory.create('Post', { id: 'p2', title: 'Disabled post', deleted: false }),
|
||||||
factory.create('Post', { title: 'Publicly visible post', deleted: false, disabled: false })
|
factory.create('Post', { title: 'Publicly visible post', deleted: false })
|
||||||
])
|
])
|
||||||
|
const moderatorFactory = Factory()
|
||||||
|
await moderatorFactory.authenticateAs({ email: 'moderator@example.org', password: '1234' })
|
||||||
|
const disableMutation = `
|
||||||
|
mutation {
|
||||||
|
disable(resource: {
|
||||||
|
id: "p2"
|
||||||
|
type: contribution
|
||||||
|
})
|
||||||
|
}
|
||||||
|
`
|
||||||
|
await moderatorFactory.mutate(disableMutation)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
|
|||||||
30
src/resolvers/moderation.js
Normal file
30
src/resolvers/moderation.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
export default {
|
||||||
|
Mutation: {
|
||||||
|
disable: async (object, params, { user, driver }) => {
|
||||||
|
const { resource: { id } } = params
|
||||||
|
const { id: userId } = user
|
||||||
|
const cypher = `
|
||||||
|
MATCH (u:User {id: $userId})
|
||||||
|
MATCH (r {id: $id})
|
||||||
|
SET r.disabled = true
|
||||||
|
MERGE (r)<-[:DISABLED]-(u)
|
||||||
|
`
|
||||||
|
const session = driver.session()
|
||||||
|
const res = await session.run(cypher, { id, userId })
|
||||||
|
session.close()
|
||||||
|
return Boolean(res)
|
||||||
|
},
|
||||||
|
enable: async (object, params, { user, driver }) => {
|
||||||
|
const { resource: { id } } = params
|
||||||
|
const cypher = `
|
||||||
|
MATCH (r {id: $id})<-[d:DISABLED]-()
|
||||||
|
SET r.disabled = false
|
||||||
|
DELETE d
|
||||||
|
`
|
||||||
|
const session = driver.session()
|
||||||
|
const res = await session.run(cypher, { id })
|
||||||
|
session.close()
|
||||||
|
return Boolean(res)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
370
src/resolvers/moderation.spec.js
Normal file
370
src/resolvers/moderation.spec.js
Normal file
@ -0,0 +1,370 @@
|
|||||||
|
import Factory from '../seed/factories'
|
||||||
|
import { GraphQLClient } from 'graphql-request'
|
||||||
|
import { host, login } from '../jest/helpers'
|
||||||
|
|
||||||
|
const factory = Factory()
|
||||||
|
let client
|
||||||
|
|
||||||
|
const setupAuthenticateClient = (params) => {
|
||||||
|
const authenticateClient = async () => {
|
||||||
|
await factory.create('User', params)
|
||||||
|
const headers = await login(params)
|
||||||
|
client = new GraphQLClient(host, { headers })
|
||||||
|
}
|
||||||
|
return authenticateClient
|
||||||
|
}
|
||||||
|
|
||||||
|
let setup
|
||||||
|
const runSetup = async () => {
|
||||||
|
await setup.createResource()
|
||||||
|
await setup.authenticateClient()
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
setup = {
|
||||||
|
createResource: () => {
|
||||||
|
},
|
||||||
|
authenticateClient: () => {
|
||||||
|
client = new GraphQLClient(host)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await factory.cleanDatabase()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('disable', () => {
|
||||||
|
const mutation = `
|
||||||
|
mutation($id: ID!, $type: ResourceEnum!) {
|
||||||
|
disable(resource: { id: $id, type: $type })
|
||||||
|
}
|
||||||
|
`
|
||||||
|
let variables
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// our defaul set of variables
|
||||||
|
variables = {
|
||||||
|
id: 'blabla',
|
||||||
|
type: 'contribution'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const action = async () => {
|
||||||
|
return client.request(mutation, variables)
|
||||||
|
}
|
||||||
|
|
||||||
|
it('throws authorization error', async () => {
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).rejects.toThrow('Not Authorised')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('authenticated', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setup.authenticateClient = setupAuthenticateClient({
|
||||||
|
email: 'user@example.org',
|
||||||
|
password: '1234'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws authorization error', async () => {
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).rejects.toThrow('Not Authorised')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('as moderator', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setup.authenticateClient = setupAuthenticateClient({
|
||||||
|
id: 'u7',
|
||||||
|
email: 'moderator@example.org',
|
||||||
|
password: '1234',
|
||||||
|
role: 'moderator'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('on a comment', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
variables = {
|
||||||
|
id: 'c47',
|
||||||
|
type: 'comment'
|
||||||
|
}
|
||||||
|
|
||||||
|
setup.createResource = async () => {
|
||||||
|
await factory.create('User', { id: 'u45', email: 'commenter@example.org', password: '1234' })
|
||||||
|
await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
||||||
|
await Promise.all([
|
||||||
|
factory.create('Post', { id: 'p3' }),
|
||||||
|
factory.create('Comment', { id: 'c47' })
|
||||||
|
])
|
||||||
|
await Promise.all([
|
||||||
|
factory.relate('Comment', 'Author', { from: 'u45', to: 'c47' }),
|
||||||
|
factory.relate('Comment', 'Post', { from: 'c47', to: 'p3' })
|
||||||
|
])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', async () => {
|
||||||
|
const expected = { disable: true }
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('changes .disabledBy', async () => {
|
||||||
|
const before = { Comment: [{ id: 'c47', disabledBy: null }] }
|
||||||
|
const expected = { Comment: [{ id: 'c47', disabledBy: { id: 'u7' } }] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment(disabled: true) { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('updates .disabled on comment', async () => {
|
||||||
|
const before = { Comment: [ { id: 'c47', disabled: false } ] }
|
||||||
|
const expected = { Comment: [ { id: 'c47', disabled: true } ] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment { id disabled } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment(disabled: true) { id disabled } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('on a post', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
variables = {
|
||||||
|
id: 'p9',
|
||||||
|
type: 'contribution'
|
||||||
|
}
|
||||||
|
|
||||||
|
setup.createResource = async () => {
|
||||||
|
await factory.create('User', { email: 'author@example.org', password: '1234' })
|
||||||
|
await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
||||||
|
await factory.create('Post', {
|
||||||
|
id: 'p9' // that's the ID we will look for
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', async () => {
|
||||||
|
const expected = { disable: true }
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('changes .disabledBy', async () => {
|
||||||
|
const before = { Post: [{ id: 'p9', disabledBy: null }] }
|
||||||
|
const expected = { Post: [{ id: 'p9', disabledBy: { id: 'u7' } }] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post(disabled: true) { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('updates .disabled on post', async () => {
|
||||||
|
const before = { Post: [ { id: 'p9', disabled: false } ] }
|
||||||
|
const expected = { Post: [ { id: 'p9', disabled: true } ] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post { id disabled } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post(disabled: true) { id disabled } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('enable', () => {
|
||||||
|
const mutation = `
|
||||||
|
mutation($id: ID!, $type: ResourceEnum!) {
|
||||||
|
enable(resource: { id: $id, type: $type })
|
||||||
|
}
|
||||||
|
`
|
||||||
|
let variables
|
||||||
|
|
||||||
|
const action = async () => {
|
||||||
|
return client.request(mutation, variables)
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// our defaul set of variables
|
||||||
|
variables = {
|
||||||
|
id: 'blabla',
|
||||||
|
type: 'contribution'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws authorization error', async () => {
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).rejects.toThrow('Not Authorised')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('authenticated', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
setup.authenticateClient = setupAuthenticateClient({
|
||||||
|
email: 'user@example.org',
|
||||||
|
password: '1234'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws authorization error', async () => {
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).rejects.toThrow('Not Authorised')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('as moderator', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
setup.authenticateClient = setupAuthenticateClient({
|
||||||
|
role: 'moderator',
|
||||||
|
email: 'someUser@example.org',
|
||||||
|
password: '1234'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('on a comment', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
variables = {
|
||||||
|
id: 'c456',
|
||||||
|
type: 'comment'
|
||||||
|
}
|
||||||
|
|
||||||
|
setup.createResource = async () => {
|
||||||
|
await factory.create('User', { id: 'u123', email: 'author@example.org', password: '1234' })
|
||||||
|
await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
||||||
|
await Promise.all([
|
||||||
|
factory.create('Post', { id: 'p9' }),
|
||||||
|
factory.create('Comment', { id: 'c456' })
|
||||||
|
])
|
||||||
|
await Promise.all([
|
||||||
|
factory.relate('Comment', 'Author', { from: 'u123', to: 'c456' }),
|
||||||
|
factory.relate('Comment', 'Post', { from: 'c456', to: 'p9' })
|
||||||
|
])
|
||||||
|
|
||||||
|
const disableMutation = `
|
||||||
|
mutation {
|
||||||
|
disable(resource: {
|
||||||
|
id: "c456"
|
||||||
|
type: comment
|
||||||
|
})
|
||||||
|
}
|
||||||
|
`
|
||||||
|
await factory.mutate(disableMutation) // that's we want to delete
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', async () => {
|
||||||
|
const expected = { enable: true }
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('changes .disabledBy', async () => {
|
||||||
|
const before = { Comment: [{ id: 'c456', disabledBy: { id: 'u123' } }] }
|
||||||
|
const expected = { Comment: [{ id: 'c456', disabledBy: null }] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment(disabled: true) { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('updates .disabled on post', async () => {
|
||||||
|
const before = { Comment: [ { id: 'c456', disabled: true } ] }
|
||||||
|
const expected = { Comment: [ { id: 'c456', disabled: false } ] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment(disabled: true) { id disabled } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action() // this updates .disabled
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Comment { id disabled } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('on a post', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
variables = {
|
||||||
|
id: 'p9',
|
||||||
|
type: 'contribution'
|
||||||
|
}
|
||||||
|
|
||||||
|
setup.createResource = async () => {
|
||||||
|
await factory.create('User', { id: 'u123', email: 'author@example.org', password: '1234' })
|
||||||
|
await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
||||||
|
await factory.create('Post', {
|
||||||
|
id: 'p9' // that's the ID we will look for
|
||||||
|
})
|
||||||
|
|
||||||
|
const disableMutation = `
|
||||||
|
mutation {
|
||||||
|
disable(resource: {
|
||||||
|
id: "p9"
|
||||||
|
type: contribution
|
||||||
|
})
|
||||||
|
}
|
||||||
|
`
|
||||||
|
await factory.mutate(disableMutation) // that's we want to delete
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', async () => {
|
||||||
|
const expected = { enable: true }
|
||||||
|
await runSetup()
|
||||||
|
await expect(action()).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('changes .disabledBy', async () => {
|
||||||
|
const before = { Post: [{ id: 'p9', disabledBy: { id: 'u123' } }] }
|
||||||
|
const expected = { Post: [{ id: 'p9', disabledBy: null }] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post(disabled: true) { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post { id, disabledBy { id } } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('updates .disabled on post', async () => {
|
||||||
|
const before = { Post: [ { id: 'p9', disabled: true } ] }
|
||||||
|
const expected = { Post: [ { id: 'p9', disabled: false } ] }
|
||||||
|
|
||||||
|
await runSetup()
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post(disabled: true) { id disabled } }'
|
||||||
|
)).resolves.toEqual(before)
|
||||||
|
await action() // this updates .disabled
|
||||||
|
await expect(client.request(
|
||||||
|
'{ Post { id disabled } }'
|
||||||
|
)).resolves.toEqual(expected)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -7,6 +7,8 @@ type Mutation {
|
|||||||
login(email: String!, password: String!): String!
|
login(email: String!, password: String!): String!
|
||||||
signup(email: String!, password: String!): Boolean!
|
signup(email: String!, password: String!): Boolean!
|
||||||
report(resource: Resource!, description: String): Report
|
report(resource: Resource!, description: String): Report
|
||||||
|
disable(resource: Resource!): Boolean!
|
||||||
|
enable(resource: Resource!): Boolean!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Statistics {
|
type Statistics {
|
||||||
@ -74,6 +76,7 @@ type User {
|
|||||||
avatar: String
|
avatar: String
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
|
disabledBy: User @relation(name: "DISABLED", direction: "IN")
|
||||||
role: UserGroupEnum
|
role: UserGroupEnum
|
||||||
|
|
||||||
location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
location: Location @cypher(statement: "MATCH (this)-[:IS_IN]->(l:Location) RETURN l")
|
||||||
@ -133,6 +136,7 @@ type Post {
|
|||||||
visibility: VisibilityEnum
|
visibility: VisibilityEnum
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
|
disabledBy: User @relation(name: "DISABLED", direction: "IN")
|
||||||
createdAt: String
|
createdAt: String
|
||||||
updatedAt: String
|
updatedAt: String
|
||||||
|
|
||||||
@ -162,6 +166,7 @@ type Comment {
|
|||||||
updatedAt: String
|
updatedAt: String
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
|
disabledBy: User @relation(name: "DISABLED", direction: "IN")
|
||||||
}
|
}
|
||||||
|
|
||||||
type Report {
|
type Report {
|
||||||
|
|||||||
@ -86,6 +86,10 @@ export default function Factory (options = {}) {
|
|||||||
this.lastResponse = await this.graphQLClient.request(mutation)
|
this.lastResponse = await this.graphQLClient.request(mutation)
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
async mutate (mutation, variables) {
|
||||||
|
this.lastResponse = await this.graphQLClient.request(mutation, variables)
|
||||||
|
return this
|
||||||
|
},
|
||||||
async cleanDatabase () {
|
async cleanDatabase () {
|
||||||
this.lastResponse = await cleanDatabase({ driver: this.neo4jDriver })
|
this.lastResponse = await cleanDatabase({ driver: this.neo4jDriver })
|
||||||
return this
|
return this
|
||||||
@ -94,6 +98,7 @@ export default function Factory (options = {}) {
|
|||||||
result.authenticateAs.bind(result)
|
result.authenticateAs.bind(result)
|
||||||
result.create.bind(result)
|
result.create.bind(result)
|
||||||
result.relate.bind(result)
|
result.relate.bind(result)
|
||||||
|
result.mutate.bind(result)
|
||||||
result.cleanDatabase.bind(result)
|
result.cleanDatabase.bind(result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@ export default function (params) {
|
|||||||
].join('. '),
|
].join('. '),
|
||||||
image = faker.image.image(),
|
image = faker.image.image(),
|
||||||
visibility = 'public',
|
visibility = 'public',
|
||||||
disabled = false,
|
|
||||||
deleted = false
|
deleted = false
|
||||||
} = params
|
} = params
|
||||||
|
|
||||||
@ -26,7 +25,6 @@ export default function (params) {
|
|||||||
content: "${content}",
|
content: "${content}",
|
||||||
image: "${image}",
|
image: "${image}",
|
||||||
visibility: ${visibility},
|
visibility: ${visibility},
|
||||||
disabled: ${disabled},
|
|
||||||
deleted: ${deleted}
|
deleted: ${deleted}
|
||||||
) { title, content }
|
) { title, content }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,10 +25,13 @@ export default function create (params) {
|
|||||||
disabled: ${disabled},
|
disabled: ${disabled},
|
||||||
deleted: ${deleted}
|
deleted: ${deleted}
|
||||||
) {
|
) {
|
||||||
|
id
|
||||||
name
|
name
|
||||||
email
|
email
|
||||||
avatar
|
avatar
|
||||||
role
|
role
|
||||||
|
deleted
|
||||||
|
disabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -87,7 +87,7 @@ import Factory from './factories'
|
|||||||
asTrick.create('Post', { id: 'p4' }),
|
asTrick.create('Post', { id: 'p4' }),
|
||||||
asTrack.create('Post', { id: 'p5' }),
|
asTrack.create('Post', { id: 'p5' }),
|
||||||
asAdmin.create('Post', { id: 'p6' }),
|
asAdmin.create('Post', { id: 'p6' }),
|
||||||
asModerator.create('Post', { id: 'p7', disabled: true }),
|
asModerator.create('Post', { id: 'p7' }),
|
||||||
asUser.create('Post', { id: 'p8' }),
|
asUser.create('Post', { id: 'p8' }),
|
||||||
asTick.create('Post', { id: 'p9' }),
|
asTick.create('Post', { id: 'p9' }),
|
||||||
asTrick.create('Post', { id: 'p10' }),
|
asTrick.create('Post', { id: 'p10' }),
|
||||||
@ -98,6 +98,16 @@ import Factory from './factories'
|
|||||||
asTick.create('Post', { id: 'p15' })
|
asTick.create('Post', { id: 'p15' })
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const disableMutation = `
|
||||||
|
mutation {
|
||||||
|
disable(resource: {
|
||||||
|
id: "p11"
|
||||||
|
type: contribution
|
||||||
|
})
|
||||||
|
}
|
||||||
|
`
|
||||||
|
await asModerator.mutate(disableMutation)
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
f.relate('Post', 'Categories', { from: 'p0', to: 'cat16' }),
|
f.relate('Post', 'Categories', { from: 'p0', to: 'cat16' }),
|
||||||
f.relate('Post', 'Categories', { from: 'p1', to: 'cat1' }),
|
f.relate('Post', 'Categories', { from: 'p1', to: 'cat1' }),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user