<commit_before>require 'spec_helper'


describe 'catalog searching' do

  let(:user) { FactoryGirl.find_or_create(:jill) }


  before :each do
    @gf1 =  GenericFile.new.tap do |f|
      f.title = 'title 1'
      f.tag = ["tag1", "tag2"]
      f.apply_depositor_metadata('jilluser')
      f.save!
    end
    @gf2 =  GenericFile.new.tap do |f|
      f.title = 'title 2'
      f.tag = ["tag2", "tag3"]
      f.apply_depositor_metadata('jilluser')
      f.save!
    end
    @col =  Collection.new.tap do |f|
      f.title = 'title 3'
      f.tag = ["tag3", "tag4"]
      f.apply_depositor_metadata('jilluser')
      f.save!
    end
  end

  before do
    sign_in_as user
    visit '/'
  end

  it "finds multiple files" do
    within('#masthead_controls') do
      fill_in('search-field-header', with: "tag2")
      click_button("Go")
    end
    page.should have_content('Search Results')
    page.should have_content(@gf1.title.first)
    page.should have_content(@gf2.title.first)
    page.should_not have_content(@col.title)
  end

  it "finds files and collections" do
    within('#masthead_controls') do
      fill_in('search-field-header', with: "tag3")
      click_button("Go")
    end
    page.should have_content('Search Results')
    page.should have_content(@col.title)
    page.should have_content(@gf2.title.first)
    page.should_not have_content(@gf1.title.first)
  end

  it "finds collections" do
    within('#masthead_controls') do
      fill_in('search-field-header', with: "tag4")
      click_button("Go")
    end
    page.should have_content('Search Results')
    page.should have_content(@col.title)
    page.should_not have_content(@gf2.title.first)
    page.should_not have_content(@gf1.title.first)
  end
end<commit_msg>Adding a test to make sure the features exist on the catalog search result page. fixes #9301<commit_after>require_relative './feature_spec_helper'


describe 'catalog searching' do

  let(:user) { create :jill }
  let!(:gf1) { create_file user, {title:'title 1', tag:["tag1", "tag2"]} }
  let!(:gf2) { create_file user, {title:'title 2', tag:["tag2", "tag3"]} }
  let!(:gf3) { create_file user, {title:'title 3', tag:["tag3", "tag4"]} }
  let!(:collection) do
    Collection.new.tap do|col|
      col.apply_depositor_metadata(user.user_key)
      col.title = "collection title"
      col.tag = ["tag3","tag4"]
      col.save!
    end
  end

  before do
    sign_in_as user
    visit '/'
  end

  it "shows the facets" do
    within('#masthead_controls') do
      click_button("Go")
    end
    expect(page).to have_css "div#facets"
  end

  it "finds multiple files" do
    within('#masthead_controls') do
      fill_in('search-field-header', with: "tag2")
      click_button("Go")
    end
    expect(page).to have_content('Search Results')
    expect(page).to have_content(gf1.title.first)
    expect(page).to have_content(gf2.title.first)
    expect(page).not_to have_content(collection.title)
  end

  it "finds files and collections" do
    within('#masthead_controls') do
      fill_in('search-field-header', with: "tag3")
      click_button("Go")
    end
    expect(page).to have_content('Search Results')
    expect(page).to have_content(collection.title)
    expect(page).to have_content(gf2.title.first)
    expect(page).not_to have_content(gf1.title.first)
  end

  it "finds collections" do
    within('#masthead_controls') do
      fill_in('search-field-header', with: "tag4")
      click_button("Go")
    end
    expect(page).to have_content('Search Results')
    expect(page).to have_content(collection.title)
    expect(page).not_to have_content(gf2.title.first)
    expect(page).not_to have_content(gf1.title.first)
  end
end
{'fraction_non_alphanumeric': 0.13510580575149214, 'fraction_numerical': 0.012750949538795442, 'mean_word_length': 3.384066587395957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2475212', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1267, 'n_words': 268}