2019-07-25 05:24:42 +00:00
# frozen_string_literal: true
2018-04-03 10:27:56 +00:00
require " spec_helper "
# The main goal of this spec is not to check whether the sorting UI works, but
# to check if the sorting option set by user is being kept persisted while going through pages.
# The `it`s are named here by convention `starting point -> some pages -> final point`.
# All those specs are moved out to this spec intentionally to keep them all in one place.
2022-03-09 12:07:06 +00:00
RSpec . describe " User sorts things " , :js do
2018-04-03 10:27:56 +00:00
include Spec :: Support :: Helpers :: Features :: SortingHelpers
2018-11-09 18:54:19 +00:00
include DashboardHelper
2018-04-03 10:27:56 +00:00
2020-02-26 18:09:24 +00:00
let_it_be ( :project ) { create ( :project_empty_repo , :public ) }
let_it_be ( :current_user ) { create ( :user ) } # Using `current_user` instead of just `user` because of the hardoced call in `assigned_mrs_dashboard_path` which is used below.
let_it_be ( :issue ) { create ( :issue , project : project , author : current_user ) }
let_it_be ( :merge_request ) { create ( :merge_request , target_project : project , source_project : project , author : current_user ) }
2018-04-03 10:27:56 +00:00
before do
project . add_developer ( current_user )
sign_in ( current_user )
end
it " issues -> project home page -> issues " do
2022-03-09 12:07:06 +00:00
sort_option = s_ ( 'SortOptions|Updated date' )
2018-04-03 10:27:56 +00:00
visit ( project_issues_path ( project ) )
2022-03-09 12:07:06 +00:00
pajamas_sort_by ( sort_option )
2018-04-03 10:27:56 +00:00
visit ( project_path ( project ) )
visit ( project_issues_path ( project ) )
expect ( find ( " .issues-filters " ) ) . to have_content ( sort_option )
end
it " merge requests -> dashboard merge requests " do
2022-03-09 12:07:06 +00:00
sort_option = s_ ( 'SortOptions|Updated date' )
2018-04-03 10:27:56 +00:00
visit ( project_merge_requests_path ( project ) )
2022-03-09 12:07:06 +00:00
pajamas_sort_by ( sort_option )
2018-04-03 10:27:56 +00:00
visit ( assigned_mrs_dashboard_path )
expect ( find ( " .issues-filters " ) ) . to have_content ( sort_option )
end
end