mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
First refactoring tests to new database structure
This commit is contained in:
parent
47d5cc89dd
commit
54be7782ba
@ -25,7 +25,7 @@ module.exports = {
|
||||
target: 'User',
|
||||
direction: 'in',
|
||||
},
|
||||
disabledBy: {
|
||||
decidedByModerator: {
|
||||
type: 'relationship',
|
||||
relationship: 'DECIDED',
|
||||
target: 'User',
|
||||
|
||||
@ -17,7 +17,7 @@ module.exports = {
|
||||
image: { type: 'string', allow: [null] },
|
||||
deleted: { type: 'boolean', default: false },
|
||||
disabled: { type: 'boolean', default: false },
|
||||
disabledBy: {
|
||||
decidedByModerator: {
|
||||
type: 'relationship',
|
||||
relationship: 'DECIDED',
|
||||
target: 'User',
|
||||
|
||||
@ -42,7 +42,7 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
friends: { type: 'relationship', relationship: 'FRIENDS', target: 'User', direction: 'both' },
|
||||
disabledBy: {
|
||||
decidedByModerator: {
|
||||
type: 'relationship',
|
||||
relationship: 'DECIDED',
|
||||
target: 'User',
|
||||
|
||||
@ -68,7 +68,7 @@ export default {
|
||||
hasOne: {
|
||||
author: '<-[:WROTE]-(related:User)',
|
||||
post: '-[:COMMENTS]->(related:Post)',
|
||||
disabledBy: '<-[:DECIDED]-(related:User)',
|
||||
decidedByModerator: '<-[:DECIDED]-(related:User)',
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
@ -4,21 +4,21 @@ export default {
|
||||
const { id: resourceId } = params
|
||||
const { id: userId } = user
|
||||
const cypher = `
|
||||
MATCH (u:User {id: $userId})
|
||||
MATCH (resource {id: $resourceId})
|
||||
WHERE resource:User OR resource:Comment OR resource:Post
|
||||
SET resource.disabled = true
|
||||
MERGE (resource)<-[decision:DECIDED]-(u)
|
||||
SET (
|
||||
CASE
|
||||
WHEN decision.createdAt IS NOT NULL
|
||||
THEN decision END).updatedAt = toString(datetime())
|
||||
SET (
|
||||
CASE
|
||||
WHEN decision.createdAt IS NULL
|
||||
THEN decision END).createdAt = toString(datetime())
|
||||
SET decision.disabled = true, decision.closed = false, decision.last = true
|
||||
RETURN resource {.id}
|
||||
MATCH (u:User {id: $userId})
|
||||
MATCH (resource {id: $resourceId})
|
||||
WHERE resource:User OR resource:Comment OR resource:Post
|
||||
SET resource.disabled = true
|
||||
MERGE (resource)<-[decision:DECIDED]-(u)
|
||||
SET (
|
||||
CASE
|
||||
WHEN decision.createdAt IS NOT NULL
|
||||
THEN decision END).updatedAt = toString(datetime())
|
||||
SET (
|
||||
CASE
|
||||
WHEN decision.createdAt IS NULL
|
||||
THEN decision END).createdAt = toString(datetime())
|
||||
SET decision.disabled = true, decision.closed = false, decision.last = true
|
||||
RETURN resource {.id}
|
||||
`
|
||||
const session = driver.session()
|
||||
const res = await session.run(cypher, { resourceId, userId })
|
||||
@ -32,14 +32,14 @@ export default {
|
||||
enable: async (object, params, { user, driver }) => {
|
||||
const { id: resourceId } = params
|
||||
const cypher = `
|
||||
MATCH (resource {id: $resourceId})<-[decision:DECIDED]-(:User)
|
||||
SET resource.disabled = false
|
||||
DELETE decision
|
||||
RETURN resource {.id}
|
||||
MATCH (resource {id: $resourceId})<-[decision:DECIDED]-(:User)
|
||||
SET resource.disabled = false
|
||||
SET decision.disabled = false, decision.updatedAt = toString(datetime())
|
||||
RETURN resource {.id}
|
||||
`
|
||||
// Wolle
|
||||
// SET decision.updatedAt = toString(datetime())
|
||||
// SET decision.disabled = false
|
||||
// DELETE decision
|
||||
|
||||
const session = driver.session()
|
||||
const res = await session.run(cypher, { resourceId })
|
||||
session.close()
|
||||
|
||||
@ -26,7 +26,7 @@ const commentQuery = gql`
|
||||
Comment(id: $id) {
|
||||
id
|
||||
disabled
|
||||
disabledBy {
|
||||
decidedByModerator {
|
||||
id
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ const postQuery = gql`
|
||||
Post(id: $id) {
|
||||
id
|
||||
disabled
|
||||
disabledBy {
|
||||
decidedByModerator {
|
||||
id
|
||||
}
|
||||
}
|
||||
@ -144,11 +144,11 @@ describe('moderate resources', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('changes .disabledBy', async () => {
|
||||
it('changes .decidedByModerator', async () => {
|
||||
variables = { id: 'comment-id' }
|
||||
const before = { data: { Comment: [{ id: 'comment-id', disabledBy: null }] } }
|
||||
const before = { data: { Comment: [{ id: 'comment-id', decidedByModerator: null }] } }
|
||||
const expected = {
|
||||
data: { Comment: [{ id: 'comment-id', disabledBy: { id: 'moderator-id' } }] },
|
||||
data: { Comment: [{ id: 'comment-id', decidedByModerator: { id: 'moderator-id' } }] },
|
||||
}
|
||||
await expect(query({ query: commentQuery, variables })).resolves.toMatchObject(before)
|
||||
await expect(mutate({ mutation: disableMutation, variables })).resolves.toMatchObject({
|
||||
@ -185,11 +185,11 @@ describe('moderate resources', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('changes .disabledBy', async () => {
|
||||
it('changes .decidedByModerator', async () => {
|
||||
variables = { id: 'sample-post-id' }
|
||||
const before = { data: { Post: [{ id: 'sample-post-id', disabledBy: null }] } }
|
||||
const before = { data: { Post: [{ id: 'sample-post-id', decidedByModerator: null }] } }
|
||||
const expected = {
|
||||
data: { Post: [{ id: 'sample-post-id', disabledBy: { id: 'moderator-id' } }] },
|
||||
data: { Post: [{ id: 'sample-post-id', decidedByModerator: { id: 'moderator-id' } }] },
|
||||
}
|
||||
|
||||
await expect(query({ query: postQuery, variables })).resolves.toMatchObject(before)
|
||||
@ -278,9 +278,9 @@ describe('moderate resources', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('changes .disabledBy', async () => {
|
||||
it('changes .decidedByModerator', async () => {
|
||||
const expected = {
|
||||
data: { Comment: [{ id: 'comment-id', disabledBy: null }] },
|
||||
data: { Comment: [{ id: 'comment-id', decidedByModerator: { id: 'moderator-id' } }] },
|
||||
errors: undefined,
|
||||
}
|
||||
await expect(mutate({ mutation: enableMutation, variables })).resolves.toMatchObject({
|
||||
@ -320,9 +320,9 @@ describe('moderate resources', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('changes .disabledBy', async () => {
|
||||
it('changes .decidedByModerator', async () => {
|
||||
const expected = {
|
||||
data: { Post: [{ id: 'post-id', disabledBy: null }] },
|
||||
data: { Post: [{ id: 'post-id', decidedByModerator: { id: 'moderator-id' } }] },
|
||||
errors: undefined,
|
||||
}
|
||||
await expect(mutate({ mutation: enableMutation, variables })).resolves.toMatchObject({
|
||||
|
||||
@ -306,7 +306,7 @@ export default {
|
||||
},
|
||||
hasOne: {
|
||||
author: '<-[:WROTE]-(related:User)',
|
||||
disabledBy: '<-[:DECIDED]-(related:User)',
|
||||
decidedByModerator: '<-[:DECIDED]-(related:User)',
|
||||
pinnedBy: '<-[:PINNED]-(related:User)',
|
||||
},
|
||||
count: {
|
||||
|
||||
@ -198,7 +198,7 @@ export default {
|
||||
},
|
||||
hasOne: {
|
||||
invitedBy: '<-[:INVITED]-(related:User)',
|
||||
disabledBy: '<-[:DECIDED]-(related:User)',
|
||||
decidedByModerator: '<-[:DECIDED]-(related:User)',
|
||||
location: '-[:IS_IN]->(related:Location)',
|
||||
},
|
||||
hasMany: {
|
||||
|
||||
@ -9,7 +9,7 @@ type Comment {
|
||||
updatedAt: String
|
||||
deleted: Boolean
|
||||
disabled: Boolean
|
||||
disabledBy: User @relation(name: "DECIDED", direction: "IN")
|
||||
decidedByModerator: User @relation(name: "DECIDED", direction: "IN")
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
|
||||
@ -47,7 +47,7 @@ type Post {
|
||||
deleted: Boolean
|
||||
disabled: Boolean
|
||||
pinned: Boolean
|
||||
disabledBy: User @relation(name: "DECIDED", direction: "IN")
|
||||
decidedByModerator: User @relation(name: "DECIDED", direction: "IN")
|
||||
createdAt: String
|
||||
updatedAt: String
|
||||
language: String
|
||||
|
||||
@ -8,7 +8,7 @@ type User {
|
||||
coverImg: String
|
||||
deleted: Boolean
|
||||
disabled: Boolean
|
||||
disabledBy: User @relation(name: "DECIDED", direction: "IN")
|
||||
decidedByModerator: User @relation(name: "DECIDED", direction: "IN")
|
||||
role: UserGroup!
|
||||
publicKey: String
|
||||
invitedBy: User @relation(name: "INVITED", direction: "IN")
|
||||
|
||||
@ -25,7 +25,7 @@ export const reportListQuery = () => {
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
disabledBy {
|
||||
decidedByModerator {
|
||||
id
|
||||
slug
|
||||
name
|
||||
@ -56,7 +56,7 @@ export const reportListQuery = () => {
|
||||
disabled
|
||||
deleted
|
||||
}
|
||||
disabledBy {
|
||||
decidedByModerator {
|
||||
id
|
||||
slug
|
||||
name
|
||||
@ -80,7 +80,7 @@ export const reportListQuery = () => {
|
||||
contributionsCount
|
||||
commentedCount
|
||||
}
|
||||
disabledBy {
|
||||
decidedByModerator {
|
||||
id
|
||||
slug
|
||||
name
|
||||
|
||||
@ -29,7 +29,10 @@
|
||||
<tr valign="top">
|
||||
<td class="ds-table-col ds-table-head-col ds-table-head-col-border">
|
||||
<!-- Icon -->
|
||||
<ds-text :class="[!content.resource.disabledBy && 'no-decision']" color="soft">
|
||||
<ds-text
|
||||
:class="[!content.resource.decidedByModerator && 'no-decision']"
|
||||
color="soft"
|
||||
>
|
||||
<ds-icon
|
||||
v-if="content.type === 'Post'"
|
||||
v-tooltip="{ content: $t('report.contribution.type'), placement: 'right' }"
|
||||
@ -85,10 +88,10 @@
|
||||
</td>
|
||||
<td class="ds-table-col ds-table-head-col-border">
|
||||
<!-- disabledBy -->
|
||||
<div v-if="content.resource.disabledBy">
|
||||
<div v-if="content.resource.decidedByModerator">
|
||||
{{ $t('moderation.reports.disabledBy') }}
|
||||
<br />
|
||||
<hc-user :user="content.resource.disabledBy" :showAvatar="false" :trunc="30" />
|
||||
<hc-user :user="content.resource.decidedByModerator" :showAvatar="false" :trunc="30" />
|
||||
</div>
|
||||
<span v-else class="no-decision">{{ $t('moderation.reports.noDecision') }}</span>
|
||||
</td>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user