# Now re-run the pipeline
if with_options
- find('a,button', text: 'Re-run options').click
+ assert_triggers_dom_event 'shown.bs.modal' do
+ find('a,button', text: 'Re-run options').click
+ end
within('.modal-dialog') do
page.assert_selector 'a,button', text: 'Copy and edit inputs'
page.assert_selector 'a,button', text: 'Run now'
find('a,button', text: 'Re-run with latest').click
end
- # Wait for the dialog to close. (Otherwise, the next assertion
- # could fail while we're still looking at the source instance
- # page, even if the correct behavior is about to happen.)
- assert_no_selector 'body.modal-open'
-
# Verify that the newly created instance is created in the right
# project. In case of project_viewer user, since the user cannot
# write to the project, the pipeline should have been created in
}
end
-Headless.new.start
-
module WaitForAjax
Capybara.default_wait_time = 5
def wait_for_ajax
end
end
+module AssertDomEvent
+ # Yield the supplied block, then wait for an event to arrive at a
+ # DOM element.
+ def assert_triggers_dom_event events, target='body'
+ magic = 'RXC0lObcVwEXwSvA'
+ page.evaluate_script <<eos
+ $('#{target}').one('#{events}', function() {
+ $('body').append('<div id="#{magic}"></div>');
+ });
+eos
+ yield
+ assert_selector "##{magic}"
+ page.evaluate_script "$('##{magic}').remove();";
+ end
+end
+
module HeadlessHelper
class HeadlessSingleton
def self.get
include Capybara::DSL
include ApiFixtureLoader
include WaitForAjax
+ include AssertDomEvent
include HeadlessHelper
@@API_AUTHS = self.api_fixture('api_client_authorizations')