mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Refactor test to avoid unneccessary http request
- Set up/tear down should not needlessly run http requests. These tests are not designed to test that the report/review process works as expected. that is the job of their respective unit tests/e2e tests.
This commit is contained in:
parent
7441dbf28c
commit
c088c6eac4
@ -9,45 +9,25 @@ import { neode as getNeode } from '../../bootstrap/neo4j'
|
|||||||
|
|
||||||
const factory = Factory()
|
const factory = Factory()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
let query
|
let query, mutate, variables, req, user
|
||||||
let mutate
|
|
||||||
let variables
|
|
||||||
let req
|
|
||||||
let user
|
|
||||||
|
|
||||||
const disable = async id => {
|
const disable = async id => {
|
||||||
await factory.create('User', { id: 'u2', role: 'moderator' })
|
const moderator = await factory.create('User', { id: 'u2', role: 'moderator' })
|
||||||
const moderatorBearerToken = encode({ id: 'u2' })
|
const user = await neode.find('User', id)
|
||||||
req = { headers: { authorization: `Bearer ${moderatorBearerToken}` } }
|
const reportAgainstUser = await factory.create('Report')
|
||||||
await mutate({
|
await Promise.all([
|
||||||
mutation: gql`
|
reportAgainstUser.relateTo(moderator, 'filed', {
|
||||||
mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
|
||||||
fileReport(
|
|
||||||
resourceId: $resourceId
|
|
||||||
reasonCategory: $reasonCategory
|
|
||||||
reasonDescription: $reasonDescription
|
|
||||||
) {
|
|
||||||
type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables: {
|
|
||||||
resourceId: id,
|
resourceId: id,
|
||||||
reasonCategory: 'discrimination_etc',
|
reasonCategory: 'discrimination_etc',
|
||||||
reasonDescription: 'I am what I am !!!',
|
reasonDescription: 'This user is harassing me with bigoted remarks!',
|
||||||
},
|
}),
|
||||||
})
|
reportAgainstUser.relateTo(user, 'belongsTo'),
|
||||||
await mutate({
|
])
|
||||||
mutation: gql`
|
const disableVariables = { resourceId: user.id, disable: true, closed: false }
|
||||||
mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
|
await Promise.all([
|
||||||
review(resourceId: $resourceId, disable: $disable, closed: $closed) {
|
reportAgainstUser.relateTo(moderator, 'reviewed', disableVariables),
|
||||||
disable
|
user.update({ disabled: true, updatedAt: new Date().toISOString() }),
|
||||||
}
|
])
|
||||||
}
|
|
||||||
`,
|
|
||||||
variables: { resourceId: id, disable: true, closed: false },
|
|
||||||
})
|
|
||||||
req = { headers: {} }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user