2024-05-29 12:39:58 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Pages
|
|
|
|
class AdminFlags < PageObjects::Pages::Base
|
2024-08-05 09:01:25 +08:00
|
|
|
def visit
|
|
|
|
page.visit("/admin/config/flags")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2024-05-29 12:39:58 +08:00
|
|
|
def toggle(key)
|
|
|
|
PageObjects::Components::DToggleSwitch.new(".admin-flag-item__toggle.#{key}").toggle
|
2024-08-05 09:01:25 +08:00
|
|
|
has_saved_flag?(key)
|
|
|
|
self
|
2024-05-29 12:39:58 +08:00
|
|
|
end
|
2024-06-05 11:27:06 +08:00
|
|
|
|
|
|
|
def open_flag_menu(key)
|
|
|
|
find(".#{key} .flag-menu-trigger").click
|
2024-08-05 09:01:25 +08:00
|
|
|
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
|
|
|
|
|
2024-08-06 08:50:12 +08:00
|
|
|
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
|
|
|
|
|
2024-08-05 09:01:25 +08:00
|
|
|
def has_flag?(flag)
|
|
|
|
has_css?(".admin-flag-item.#{flag}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_flag?(flag)
|
2024-10-08 05:38:42 +08:00
|
|
|
has_no_css?(".admin-flag-item.#{flag}", wait: Capybara.default_max_wait_time * 3)
|
2024-08-05 09:01:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_saved_flag?(key)
|
2024-08-09 07:56:10 +08:00
|
|
|
has_css?(".admin-flag-item.#{key}.saved")
|
2024-06-05 11:27:06 +08:00
|
|
|
end
|
|
|
|
|
2024-08-08 09:50:28 +08:00
|
|
|
def has_closed_flag_menu?
|
|
|
|
has_no_css?(".flag-menu-content")
|
|
|
|
end
|
|
|
|
|
2024-06-05 11:27:06 +08:00
|
|
|
def move_down(key)
|
|
|
|
open_flag_menu(key)
|
2024-07-03 06:45:37 +08:00
|
|
|
find(".admin-flag-item__move-down").click
|
2024-08-08 09:50:28 +08:00
|
|
|
has_closed_flag_menu?
|
2024-08-05 09:01:25 +08:00
|
|
|
self
|
2024-06-05 11:27:06 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def move_up(key)
|
|
|
|
open_flag_menu(key)
|
2024-07-03 06:45:37 +08:00
|
|
|
find(".admin-flag-item__move-up").click
|
2024-08-08 09:50:28 +08:00
|
|
|
has_closed_flag_menu?
|
2024-08-05 09:01:25 +08:00
|
|
|
self
|
2024-07-03 06:45:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_add_flag
|
|
|
|
find(".admin-flags__header-add-flag").click
|
2024-08-05 09:01:25 +08:00
|
|
|
self
|
2024-07-03 06:45:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_edit_flag(key)
|
|
|
|
find(".#{key} .admin-flag-item__edit").click
|
2024-08-05 09:01:25 +08:00
|
|
|
self
|
2024-07-03 06:45:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_delete_flag(key)
|
|
|
|
find(".#{key} .flag-menu-trigger").click
|
|
|
|
find(".admin-flag-item__delete").click
|
2024-08-05 09:01:25 +08:00
|
|
|
self
|
2024-07-03 06:45:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def confirm_delete
|
|
|
|
find(".dialog-footer .btn-primary").click
|
2024-10-08 05:38:42 +08:00
|
|
|
expect(page).to have_no_css(".dialog-body", wait: Capybara.default_max_wait_time * 3)
|
2024-08-05 09:01:25 +08:00
|
|
|
self
|
2024-06-05 11:27:06 +08:00
|
|
|
end
|
2024-08-27 07:47:19 +08:00
|
|
|
|
|
|
|
def click_settings_tab
|
|
|
|
find(".admin-flags-tabs__settings a").click
|
|
|
|
self
|
|
|
|
end
|
2024-05-29 12:39:58 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|