2023-04-13 03:38:54 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-06 21:26:58 -04:00
|
|
|
describe "Emoji deny list", type: :system do
|
2023-04-13 03:38:54 -04:00
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
|
|
|
let(:emoji_picker) { PageObjects::Components::EmojiPicker.new }
|
|
|
|
fab!(:admin) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
before { sign_in(admin) }
|
|
|
|
|
|
|
|
describe "when editing admin settings" do
|
|
|
|
before { SiteSetting.emoji_deny_list = "" }
|
|
|
|
let(:site_settings_page) { PageObjects::Pages::AdminSettings.new }
|
|
|
|
|
|
|
|
it "should allow admin to update emoji deny list" do
|
|
|
|
site_settings_page.visit_category("posting")
|
|
|
|
|
|
|
|
site_settings_page.select_from_emoji_list("emoji_deny_list", "fu", false)
|
|
|
|
site_settings_page.select_from_emoji_list("emoji_deny_list", "poop")
|
|
|
|
|
|
|
|
expect(site_settings_page.values_in_list("emoji_deny_list")).to eq(%w[fu poop])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when visiting topics" do
|
|
|
|
SiteSetting.emoji_deny_list = "monkey"
|
|
|
|
Emoji.clear_cache
|
|
|
|
|
|
|
|
fab!(:topic) { Fabricate(:topic, title: "Time for :monkey: business") }
|
|
|
|
fab!(:post) { Fabricate(:post, topic: topic, raw: "We have no time to :monkey: around!") }
|
|
|
|
|
|
|
|
it "should remove denied emojis from page title, heading and body" do
|
|
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(page.title).to eq("Time for business - Discourse")
|
|
|
|
expect(topic_page).to have_topic_title("Time for business")
|
|
|
|
expect(page).not_to have_css(".emoji[title=':monkey:']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when using composer" do
|
|
|
|
before do
|
2023-04-26 07:02:19 -04:00
|
|
|
SiteSetting.enable_emoji = true
|
2023-04-13 03:38:54 -04:00
|
|
|
SiteSetting.emoji_deny_list = "fu|poop"
|
|
|
|
Emoji.clear_cache && Discourse.request_refresh!
|
|
|
|
end
|
|
|
|
|
|
|
|
fab!(:topic) { Fabricate(:topic) }
|
|
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
|
|
|
|
2023-04-26 13:41:34 -04:00
|
|
|
xit "should remove denied emojis from emoji picker" do
|
2023-04-13 03:38:54 -04:00
|
|
|
topic_page.visit_topic_and_open_composer(topic)
|
|
|
|
expect(composer).to be_opened
|
|
|
|
|
2023-04-20 20:55:05 -04:00
|
|
|
composer.click_toolbar_button("insert-emoji")
|
2023-04-13 03:38:54 -04:00
|
|
|
expect(composer.emoji_picker).to be_visible
|
|
|
|
|
2023-05-04 19:45:53 -04:00
|
|
|
expect(emoji_picker).to have_no_emoji("fu")
|
2023-04-13 03:38:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not show denied emojis and aliases in emoji autocomplete" do
|
|
|
|
topic_page.visit_topic_and_open_composer(topic)
|
|
|
|
|
|
|
|
composer.type_content(":poop") # shows no results
|
2023-05-04 19:45:53 -04:00
|
|
|
expect(composer).to have_no_emoji_autocomplete
|
2023-04-13 03:38:54 -04:00
|
|
|
|
|
|
|
composer.clear_content
|
|
|
|
|
|
|
|
composer.type_content(":middle") # middle_finger is alias
|
2023-05-04 19:45:53 -04:00
|
|
|
expect(composer).to have_no_emoji_suggestion("fu")
|
2023-04-13 03:38:54 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not show denied emoji in preview" do
|
|
|
|
topic_page.visit_topic_and_open_composer(topic)
|
|
|
|
|
|
|
|
composer.fill_content(":wave:")
|
|
|
|
expect(composer).to have_emoji_preview("wave")
|
|
|
|
|
|
|
|
composer.clear_content
|
|
|
|
|
|
|
|
composer.fill_content(":fu:")
|
2023-05-04 19:45:53 -04:00
|
|
|
expect(composer).to have_no_emoji_preview("fu")
|
2023-04-13 03:38:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "when using private messages" do
|
|
|
|
before do
|
|
|
|
SiteSetting.emoji_deny_list = "pancakes|monkey"
|
|
|
|
Emoji.clear_cache && Discourse.request_refresh!
|
|
|
|
end
|
|
|
|
|
|
|
|
fab!(:topic) do
|
|
|
|
Fabricate(:private_message_topic, title: "Want to catch up for :pancakes: today?")
|
|
|
|
end
|
|
|
|
fab!(:post) { Fabricate(:post, topic: topic, raw: "Can we use the :monkey: emoji here?") }
|
|
|
|
|
|
|
|
it "should remove denied emojis from message title and body" do
|
|
|
|
topic_page.visit_topic(topic)
|
|
|
|
expect(topic_page).to have_topic_title("Want to catch up for today?")
|
|
|
|
expect(post).not_to have_css(".emoji[title=':monkey:']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|