2024-05-29 12:39:58 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Admin Flags Page", type: :system do
|
|
|
|
fab!(:admin)
|
|
|
|
fab!(:topic)
|
|
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
|
|
|
|
|
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
let(:admin_flags_page) { PageObjects::Pages::AdminFlags.new }
|
2024-07-03 06:45:37 +08:00
|
|
|
let(:admin_flag_form_page) { PageObjects::Pages::AdminFlagForm.new }
|
2024-07-08 09:09:30 +08:00
|
|
|
let(:sidebar) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2024-05-29 12:39:58 +08:00
|
|
|
|
|
|
|
before { sign_in(admin) }
|
|
|
|
|
2024-07-15 07:36:54 +08:00
|
|
|
it "allows admin to disable, change order, create, update and delete flags" do
|
|
|
|
# disable
|
2024-05-29 12:39:58 +08:00
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
2024-06-06 13:45:30 +08:00
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else"],
|
2024-05-29 12:39:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
admin_flags_page.toggle("spam")
|
2024-07-03 10:02:18 +08:00
|
|
|
expect(page).not_to have_css(".admin-flag-item.spam.saving")
|
2024-05-29 12:39:58 +08:00
|
|
|
|
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
2024-06-06 13:45:30 +08:00
|
|
|
["It's Inappropriate", "It's Illegal", "Something Else"],
|
2024-05-29 12:39:58 +08:00
|
|
|
)
|
2024-06-06 07:40:14 +08:00
|
|
|
|
|
|
|
Flag.system.where(name: "spam").update!(enabled: true)
|
2024-06-05 11:27:06 +08:00
|
|
|
|
2024-07-15 07:36:54 +08:00
|
|
|
# change order
|
2024-06-05 11:27:06 +08:00
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
2024-06-06 13:45:30 +08:00
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else"],
|
2024-06-05 11:27:06 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
admin_flags_page.move_down("spam")
|
2024-07-03 10:02:18 +08:00
|
|
|
expect(page).not_to have_css(".admin-flag-item.spam.saving")
|
2024-06-05 11:27:06 +08:00
|
|
|
|
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
2024-06-06 13:45:30 +08:00
|
|
|
["It's Inappropriate", "It's Illegal", "It's Spam", "Something Else"],
|
2024-06-05 11:27:06 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
admin_flags_page.move_up("spam")
|
2024-07-03 10:02:18 +08:00
|
|
|
expect(page).not_to have_css(".admin-flag-item.spam.saving")
|
2024-06-05 11:27:06 +08:00
|
|
|
|
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
2024-06-06 13:45:30 +08:00
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else"],
|
2024-06-05 11:27:06 +08:00
|
|
|
)
|
|
|
|
|
2024-07-15 07:36:54 +08:00
|
|
|
# create
|
2024-07-03 06:45:37 +08:00
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else"],
|
|
|
|
)
|
|
|
|
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
|
|
|
|
admin_flags_page.click_add_flag
|
|
|
|
|
|
|
|
expect(admin_flag_form_page).to have_disabled_save_button
|
|
|
|
|
|
|
|
admin_flag_form_page.fill_in_name("Vulgar")
|
|
|
|
admin_flag_form_page.fill_in_description("New flag description")
|
|
|
|
admin_flag_form_page.fill_in_applies_to("Topic")
|
|
|
|
admin_flag_form_page.fill_in_applies_to("Post")
|
|
|
|
admin_flag_form_page.click_save
|
|
|
|
|
2024-07-03 07:46:53 +08:00
|
|
|
expect(all(".admin-flag-item__name").map(&:text)).to eq(
|
|
|
|
[
|
|
|
|
"Send @%{username} a message",
|
|
|
|
"Off-Topic",
|
|
|
|
"Inappropriate",
|
|
|
|
"Spam",
|
|
|
|
"Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Vulgar",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2024-07-03 06:45:37 +08:00
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else", "Vulgar"],
|
|
|
|
)
|
|
|
|
|
2024-07-15 07:36:54 +08:00
|
|
|
# update
|
2024-07-03 06:45:37 +08:00
|
|
|
visit "/admin/config/flags"
|
|
|
|
|
|
|
|
admin_flags_page.click_edit_flag("vulgar")
|
|
|
|
|
|
|
|
admin_flag_form_page.fill_in_name("Tasteless")
|
|
|
|
admin_flag_form_page.click_save
|
|
|
|
|
2024-07-15 07:36:54 +08:00
|
|
|
expect(all(".admin-flag-item__name").map(&:text)).to eq(
|
|
|
|
[
|
|
|
|
"Send @%{username} a message",
|
|
|
|
"Off-Topic",
|
|
|
|
"Inappropriate",
|
|
|
|
"Spam",
|
|
|
|
"Illegal",
|
|
|
|
"Something Else",
|
|
|
|
"Tasteless",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2024-07-03 06:45:37 +08:00
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else", "Tasteless"],
|
|
|
|
)
|
|
|
|
|
2024-07-15 07:36:54 +08:00
|
|
|
# delete
|
2024-07-03 06:45:37 +08:00
|
|
|
visit "/admin/config/flags"
|
|
|
|
admin_flags_page.click_delete_flag("tasteless")
|
|
|
|
admin_flags_page.confirm_delete
|
2024-07-03 10:02:18 +08:00
|
|
|
expect(page).not_to have_css(".admin-flag-item.tasteless.saving")
|
2024-07-03 06:45:37 +08:00
|
|
|
|
|
|
|
topic_page.visit_topic(post.topic)
|
|
|
|
topic_page.open_flag_topic_modal
|
|
|
|
expect(all(".flag-action-type-details strong").map(&:text)).to eq(
|
|
|
|
["It's Inappropriate", "It's Spam", "It's Illegal", "Something Else"],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2024-06-05 11:27:06 +08:00
|
|
|
it "does not allow to move notify user flag" do
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
expect(page).not_to have_css(".notify_user .flag-menu-trigger")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not allow bottom flag to move down" do
|
|
|
|
visit "/admin/config/flags"
|
2024-06-06 13:45:30 +08:00
|
|
|
admin_flags_page.open_flag_menu("notify_moderators")
|
2024-06-05 11:27:06 +08:00
|
|
|
expect(page).not_to have_css(".dropdown-menu__item .move-down")
|
|
|
|
end
|
|
|
|
|
2024-07-03 06:45:37 +08:00
|
|
|
it "does not allow to system flag to be edited" do
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
expect(page).to have_css(".off_topic .admin-flag-item__edit[disabled]")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not allow to system flag to be deleted" do
|
|
|
|
visit "/admin/config/flags"
|
|
|
|
admin_flags_page.open_flag_menu("notify_moderators")
|
|
|
|
expect(page).to have_css(".admin-flag-item__delete[disabled]")
|
|
|
|
end
|
|
|
|
|
2024-06-05 11:27:06 +08:00
|
|
|
it "does not allow top flag to move up" do
|
|
|
|
visit "/admin/config/flags"
|
2024-06-06 13:45:30 +08:00
|
|
|
admin_flags_page.open_flag_menu("off_topic")
|
2024-06-05 11:27:06 +08:00
|
|
|
expect(page).not_to have_css(".dropdown-menu__item .move-up")
|
|
|
|
end
|
2024-07-08 09:09:30 +08:00
|
|
|
|
|
|
|
it "does not show the moderation flags link in the sidebar by default" do
|
|
|
|
visit "/admin"
|
|
|
|
sidebar.toggle_all_sections
|
|
|
|
expect(sidebar).to have_no_section_link(
|
|
|
|
I18n.t("admin_js.admin.community.sidebar_link.moderation_flags"),
|
|
|
|
)
|
|
|
|
SiteSetting.experimental_flags_admin_page_enabled_groups = Group::AUTO_GROUPS[:admins]
|
|
|
|
visit "/admin"
|
|
|
|
expect(sidebar).to have_section_link(
|
|
|
|
I18n.t("admin_js.admin.community.sidebar_link.moderation_flags"),
|
|
|
|
)
|
|
|
|
end
|
2024-05-29 12:39:58 +08:00
|
|
|
end
|