diff options
Diffstat (limited to 'spec/support/helpers/listbox_helpers.rb')
-rw-r--r-- | spec/support/helpers/listbox_helpers.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/support/helpers/listbox_helpers.rb b/spec/support/helpers/listbox_helpers.rb new file mode 100644 index 00000000000..5fcd05f31fb --- /dev/null +++ b/spec/support/helpers/listbox_helpers.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module ListboxHelpers + def select_from_listbox(text, from:, exact_item_text: false) + click_button from + select_listbox_item(text, exact_text: exact_item_text) + end + + def select_listbox_item(text, exact_text: false) + find('.gl-listbox-item[role="option"]', text: text, exact_text: exact_text).click + end + + def expect_listbox_item(text) + expect(page).to have_css('.gl-listbox-item[role="option"]', text: text) + end + + def expect_no_listbox_item(text) + expect(page).not_to have_css('.gl-listbox-item[role="option"]', text: text) + end + + def expect_listbox_items(items) + expect(find_all('.gl-listbox-item[role="option"]').map(&:text)).to eq(items) + end +end |