spec: add fixDialogButtons support to submit_form
refs #10236 Change-Id: Ieb90b72d6a7a67c97cec88a6f539ef255d190886 Reviewed-on: https://gerrit.instructure.com/14187 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jake Sorce <jake@instructure.com> Reviewed-by: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
parent
dacc7f9d9f
commit
589ae2c449
|
@ -12,6 +12,7 @@ define [
|
|||
$dialog.find(".button-container:last, button[type=submit]").hide()
|
||||
buttons = $.map $buttons.toArray(), (button) ->
|
||||
$button = $(button)
|
||||
classes = $button.attr('class') ? ''
|
||||
|
||||
# if you add the class 'dialog_closer' to any of the buttons,
|
||||
# clicking it will cause the dialog to close
|
||||
|
@ -20,6 +21,7 @@ define [
|
|||
|
||||
# make it so if you hit enter in the dialog, you submit the form
|
||||
if $button.prop('type') is 'submit' && $button[0].form
|
||||
classes += ' button_type_submit'
|
||||
$dialog.keypress (e) ->
|
||||
$($button[0].form).submit() if e.keyCode is $.ui.keyCode.ENTER
|
||||
|
||||
|
@ -27,6 +29,6 @@ define [
|
|||
text: $button.text()
|
||||
"data-text-while-loading": $button.data("textWhileLoading")
|
||||
click: -> $button.click()
|
||||
class: $button.attr('class')
|
||||
class: classes
|
||||
}
|
||||
$dialog.dialog "option", "buttons", buttons
|
|
@ -734,7 +734,13 @@ shared_examples_for "all selenium tests" do
|
|||
# can pass in either an element or a forms css
|
||||
def submit_form(form)
|
||||
submit_button_css = 'button[type="submit"]'
|
||||
form.is_a?(Selenium::WebDriver::Element) ? form.find_element(:css, submit_button_css).click : f("#{form} #{submit_button_css}").click
|
||||
button = form.is_a?(Selenium::WebDriver::Element) ? form.find_element(:css, submit_button_css) : f("#{form} #{submit_button_css}")
|
||||
# the button may have been hidden via fixDialogButtons
|
||||
if !button.displayed? && dialog = button.find_element(:xpath, "ancestor::div[contains(@class, 'ui-dialog')]")
|
||||
submit_dialog(dialog, ".ui-dialog-buttonpane .button_type_submit")
|
||||
else
|
||||
button.click
|
||||
end
|
||||
end
|
||||
|
||||
def submit_dialog(dialog, submit_button_css = '.submit_button')
|
||||
|
|
Loading…
Reference in New Issue