I’ve got a system test that runs with headless Chrome (it’s the only system test I’ve written so far) that runs fine on it’s own, but when run as part of the entire test suite gives the following error:
Failure/Error: check 'send_amazon_email_after_processing' # turns it on
Capybara::ElementNotFound:
Unable to find checkbox "send_amazon_email_after_processing"
[Screenshot]: tmp/screenshots/failures_r_spec_example_groups_upload_features_amazon_toggle_send_email_flag_turns_off_the_flag_723.png
Here is the test:
require 'spec_helper'
require 'wait_for_ajax'
describe "Upload Features", js: true do
describe 'Amazon' do
describe 'Toggle "Send Email" flag' do
before do
@user = FactoryBot.create :user
FactoryBot.create :user_distributor, :amazon, user: @user
integration_sign_in(@user)
visit uploads_path
expect(page.title).to include 'Upload'
wait_for_page_load
end
it 'defaults to off' do
expect(page).to have_unchecked_field 'send_amazon_email_after_processing'
end
end
end
end
The code in “wait_for_ajax”, which includes “wiat_for_page_load”, is:
module WaitForAjax
def wait_for_ajax
Timeout.timeout(Capybara.default_max_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end
def wait_for_page_load(css='div#body')
expect(page).to have_css(css)
end
end
RSpec.configure do |config|
config.include WaitForAjax, type: :system
end