diff options
author | Ezekiel Kigbo <ekigbo@gitlab.com> | 2019-04-19 11:36:16 +0300 |
---|---|---|
committer | Ezekiel Kigbo <ekigbo@gitlab.com> | 2019-05-06 18:42:44 +0300 |
commit | 6accad69e214f44ac84f3ceac4159c712aa9af2e (patch) | |
tree | 5b07c67d5be2667a1187c13efb37424a6356af41 /spec/features | |
parent | b736a9f000d1e1f6c2c94ea74a700abf5a44139e (diff) |
Added blank lines to meet style guide
Un-nest title variable output
Update spec test names
Rename sort_value_most_stars -> sort_value_stars_desc
Rename sorted_by_stars -> sorted_by_stars_desc
Renname sort_value_most_stars_asc -> sort_value_stars_asc
Invert feature check, assign feature condition to a variable
Inline conditional nav bar rendering
Invert conditional label
Added follow up task
Fix filters returning 0 projects show the wrong view
Move click action out of test expectation
Use proper variable name for project in before block
Rename projects_sort_admin_options_hash
Renamed projects_sort_admin_options_has to
old_projects_sort_options_hash as its not only used
on the admin screen
Fix extra whitespace errors
Stub project_list_filter_bar in the projects_helper specs
Added follow up task for `show_projects?`
Removed url test expectations
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/dashboard/projects_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/dashboard/user_filters_projects_spec.rb | 93 |
2 files changed, 43 insertions, 51 deletions
diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 8b5f645b2b4..d1ed64cce7f 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -145,6 +145,7 @@ describe 'Dashboard Projects' do it 'does not show tabs to filter by all projects or personal' do visit(starred_dashboard_projects_path) + expect(page).not_to have_content '.filtered-search-nav' end end diff --git a/spec/features/dashboard/user_filters_projects_spec.rb b/spec/features/dashboard/user_filters_projects_spec.rb index 9945bf85997..e0553086fd7 100644 --- a/spec/features/dashboard/user_filters_projects_spec.rb +++ b/spec/features/dashboard/user_filters_projects_spec.rb @@ -53,7 +53,7 @@ describe 'Dashboard > User filters projects' do visit dashboard_projects_path end - it 'will autocomplete searches', :js do + it 'autocompletes searches upon typing', :js do expect(page).to have_content 'Victorialand' expect(page).to have_content 'Treasure' @@ -85,13 +85,12 @@ describe 'Dashboard > User filters projects' do end def expect_to_see_projects(sorted_projects) - click_sort_direction list = page.all('.projects-list .project-name').map(&:text) expect(list).to match(sorted_projects) end describe 'Search' do - it 'will execute when i click the search button' do + it 'executes when the search button is clicked' do expect(page).to have_content 'Victorialand' expect(page).to have_content 'Treasure' @@ -116,30 +115,37 @@ describe 'Dashboard > User filters projects' do describe 'Filter' do before do - priv = create(:project, :private, name: 'Private project', namespace: user.namespace) - int = create(:project, :internal, name: 'Internal project', namespace: user.namespace) + private_project = create(:project, :private, name: 'Private project', namespace: user.namespace) + internal_project = create(:project, :internal, name: 'Internal project', namespace: user.namespace) - priv.add_maintainer(user) - int.add_maintainer(user) + private_project.add_maintainer(user) + internal_project.add_maintainer(user) end - it 'can filter for only private projects' do + it 'filters private projects only' do select_dropdown_option '#filtered-search-visibility-dropdown', 'Private' + expect(current_url).to match(/visibility_level=0/) + list = page.all('.projects-list .project-name').map(&:text) + expect(list).to match(["Private project", "Treasure", "Victorialand"]) end - it 'can filter for only internal projects' do + it 'filters internal projects only' do select_dropdown_option '#filtered-search-visibility-dropdown', 'Internal' + expect(current_url).to match(/visibility_level=10/) + list = page.all('.projects-list .project-name').map(&:text) + expect(list).to match(['Internal project']) end - it 'can filter for any project' do + it 'filters any project' do select_dropdown_option '#filtered-search-visibility-dropdown', 'Any' list = page.all('.projects-list .project-name').map(&:text) + expect(list).to match(["Internal project", "Private project", "Treasure", "Victorialand"]) end end @@ -151,8 +157,8 @@ describe 'Dashboard > User filters projects' do { name: 'Cell saga', created_at: Time.now }, { name: 'Frieza saga', created_at: 10.days.ago } ].each do |item| - proj = create(:project, name: item[:name], namespace: user.namespace, created_at: item[:created_at]) - proj.add_developer(user) + project = create(:project, name: item[:name], namespace: user.namespace, created_at: item[:created_at]) + project.add_developer(user) end user.toggle_star(project) @@ -160,12 +166,13 @@ describe 'Dashboard > User filters projects' do user2.toggle_star(project2) end - it 'will include sorting direction' do + it 'includes sorting direction' do sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown') + expect(sorting_dropdown).to have_css '.reverse-sort-btn' end - it 'will have all sorting options', :js do + it 'has all sorting options', :js do sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown') sorting_option_labels = ['Last updated', 'Created date', 'Name', 'Stars'] @@ -176,7 +183,7 @@ describe 'Dashboard > User filters projects' do end end - it 'will default to Last updated', :js do + it 'defaults to "Last updated"', :js do page.find('.filtered-search-block #filtered-search-sorting-dropdown').click active_sorting_option = page.first('.filtered-search-block #filtered-search-sorting-dropdown .is-active') @@ -184,86 +191,70 @@ describe 'Dashboard > User filters projects' do end context 'Sorting by name' do - it 'will sort the project list' do + it 'sorts the project list' do select_dropdown_option '#filtered-search-sorting-dropdown', 'Name' desc = ['Victorialand', 'Treasure', 'Red ribbon army', 'Frieza saga', 'Cell saga'] asc = ['Cell saga', 'Frieza saga', 'Red ribbon army', 'Treasure', 'Victorialand'] + click_sort_direction + expect_to_see_projects(desc) - expect_to_see_projects(asc) - end - it 'will update the url query' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Name' + click_sort_direction - [/sort=name_desc/, /sort=name_asc/].each do |query_param| - click_sort_direction - expect(current_url).to match(query_param) - end + expect_to_see_projects(asc) end end context 'Sorting by Last updated' do - it 'will sort the project list' do + it 'sorts the project list' do select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated' desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"] asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"] + click_sort_direction + expect_to_see_projects(desc) - expect_to_see_projects(asc) - end - it 'will update the url query' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Last updated' + click_sort_direction - [/sort=latest_activity_asc/, /sort=latest_activity_desc/].each do |query_param| - click_sort_direction - expect(current_url).to match(query_param) - end + expect_to_see_projects(asc) end end context 'Sorting by Created date' do - it 'will sort the project list' do + it 'sorts the project list' do select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date' desc = ["Frieza saga", "Red ribbon army", "Victorialand", "Treasure", "Cell saga"] asc = ["Cell saga", "Treasure", "Victorialand", "Red ribbon army", "Frieza saga"] + click_sort_direction + expect_to_see_projects(desc) - expect_to_see_projects(asc) - end - it 'will update the url query' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date' + click_sort_direction - [/sort=created_asc/, /sort=created_desc/].each do |query_param| - click_sort_direction - expect(current_url).to match(query_param) - end + expect_to_see_projects(asc) end end context 'Sorting by Stars' do - it 'will sort the project list' do + it 'sorts the project list' do select_dropdown_option '#filtered-search-sorting-dropdown', 'Stars' desc = ["Red ribbon army", "Cell saga", "Frieza saga", "Victorialand", "Treasure"] asc = ["Treasure", "Victorialand", "Red ribbon army", "Cell saga", "Frieza saga"] + click_sort_direction + expect_to_see_projects(desc) - expect_to_see_projects(asc) - end - it 'will update the url query' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Stars' + click_sort_direction - [/sort=stars_asc/, /sort=stars_desc/].each do |query_param| - click_sort_direction - expect(current_url).to match(query_param) - end + expect_to_see_projects(asc) end end end |