2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require "spec_helper"
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe "User sorts issues" do
|
2020-03-13 15:44:24 +05:30
|
|
|
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) }
|
2022-05-07 20:08:51 +05:30
|
|
|
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) }
|
2020-03-13 15:44:24 +05:30
|
|
|
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') }
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
before do
|
2022-07-16 23:28:13 +05:30
|
|
|
stub_feature_flags(vue_issues_list: true)
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
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)
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it 'keeps the sort option', :js do
|
2021-09-30 23:02:18 +05:30
|
|
|
visit(project_issues_path(project))
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
click_button 'Created date'
|
|
|
|
click_button 'Milestone'
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
visit(issues_dashboard_path(assignee_username: user.username))
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(page).to have_button 'Milestone'
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
visit(project_issues_path(project))
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(page).to have_button 'Milestone'
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
visit(issues_group_path(group))
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
expect(page).to have_button 'Milestone'
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it 'sorts by popularity', :js do
|
2021-09-30 23:02:18 +05:30
|
|
|
visit(project_issues_path(project))
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
click_button 'Created date'
|
|
|
|
click_on 'Popularity'
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
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
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it 'sorts by newest', :js do
|
2020-03-13 15:44:24 +05:30
|
|
|
visit project_issues_path(project, sort: sort_value_created_date)
|
|
|
|
|
|
|
|
expect(first_issue).to include('foo')
|
|
|
|
expect(last_issue).to include('baz')
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it 'sorts by most recently updated', :js do
|
2022-05-07 20:08:51 +05:30
|
|
|
issue3.updated_at = Time.zone.now + 100
|
2021-04-29 21:17:54 +05:30
|
|
|
issue3.save!
|
2020-03-13 15:44:24 +05:30
|
|
|
visit project_issues_path(project, sort: sort_value_recently_updated)
|
|
|
|
|
|
|
|
expect(first_issue).to include('baz')
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe 'sorting by due date', :js do
|
2020-03-13 15:44:24 +05:30
|
|
|
before do
|
2021-04-29 21:17:54 +05:30
|
|
|
issue1.update!(due_date: 1.day.from_now)
|
|
|
|
issue2.update!(due_date: 6.days.from_now)
|
2020-03-13 15:44:24 +05:30
|
|
|
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
|
2021-04-29 21:17:54 +05:30
|
|
|
issue2.update!(due_date: nil)
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
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
|
2021-04-29 21:17:54 +05:30
|
|
|
issue2.update!(due_date: nil)
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later)
|
|
|
|
|
|
|
|
expect(first_issue).to include('foo')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe 'sorting by milestone', :js do
|
2020-03-13 15:44:24 +05:30
|
|
|
before do
|
|
|
|
issue1.milestone = newer_due_milestone
|
2021-04-29 21:17:54 +05:30
|
|
|
issue1.save!
|
2020-03-13 15:44:24 +05:30
|
|
|
issue2.milestone = later_due_milestone
|
2021-04-29 21:17:54 +05:30
|
|
|
issue2.save!
|
2020-03-13 15:44:24 +05:30
|
|
|
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
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe 'combine filter and sort', :js do
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:user2) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
issue1.assignees << user2
|
2021-04-29 21:17:54 +05:30
|
|
|
issue1.save!
|
2020-03-13 15:44:24 +05:30
|
|
|
issue2.assignees << user2
|
2021-04-29 21:17:54 +05:30
|
|
|
issue2.save!
|
2020-03-13 15:44:24 +05:30
|
|
|
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
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|