BigW Consortium Gitlab

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

3
describe 'Dashboard Groups page', js: true, feature: true do
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  include WaitForAjax

  let!(:user) { create :user }
  let!(:group) { create(:group) }
  let!(:nested_group) { create(:group, :nested) }
  let!(:another_group) { create(:group) }

  before do
    group.add_owner(user)
    nested_group.add_owner(user)

    login_as(user)

    visit dashboard_groups_path
  end

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

  it 'filters groups' do
    fill_in 'filter_groups', with: group.name
    wait_for_ajax

    expect(page).to have_content(group.full_name)
    expect(page).not_to have_content(nested_group.full_name)
    expect(page).not_to have_content(another_group.full_name)
  end
34 35 36 37 38 39 40 41 42

  it 'resets search when user cleans the input' do
    fill_in 'filter_groups', with: group.name
    wait_for_ajax

    fill_in 'filter_groups', with: ""
    wait_for_ajax

    expect(page).to have_content(group.full_name)
43 44
    expect(page).to have_content(nested_group.full_name)
    expect(page).not_to have_content(another_group.full_name)
45 46
    expect(page.all('.js-groups-list-holder .content-list li').length).to eq 2
  end
47
end