mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Clear editor, write cypress test
- the editor only clears once, also there are some other bugs associated with clearing it this way - according to https://github.com/scrumpy/tiptap/issues/21 there should be a clearContent(), but haven't been able to get it to work - cypress test for some reason is with a weird bug where I need to submit the form, then click on the submit button, otherwise it doesn't call the handleSubmit method
This commit is contained in:
parent
a360a688b9
commit
c6b11319fe
18
cypress/integration/common/post.js
Normal file
18
cypress/integration/common/post.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { When, Then } from 'cypress-cucumber-preprocessor/steps'
|
||||||
|
|
||||||
|
When('I should be able to post a comment', () => {
|
||||||
|
cy.get('.ProseMirror')
|
||||||
|
.type('This is a comment')
|
||||||
|
.get('.ds-form')
|
||||||
|
.submit()
|
||||||
|
.get('button')
|
||||||
|
.contains('Submit Comment')
|
||||||
|
.click()
|
||||||
|
.get('.iziToast-message')
|
||||||
|
.contains('Comment Submitted')
|
||||||
|
})
|
||||||
|
|
||||||
|
Then('I should see my comment', () => {
|
||||||
|
cy.get('div.comment p')
|
||||||
|
.should('contain', 'This is a comment')
|
||||||
|
})
|
||||||
@ -1,7 +1,7 @@
|
|||||||
Feature: Post Comment
|
Feature: Post Comment
|
||||||
As a user
|
As a user
|
||||||
I want to comment on contributions of others
|
I want to comment on contributions of others
|
||||||
To be able to express my thoughts and emotions about these, discuss and add give further information.
|
To be able to express my thoughts and emotions about these, discuss, and add give further information.
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given we have the following posts in our database:
|
Given we have the following posts in our database:
|
||||||
@ -11,5 +11,6 @@ Feature: Post Comment
|
|||||||
And I am logged in
|
And I am logged in
|
||||||
|
|
||||||
Scenario:
|
Scenario:
|
||||||
Given I get to the post page of "101-essays"
|
Given I visit "post/bWBjpkTKZp/101-essays"
|
||||||
Then I should be able to post a comment to the post "101-essays"
|
Then I should be able to post a comment
|
||||||
|
And I should see my comment
|
||||||
@ -97,7 +97,7 @@
|
|||||||
<!-- Comments -->
|
<!-- Comments -->
|
||||||
<ds-section slot="footer">
|
<ds-section slot="footer">
|
||||||
<ds-flex>
|
<ds-flex>
|
||||||
<ds-flex-item width="30%">
|
<ds-flex-item width="20%">
|
||||||
<h3 style="margin-top: 0;">
|
<h3 style="margin-top: 0;">
|
||||||
<span>
|
<span>
|
||||||
<ds-icon name="comments" />
|
<ds-icon name="comments" />
|
||||||
@ -111,7 +111,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
<ds-flex-item width="70%">
|
<ds-flex-item width="80%">
|
||||||
<ds-form
|
<ds-form
|
||||||
ref="commentForm"
|
ref="commentForm"
|
||||||
v-model="form"
|
v-model="form"
|
||||||
@ -122,19 +122,18 @@
|
|||||||
<ds-card>
|
<ds-card>
|
||||||
<no-ssr>
|
<no-ssr>
|
||||||
<hc-editor
|
<hc-editor
|
||||||
:post="post"
|
|
||||||
:value="form.content"
|
:value="form.content"
|
||||||
@input="updateEditorContent"
|
@input="updateEditorContent"
|
||||||
/>
|
/>
|
||||||
</no-ssr>
|
</no-ssr>
|
||||||
<ds-space />
|
<ds-space />
|
||||||
<ds-flex>
|
<ds-flex>
|
||||||
<ds-flex-item width="50%" />
|
<ds-flex-item width="50%"/>
|
||||||
<ds-flex-item width="20%">
|
<ds-flex-item width="20%">
|
||||||
<ds-button
|
<ds-button
|
||||||
:disabled="loading || disabled"
|
:disabled="loading || disabled"
|
||||||
ghost
|
ghost
|
||||||
@click="clearEditor"
|
@click.prevent="clearEditor"
|
||||||
>
|
>
|
||||||
{{ $t('actions.cancel') }}
|
{{ $t('actions.cancel') }}
|
||||||
</ds-button>
|
</ds-button>
|
||||||
@ -244,8 +243,9 @@ export default {
|
|||||||
this.$refs.commentForm.update('content', value)
|
this.$refs.commentForm.update('content', value)
|
||||||
},
|
},
|
||||||
clearEditor() {
|
clearEditor() {
|
||||||
this.$emit('clear')
|
this.loading = false
|
||||||
this.$refs.commentForm.update('content', '')
|
this.disabled = false
|
||||||
|
this.form.content = ' '
|
||||||
},
|
},
|
||||||
addComment(comment) {
|
addComment(comment) {
|
||||||
this.$apollo.queries.Post.refetch()
|
this.$apollo.queries.Post.refetch()
|
||||||
@ -253,7 +253,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
const content = this.form.content
|
const content = this.form.content
|
||||||
this.form.content = ''
|
this.form.content = ' '
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
mutation: gql`
|
mutation: gql`
|
||||||
@ -266,7 +266,7 @@ export default {
|
|||||||
`,
|
`,
|
||||||
variables: {
|
variables: {
|
||||||
postId: this.post.id,
|
postId: this.post.id,
|
||||||
content: content
|
content
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user