<commit_before>module Features
  module SessionHelpers
    
    # search helpers
    def search(options = {})
      path = options[:path] || ''
      keyword = options[:keyword] || ''
      location = options[:location] || ''

      visit(path) if path.present?
      fill_in('keyword', :with => keyword) if keyword.present?
      fill_in('location', :with => location) if location.present?
      click_button 'Find'
      looks_like_results
    end

    def invalid_search(options = {})
      search(options)
      
      keyword = options[:keyword] || ''
      location = options[:location] || ''

      within ("#results-container header") do
        expect(page).
          to have_content("Showing 0 of 0 results matching '#{keyword}'") if keyword.present?

        expect(page).
          to have_content("Showing 0 of 0 results within 2 miles of '#{location}'") if location.present?

        expect(page).
          to have_content("Showing 0 of 0 results matching '#{keyword}' within 2 miles of '#{location}'") if keyword.present? && location.present?
      end

      find_field("keyword").value.should == "#{keyword}" if keyword.present?
      find_field("location").value.should == "#{location}" if location.present?
    end

    # navigation helpers
    def visit_details
      looks_like_results_list
      page.find(:css, '#list-view li:first-child a').click
    end


    # webbrowser navigation using requirejs
    def back_button_pressed
      page.execute_script("console.log('back');window.history.back();")
    end

    def forward_button_pressed
      page.execute_script("console.log('forward');window.history.forward();")
    end


    # check for distinctive features of pages
    def looks_like_homepage
      within ( ".home main" ) do
        expect(page).to have_title "OhanaSMC"
        expect(page).to have_css("#search-container")
        expect(page).to_not have_css("#results-container")
      end
    end

    def looks_like_results
      within ( ".inside main" ) do
        expect(page).to have_css("#search-container")
        expect(page).to have_css("#results-entries")
      end
    end

    def looks_like_results_list
      within ( ".inside main" ) do<commit_msg>Removes browser button test console messages<commit_after>module Features
  module SessionHelpers
    
    # search helpers
    def search(options = {})
      path = options[:path] || ''
      keyword = options[:keyword] || ''
      location = options[:location] || ''

      visit(path) if path.present?
      fill_in('keyword', :with => keyword) if keyword.present?
      fill_in('location', :with => location) if location.present?
      click_button 'Find'
      looks_like_results
    end

    def invalid_search(options = {})
      search(options)
      
      keyword = options[:keyword] || ''
      location = options[:location] || ''

      within ("#results-container header") do
        expect(page).
          to have_content("Showing 0 of 0 results matching '#{keyword}'") if keyword.present?

        expect(page).
          to have_content("Showing 0 of 0 results within 2 miles of '#{location}'") if location.present?

        expect(page).
          to have_content("Showing 0 of 0 results matching '#{keyword}' within 2 miles of '#{location}'") if keyword.present? && location.present?
      end

      find_field("keyword").value.should == "#{keyword}" if keyword.present?
      find_field("location").value.should == "#{location}" if location.present?
    end

    # navigation helpers
    def visit_details
      looks_like_results_list
      page.find(:css, '#list-view li:first-child a').click
    end


    # webbrowser navigation using requirejs
    def back_button_pressed
      page.execute_script("window.history.back();")
    end

    def forward_button_pressed
      page.execute_script("window.history.forward();")
    end


    # check for distinctive features of pages
    def looks_like_homepage
      within ( ".home main" ) do
        expect(page).to have_title "OhanaSMC"
        expect(page).to have_css("#search-container")
        expect(page).to_not have_css("#results-container")
      end
    end

    def looks_like_results
      within ( ".inside main" ) do
        expect(page).to have_css("#search-container")
        expect(page).to have_css("#results-entries")
      end
    end

    def looks_like_results_list
      within ( ".inside main" ) do
{'fraction_non_alphanumeric': 0.12090909090909091, 'fraction_numerical': 0.0036363636363636364, 'mean_word_length': 2.8403141361256545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2876311', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1208, 'n_words': 314}