<commit_before>require_relative './wait_for_requests'

module WaitForRequests
  extend self

  # This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
  def block_and_wait_for_requests_complete
    Gitlab::Testing::RequestBlockerMiddleware.block_requests!
    wait_for('pending requests complete') do
      Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero?
    end
  ensure
    Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
  end

  def wait_for_requests
    wait_for('JS requests') { finished_all_requests? }
  end<commit_msg>Wait for all Ajax and Vue requests to complete in JavaScript tests<commit_after>require_relative './wait_for_requests'

module WaitForRequests
  extend self

  # This is inspired by http://www.salsify.com/blog/engineering/tearing-capybara-ajax-tests
  def block_and_wait_for_requests_complete
    Gitlab::Testing::RequestBlockerMiddleware.block_requests!
    wait_for('pending requests complete') do
      Gitlab::Testing::RequestBlockerMiddleware.num_active_requests.zero? && finished_all_requests?
    end
  ensure
    Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
  end

  def wait_for_requests
    wait_for('JS requests') { finished_all_requests? }
  end
{'fraction_non_alphanumeric': 0.08009516256938938, 'fraction_numerical': 0.0, 'mean_word_length': 5.505154639175258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6519571', 'n_tokens_mistral': 373, 'n_tokens_neox': 373, 'n_words': 69}