Simplify code to show/collapse comment replies
Tests are also a bit easier to read, even though we need to use the `text:` option to find links because otherwise the text in the hidden `<span>` tags will cause `click_link` to miss the link we want to click. Here's an explanation by one of Capybara's authors: https://github.com/teamcapybara/capybara/issues/2347#issuecomment-626373440
This commit is contained in:
@@ -62,20 +62,26 @@ describe "Commenting proposals" do
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content("1 response (collapse)", count: 2)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
within ".comment .comment", text: "First subcomment" do
|
||||
click_link text: "1 response (collapse)"
|
||||
end
|
||||
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).to have_content("1 response (collapse)")
|
||||
expect(page).to have_content("1 response (show)")
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
within ".comment .comment", text: "First subcomment" do
|
||||
click_link text: "1 response (show)"
|
||||
end
|
||||
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content("1 response (collapse)", count: 2)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
within ".comment", text: "Main comment" do
|
||||
click_link text: "1 response (collapse)", match: :first
|
||||
end
|
||||
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).to have_content("1 response (show)")
|
||||
|
||||
Reference in New Issue
Block a user