groups_list_spec.rb 2.76 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Explore Groups page', :js do
4 5 6 7
  let!(:user) { create :user }
  let!(:group) { create(:group) }
  let!(:public_group) { create(:group, :public) }
  let!(:private_group) { create(:group, :private) }
8
  let!(:empty_project) { create(:project, group: public_group) }
9 10 11 12

  before do
    group.add_owner(user)

13
    sign_in(user)
14 15

    visit explore_groups_path
16
    wait_for_requests
17 18 19 20 21 22 23 24 25
  end

  it 'shows groups user is member of' do
    expect(page).to have_content(group.full_name)
    expect(page).to have_content(public_group.full_name)
    expect(page).not_to have_content(private_group.full_name)
  end

  it 'filters groups' do
26
    fill_in 'filter', with: group.name
27
    wait_for_requests
28 29 30 31 32

    expect(page).to have_content(group.full_name)
    expect(page).not_to have_content(public_group.full_name)
    expect(page).not_to have_content(private_group.full_name)
  end
33 34

  it 'resets search when user cleans the input' do
35
    fill_in 'filter', with: group.name
36
    wait_for_requests
37

38 39 40
    expect(page).to have_content(group.full_name)
    expect(page).not_to have_content(public_group.full_name)

41
    fill_in 'filter', with: ""
42
    page.find('[name="filter"]').send_keys(:enter)
43
    wait_for_requests
44 45 46 47 48 49

    expect(page).to have_content(group.full_name)
    expect(page).to have_content(public_group.full_name)
    expect(page).not_to have_content(private_group.full_name)
    expect(page.all('.js-groups-list-holder .content-list li').length).to eq 2
  end
50 51 52

  it 'shows non-archived projects count' do
    # Initially project is not archived
53
    expect(find('.js-groups-list-holder .content-list li:first-child .stats .number-projects')).to have_text("1")
54

55
    # Archive project
56
    ::Projects::UpdateService.new(empty_project, user, archived: true).execute
57 58 59
    visit explore_groups_path

    # Check project count
60
    expect(find('.js-groups-list-holder .content-list li:first-child .stats .number-projects')).to have_text("0")
61

62
    # Unarchive project
63
    ::Projects::UpdateService.new(empty_project, user, archived: false).execute
64 65 66
    visit explore_groups_path

    # Check project count
67
    expect(find('.js-groups-list-holder .content-list li:first-child .stats .number-projects')).to have_text("1")
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  end

  describe 'landing component' do
    it 'should show a landing component' do
      expect(page).to have_content('Below you will find all the groups that are public.')
    end

    it 'should be dismissable' do
      find('.dismiss-button').click

      expect(page).not_to have_content('Below you will find all the groups that are public.')
    end

    it 'should persistently not show once dismissed' do
      find('.dismiss-button').click

      visit explore_groups_path

      expect(page).not_to have_content('Below you will find all the groups that are public.')
    end
88
  end
89
end