2024-05-29 00:39:58 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Admin Flags Page", type: :system do
|
|
|
|
fab!(:admin)
|
2024-08-04 21:01:25 -04:00
|
|
|
fab!(:post)
|
2024-05-29 00:39:58 -04:00
|
|
|
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
let(:admin_flags_page) { PageObjects::Pages::AdminFlags.new }
|
2024-07-02 18:45:37 -04:00
|
|
|
let(:admin_flag_form_page) { PageObjects::Pages::AdminFlagForm.new }
|
2024-08-04 21:01:25 -04:00
|
|
|
let(:flag_modal) { PageObjects::Modals::Flag.new }
|
2024-12-17 17:13:39 -05:00
|
|
|
let(:d_page_header) { PageObjects::Components::DPageHeader.new }
|
2024-05-29 00:39:58 -04:00
|
|
|
|
2024-08-05 20:50:12 -04:00
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
SiteSetting.custom_flags_limit = 1
|
|
|
|
end
|
2024-05-29 00:39:58 -04:00
|
|
|
|
2024-10-07 17:38:42 -04:00
|
|
|
it "allows admin to disable, change order, create, update and delete flags" do
|
2024-07-14 19:36:54 -04:00
|
|
|
# disable
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
|
|
|
|
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
2024-05-29 00:39:58 -04:00
|
|
|
)
|
|
|
|
|
2024-11-18 22:46:08 -05:00
|
|
|
admin_flags_page.visit
|
2024-12-17 17:13:39 -05:00
|
|
|
expect(d_page_header).to be_visible
|
2024-11-18 22:46:08 -05:00
|
|
|
|
|
|
|
admin_flags_page.toggle("spam")
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
2024-05-29 00:39:58 -04:00
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
expect(flag_modal).to have_choices("It's Inappropriate", "It's Illegal", "Something Else")
|
2024-06-05 19:40:14 -04:00
|
|
|
|
|
|
|
Flag.system.where(name: "spam").update!(enabled: true)
|
2024-06-04 23:27:06 -04:00
|
|
|
|
2024-07-14 19:36:54 -04:00
|
|
|
# change order
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
|
|
|
|
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
2024-06-04 23:27:06 -04:00
|
|
|
)
|
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit.move_down("spam")
|
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
2024-06-04 23:27:06 -04:00
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Illegal",
|
|
|
|
"It's Spam",
|
|
|
|
"Something Else",
|
2024-06-04 23:27:06 -04:00
|
|
|
)
|
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit.move_up("spam")
|
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
2024-06-04 23:27:06 -04:00
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
2024-06-04 23:27:06 -04:00
|
|
|
)
|
|
|
|
|
2024-07-14 19:36:54 -04:00
|
|
|
# create
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
2024-07-02 18:45:37 -04:00
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
|
|
|
)
|
2024-07-02 18:45:37 -04:00
|
|
|
|
2024-08-05 20:50:12 -04:00
|
|
|
admin_flags_page.visit
|
|
|
|
|
|
|
|
expect(admin_flags_page).to have_add_flag_button_enabled
|
|
|
|
|
|
|
|
admin_flags_page.click_add_flag
|
2024-12-17 17:13:39 -05:00
|
|
|
expect(d_page_header).to be_hidden
|
2024-12-09 19:59:47 -05:00
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flag_form_page
|
|
|
|
.fill_in_name("Vulgar")
|
|
|
|
.fill_in_description("New flag description")
|
|
|
|
.select_applies_to("Topic")
|
|
|
|
.select_applies_to("Post")
|
|
|
|
.click_save
|
|
|
|
|
|
|
|
expect(admin_flags_page).to have_flags(
|
|
|
|
"Send @%{username} a message",
|
|
|
|
"Off-Topic",
|
|
|
|
"Inappropriate",
|
|
|
|
"Spam",
|
|
|
|
"Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Vulgar",
|
2024-07-02 19:46:53 -04:00
|
|
|
)
|
|
|
|
|
2024-08-05 20:50:12 -04:00
|
|
|
expect(admin_flags_page).to have_add_flag_button_disabled
|
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
|
|
|
|
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Vulgar",
|
2024-07-02 18:45:37 -04:00
|
|
|
)
|
|
|
|
|
2024-07-14 19:36:54 -04:00
|
|
|
# update
|
2024-09-11 01:30:20 -04:00
|
|
|
admin_flags_page.visit.click_edit_flag("custom_vulgar")
|
2024-12-17 17:13:39 -05:00
|
|
|
expect(d_page_header).to be_hidden
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flag_form_page.fill_in_name("Tasteless").click_save
|
|
|
|
|
|
|
|
expect(admin_flags_page).to have_flags(
|
|
|
|
"Send @%{username} a message",
|
|
|
|
"Off-Topic",
|
|
|
|
"Inappropriate",
|
|
|
|
"Spam",
|
|
|
|
"Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Tasteless",
|
2024-07-14 19:36:54 -04:00
|
|
|
)
|
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
|
|
|
|
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Tasteless",
|
2024-07-02 18:45:37 -04:00
|
|
|
)
|
|
|
|
|
2024-07-14 19:36:54 -04:00
|
|
|
# delete
|
2024-09-11 01:30:20 -04:00
|
|
|
admin_flags_page.visit.click_delete_flag("custom_tasteless").confirm_delete
|
2024-08-04 21:01:25 -04:00
|
|
|
|
2024-09-12 16:25:30 -04:00
|
|
|
expect(admin_flags_page).to have_no_flag("custom_tasteless")
|
2024-08-04 21:01:25 -04:00
|
|
|
|
2024-08-05 20:50:12 -04:00
|
|
|
expect(admin_flags_page).to have_add_flag_button_enabled
|
|
|
|
|
2024-08-04 21:01:25 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
|
|
|
|
|
|
|
expect(flag_modal).to have_choices(
|
|
|
|
"It's Inappropriate",
|
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
2024-07-02 18:45:37 -04:00
|
|
|
)
|
2024-10-07 17:38:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "has settings tab" do
|
|
|
|
admin_flags_page.visit
|
|
|
|
|
2024-12-17 17:13:39 -05:00
|
|
|
expect(d_page_header).to have_tabs(
|
2024-10-07 17:38:42 -04:00
|
|
|
[I18n.t("admin_js.settings"), I18n.t("admin_js.admin.config_areas.flags.flags_tab")],
|
|
|
|
)
|
|
|
|
|
|
|
|
admin_flags_page.click_settings_tab
|
|
|
|
expect(page.all(".setting-label h3").map(&:text)).to eq(
|
|
|
|
[
|
|
|
|
"silence new user sensitivity",
|
|
|
|
"num users to silence new user",
|
|
|
|
"flag sockpuppets",
|
|
|
|
"num flaggers to close topic",
|
|
|
|
"auto respond to flag actions",
|
|
|
|
"high trust flaggers auto hide posts",
|
|
|
|
"max flags per day",
|
|
|
|
"tl2 additional flags per day multiplier",
|
|
|
|
"tl3 additional flags per day multiplier",
|
|
|
|
"tl4 additional flags per day multiplier",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
end
|
2024-09-11 01:30:20 -04:00
|
|
|
|
2024-10-07 17:38:42 -04:00
|
|
|
it "allows to create custom flag with same name as system flag" do
|
|
|
|
admin_flags_page.visit
|
2024-09-11 01:30:20 -04:00
|
|
|
admin_flags_page.click_add_flag
|
|
|
|
admin_flag_form_page
|
|
|
|
.fill_in_name("Inappropriate")
|
|
|
|
.fill_in_description("New flag description")
|
|
|
|
.select_applies_to("Topic")
|
|
|
|
.select_applies_to("Post")
|
|
|
|
.click_save
|
|
|
|
|
2024-09-12 16:25:30 -04:00
|
|
|
expect(admin_flags_page).to have_flags(
|
|
|
|
"Send @%{username} a message",
|
|
|
|
"Off-Topic",
|
|
|
|
"Inappropriate",
|
|
|
|
"Spam",
|
|
|
|
"Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Inappropriate",
|
|
|
|
)
|
|
|
|
|
2024-09-11 01:30:20 -04:00
|
|
|
topic_page.visit_topic(post.topic).open_flag_topic_modal
|
|
|
|
|
|
|
|
expect(flag_modal).to have_choices(
|
2024-10-07 17:38:42 -04:00
|
|
|
"It's Inappropriate",
|
2024-09-11 01:30:20 -04:00
|
|
|
"It's Spam",
|
|
|
|
"It's Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Inappropriate",
|
|
|
|
)
|
|
|
|
|
|
|
|
admin_flags_page.visit.click_delete_flag("custom_inappropriate").confirm_delete
|
2024-07-02 18:45:37 -04:00
|
|
|
end
|
|
|
|
|
2024-06-04 23:27:06 -04:00
|
|
|
it "does not allow to move notify user flag" do
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit
|
|
|
|
expect(admin_flags_page).to have_no_action_for_flag("notify_user")
|
2024-06-04 23:27:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not allow bottom flag to move down" do
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit.open_flag_menu("notify_moderators")
|
|
|
|
expect(admin_flags_page).to have_no_item_action("move-down")
|
2024-06-04 23:27:06 -04:00
|
|
|
end
|
|
|
|
|
2024-07-02 18:45:37 -04:00
|
|
|
it "does not allow to system flag to be edited" do
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit
|
|
|
|
expect(admin_flags_page).to have_disabled_edit_for_flag("off_topic")
|
2024-07-02 18:45:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "does not allow to system flag to be deleted" do
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit.open_flag_menu("notify_moderators")
|
|
|
|
expect(admin_flags_page).to have_disabled_item_action("delete")
|
2024-07-02 18:45:37 -04:00
|
|
|
end
|
|
|
|
|
2024-06-04 23:27:06 -04:00
|
|
|
it "does not allow top flag to move up" do
|
2024-08-04 21:01:25 -04:00
|
|
|
admin_flags_page.visit.open_flag_menu("off_topic")
|
|
|
|
expect(admin_flags_page).to have_no_item_action("move-up")
|
2024-06-04 23:27:06 -04:00
|
|
|
end
|
2024-05-29 00:39:58 -04:00
|
|
|
end
|