<commit_before>PAGES = {
  'main page' => '/'
}

When(/^I visit (?:the )?"(.*?)"$/) do |page|
  # Find address from dictionary of named pages, unless we actually got
  # an URL path.
  page = PAGES[page.downcase] unless page =~ /^\//
  visit(page)
end

Then(/^I can see "(.*?)"$/) do |text|
  # We normally expect the request to succeed, put the assertion here
  # to avoid too verbose feature files.
  assert { (200..399).include?(page.status_code) }
  assert { page.has_content?(text) }
end

When(/^I click on "(.*?)"$/) do |text|
  click_on(text)
end

Then(/^I am at "(.*?)"$/) do |path|
  assert { current_path == path }
end

Then(/^I see an? (\w+) attribute "([^\"]+)" with value (.*)$/) do |kind, path, value|
  values = all("div#attributes-#{kind} tr"). # all table rows inside div with id=attributes-`kind`
    select { |row| row.find('td[1]').text == path }. # select rows where first cell's text is `path`
    map { |row| row.find('td[2]').text }             # make array of such rows' second cell's texts

  assert { values.length == 1 }    # there should be only one such row, no more and no less
  assert { values.first == value } # and its value should be as specified
end

Then(/^I see an attribute "(.*?)" with value (.*?)$/) do |path, value|
  values = all("table.table tr").                    # all table rows inside table with class="table"
    select { |row| row.find('td[1]').text == path }. # select rows where first cell's text is `path`
    map { |row| row.find('td[2]').text }             # make an array of such rows' second cell texts

  assert { values.length == 1 }
  assert { values.first == value }
end

When(/^I search for "(.*?)"$/) do |search_query|
  page.fill_in 'search', with: search_query
end

When /^(?:|I )press "([^"]*)"$/ do |button|
  click_button(button)
end<commit_msg>Fixes tests.<commit_after>PAGES = {
  'main page' => '/'
}

When(/^I visit (?:the )?"(.*?)"$/) do |page|
  # Find address from dictionary of named pages, unless we actually got
  # an URL path.
  page = PAGES[page.downcase] unless page =~ /^\//
  visit(page)
end

Then(/^I can see "(.*?)"$/) do |text|
  # We normally expect the request to succeed, put the assertion here
  # to avoid too verbose feature files.
  assert { (200..399).include?(page.status_code) }
  assert { page.has_content?(text) }
end

When(/^I click on "(.*?)"$/) do |text|
  click_on(text)
end

Then(/^I am at "(.*?)"$/) do |path|
  assert { current_path == path }
end

Then(/^I see an? (\w+) attribute "([^\"]+)" with value (.*)$/) do |kind, path, value|
  values = all("div#attributes-#{kind} tr"). # all table rows inside div with id=attributes-`kind`
    select { |row| row.find('td[1]').text == path }. # select rows where first cell's text is `path`
    map { |row| row.find('td[2]').text }             # make array of such rows' second cell's texts

  assert { values.length == 1 }    # there should be only one such row, no more and no less
  assert { values.first == value } # and its value should be as specified
end

Then(/^I see an attribute "(.*?)" with value (.*?)$/) do |path, value|
  values = all("table.table tr").                    # all table rows inside table with class="table"
    select { |row| row.find('td[1]').text == path }. # select rows where first cell's text is `path`
    map { |row| row.find('td[2]').text }             # make an array of such rows' second cell texts

  assert { values.length == 1 }
  assert { values.first == value }
end

When(/^I search for "(.*?)"$/) do |search_query|
  page.fill_in 'q', with: search_query
end

When /^(?:|I )press "([^"]*)"$/ do |button|
  click_button(button)
end
{'fraction_non_alphanumeric': 0.18284611141753998, 'fraction_numerical': 0.006618863761720904, 'mean_word_length': 3.135689851767389, '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': '125725', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1206, 'n_words': 416}