From c387760046bb2bd4c4170dbafb9283edf0b4e1d9 Mon Sep 17 00:00:00 2001 From: Matt Rider Date: Thu, 25 Apr 2019 14:20:00 -0300 Subject: [PATCH] Extract CommentForm component - Cypress test is now passing as a result Co-authored-by: Tirokk --- cypress/integration/common/post.js | 2 - webapp/components/CommentForm/index.vue | 123 ++++++++++++++++++++++++ webapp/pages/post/_id/_slug/index.vue | 110 +-------------------- 3 files changed, 127 insertions(+), 108 deletions(-) create mode 100644 webapp/components/CommentForm/index.vue diff --git a/cypress/integration/common/post.js b/cypress/integration/common/post.js index e3a922139..23a7d5764 100644 --- a/cypress/integration/common/post.js +++ b/cypress/integration/common/post.js @@ -1,8 +1,6 @@ import { When, Then } from 'cypress-cucumber-preprocessor/steps' Then('my comment should be successfully created', () => { - cy.get('.ds-form') - .submit() cy.get('.iziToast-message') .contains('Comment Submitted') }) diff --git a/webapp/components/CommentForm/index.vue b/webapp/components/CommentForm/index.vue new file mode 100644 index 000000000..f13ce6927 --- /dev/null +++ b/webapp/components/CommentForm/index.vue @@ -0,0 +1,123 @@ + + + diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue index c99e4e5be..82de14481 100644 --- a/webapp/pages/post/_id/_slug/index.vue +++ b/webapp/pages/post/_id/_slug/index.vue @@ -111,49 +111,7 @@ - - - - - +
/gm, '').trim() - if (content.length < 3) { - this.disabled = true - } else { - this.disabled = false - } - console.log(value) - this.form.content = value - // this.$refs.commentForm.update('content', value) - // this.$refs.editor.update(value) - }, - clear() { - this.$refs.editor.clear() - }, addComment(comment) { this.$apollo.queries.CommentByPost.refetch() - }, - handleSubmit() { - console.log('content', this.form.content) - this.$apollo - .mutate({ - mutation: gql` - mutation($postId: ID, $content: String!) { - CreateComment(postId: $postId, content: $content) { - id - content - } - } - `, - variables: { - postId: this.post.id, - content: this.form.content - } - }) - .then(res => { - this.addComment(res.data.CreateComment) - this.$refs.editor.clear() - this.$toast.success(this.$t('post.comment.submitted')) - }) - .catch(err => { - this.$toast.error(err.message) - }) } }, apollo: { @@ -394,19 +305,6 @@ export default { } }, fetchPolicy: 'cache-and-network' - }, - User: { - query() { - return gql(`{ - User(orderBy: slug_asc) { - id - slug - } - }`) - }, - result(result) { - this.users = result.data.User - } } } }