require "rails_helper"

feature "User managing reports" do
  let(:current_user) { create(:user) }
  let(:project) { create(:project, account: current_user.primary_account) }

  before :each do
    sign_in current_user
  end

  scenario "searching for a report", js: true do
    create(:video, :published, project: project, name: "My Video", number: "001")

    visit project_reports_path(project)

    fill_in "query", with: "Production"
    click_on "search-button"

    expect(page).to have_content "Production Elements Log"
    expect(page).not_to have_content "GFX Cue List"
    expect(page).not_to have_content "Music Cue Sheet"
    expect(page).not_to have_content "BiG Music Cue Sheet"
    expect(page).not_to have_content "Issues and Concerns Report"

    fill_in "query", with: "Cue"
    click_on "search-button"

    expect(page).not_to have_content "Production Elements Log"
    expect(page).to have_content "GFX Cue List"
    expect(page).to have_content "Music Cue Sheet"
    expect(page).to have_content "BiG Music Cue Sheet"
    expect(page).not_to have_content "Issues and Concerns Report"
  end
end
