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

variable_list_pagination_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: 0b0c9edcb421101228e5dbeeb5d2dc66af2439f0 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true

RSpec.shared_examples 'variable list pagination' do |variable_type|
  first_page_count = 20

  before do
    first_page_count.times do |i|
      case variable_type
      when :ci_variable
        create(variable_type, key: "test_key_#{i}", value: 'test_value', masked: true, project: project)
      when :ci_group_variable
        create(variable_type, key: "test_key_#{i}", value: 'test_value', masked: true, group: group)
      else
        create(variable_type, key: "test_key_#{i}", value: 'test_value', masked: true)
      end
    end

    visit page_path
    wait_for_requests
  end

  it 'can navigate between pages' do
    page.within('[data-testid="ci-variable-table"]') do
      expect(page.all('.js-ci-variable-row').length).to be(first_page_count)
    end

    click_button 'Next'
    wait_for_requests

    page.within('[data-testid="ci-variable-table"]') do
      expect(page.all('.js-ci-variable-row').length).to be(1)
    end

    click_button 'Previous'
    wait_for_requests

    page.within('[data-testid="ci-variable-table"]') do
      expect(page.all('.js-ci-variable-row').length).to be(first_page_count)
    end
  end

  it 'sorts variables alphabetically in ASC and DESC order' do
    page.within('[data-testid="ci-variable-table"]') do
      expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq(variable.key)
      expect(find('.js-ci-variable-row:nth-child(20) td[data-label="Key"]').text).to eq('test_key_8')
    end

    click_button 'Next'
    wait_for_requests

    page.within('[data-testid="ci-variable-table"]') do
      expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('test_key_9')
    end

    page.within('[data-testid="ci-variable-table"]') do
      find('.b-table-sort-icon-left').click
    end

    wait_for_requests

    page.within('[data-testid="ci-variable-table"]') do
      expect(find('.js-ci-variable-row:nth-child(1) td[data-label="Key"]').text).to eq('test_key_9')
      expect(find('.js-ci-variable-row:nth-child(20) td[data-label="Key"]').text).to eq('test_key_0')
    end
  end
end