Unify reply comments specs

Note that the click_link "Reply" is now inside a "within".

This is due to the case of "legislation_annotation" before in the original test
no comment was created as it simply took the one created by default when creating
a "legislation_annotation".

```
  annotation = create(:legislation_annotation, author: citizen)
  comment = annotation.comments.first
```

Now to try to unify this test, we always create a comment, and in this case as we
also created the "legislation_annotation" we have 2 comments, so it is necessary
to add the "click_link" inside the "within".
This commit is contained in:
taitus
2023-12-19 10:17:07 +01:00
parent ed5ba0592c
commit d3f4c7f99e
8 changed files with 22 additions and 181 deletions

View File

@@ -6,30 +6,6 @@ describe "Commenting topics from proposals" do
it_behaves_like "flaggable", :topic_with_community_comment
scenario "Reply" do
community = proposal.community
topic = create(:topic, community: community)
citizen = create(:user, username: "Ana")
manuela = create(:user, username: "Manuela")
comment = create(:comment, commentable: topic, user: citizen)
login_as(manuela)
visit community_topic_path(community, topic)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
within "#comment_#{comment.id}" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
end
scenario "Reply update parent comment responses count" do
community = proposal.community
topic = create(:topic, community: community)
@@ -334,30 +310,6 @@ describe "Commenting topics from budget investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }
scenario "Reply" do
community = investment.community
topic = create(:topic, community: community)
citizen = create(:user, username: "Ana")
manuela = create(:user, username: "Manuela")
comment = create(:comment, commentable: topic, user: citizen)
login_as(manuela)
visit community_topic_path(community, topic)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
end
within "#comment_#{comment.id}" do
expect(page).to have_content "It will be done next week."
end
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
end
scenario "Errors on reply" do
community = investment.community
topic = create(:topic, community: community)