diff --git a/app/assets/javascripts/collections/field.coffee b/app/assets/javascripts/collections/field.coffee index 800622ac4..93bcfd0b9 100644 --- a/app/assets/javascripts/collections/field.coffee +++ b/app/assets/javascripts/collections/field.coffee @@ -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() diff --git a/app/views/collections/index/_map.haml b/app/views/collections/index/_map.haml index 2279f5681..9b06cf62d 100644 --- a/app/views/collections/index/_map.haml +++ b/app/views/collections/index/_map.haml @@ -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() diff --git a/spec/integration/collections/sites/field_edition_spec.rb b/spec/integration/collections/sites/field_edition_spec.rb index b8ded5bfd..306a2f846 100644 --- a/spec/integration/collections/sites/field_edition_spec.rb +++ b/spec/integration/collections/sites/field_edition_spec.rb @@ -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" @@ -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') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cd4cbc4fc..0b44edc2f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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