Simplify tests replying to a comment

We were using the `reply_to` method in some places, but not in others.
This commit is contained in:
Javi Martín
2025-03-27 17:06:17 +01:00
parent 1c2ec3f37e
commit f15991dd3e
3 changed files with 12 additions and 42 deletions

View File

@@ -51,18 +51,7 @@ shared_examples "notifiable in-app" do |factory_name|
scenario "A user replied to my comment" do
comment = create(:comment, commentable: notifiable, user: author)
login_as(create(:user, :verified))
visit path_for(notifiable)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in comment_body(notifiable), with: "I replied to your comment"
click_button "Publish reply"
end
within "#comment_#{comment.id}" do
expect(page).to have_content "I replied to your comment"
end
reply_to(comment, with: "I replied to your comment", replier: create(:user, :verified))
logout
login_as author
@@ -120,18 +109,7 @@ shared_examples "notifiable in-app" do |factory_name|
scenario "Author replied to his own comment" do
comment = create(:comment, commentable: notifiable, user: author)
login_as author
visit path_for(notifiable)
click_link "Reply"
within "#js-comment-form-comment_#{comment.id}" do
fill_in comment_body(notifiable), with: "I replied to my own comment"
click_button "Publish reply"
end
within "#comment_#{comment.id}" do
expect(page).to have_content "I replied to my own comment"
end
reply_to(comment, with: "I replied to my own comment", replier: author)
within("#notifications") do
click_link "You don't have new notifications"

View File

@@ -4,11 +4,17 @@ module Comments
visit polymorphic_path(comment.commentable)
click_link "Reply"
within "#comment_#{comment.id}" do
click_link "Reply"
end
within "#js-comment-form-comment_#{comment.id}" do
fill_in "Leave your comment", with: with
fill_in comment_body(comment.commentable), with: with
click_button "Publish reply"
end
expect(page).to have_content with
within "#comment_#{comment.id}" do
expect(page).to have_content with
end
end
end

View File

@@ -383,21 +383,7 @@ describe "Comments" do
scenario "Reply" do
comment = create(:comment, commentable: resource)
login_as(user)
visit polymorphic_path(resource)
within "#comment_#{comment.id}" do
click_link "Reply"
end
within "#js-comment-form-comment_#{comment.id}" do
fill_in fill_text, 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
reply_to(comment, with: "It will be done next week.", replier: user)
expect(page).not_to have_css "#js-comment-form-comment_#{comment.id}"
end