<commit_before>module CapybaraExt
  def page!
    save_and_open_page
  end

  def click_icon(type)
    find(".fa-#{type}").click
  end

  def eventually_fill_in(field, options={})
    expect(page).to have_css('#' + field)
    fill_in field, options
  end

  def within_row(num, &block)
    if RSpec.current_example.metadata[:js]
      within("table.index tbody tr:nth-child(#{num})", &block)
    else
      within(:xpath, all("table.index tbody tr")[num-1].path, &block)
    end
  end

  def column_text(num)
    if RSpec.current_example.metadata[:js]
      find("td:nth-child(#{num})").text
    else
      all("td")[num-1].text
    end
  end

  def fill_in_quantity(table_column, selector, quantity)
    within(table_column) do
      fill_in selector, :with => quantity
    end
  end

  def select2_search(value, options)
    label = find_label_by_text(options[:from])
    within label.first(:xpath,".//..") do
      options[:from] = "##{find(".select2-container")["id"]}"
    end
    targetted_select2_search(value, options)
  end

  def select2_search_without_selection(value, options)
    find("#{options[:from]}:not(.select2-container-disabled)").click

    within_entire_page do
      select2input = first("#select2-drop input.select2-input") || find("input.select2-input")
      select2input.set(value)
    end
  end<commit_msg>Find select2 input base on select2-focused<commit_after>module CapybaraExt
  def page!
    save_and_open_page
  end

  def click_icon(type)
    find(".fa-#{type}").click
  end

  def eventually_fill_in(field, options={})
    expect(page).to have_css('#' + field)
    fill_in field, options
  end

  def within_row(num, &block)
    if RSpec.current_example.metadata[:js]
      within("table.index tbody tr:nth-child(#{num})", &block)
    else
      within(:xpath, all("table.index tbody tr")[num-1].path, &block)
    end
  end

  def column_text(num)
    if RSpec.current_example.metadata[:js]
      find("td:nth-child(#{num})").text
    else
      all("td")[num-1].text
    end
  end

  def fill_in_quantity(table_column, selector, quantity)
    within(table_column) do
      fill_in selector, :with => quantity
    end
  end

  def select2_search(value, options)
    label = find_label_by_text(options[:from])
    within label.first(:xpath,".//..") do
      options[:from] = "##{find(".select2-container")["id"]}"
    end
    targetted_select2_search(value, options)
  end

  def select2_search_without_selection(value, options)
    find("#{options[:from]}:not(.select2-container-disabled)").click

    within_entire_page do
      find("input.select2-input.select2-focused").set(value)
    end
  end
{'fraction_non_alphanumeric': 0.14193548387096774, 'fraction_numerical': 0.00872865275142315, 'mean_word_length': 3.6083916083916083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5208467', 'n_tokens_mistral': 923, 'n_tokens_neox': 902, 'n_words': 170}