summaryrefslogtreecommitdiff
path: root/spec/features/issues/filter_by_labels_spec.rb
blob: 7944403f874ee2ebc06292998de3de101f361a6e (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
require 'rails_helper'

feature 'Issue filtering by Labels', feature: true do
  let(:project) { create(:project, :public) }
  let!(:user)   { create(:user)}
  let!(:label)  { create(:label, project: project) }

  before do
    ['bug', 'feature', 'enhancement'].each do |title|
      create(:label,
             project: project,
             title: title)
    end

    issue1 = create(:issue, title: "Bugfix1", project: project)
    issue1.labels << project.labels.find_by(title: 'bug')

    issue2 = create(:issue, title: "Bugfix2", project: project)
    issue2.labels << project.labels.find_by(title: 'bug')
    issue2.labels << project.labels.find_by(title: 'enhancement')

    issue3 = create(:issue, title: "Feature1", project: project)
    issue3.labels << project.labels.find_by(title: 'feature')

    project.team << [user, :master]
    login_as(user)

    visit namespace_project_issues_path(project.namespace, project)
  end

  context 'filter by label bug', js: true do
    before do
      page.find('.js-label-select').click
      sleep 0.5
      execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()")
      page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
      sleep 2
    end

    it 'should show issue "Bugfix1" and "Bugfix2" in issues list' do
      expect(page).to have_content "Bugfix1"
      expect(page).to have_content "Bugfix2"
    end

    it 'should not show "Feature1" in issues list' do
      expect(page).not_to have_content "Feature1"
    end

    it 'should show label "bug" in filtered-labels' do
      expect(find('.filtered-labels')).to have_content "bug"
    end

    it 'should not show label "feature" and "enhancement" in filtered-labels' do
      expect(find('.filtered-labels')).not_to have_content "feature"
      expect(find('.filtered-labels')).not_to have_content "enhancement"
    end
  end

  context 'filter by label feature', js: true do
    before do
      page.find('.js-label-select').click
      sleep 0.5
      execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()")
      page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
      sleep 2
    end

    it 'should show issue "Feature1" in issues list' do
      expect(page).to have_content "Feature1"
    end

    it 'should not show "Bugfix1" and "Bugfix2" in issues list' do
      expect(page).not_to have_content "Bugfix2"
      expect(page).not_to have_content "Bugfix1"
    end

    it 'should show label "feature" in filtered-labels' do
      expect(find('.filtered-labels')).to have_content "feature"
    end

    it 'should not show label "bug" and "enhancement" in filtered-labels' do
      expect(find('.filtered-labels')).not_to have_content "bug"
      expect(find('.filtered-labels')).not_to have_content "enhancement"
    end
  end

  context 'filter by label enhancement', js: true do
    before do
      page.find('.js-label-select').click
      sleep 0.5
      execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
      page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
      sleep 2
    end

    it 'should show issue "Bugfix2" in issues list' do
      expect(page).to have_content "Bugfix2"
    end

    it 'should not show "Feature1" and "Bugfix1" in issues list' do
      expect(page).not_to have_content "Feature1"
      expect(page).not_to have_content "Bugfix1"
    end

    it 'should show label "enhancement" in filtered-labels' do
      expect(find('.filtered-labels')).to have_content "enhancement"
    end

    it 'should not show label "feature" and "bug" in filtered-labels' do
      expect(find('.filtered-labels')).not_to have_content "bug"
      expect(find('.filtered-labels')).not_to have_content "feature"
    end
  end

  context 'filter by label enhancement or feature', js: true do
    before do
      page.find('.js-label-select').click
      sleep 0.5
      execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
      execute_script("$('.dropdown-menu-labels li:contains(\"feature\") a').click()")
      page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
      sleep 2
    end

    it 'should show issue "Bugfix2" or "Feature1" in issues list' do
      expect(page).to have_content "Bugfix2"
      expect(page).to have_content "Feature1"
    end

    it 'should not show "Bugfix1" in issues list' do
      expect(page).not_to have_content "Bugfix1"
    end

    it 'should show label "enhancement" and "feature" in filtered-labels' do
      expect(find('.filtered-labels')).to have_content "enhancement"
      expect(find('.filtered-labels')).to have_content "feature"
    end

    it 'should not show label "bug" in filtered-labels' do
      expect(find('.filtered-labels')).not_to have_content "bug"
    end
  end

  context 'filter by label enhancement or bug in issues list', js: true do
    before do
      page.find('.js-label-select').click
      sleep 0.5
      execute_script("$('.dropdown-menu-labels li:contains(\"enhancement\") a').click()")
      execute_script("$('.dropdown-menu-labels li:contains(\"bug\") a').click()")
      page.first('.labels-filter .dropdown-title .dropdown-menu-close-icon').click
      sleep 2
    end

    it 'should show issue "Bugfix2" or "Bugfix1" in issues list' do
      expect(page).to have_content "Bugfix2"
      expect(page).to have_content "Bugfix1"
    end

    it 'should not show "Feature1"' do
      expect(page).not_to have_content "Feature1"
    end

    it 'should show label "bug" and "enhancement" in filtered-labels' do
      expect(find('.filtered-labels')).to have_content "bug"
      expect(find('.filtered-labels')).to have_content "enhancement"
    end

    it 'should not show label "feature" in filtered-labels' do
      expect(find('.filtered-labels')).not_to have_content "feature"
    end
  end
end