Class: Workarea::SystemTest
- Inherits:
-
ActionDispatch::SystemTestCase
- Object
- ActionDispatch::SystemTestCase
- Workarea::SystemTest
- Extended by:
- TestCase::Decoration
- Includes:
- Factories, IntegrationTest::Configuration, TestCase::Configuration, TestCase::Encryption, TestCase::Geocoder, TestCase::Locales, TestCase::Mail, TestCase::RunnerLocation, TestCase::S3, TestCase::SearchIndexing, TestCase::Workers
- Defined in:
- lib/workarea/system_test.rb
Instance Method Summary collapse
- #javascript? ⇒ Boolean
-
#reset_window_size ⇒ Object
Resets the dimensions of the testing browser.
- #scroll_to_bottom ⇒ Object
-
#wait_for_iframe ⇒ Object
There is some kind of timing problem around waiting for this iframe that after a few hours we still can’t find.
-
#wait_for_xhr(time = Capybara.default_max_wait_time) ⇒ Object
Waits until all XHR requests have finished, according to jQuery.
Methods included from TestCase::Decoration
Methods included from IntegrationTest::Configuration
#set_current_admin, #set_current_user
Methods included from Factories
add, #create_admin_bookmark, #create_admin_visit, #create_audit_log_entry, #create_email_signup, #create_help_article, #create_inventory, #create_release, #create_shipping, #create_shipping_service, #create_shipping_sku, #create_tax_category, #create_tempfile, #factory_defaults, #factory_defaults_config, included, require_factories
Methods included from TestCase::Geocoder
#restore_geocoder_config, #save_geocoder_config
Methods included from TestCase::Encryption
#ensure_encryption_key, #reset_encryption_key
Methods included from TestCase::S3
#mock_s3, #mock_s3_cors_response, #reset_s3
Methods included from TestCase::Locales
#restore_locales, #save_locales, #set_locales
Methods included from TestCase::RunnerLocation
#running_from_source?, #running_in_dummy_app?, #running_in_gem?
Methods included from TestCase::Configuration
#reset_config_state, #store_config_state
Instance Method Details
#javascript? ⇒ Boolean
145 146 147 |
# File 'lib/workarea/system_test.rb', line 145 def javascript? .current_driver == .javascript_driver end |
#reset_window_size ⇒ Object
Resets the dimensions of the testing browser
136 137 138 139 140 141 142 143 |
# File 'lib/workarea/system_test.rb', line 136 def reset_window_size return unless javascript? page.driver.browser.manage.window.resize_to( Workarea.config., Workarea.config. ) end |
#scroll_to_bottom ⇒ Object
149 150 151 |
# File 'lib/workarea/system_test.rb', line 149 def scroll_to_bottom page.execute_script('window.scrollBy(0, 9999999)') end |
#wait_for_iframe ⇒ Object
There is some kind of timing problem around waiting for this iframe that after a few hours we still can’t find. This is a hack to keep this passing.
May God have mercy on our souls.
TODO v3.6 Remove this after we stop using an iframe for the admin toolbar
166 167 168 |
# File 'lib/workarea/system_test.rb', line 166 def wait_for_iframe sleep(0.5) end |
#wait_for_xhr(time = Capybara.default_max_wait_time) ⇒ Object
Waits until all XHR requests have finished, according to jQuery. Times out according to Capybara’s set timeout. Used to solve race conditions between XHR requests and assertions.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/workarea/system_test.rb', line 108 def wait_for_xhr(time=.default_max_wait_time) Timeout.timeout(time) do loop until finished_all_xhr_requests? end rescue Timeout::Error => error javascript_errors = page.driver.browser.manage.logs.get(:browser).each do |log_entry| log_entry.level == 'SEVERE' && /Uncaught/.match?(log_entry.) end if javascript_errors.present? raise( Timeout::Error, " Problem:\n JavaScript errors were detected during Workarea::SystemTest#wait_for_xhr.\n You might have an error in an XHR callback. wait_for_xhr is a test helper\n that checks if there are any unfinished XHR requests. This is called\n automatically throughout testing in Capybara interactions to ensure\n consistency in test results.\n Errors:\n \#{javascript_errors.map(&:message).join(\"\\r\")}\n eos\n )\n else\n raise error\n end\nend\n" |