discourse/spec/support/system_helpers.rb
Alan Guo Xiang Tan 7688628993
FIX: horizontal scrolling was not working correctly (#19236)
Fixes broken behaviour of arrow buttons for certain users as the interval to scroll menu can be cancelled before the scrolling actually happens.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2022-12-01 05:27:53 +08:00

34 lines
1007 B
Ruby

# frozen_string_literal: true
module SystemHelpers
def sign_in(user)
visit "/session/#{user.encoded_username}/become"
end
def setup_system_test
SiteSetting.login_required = false
SiteSetting.content_security_policy = false
SiteSetting.force_hostname = "#{Capybara.server_host}:#{Capybara.server_port}"
SiteSetting.external_system_avatars_enabled = false
end
def try_until_success(timeout: 2, frequency: 0.01)
start ||= Time.zone.now
backoff ||= frequency
yield
rescue RSpec::Expectations::ExpectationNotMetError
raise if Time.zone.now >= start + timeout.seconds
sleep backoff
backoff += frequency
retry
end
def resize_window(width: nil, height: nil)
original_size = page.driver.browser.manage.window.size
page.driver.browser.manage.window.resize_to(width || original_size.width, height || original_size.height)
yield
ensure
page.driver.browser.manage.window.resize_to(original_size.width, original_size.height)
end
end