Welcome to mirror list, hosted at ThFree Co, Russian Federation.

snippets_shared_examples.rb « features « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1c8a9714bdf38449dc2bfc8aed83fbeedb6f0f60 (plain)
1
2
3
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# frozen_string_literal: true

# These shared examples expect a `snippets` array of snippets
RSpec.shared_examples 'paginated snippets' do |remote: false|
  it "is limited to #{Snippet.default_per_page} items per page" do
    expect(page.all('.snippets-list-holder .snippet-row').count).to eq(Snippet.default_per_page)
  end

  context 'clicking on the link to the second page' do
    before do
      click_link('2')
      wait_for_requests if remote
    end

    it 'shows the remaining snippets' do
      remaining_snippets_count = [snippets.size - Snippet.default_per_page, Snippet.default_per_page].min
      expect(page).to have_selector('.snippets-list-holder .snippet-row', count: remaining_snippets_count)
    end
  end
end

RSpec.shared_examples 'tabs with counts' do
  let(:tabs) { page.all('.snippet-scope-menu li') }

  it 'shows a tab for All snippets and count' do
    tab = tabs[0]

    expect(tab.text).to include('All')
    expect(tab.find('.badge').text).to eq(counts[:all])
  end

  it 'shows a tab for Private snippets and count' do
    tab = tabs[1]

    expect(tab.text).to include('Private')
    expect(tab.find('.badge').text).to eq(counts[:private])
  end

  it 'shows a tab for Internal snippets and count' do
    tab = tabs[2]

    expect(tab.text).to include('Internal')
    expect(tab.find('.badge').text).to eq(counts[:internal])
  end

  it 'shows a tab for Public snippets and count' do
    tab = tabs[3]

    expect(tab.text).to include('Public')
    expect(tab.find('.badge').text).to eq(counts[:public])
  end
end