Unify collapsable comments specs

This commit is contained in:
taitus
2023-12-15 09:52:47 +01:00
parent 0c58e7e3b4
commit daab57a21e
8 changed files with 47 additions and 313 deletions

View File

@@ -6,49 +6,6 @@ describe "Commenting Budget::Investments" do
it_behaves_like "flaggable", :budget_investment_comment
scenario "Collapsable comments" do
parent_comment = create(:comment, body: "Main comment", commentable: investment)
child_comment = create(:comment,
body: "First subcomment",
commentable: investment,
parent: parent_comment)
grandchild_comment = create(:comment,
body: "Last subcomment",
commentable: investment,
parent: child_comment)
visit budget_investment_path(investment.budget, investment)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
c1 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)

View File

@@ -6,43 +6,6 @@ describe "Commenting debates" do
it_behaves_like "flaggable", :debate_comment
scenario "Collapsable comments" do
parent_comment = create(:comment, body: "Main comment", commentable: debate)
child_comment = create(:comment, body: "First subcomment", commentable: debate, parent: parent_comment)
grandchild_comment = create(:comment, body: "Last subcomment", commentable: debate, parent: child_comment)
visit debate_path(debate)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "can collapse comments after adding a reply" do
create(:comment, body: "Main comment", commentable: debate)

View File

@@ -6,49 +6,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_annotation_comment
scenario "Collapsable comments" do
parent_comment = annotation.comments.first
child_comment = create(:comment,
body: "First subcomment",
commentable: annotation,
parent: parent_comment)
grandchild_comment = create(:comment,
body: "Last subcomment",
commentable: annotation,
parent: child_comment)
visit polymorphic_path(annotation)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
within ".comment", text: parent_comment.body 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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
c1 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)

View File

@@ -10,46 +10,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_question_comment
end
scenario "Collapsable comments" do
parent_comment = create(:comment, body: "Main comment", commentable: question)
child_comment = create(:comment, body: "First subcomment", commentable: question, parent: parent_comment)
grandchild_comment = create(:comment,
body: "Last subcomment",
commentable: question,
parent: child_comment)
visit legislation_process_question_path(question.process, question)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
c1 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)

View File

@@ -4,43 +4,6 @@ describe "Commenting polls" do
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }
scenario "Collapsable comments" do
parent_comment = create(:comment, body: "Main comment", commentable: poll)
child_comment = create(:comment, body: "First subcomment", commentable: poll, parent: parent_comment)
grandchild_comment = create(:comment, body: "Last subcomment", commentable: poll, parent: child_comment)
visit poll_path(poll)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
c1 = create(:comment, :with_confidence_score, commentable: poll, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)

View File

@@ -6,46 +6,6 @@ describe "Commenting proposals" do
it_behaves_like "flaggable", :proposal_comment
scenario "Collapsable comments" do
parent_comment = create(:comment, body: "Main comment", commentable: proposal)
child_comment = create(:comment, body: "First subcomment", commentable: proposal, parent: parent_comment)
grandchild_comment = create(:comment,
body: "Last subcomment",
commentable: proposal,
parent: child_comment)
visit proposal_path(proposal)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
c1 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)

View File

@@ -6,45 +6,6 @@ describe "Commenting topics from proposals" do
it_behaves_like "flaggable", :topic_with_community_comment
scenario "Collapsable comments" do
community = proposal.community
topic = create(:topic, community: community)
parent_comment = create(:comment, body: "Main comment", commentable: topic)
child_comment = create(:comment, body: "First subcomment", commentable: topic, parent: parent_comment)
grandchild_comment = create(:comment, body: "Last subcomment", commentable: topic, parent: child_comment)
visit community_topic_path(community, topic)
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("1 response (collapse)", count: 2)
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
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
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)")
expect(page).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
community = proposal.community
topic = create(:topic, community: community)
@@ -498,40 +459,6 @@ describe "Commenting topics from budget investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }
scenario "Collapsable comments" do
community = investment.community
topic = create(:topic, community: community)
parent_comment = create(:comment, body: "Main comment", commentable: topic)
child_comment = create(:comment, body: "First subcomment", commentable: topic, parent: parent_comment)
grandchild_comment = create(:comment, body: "Last subcomment", commentable: topic, parent: child_comment)
visit community_topic_path(community, topic)
expect(page).to have_css(".comment", count: 3)
within ".comment .comment", text: "First subcomment" do
click_link text: "1 response (collapse)"
end
expect(page).to have_css(".comment", count: 2)
expect(page).not_to have_content grandchild_comment.body
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 grandchild_comment.body
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).not_to have_content child_comment.body
expect(page).not_to have_content grandchild_comment.body
end
scenario "Comment order" do
community = investment.community
topic = create(:topic, community: community)