mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 08:13:44 +08:00
4ea3d69979
Because of unreliability, the spec was temporarily disabled. However, it is ensuring that the custom flags system is working correctly. Therefore it would be great to enable it again. I made a few fixes to try to mitigate this situation: - Reduced amount of Redis calls; - When deleting, ensure that the modal is closed before checking the result; - Moved duplicated name tests to a separate block; - Increased wait time to 3 times the default because I noticed that sometimes it gets stuck for a moment. Most of the time it is fast, but sometimes when I run tests in a loop 50 times I see slowness.
117 lines
2.8 KiB
Ruby
117 lines
2.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class AdminFlags < PageObjects::Pages::Base
|
|
def visit
|
|
page.visit("/admin/config/flags")
|
|
self
|
|
end
|
|
|
|
def toggle(key)
|
|
PageObjects::Components::DToggleSwitch.new(".admin-flag-item__toggle.#{key}").toggle
|
|
has_saved_flag?(key)
|
|
self
|
|
end
|
|
|
|
def open_flag_menu(key)
|
|
find(".#{key} .flag-menu-trigger").click
|
|
self
|
|
end
|
|
|
|
def has_action_for_flag?(flag)
|
|
has_selector?(".#{flag} .flag-menu-trigger")
|
|
end
|
|
|
|
def has_no_action_for_flag?(flag)
|
|
has_no_selector?(".#{flag} .flag-menu-trigger")
|
|
end
|
|
|
|
def has_disabled_edit_for_flag?(flag)
|
|
has_selector?(".#{flag} .admin-flag-item__edit[disabled]")
|
|
end
|
|
|
|
def has_disabled_item_action?(action)
|
|
has_selector?(".admin-flag-item__#{action}[disabled]")
|
|
end
|
|
|
|
def has_item_action?(action)
|
|
has_selector?(".admin-flag-item__#{action}")
|
|
end
|
|
|
|
def has_no_item_action?(action)
|
|
has_no_selector?(".admin-flag-item__#{action}")
|
|
end
|
|
|
|
def has_flags?(*flags)
|
|
all(".admin-flag-item__name").map(&:text) == flags
|
|
end
|
|
|
|
def has_add_flag_button_enabled?
|
|
has_css?(".admin-flags__header-add-flag:not([disabled])")
|
|
end
|
|
|
|
def has_add_flag_button_disabled?
|
|
has_no_css?(".admin-flags__header-add-flag[disabled]")
|
|
end
|
|
|
|
def has_flag?(flag)
|
|
has_css?(".admin-flag-item.#{flag}")
|
|
end
|
|
|
|
def has_no_flag?(flag)
|
|
has_no_css?(".admin-flag-item.#{flag}", wait: Capybara.default_max_wait_time * 3)
|
|
end
|
|
|
|
def has_saved_flag?(key)
|
|
has_css?(".admin-flag-item.#{key}.saved")
|
|
end
|
|
|
|
def has_closed_flag_menu?
|
|
has_no_css?(".flag-menu-content")
|
|
end
|
|
|
|
def move_down(key)
|
|
open_flag_menu(key)
|
|
find(".admin-flag-item__move-down").click
|
|
has_closed_flag_menu?
|
|
self
|
|
end
|
|
|
|
def move_up(key)
|
|
open_flag_menu(key)
|
|
find(".admin-flag-item__move-up").click
|
|
has_closed_flag_menu?
|
|
self
|
|
end
|
|
|
|
def click_add_flag
|
|
find(".admin-flags__header-add-flag").click
|
|
self
|
|
end
|
|
|
|
def click_edit_flag(key)
|
|
find(".#{key} .admin-flag-item__edit").click
|
|
self
|
|
end
|
|
|
|
def click_delete_flag(key)
|
|
find(".#{key} .flag-menu-trigger").click
|
|
find(".admin-flag-item__delete").click
|
|
self
|
|
end
|
|
|
|
def confirm_delete
|
|
find(".dialog-footer .btn-primary").click
|
|
expect(page).to have_no_css(".dialog-body", wait: Capybara.default_max_wait_time * 3)
|
|
self
|
|
end
|
|
|
|
def click_settings_tab
|
|
find(".admin-flags-tabs__settings a").click
|
|
self
|
|
end
|
|
end
|
|
end
|
|
end
|