Browse Source

Maintenance: Try to improve the stabilzation of the manage groups selenium test.

Dominik Klein 3 years ago
parent
commit
2d8780c269
2 changed files with 30 additions and 4 deletions
  1. 11 0
      spec/support/capybara/common_actions.rb
  2. 19 4
      spec/system/manage/groups_spec.rb

+ 11 - 0
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|

+ 19 - 4
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