Skip to content

Commit

Permalink
Behat test coverage of posts and comments deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
BiaInacio committed Sep 27, 2024
1 parent 721510d commit 20e5d2f
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 10 deletions.
67 changes: 61 additions & 6 deletions tests/behat/features/capabilities/comment/comment-delete.feature
Original file line number Diff line number Diff line change
@@ -1,19 +1,74 @@
@api @comment @stability @DS-478 @stability-3 @comment-delete
@api
Feature: Delete Comment
Benefit: In order to manage my content
Role: As a Verified
Goal/desire: I want to delete my comments on the platform

Scenario: Successfully delete comment
Scenario: Successfully delete comment on a topic
Given I am logged in as an "verified"
And I am viewing a "topic" with the title "Comment delete topic"

When I fill in the following:
| Add a comment | This is my comment |
And I press "Comment"
Then I should see "This is my comment" in the "Main content"
When I click the element with css selector ".comment .comment__actions .dropdown-toggle"
And I should see "This is my comment" in the "Main content"
And I click the element with css selector ".comment .comment__actions .dropdown-toggle"
And I should see the link "Delete"
When I click "Delete"
And I click "Delete"
And I should see "Any replies to this comment will be lost."
And I click "Delete"
And I should not see "This is my comment"

Then I should not see "This is my comment"

Scenario: Successfully delete comment on a homepage
Given I am logged in as an "verified"
And I am viewing a "topic" with the title "Comment delete topic"

When I fill in the following:
| Add a comment | This is my comment |
And I press "Comment"
And I should see "This is my comment" in the "Main content"
And I click the element with css selector ".comment .comment__actions .dropdown-toggle"
And I should see the link "Delete"
And I click "Delete"
And I should see "Any replies to this comment will be lost."
And I click "Delete"

Then I should not see "This is my comment"

Scenario: Successfully delete comment on a group
Given users:
| name | mail | status | roles |
| Group User One | group_user_1@example.com | 1 | verified |
And groups with non-anonymous owner:
| label | field_group_description | type | langcode | field_flexible_group_visibility | field_group_allowed_join_method |
| Test group | Public visibility | flexible_group | en | public | direct |
And group members:
| group | user |
| Test group | Group User One |
And I am logged in as "Group User One"

When I am viewing the group "Test group"
And I click "Stream"
And I fill in "Say something to the group" with "This is a post in a group."
And I press "Post"
And I should see "This is a post in a group."
And I should see "Group User One" in the ".media-heading" element
And I fill in "Write a comment..." with "This is a comment in post in a group."
And I press "Comment"
And I should see "Your comment has been posted."
And I should see "This is a comment in post in a group."
And I am on the homepage
And I should see "This is a comment in post in a group."

# Delete post
Then I am viewing the group "Test group"
And I click the element with css selector ".comment .comment__actions .dropdown-toggle"
And I click the element with css selector ".comment-delete"
And I should see "Any replies to this comment will be lost. This action cannot be undone."
And I press "Delete"
And I wait for AJAX to finish
And I should see "The comment and all its replies have been deleted."
And I should not see "This is a comment in post in a group."
And I am on the homepage
And I should not see "This is a comment in post in a group."
54 changes: 54 additions & 0 deletions tests/behat/features/capabilities/event/event-delete.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@api
Feature: Delete Event
Benefit: In order to delete content created
Role: As a Verified
Goal/desire: I want to delete Events

@verified @perfect @critical
Scenario: Successfully create event within a group
Given I enable the module "automated_cron"
And users:
| name | status | roles |
| Event enrollee 1 | 1 | verified |
| Event enrollee 2 | 1 | verified |
| Event manager | 1 | verified |
And groups with non-anonymous owner:
| label | field_group_description | type | langcode | field_flexible_group_visibility | field_group_allowed_join_method |
| Test group | Public visibility | flexible_group | en | public | direct |
And group members:
| group | user |
| Test group | Event enrollee 1 |
| Test group | Event enrollee 2 |
| Test group | Event manager |
And event content:
| title | body | field_event_date | field_event_date_end | groups | field_content_visibility | author |
| Public event in group | Body description text. | +2 days | +3 days | 6 | public | Event manager |
And event enrollees:
| event | user |
| Public event in group | Event enrollee 1 |
| Public event in group | Event enrollee 2 |
| Public event in group | Event manager |
And I run cron
And I wait for the queue to be empty
And I am logged in as "Event manager"
And I should see "Event manager created an event in Test group"
And I should see "Public event in group"
And I am viewing the group "Test group"
And I click "Stream"
And I should see "Event manager created an event in Test group"
And I should see "Public event in group"

#delete event
When I click "Public event in group"
And I click "Edit content"
And I click "Delete"
And I should see "Are you sure you want to delete the content item Public event in group?"
And I should see "This action cannot be undone."
And I press "Delete"
And I wait for AJAX to finish

Then I should see "The Event Public event in group has been deleted."
And I should not see "Event manager created an event in Test group"
And I am viewing the group "Test group"
And I click "Stream"
And I should not see "Event manager created an event in Test group"
39 changes: 39 additions & 0 deletions tests/behat/features/capabilities/post/post-delete.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@api
Feature: Delete Post
Benefit: In order to be able to delete content created
Role: As a Verified
Goal/desire: I want to delete Posts

Scenario: Successfully delete post
Given users:
| name | status | pass | roles |
| PostCreateUser1 | 1 | PostCreateUser1 | verified |
| PostCreateUser2 | 1 | PostCreateUser2 | verified |
And I am logged in as "PostCreateUser1"
And I am on the homepage

When I fill in "Say something to the Community" with "This is a post made on the homepage."
And I select post visibility "Public"
And I press "Post"
And I should see the success message "Your post has been posted."
And I should see "This is a post made on the homepage."
And I should see "PostCreateUser1" in the "Main content front"
And I am on "/user"
And I should see "This is a post made on the homepage."

# Delete post
Then I click the element with css selector ".btn.btn-icon-toggle.dropdown-toggle.waves-effect.waves-circle"
And I click "Delete"
And I should see "Are you sure you want to delete the post"
And I should see "This action cannot be undone."
And I press "Delete"
And I wait for AJAX to finish
And I should see "has been deleted."
And I should not see "This is a post made on the homepage."
And I am on the homepage
And I should not see "This is a post made on the homepage."
And I am logged in as "PostCreateUser2"
And I am on the homepage
And I should not see "This is a post made on the homepage."


43 changes: 39 additions & 4 deletions tests/behat/features/capabilities/post/post-group.feature
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
@api
Feature: Create Post on Group
Feature: Create and Delete a Post on Group
Benefit: In order to share knowledge with people in group
Role: As a Verified
Goal/desire: I want to create Posts
Goal/desire: I want to create Posts in a group

Scenario: Successfully create, edit and delete post in group
Scenario: Successfully create and edit post in group
Given users:
| name | mail | status | roles |
| Group User One | group_user_1@example.com | 1 | verified |
| Group User Two | group_user_2@example.com | 1 | verified |
And I am logged in as "Group User One"
And I am on "group/add/flexible_group"

Expand Down Expand Up @@ -43,3 +42,39 @@ Feature: Create Post on Group
# Scenario: See post on profile stream
And I am on "/user"
And I should see "This is a community post in a group."

Scenario: Successfully delete post in group
Given users:
| name | mail | status | roles |
| Group User One | group_user_1@example.com | 1 | verified |
And groups with non-anonymous owner:
| label | field_group_description | type | langcode | field_flexible_group_visibility | field_group_allowed_join_method |
| Test group | Public visibility | flexible_group | en | public | direct |
And group members:
| group | user |
| Test group | Group User One |
And I am logged in as "Group User One"

When I am viewing the group "Test group"
And I click "Stream"
And I fill in "Say something to the group" with "This is a post in a group."
And I press "Post"
And I should see "This is a post in a group."
And I should see "Group User One" in the ".media-heading" element
And I am on the homepage
And I should see "This is a post in a group."
And I should see "Group User One" in the ".media-heading" element

# Delete post
Then I am viewing the group "Test group"
And I click the element with css selector ".btn.btn-icon-toggle.dropdown-toggle.waves-effect.waves-circle"
And I click "Delete"
And I should see "Are you sure you want to delete the post"
And I should see "This action cannot be undone."
And I press "Delete"
And I wait for AJAX to finish
And I should see "has been deleted."
And I should not see "This is a post in a group."
And I am on the homepage
And I should not see "This is a post in a group."

0 comments on commit 20e5d2f

Please sign in to comment.