mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge branch '552-update_comment' of https://github.com/Human-Connection/Human-Connection into 552-update_comment
This commit is contained in:
commit
e4fd7f4cf7
@ -17,8 +17,8 @@ const validateUpdateComment = async (resolve, root, args, context, info) => {
|
||||
if (!args.content || content.length < COMMENT_MIN_LENGTH) {
|
||||
throw new UserInputError(`Comment must be at least ${COMMENT_MIN_LENGTH} character long!`)
|
||||
}
|
||||
/* eslint-disable-next-line no-return-await */
|
||||
return await resolve(root, args, context, info)
|
||||
|
||||
return resolve(root, args, context, info)
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@ -188,22 +188,24 @@ describe('CreateComment', () => {
|
||||
})
|
||||
|
||||
describe('ManageComments', () => {
|
||||
let manageCommentsUserParams
|
||||
let authorParams
|
||||
beforeEach(async () => {
|
||||
manageCommentsUserParams = {
|
||||
authorParams = {
|
||||
email: 'author@example.org',
|
||||
password: '1234',
|
||||
}
|
||||
createCommentVariables = {
|
||||
const asAuthor = Factory()
|
||||
await asAuthor.create('User', authorParams)
|
||||
await asAuthor.authenticateAs(authorParams)
|
||||
await asAuthor.create('Post', {
|
||||
id: 'p1',
|
||||
content: 'Post to be commented',
|
||||
})
|
||||
await asAuthor.create('Comment', {
|
||||
id: 'c456',
|
||||
postId: 'p1',
|
||||
content: "I'm authorised to comment",
|
||||
}
|
||||
await factory.create('User', manageCommentsUserParams)
|
||||
headers = await login(manageCommentsUserParams)
|
||||
client = new GraphQLClient(host, { headers })
|
||||
await client.request(createPostMutation, createPostVariables)
|
||||
await client.request(createCommentMutation, createCommentVariables)
|
||||
content: 'Comment to be deleted',
|
||||
})
|
||||
})
|
||||
|
||||
describe('UpdateComment', () => {
|
||||
@ -249,6 +251,11 @@ describe('ManageComments', () => {
|
||||
})
|
||||
|
||||
describe('authenticated as author', () => {
|
||||
beforeEach(async () => {
|
||||
headers = await login(authorParams)
|
||||
client = new GraphQLClient(host, { headers })
|
||||
})
|
||||
|
||||
it('updates the comment', async () => {
|
||||
const expected = {
|
||||
UpdateComment: {
|
||||
@ -304,6 +311,11 @@ describe('ManageComments', () => {
|
||||
})
|
||||
|
||||
describe('authenticated as author', () => {
|
||||
beforeEach(async () => {
|
||||
headers = await login(authorParams)
|
||||
client = new GraphQLClient(host, { headers })
|
||||
})
|
||||
|
||||
it('deletes the comment', async () => {
|
||||
const expected = {
|
||||
DeleteComment: {
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<div v-else :class="{ comment: true, 'disabled-content': comment.deleted || comment.disabled }">
|
||||
<ds-card>
|
||||
<ds-space margin-bottom="x-small">
|
||||
<ds-space margin-bottom="small">
|
||||
<hc-user :user="author" :date-time="comment.createdAt" />
|
||||
</ds-space>
|
||||
<!-- Content Menu (can open Modals) -->
|
||||
@ -62,7 +62,7 @@ import gql from 'graphql-tag'
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import HcUser from '~/components/User'
|
||||
import ContentMenu from '~/components/ContentMenu'
|
||||
import HcEditCommentForm from '~/components/comments/EditCommentForm'
|
||||
import HcEditCommentForm from '~/components/comments/EditCommentForm/EditCommentForm'
|
||||
|
||||
export default {
|
||||
data: function() {
|
||||
|
||||
@ -2,9 +2,8 @@
|
||||
<ds-form v-model="form" @submit="handleSubmit">
|
||||
<template slot-scope="{ errors }">
|
||||
<ds-card>
|
||||
<!-- <no-ssr> -->
|
||||
<!-- with no-ssr the content is not shown -->
|
||||
<hc-editor ref="editor" :users="users" :value="form.content" @input="updateEditorContent" />
|
||||
<!-- </no-ssr> -->
|
||||
<ds-space />
|
||||
<ds-flex :gutter="{ base: 'small', md: 'small', sm: 'x-large', xs: 'x-large' }">
|
||||
<ds-flex-item :width="{ base: '0%', md: '50%', sm: '0%', xs: '0%' }" />
|
||||
@ -81,7 +80,7 @@ export default {
|
||||
id: this.comment.id,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
.then(() => {
|
||||
this.loading = false
|
||||
|
||||
this.$toast.success(this.$t('post.comment.updated'))
|
||||
@ -104,8 +103,8 @@ export default {
|
||||
}
|
||||
}`)
|
||||
},
|
||||
result(result) {
|
||||
this.users = result.data.User
|
||||
result({ data: { User } }) {
|
||||
this.users = User
|
||||
},
|
||||
},
|
||||
},
|
||||
Loading…
x
Reference in New Issue
Block a user