Skip to content

Commit

Permalink
Attempt to fix failing acceptance test in TravisCI
Browse files Browse the repository at this point in the history
- Increase the default Capybara wait time back to 5 seconds.
- Retry clicking the fields to edit.
- Ugly hack to always activate the edition of the fields when clicking
  on the row or the value span.
  • Loading branch information
ggiraldez committed Mar 21, 2016
1 parent 73bcb52 commit 2d7ba16
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
6 changes: 6 additions & 0 deletions app/assets/javascripts/collections/field.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ onCollections ->
window.model.initDatePicker(optionsDatePicker)
window.model.initAutocomplete()

notifyEdit: (ev) =>
# TODO: remove this eventually; this handler exists only to be installed
# as the mousedown handler for the field's row DIV. Otherwise, there are
# situations when clicking on the row doesn't activate the edition
undefined

keyPress: (field, event) =>
switch event.keyCode
when 13 then @save()
Expand Down
4 changes: 3 additions & 1 deletion app/views/collections/index/_map.haml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@
/ko if: expanded()
/ko foreach: fields
/ko if: writeable
%div.site_row.writeable{ko(click: 'edit')}
/- TODO: remove the mousedown handler. Otherwise, there are
/- situations when clicking on the row doesn't activate the edition
%div.site_row.writeable{ko(click: 'edit', event: {mousedown: 'notifyEdit'})}
%span{ko(text: :errorMessage, validationPopover: :errorMessage), style: 'display: none;'}
%label.field-name{ko(text: "name + ':'", topPopover: "__('Field Code') + ': ' + code", css: { error: :error })}
/ko if: hasValue() && !error()
Expand Down
21 changes: 14 additions & 7 deletions spec/integration/collections/sites/field_edition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ def expect_old_values_and_edit
all_rows = page.all('div.site_row')
for i in 3..all_rows.count() - 1
row = all_rows[i]
row.click
x = if row.has_selector?('input')
row.find('input')
elsif row.has_selector?('select')
row.find('select')
end
x = nil
retries = 2
while x.nil? and retries > 0
row.find('span.value').click
x = if row.has_selector?('input')
row.find('input')
else
if row.has_selector?('select')
row.find('select')
end
end
retries = retries - 1
end
expect(x).to_not be_nil

if x[:id] != "yes-no-input-yes_no"
Expand All @@ -72,7 +79,7 @@ def expect_new_values
for i in 3..all_rows.count() - 1
row = all_rows[i]
x = nil
retries = 3
retries = 2
while x.nil? and retries > 0
row.find('span.value').click
x = if row.has_selector?('input')
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def format(result)
Warden.test_mode!

# Set the default timeout for Capybara to re-synchronize with Selenium
Capybara.default_max_wait_time = (ENV['CAPYBARA_TIMEOUT'] || '3').to_i
Capybara.default_max_wait_time = (ENV['CAPYBARA_TIMEOUT'] || '5').to_i
Capybara.javascript_driver = :selenium
Capybara.default_selector = :css

Expand Down

0 comments on commit 2d7ba16

Please sign in to comment.