mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 21:45:25 -05:00
FEATURE: Add new don't feed the trolls feature (#21001)
Responding to negative behaviour tends to solicit more of the same. Common wisdom states: "don't feed the trolls". This change codifies that advice by introducing a new nudge when hitting the reply button on a flagged post. It will be shown if either the current user, or two other users (configurable via a site setting) have flagged the post.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe "Composer don't feed the trolls popup", type: :system, js: true do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:troll) { Fabricate(:user) }
|
||||
fab!(:topic) { Fabricate(:topic, user: user) }
|
||||
fab!(:post) { Fabricate(:post, user: user, topic: topic) }
|
||||
fab!(:reply) { Fabricate(:post, user: troll, topic: topic) }
|
||||
fab!(:flag) { Fabricate(:flag, post: reply, user: user) }
|
||||
let(:topic_page) { PageObjects::Pages::Topic.new }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it "shows a popup when about to reply to a troll" do
|
||||
SiteSetting.educate_until_posts = 0
|
||||
|
||||
topic_page.visit_topic(topic)
|
||||
topic_page.click_post_action_button(reply, :reply)
|
||||
|
||||
expect(topic_page).to have_composer_popup_content(I18n.t("education.dont_feed_the_trolls"))
|
||||
end
|
||||
end
|
||||
@@ -43,6 +43,10 @@ module PageObjects
|
||||
composer_input.value == content
|
||||
end
|
||||
|
||||
def has_popup_content?(content)
|
||||
composer_popup.has_content?(content)
|
||||
end
|
||||
|
||||
def select_action(action)
|
||||
find(action(action)).click
|
||||
self
|
||||
@@ -83,6 +87,10 @@ module PageObjects
|
||||
def composer_input
|
||||
find("#{COMPOSER_ID} .d-editor .d-editor-input")
|
||||
end
|
||||
|
||||
def composer_popup
|
||||
find("#{COMPOSER_ID} .composer-popup")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -71,6 +71,8 @@ module PageObjects
|
||||
case button
|
||||
when :bookmark
|
||||
post_by_number(post).find(".bookmark.with-reminder").click
|
||||
when :reply
|
||||
post_by_number(post).find(".post-controls .reply").click
|
||||
end
|
||||
end
|
||||
|
||||
@@ -111,6 +113,10 @@ module PageObjects
|
||||
@composer_component.has_content?(content)
|
||||
end
|
||||
|
||||
def has_composer_popup_content?(content)
|
||||
@composer_component.has_popup_content?(content)
|
||||
end
|
||||
|
||||
def send_reply
|
||||
find("#reply-control .save-or-cancel .create").click
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user