diff --git a/spec/support/capybara/common_actions.rb b/spec/support/capybara/common_actions.rb index 93aa68c34a92..6e2012ac6f20 100644 --- a/spec/support/capybara/common_actions.rb +++ b/spec/support/capybara/common_actions.rb @@ -165,7 +165,7 @@ def visit(route, app: self.class.metadata[:app], skip_waiting: false) wait_for_loading_to_complete(route: route, app: app, skip_waiting: skip_waiting) end - def wait_for_loading_to_complete(route:, app: self.class.metadata[:app], skip_waiting: false) + def wait_for_loading_to_complete(route: nil, app: self.class.metadata[:app], skip_waiting: false, wait_ws: false) case app when :mobile return if skip_waiting @@ -181,6 +181,9 @@ def wait_for_loading_to_complete(route:, app: self.class.metadata[:app], skip_wa # make sure loading is completed (e.g. ticket zoom may take longer) expect(page).to have_no_css('.icon-loading', wait: 30) if !skip_waiting + + # make sure WS connection is ready to use + ensure_websocket if wait_ws end end @@ -389,6 +392,13 @@ def taskbar_tab_close(tab_data_key, discard_changes: true) end end + def refresh_with_wait + page.refresh + + # After the refresh, we must explictly wait for the app to be completely ready. + wait_for_loading_to_complete(wait_ws: true) + end + private def wait_for_pending_login(skip_waiting) diff --git a/spec/system/system/object_manager_spec.rb b/spec/system/system/object_manager_spec.rb index 98abae887ef4..89cfb03d6ea3 100644 --- a/spec/system/system/object_manager_spec.rb +++ b/spec/system/system/object_manager_spec.rb @@ -84,7 +84,7 @@ expect(page).to have_text('Database Update Required') click '.js-execute', wait: 7.minutes expect(page).to have_text('Zammad requires a restart') - page.refresh + refresh_with_wait # Update click 'tbody tr:last-child' @@ -104,12 +104,15 @@ click '.js-submit' end + # After the reload, we must explictly wait for the app to be completely ready. + wait_for_loading_to_complete(wait_ws: true) + # Delete click 'tbody tr:last-child .js-delete' expect(page).to have_text('Database Update Required') click '.js-execute', wait: 7.minutes expect(page).to have_text('Zammad requires a restart') - page.refresh + refresh_with_wait expect(page).to have_no_text('New field updated') end end @@ -136,7 +139,6 @@ # Create the field via API. object_attribute visit '/#system/object_manager' - page.refresh click 'tbody tr:last-child' in_modal do @@ -194,8 +196,6 @@ object_attribute ObjectManager::Attribute.migration_execute - refresh - visit '/#system/object_manager' click 'tbody tr:last-child td:first-child' end @@ -308,7 +308,6 @@ it 'handles removed options correctly' do object_attribute - page.refresh # Make sure option is present in the first place. ticket = create(:ticket, group: Group.find_by(name: 'Users'), object_attribute.name => 'delete') @@ -373,7 +372,6 @@ it 'shows user and organization attributes even if they are set to false' do organization_object_attribute user_object_attribute - page.refresh visit "/#ticket/zoom/#{ticket.id}" click('.content.active .tabsSidebar-tab[data-tab="organization"]') expect(page).to have_text('organization:false')