From c472b7ac8da991ac33e69462a5c5ff5cf313b988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20B?= Date: Sun, 13 Aug 2023 05:40:00 +0200 Subject: [PATCH] AO3-6561 Repair confirm dialog on comment "Spam" button (#4578) * Repair confirm dialog on "Spam" button https://otwarchive.atlassian.net/browse/AO3-6561 * Add test that isn't testing anything * Hound * Hound (bis) * Actually test popup * Hound * Hound (always two or more) * Update features/comments_and_kudos/spam_comments.feature Co-authored-by: sarken * Update features/comments_and_kudos/spam_comments.feature Co-authored-by: sarken * Update features/step_definitions/comment_steps.rb Co-authored-by: sarken * Explicit popup confirm in test Otherwise What is being tested is indeed quite mysterious --------- Co-authored-by: sarken --- app/helpers/comments_helper.rb | 2 +- .../comments_and_kudos/spam_comments.feature | 28 +++++++++++++++++++ features/step_definitions/comment_steps.rb | 8 ++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 377e50c6e3d..9a4266dc4b6 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -302,7 +302,7 @@ def cancel_delete_comment_link(comment) # return html link to mark/unmark comment as spam def tag_comment_as_spam_link(comment) if comment.approved - link_to(ts("Spam"), reject_comment_path(comment), method: :put, confirm: "Are you sure you want to mark this as spam?" ) + link_to(ts("Spam"), reject_comment_path(comment), method: :put, data: { confirm: "Are you sure you want to mark this as spam?" }) else link_to(ts("Not Spam"), approve_comment_path(comment), method: :put) end diff --git a/features/comments_and_kudos/spam_comments.feature b/features/comments_and_kudos/spam_comments.feature index 7a959d3b12a..ef87225955a 100644 --- a/features/comments_and_kudos/spam_comments.feature +++ b/features/comments_and_kudos/spam_comments.feature @@ -46,3 +46,31 @@ Feature: Marking comments as spam When I follow "Default Admin Post" Then I should see "Comments (1)" + + Scenario: Author can mark comments as spam + Given I am logged in as "author" + And I post the work "Popular Fic" + And I log out + When I view the work "Popular Fic" with comments + And I post a spam comment + And I post a guest comment + And I am logged in as "author" + And I view the work "Popular Fic" with comments + Then I should see "Comments (2)" + And I should see "Buy my product" + When I mark the comment as spam + Then I should see "Comments (1)" + And I should not see "Buy my product" + + @javascript + Scenario: If Javascript is enabled, there's a confirmation popup before marking a comment as spam + Given the work "Popular Fic" by "author" + And a guest comment on the work "Popular Fic" + And a guest comment on the work "Popular Fic" + When I am logged in as "author" + And I view the work "Popular Fic" with comments + Then I should see "Comments (2)" + When I mark the comment as spam + And I confirm I want to mark the comment as spam + And I view the work "Popular Fic" with comments + Then I should see "Comments (1)" diff --git a/features/step_definitions/comment_steps.rb b/features/step_definitions/comment_steps.rb index c434b7ea7c3..9167278d888 100644 --- a/features/step_definitions/comment_steps.rb +++ b/features/step_definitions/comment_steps.rb @@ -302,3 +302,11 @@ click_link("Yes, delete!") # TODO: Fix along with comment deletion. end end + +When "I mark the comment as spam" do + click_link("Spam") +end + +When "I confirm I want to mark the comment as spam" do + expect(page.accept_alert).to eq("Are you sure you want to mark this as spam?") if @javascript +end