From 23b7f409c73ec2ec61825ad1293aca977c6dc2ad Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Thu, 10 Nov 2022 17:18:29 +0100
Subject: [PATCH 01/20] Hide comment actions same as with JS
https://otwarchive.atlassian.net/browse/AO3-6392
Reproduce the behavior of add_comment_reply.js
---
app/views/comments/_comment_actions.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/comments/_comment_actions.html.erb b/app/views/comments/_comment_actions.html.erb
index 3a69b9f7f09..ad4b9a39b12 100644
--- a/app/views/comments/_comment_actions.html.erb
+++ b/app/views/comments/_comment_actions.html.erb
@@ -1,6 +1,6 @@
<%= ts("Comment Actions") %>
-
From eed929877a674b46680e79d5832d9ab6ae3c9a68 Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Thu, 10 Nov 2022 18:38:15 +0100
Subject: [PATCH 03/20] Hound
---
app/helpers/comments_helper.rb | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb
index 37b3a22cb91..25bcceeb6f3 100644
--- a/app/helpers/comments_helper.rb
+++ b/app/helpers/comments_helper.rb
@@ -215,14 +215,17 @@ def cancel_comment_reply_link(comment, remote = true)
comment.parent.id
link_to(
ts("Cancel"),
- url_for(controller: :comments,
- action: :cancel_comment_reply,
- id: comment.id,
- comment_id: params[:comment_id],
- commentable_id => commentable_value,
- view_full_work: params[:view_full_work],
- page: params[:page]),
- remote: remote)
+ url_for(
+ controller: :comments,
+ action: :cancel_comment_reply,
+ id: comment.id,
+ comment_id: params[:comment_id],
+ commentable_id => commentable_value,
+ view_full_work: params[:view_full_work],
+ page: params[:page]
+ ),
+ remote: remote
+ )
end
# canceling an edit
From 0da28cb61d21d020bb18f406abd393b78c4a1bd7 Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Sat, 15 Jul 2023 20:07:34 +0200
Subject: [PATCH 04/20] Hound
---
app/helpers/comments_helper.rb | 2 +-
app/views/comments/_comment_form.html.erb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb
index 3c71a453b0b..8d63e3d7b72 100644
--- a/app/helpers/comments_helper.rb
+++ b/app/helpers/comments_helper.rb
@@ -209,7 +209,7 @@ def add_comment_reply_link(comment)
end
# return link to cancel new reply to a comment
- def cancel_comment_reply_link(comment, remote = true)
+ def cancel_comment_reply_link(comment, remote: true)
commentable_id = comment.ultimate_parent.is_a?(Tag) ?
:tag_id :
comment.parent.class.name.foreign_key.to_sym
diff --git a/app/views/comments/_comment_form.html.erb b/app/views/comments/_comment_form.html.erb
index 361ef35a383..cdbba00d553 100644
--- a/app/views/comments/_comment_form.html.erb
+++ b/app/views/comments/_comment_form.html.erb
@@ -107,7 +107,7 @@
<% elsif comment.persisted? %>
<%= cancel_edit_comment_link(comment) %>
<% elsif commentable.is_a?(Comment) || commentable.is_a?(CommentDecorator) %>
- <%= cancel_comment_reply_link(commentable, remote = !(params[:add_comment_reply_id] && params[:add_comment_reply_id] == commentable.id.to_s)) %>
+ <%= cancel_comment_reply_link(commentable, remote: !(params[:add_comment_reply_id] && params[:add_comment_reply_id] == commentable.id.to_s)) %>
<% end %>
From 5a3ea87c3087a95aa8210034ec4809ca6ccdac27 Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Sun, 16 Jul 2023 16:16:38 +0200
Subject: [PATCH 05/20] Add test for hiding feature
---
features/comments_and_kudos/add_comment.feature | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/features/comments_and_kudos/add_comment.feature b/features/comments_and_kudos/add_comment.feature
index 7d6bd91def6..37ba043ec5d 100644
--- a/features/comments_and_kudos/add_comment.feature
+++ b/features/comments_and_kudos/add_comment.feature
@@ -207,3 +207,12 @@ Scenario: Try to post a comment with a < angle bracket before a linebreak, with
"""
And I press "Comment"
Then I should see "Comment created!"
+
+Scenario: It hides comment actions when a reply form is open
+ When I am logged in as "author"
+ And I post the work "The One Where Neal is Awesome"
+ When I am logged in as "commenter"
+ And I post the comment "I loved this!" on the work "The One Where Neal is Awesome"
+ When I follow "Reply"
+ Then I should see "Comment as commenter"
+ Then I should not see "Thread"
From 349662d7b1e59931accd13037c9fd34a32a1f0d7 Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Sun, 16 Jul 2023 17:01:02 +0200
Subject: [PATCH 06/20] Work page test
---
features/comments_and_kudos/add_comment.feature | 16 ++++++++++++++++
features/step_definitions/comment_steps.rb | 12 ++++++++++++
2 files changed, 28 insertions(+)
diff --git a/features/comments_and_kudos/add_comment.feature b/features/comments_and_kudos/add_comment.feature
index 37ba043ec5d..2ecf7172ca0 100644
--- a/features/comments_and_kudos/add_comment.feature
+++ b/features/comments_and_kudos/add_comment.feature
@@ -216,3 +216,19 @@ Scenario: It hides comment actions when a reply form is open
When I follow "Reply"
Then I should see "Comment as commenter"
Then I should not see "Thread"
+
+@javascript
+Scenario: It shows and hides cancel buttons properly
+ Given the work "Aftermath" by "creator"
+ And a comment "Ugh." by "pest" on the work "Aftermath"
+ When I am logged in as "creator"
+ And I view the work "Aftermath"
+ And I display comments
+ Then I should see "Ugh."
+ When I open the reply box
+ Then I should see "Cancel"
+ Then I should not see "Reply"
+ When I cancel the reply box
+ Then I should not see "Cancel"
+ Then I should see "Reply"
+
diff --git a/features/step_definitions/comment_steps.rb b/features/step_definitions/comment_steps.rb
index c434b7ea7c3..79dbe2214ae 100644
--- a/features/step_definitions/comment_steps.rb
+++ b/features/step_definitions/comment_steps.rb
@@ -302,3 +302,15 @@
click_link("Yes, delete!") # TODO: Fix along with comment deletion.
end
end
+
+When "I display comments" do
+ click_link("Comments")
+end
+
+When "I open the reply box" do
+ click_link("Reply")
+end
+
+When "I cancel the reply box" do
+ click_link("Cancel")
+end
\ No newline at end of file
From 053653e326d4a4a9294622767f445d2457b82709 Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Sun, 16 Jul 2023 20:01:36 +0200
Subject: [PATCH 07/20] Add test for the cancel button not being updated
---
features/comments_and_kudos/add_comment.feature | 17 +++++++++++++++++
features/step_definitions/comment_steps.rb | 11 ++++++++++-
features/step_definitions/web_steps.rb | 6 ++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/features/comments_and_kudos/add_comment.feature b/features/comments_and_kudos/add_comment.feature
index 2ecf7172ca0..676db113ed6 100644
--- a/features/comments_and_kudos/add_comment.feature
+++ b/features/comments_and_kudos/add_comment.feature
@@ -232,3 +232,20 @@ Scenario: It shows and hides cancel buttons properly
Then I should not see "Cancel"
Then I should see "Reply"
+@javascript
+Scenario: It shows and hides cancel buttons properly even on a new page
+ Given the work "Aftermath" by "creator"
+ And a comment "Ugh." by "pest" on the work "Aftermath"
+ When I am logged in as "creator"
+ And I view the work "Aftermath"
+ And I display comments
+ Then I should see "Ugh."
+ When I reply to the work comment "Ugh." on a new page
+ Then I should see "Aftermath"
+ Then I should see "Cancel"
+ Then I should not see "Reply"
+ When I cancel the reply box
+ And I fix the domain name
+ Then I should see "Aftermath"
+ Then I should not see "Cancel"
+
diff --git a/features/step_definitions/comment_steps.rb b/features/step_definitions/comment_steps.rb
index 79dbe2214ae..c235ec084fe 100644
--- a/features/step_definitions/comment_steps.rb
+++ b/features/step_definitions/comment_steps.rb
@@ -313,4 +313,13 @@
When "I cancel the reply box" do
click_link("Cancel")
-end
\ No newline at end of file
+end
+
+When /^I reply to the work comment "([^"]*)" on a new page$/ do |comment_content|
+ comment = Comment.find_by_comment_content(comment_content)
+ visit work_path(
+ comment.commentable,
+ add_comment_reply_id: comment.id,
+ show_comments: true,
+ )
+end
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
index 5ce950c9525..9b105164724 100644
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -319,3 +319,9 @@ def with_scope(locator)
cookie_value = Capybara.current_session.driver.request.cookies.[](cookie)
assert cookie_value.nil?
end
+
+When "I fix the domain name" do
+ parsed = URI.parse(current_url)
+ dest = parsed.path + '?' + (parsed.query || '') + '#' + (parsed.fragment || '')
+ visit dest
+end
From 9d2fb962b5e4115fe79c4d8ec0b62e50c1f3811b Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Sun, 16 Jul 2023 20:07:55 +0200
Subject: [PATCH 08/20] Hound
---
features/step_definitions/comment_steps.rb | 4 ++--
features/step_definitions/web_steps.rb | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/features/step_definitions/comment_steps.rb b/features/step_definitions/comment_steps.rb
index c235ec084fe..a3d20c24d81 100644
--- a/features/step_definitions/comment_steps.rb
+++ b/features/step_definitions/comment_steps.rb
@@ -316,10 +316,10 @@
end
When /^I reply to the work comment "([^"]*)" on a new page$/ do |comment_content|
- comment = Comment.find_by_comment_content(comment_content)
+ comment = Comment.find_by(comment_content: comment_content)
visit work_path(
comment.commentable,
add_comment_reply_id: comment.id,
- show_comments: true,
+ show_comments: true
)
end
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
index 9b105164724..23128b8a0b5 100644
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -322,6 +322,6 @@ def with_scope(locator)
When "I fix the domain name" do
parsed = URI.parse(current_url)
- dest = parsed.path + '?' + (parsed.query || '') + '#' + (parsed.fragment || '')
+ dest = "#{parsed.path}?#{(parsed.query || "")}##{(parsed.fragment || "")}"
visit dest
end
From 092ca2970b98666d69d91c01a7402793fade5596 Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Sun, 16 Jul 2023 20:08:45 +0200
Subject: [PATCH 09/20] Hound (bis)
---
features/step_definitions/web_steps.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
index 23128b8a0b5..db10b96956d 100644
--- a/features/step_definitions/web_steps.rb
+++ b/features/step_definitions/web_steps.rb
@@ -322,6 +322,6 @@ def with_scope(locator)
When "I fix the domain name" do
parsed = URI.parse(current_url)
- dest = "#{parsed.path}?#{(parsed.query || "")}##{(parsed.fragment || "")}"
+ dest = "#{parsed.path}?#{parsed.query || ''}##{parsed.fragment || ''}"
visit dest
end
From 04647990d434acb9b6c8f239029caa1e6f11340e Mon Sep 17 00:00:00 2001
From: Ceithir
Date: Tue, 22 Aug 2023 10:00:23 +0200
Subject: [PATCH 10/20] Reviewdog
---
app/views/comments/_comment_actions.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/comments/_comment_actions.html.erb b/app/views/comments/_comment_actions.html.erb
index ad4b9a39b12..953b9ddcc14 100644
--- a/app/views/comments/_comment_actions.html.erb
+++ b/app/views/comments/_comment_actions.html.erb
@@ -1,6 +1,6 @@
<%= ts("Comment Actions") %>
-