discourse/spec/system/page_objects/pages/admin_flag_form.rb
Krzysztof Kotlarek 4ea3d69979
FIX: flaky flags system spec (#29039)
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.
2024-10-08 08:38:42 +11:00

39 lines
1002 B
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class AdminFlagForm < PageObjects::Pages::Base
def fill_in_name(name)
form.field("name").fill_in(name)
self
end
def fill_in_description(description)
form.field("description").fill_in(description)
self
end
def select_applies_to(applies_to)
dropdown = PageObjects::Components::SelectKit.new(".admin-flag-form__applies-to")
dropdown.expand
dropdown.select_row_by_value(applies_to)
dropdown.collapse
self
end
def click_save
form.submit
expect(page).to have_no_css(
".admin-config.flags.new",
wait: Capybara.default_max_wait_time * 3,
)
expect(page).to have_css(".admin-flag-item__name", wait: Capybara.default_max_wait_time * 3)
end
def form
@form ||= PageObjects::Components::FormKit.new(".admin-flag-form .form-kit")
end
end
end
end