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
|
# frozen_string_literal: true
require "spec_helper"
RSpec.describe "User sorts issues", feature_category: :team_planning do
include SortingHelper
include IssueHelpers
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project_empty_repo, :public, group: group) }
let_it_be(:issue1, reload: true) { create(:issue, title: 'foo', created_at: Time.zone.now, project: project) }
let_it_be(:issue2, reload: true) { create(:issue, title: 'bar', created_at: Time.zone.now - 60, project: project) }
let_it_be(:issue3, reload: true) { create(:issue, title: 'baz', created_at: Time.zone.now - 120, project: project) }
let_it_be(:newer_due_milestone) { create(:milestone, project: project, due_date: '2013-12-11') }
let_it_be(:later_due_milestone) { create(:milestone, project: project, due_date: '2013-12-12') }
before do
create_list(:award_emoji, 2, :upvote, awardable: issue1)
create_list(:award_emoji, 2, :downvote, awardable: issue2)
create(:award_emoji, :downvote, awardable: issue1)
create(:award_emoji, :upvote, awardable: issue2)
sign_in(user)
end
it 'keeps the sort option', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/378184' do
visit(project_issues_path(project))
click_button 'Created date'
click_button 'Milestone'
visit(issues_dashboard_path(assignee_username: user.username))
expect(page).to have_button 'Milestone'
visit(project_issues_path(project))
expect(page).to have_button 'Milestone'
visit(issues_group_path(group))
expect(page).to have_button 'Milestone'
end
it 'sorts by popularity', :js do
visit(project_issues_path(project))
click_button 'Created date'
click_on 'Popularity'
page.within(".issues-list") do
page.within("li.issue:nth-child(1)") do
expect(page).to have_content(issue1.title)
end
page.within("li.issue:nth-child(2)") do
expect(page).to have_content(issue2.title)
end
page.within("li.issue:nth-child(3)") do
expect(page).to have_content(issue3.title)
end
end
end
it 'sorts by newest', :js do
visit project_issues_path(project, sort: sort_value_created_date)
expect(first_issue).to include('foo')
expect(last_issue).to include('baz')
end
it 'sorts by most recently updated', :js do
issue3.updated_at = Time.zone.now + 100
issue3.save!
visit project_issues_path(project, sort: sort_value_recently_updated)
expect(first_issue).to include('baz')
end
describe 'sorting by due date', :js do
before do
issue1.update!(due_date: 1.day.from_now)
issue2.update!(due_date: 6.days.from_now)
end
it 'sorts by due date' do
visit project_issues_path(project, sort: sort_value_due_date)
expect(first_issue).to include('foo')
end
it 'sorts by due date by excluding nil due dates' do
issue2.update!(due_date: nil)
visit project_issues_path(project, sort: sort_value_due_date)
expect(first_issue).to include('foo')
end
context 'with a filter on labels' do
let(:label) { create(:label, project: project) }
before do
create(:label_link, label: label, target: issue1)
end
it 'sorts by least recently due date by excluding nil due dates' do
issue2.update!(due_date: nil)
visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later)
expect(first_issue).to include('foo')
end
end
end
describe 'sorting by milestone', :js do
before do
issue1.milestone = newer_due_milestone
issue1.save!
issue2.milestone = later_due_milestone
issue2.save!
end
it 'sorts by milestone' do
visit project_issues_path(project, sort: sort_value_milestone)
expect(first_issue).to include('foo')
expect(last_issue).to include('baz')
end
end
describe 'combine filter and sort', :js do
let(:user2) { create(:user) }
before do
issue1.assignees << user2
issue1.save!
issue2.assignees << user2
issue2.save!
end
it 'sorts with a filter applied' do
visit project_issues_path(project, sort: sort_value_created_date, assignee_id: user2.id)
expect(first_issue).to include('foo')
expect(last_issue).to include('bar')
expect(page).not_to have_content('baz')
end
end
end
|