Skip to content

Commit

Permalink
Maintenance: Stabilize object manager attribute spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvuckovic committed Dec 5, 2023
1 parent 630c50e commit d76a609
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 11 additions & 1 deletion spec/support/capybara/common_actions.rb
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions spec/system/system/object_manager_spec.rb
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -194,8 +196,6 @@
object_attribute
ObjectManager::Attribute.migration_execute

refresh

visit '/#system/object_manager'
click 'tbody tr:last-child td:first-child'
end
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit d76a609

Please sign in to comment.