diff --git a/spec/support/capybara/common_actions.rb b/spec/support/capybara/common_actions.rb index 70961703e..96b95b2a4 100644 --- a/spec/support/capybara/common_actions.rb +++ b/spec/support/capybara/common_actions.rb @@ -283,6 +283,17 @@ module CommonActions move_mouse_to(element) move_mouse_by(5, 5) end + + # Scroll into view with javscript. + # + # @param position [Symbol] :top or :bottom, position of the scroll into view + # + # scroll_into_view('button.js-submit) + # + def scroll_into_view(css_selector, position: :top) + page.execute_script("document.querySelector('#{css_selector}').scrollIntoView(#{position == :top})") + sleep 0.3 + end end RSpec.configure do |config| diff --git a/spec/system/manage/groups_spec.rb b/spec/system/manage/groups_spec.rb index 6b0f6aa37..703b30991 100644 --- a/spec/system/manage/groups_spec.rb +++ b/spec/system/manage/groups_spec.rb @@ -30,13 +30,28 @@ RSpec.describe 'Manage > Groups', type: :system do it 'is possible to reset the assignment timeout of a group' do find('td', text: 'Users').click - fill_in 'Assignment Timeout', with: '30' - find('button', text: 'Submit').click + + within '.modal-dialog' do + fill_in 'Assignment Timeout', with: '30' + + # Needed for chrome, when element is outside viewport. + scroll_into_view('button.js-submit', position: :bottom) + + click_button + end + expect(Group.find_by(name: 'Users').assignment_timeout).to eq(30) find('td', text: 'Users').click - fill_in 'Assignment Timeout', with: '' - find('button', text: 'Submit').click + + within '.modal-dialog' do + fill_in 'Assignment Timeout', with: '' + + # Needed for chrome, when element is outside viewport. + scroll_into_view('button.js-submit', position: :bottom) + + click_button + end expect(Group.find_by(name: 'Users').assignment_timeout).to be nil end end