Test drag-and-drop schedule editor

This commit is contained in:
Andrew Kvalheim 2023-05-31 14:49:39 -07:00 committed by Henne Vogelsang
parent 6e276b2787
commit 163b12a804
4 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
module BootstrapMacros
# Interact with Bootstrap Switch
def switch(locator, to:, **)
checkbox = find(:checkbox, locator, **, visible: :hidden)
checkbox.ancestor('.bootstrap-switch').click unless checkbox.checked? == to
expect(page).to have_selector(:checkbox, locator, **, visible: :hidden, checked: to)
end
end

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
module JQueryMacros
# Wait for one jQuery Ajax request during the block
def wait_for_ajax
flag = "window.ajax_#{SecureRandom.alphanumeric(16)}"
page.execute_script "#{flag} = false; $(document).one('ajaxComplete', () => #{flag} = true);"
yield
Timeout.timeout(Capybara.default_max_wait_time) { loop until page.evaluate_script(flag) }
page.execute_script "delete #{flag};"
end
end