user_uses_search_filters_spec.rb 1.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
require 'spec_helper'

describe 'User uses search filters', :js do
  let(:group) { create(:group) }
  let!(:group_project) { create(:project, group: group) }
  let(:project) { create(:project, namespace: user.namespace) }
  let(:user) { create(:user) }

  before do
    project.add_reporter(user)
    group.add_owner(user)
    sign_in(user)

    visit(search_path)
  end

Semyon Pupkov's avatar
Semyon Pupkov committed
17
  context 'when filtering by group' do
18
    it 'shows group projects' do
19
      find('.js-search-group-dropdown').click
20 21 22 23 24 25 26 27 28 29

      wait_for_requests

      page.within('.search-holder') do
        click_link(group.name)
      end

      expect(find('.js-search-group-dropdown')).to have_content(group.name)

      page.within('.project-filter') do
30
        find('.js-search-project-dropdown').click
31 32 33

        wait_for_requests

34
        expect(page).to have_link(group_project.full_name)
35 36 37 38
      end
    end
  end

Semyon Pupkov's avatar
Semyon Pupkov committed
39
  context 'when filtering by project' do
40 41
    it 'shows a project' do
      page.within('.project-filter') do
42
        find('.js-search-project-dropdown').click
43 44 45

        wait_for_requests

46
        click_link(project.full_name)
47 48
      end

49
      expect(find('.js-search-project-dropdown')).to have_content(project.full_name)
50 51 52
    end
  end
end