Show parent comment responses when a new reply is added

When a user replies to a comment whose responses was hidden at the
moment of reply form submission and although the reply were correctly
added to the DOM it was hidden because was added to a collapsed list.

This solution is about showing all responses of parent comment after adding
the new comment to the DOM so the user can see new reply into the screen.
(This is not applicable to root comments which cannot be collapsed)
This commit is contained in:
Senén Rodero Rodríguez
2020-05-15 15:10:55 +02:00
parent 014fa6eb1c
commit dcff7e8a33
9 changed files with 147 additions and 0 deletions

View File

@@ -231,6 +231,23 @@ describe "Internal valuation comments on Budget::Investments" do
end
end
scenario "Reply show parent comments responses when hidden", :js do
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
create(:comment, :valuation, author: admin_user, commentable: investment, parent: comment)
login_as(valuator_user)
visit valuation_budget_budget_investment_path(budget, investment)
within ".comment", text: comment.body do
click_link text: "1 response (collapse)"
click_link "Reply"
fill_in "Leave your comment", with: "It will be done next week."
click_button "Publish reply"
expect(page).to have_content("It will be done next week.")
end
end
scenario "Errors on reply without comment text", :js do
comment = create(:comment, :valuation, author: admin_user, commentable: investment)