Created
December 8, 2022 17:39
-
-
Save rickychilcott/95d92564179f2d96dac9b5bfa4c8d1ab to your computer and use it in GitHub Desktop.
Some Example Avo Test Helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def avo_flatpickr_pick(selector, with:) | |
base_field = find(selector, visible: false) | |
flatpickr_field_identifier = base_field["data-resource-edit-target"] | |
flatpickr_field = find("[data-resource-edit-target='#{flatpickr_field_identifier}'].flatpickr-input", visible: false) | |
new_selector_id = flatpickr_field["id"] | |
flatpickr_pick("##{new_selector_id}", with: with) | |
end | |
def avo_tagify_select(field_selector, with:, retries: 3) | |
raise("Unable to select '#{with}' from '#{field_selector}'") if retries == 0 | |
tags = find(field_selector, visible: false).sibling("tags") | |
tags.find("[data-placeholder]").click # open tagify dropdown | |
find(".tagify__dropdown [role='option'] span", text: with).click # select the tag | |
tags.find("tag", text: with) # ensure we have added the tag | |
rescue Capybara::ElementNotFound | |
avo_tagify_select(field_selector, with:, retries: retries - 1) | |
end | |
def avo_expand_menu_group(name) | |
find("[data-menu-key-param$='main_menu.#{name.underscore}'] svg").click | |
end | |
def avo_run_action(action_name, &block) | |
click_on "Actions" | |
find("a[title='#{action_name}']").click | |
within(find("[role='dialog']")) do | |
expect(page).to have_content(action_name) | |
yield | |
click_on "button[type='submit']" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment