diff options
Diffstat (limited to 'spec/features/dashboard')
22 files changed, 138 insertions, 271 deletions
diff --git a/spec/features/dashboard/activity_spec.rb b/spec/features/dashboard/activity_spec.rb index 7390edc3c47..b1734cb353b 100644 --- a/spec/features/dashboard/activity_spec.rb +++ b/spec/features/dashboard/activity_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > Activity' do +RSpec.describe 'Dashboard > Activity', feature_category: :users do let(:user) { create(:user) } before do diff --git a/spec/features/dashboard/archived_projects_spec.rb b/spec/features/dashboard/archived_projects_spec.rb index d157d44bab7..d3992d34506 100644 --- a/spec/features/dashboard/archived_projects_spec.rb +++ b/spec/features/dashboard/archived_projects_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Archived Project' do +RSpec.describe 'Dashboard Archived Project', feature_category: :projects do let(:user) { create :user } let(:project) { create :project } let(:archived_project) { create(:project, :archived) } diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb index de8858fa8fa..34f99765c29 100644 --- a/spec/features/dashboard/datetime_on_tooltips_spec.rb +++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Tooltips on .timeago dates', :js do +RSpec.describe 'Tooltips on .timeago dates', :js, feature_category: :users do let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, name: 'test', namespace: user.namespace) } diff --git a/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb b/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb index 6861fac3cc2..f5b02a87758 100644 --- a/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb +++ b/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'The group dashboard', :js do +RSpec.describe 'The group dashboard', :js, feature_category: :subgroups do include ExternalAuthorizationServiceHelpers include Spec::Support::Helpers::Features::TopNavSpecHelpers diff --git a/spec/features/dashboard/group_spec.rb b/spec/features/dashboard/group_spec.rb index f1283d29f4c..f363007f0d7 100644 --- a/spec/features/dashboard/group_spec.rb +++ b/spec/features/dashboard/group_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Group' do +RSpec.describe 'Dashboard Group', feature_category: :subgroups do before do sign_in(create(:user)) end diff --git a/spec/features/dashboard/groups_list_spec.rb b/spec/features/dashboard/groups_list_spec.rb index 3a4296836bd..b28e2ccf787 100644 --- a/spec/features/dashboard/groups_list_spec.rb +++ b/spec/features/dashboard/groups_list_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Groups page', :js do +RSpec.describe 'Dashboard Groups page', :js, feature_category: :subgroups do let(:user) { create :user } let(:group) { create(:group) } let(:nested_group) { create(:group, :nested) } diff --git a/spec/features/dashboard/issuables_counter_spec.rb b/spec/features/dashboard/issuables_counter_spec.rb index 91901414dde..5c7285f0491 100644 --- a/spec/features/dashboard/issuables_counter_spec.rb +++ b/spec/features/dashboard/issuables_counter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do +RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching, feature_category: :team_planning do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } let(:issue) { create(:issue, project: project) } @@ -12,6 +12,7 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching d issue.assignees = [user] merge_request.update!(assignees: [user]) sign_in(user) + stub_feature_flags(limit_assigned_issues_count: false) end it 'reflects dashboard issues count' do @@ -30,6 +31,28 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching d end end + context 'when :limit_assigned_issues_count FF is used' do + before do + stub_feature_flags(limit_assigned_issues_count: true) + end + + it 'reflects dashboard issues count' do + visit issues_path + + expect_counters('issues', '1', n_("%d assigned issue", "%d assigned issues", 1) % 1) + + issue.update!(assignees: []) + + Users::AssignedIssuesCountService.new(current_user: user).delete_cache + + travel_to(3.minutes.from_now) do + visit issues_path + + expect_counters('issues', '0', n_("%d assigned issue", "%d assigned issues", 0) % 0) + end + end + end + it 'reflects dashboard merge requests count', :js do visit merge_requests_path diff --git a/spec/features/dashboard/issues_filter_spec.rb b/spec/features/dashboard/issues_filter_spec.rb index 0d10aed955a..d5f362d8449 100644 --- a/spec/features/dashboard/issues_filter_spec.rb +++ b/spec/features/dashboard/issues_filter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Issues filtering', :js do +RSpec.describe 'Dashboard Issues filtering', :js, feature_category: :team_planning do include Spec::Support::Helpers::Features::SortingHelpers include FilteredSearchHelpers diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 64181041be5..d74965f58fa 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Issues' do +RSpec.describe 'Dashboard Issues', feature_category: :team_planning do include FilteredSearchHelpers let(:current_user) { create :user } diff --git a/spec/features/dashboard/label_filter_spec.rb b/spec/features/dashboard/label_filter_spec.rb index ebe5c3e1091..f116c84ff40 100644 --- a/spec/features/dashboard/label_filter_spec.rb +++ b/spec/features/dashboard/label_filter_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > label filter', :js do +RSpec.describe 'Dashboard > label filter', :js, feature_category: :team_planning do include FilteredSearchHelpers let(:filtered_search) { find('.filtered-search') } diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index 70f614cdcef..56d7c45de5d 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Merge Requests' do +RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review do include Spec::Support::Helpers::Features::SortingHelpers include FilteredSearchHelpers include ProjectForksHelper diff --git a/spec/features/dashboard/milestones_spec.rb b/spec/features/dashboard/milestones_spec.rb index 08cb95979ac..b4d0d9c5812 100644 --- a/spec/features/dashboard/milestones_spec.rb +++ b/spec/features/dashboard/milestones_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > Milestones' do +RSpec.describe 'Dashboard > Milestones', feature_category: :team_planning do describe 'as anonymous user' do before do visit dashboard_milestones_path diff --git a/spec/features/dashboard/project_member_activity_index_spec.rb b/spec/features/dashboard/project_member_activity_index_spec.rb index c26a1a0b486..5bf1566fa31 100644 --- a/spec/features/dashboard/project_member_activity_index_spec.rb +++ b/spec/features/dashboard/project_member_activity_index_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Project member activity', :js do +RSpec.describe 'Project member activity', :js, feature_category: :users do let(:user) { create(:user) } let(:project) { create(:project, :public, name: 'x', namespace: user.namespace) } diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index c132caa88c8..2b89f16bbff 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Projects' do +RSpec.describe 'Dashboard Projects', feature_category: :projects do let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, :repository) } let_it_be(:project2) { create(:project, :public) } @@ -101,14 +101,6 @@ RSpec.describe 'Dashboard Projects' do expect(first('.project-row')).to have_content(project_with_most_stars.title) end - - it 'shows tabs to filter by all projects or personal' do - visit dashboard_projects_path - segmented_button = page.find('.filtered-search-nav .button-filter-group') - - expect(segmented_button).to have_content 'All' - expect(segmented_button).to have_content 'Personal' - end end context 'when on Starred projects tab', :js do diff --git a/spec/features/dashboard/root_explore_spec.rb b/spec/features/dashboard/root_explore_spec.rb index a3c346ffe2a..c0d1f0de1f5 100644 --- a/spec/features/dashboard/root_explore_spec.rb +++ b/spec/features/dashboard/root_explore_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Root explore' do +RSpec.describe 'Root explore', feature_category: :not_owned do let_it_be(:public_project) { create(:project, :public) } let_it_be(:archived_project) { create(:project, :archived) } let_it_be(:internal_project) { create(:project, :internal) } @@ -30,4 +30,26 @@ RSpec.describe 'Root explore' do include_examples 'shows public projects' end + + describe 'project language dropdown' do + let(:has_language_dropdown?) { page.has_selector?('[data-testid="project-language-dropdown"]') } + + it 'is conditionally rendered' do + visit explore_projects_path + + expect(has_language_dropdown?).to eq(true) + end + + context 'with project_language_search ff disabled' do + before do + stub_feature_flags(project_language_search: false) + end + + it 'is conditionally rendered' do + visit explore_projects_path + + expect(has_language_dropdown?).to eq(false) + end + end + end end diff --git a/spec/features/dashboard/shortcuts_spec.rb b/spec/features/dashboard/shortcuts_spec.rb index 3f3ab4218f2..30587756505 100644 --- a/spec/features/dashboard/shortcuts_spec.rb +++ b/spec/features/dashboard/shortcuts_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard shortcuts', :js do +RSpec.describe 'Dashboard shortcuts', :js, feature_category: :not_owned do context 'logged in' do let(:user) { create(:user) } let(:project) { create(:project) } diff --git a/spec/features/dashboard/snippets_spec.rb b/spec/features/dashboard/snippets_spec.rb index f891950eeb8..ab2cfc0573e 100644 --- a/spec/features/dashboard/snippets_spec.rb +++ b/spec/features/dashboard/snippets_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard snippets' do +RSpec.describe 'Dashboard snippets', feature_category: :source_code_management do let_it_be(:user) { create(:user) } context 'when the project has snippets' do diff --git a/spec/features/dashboard/todos/target_state_spec.rb b/spec/features/dashboard/todos/target_state_spec.rb index b0aafdda59a..f8b525a63f1 100644 --- a/spec/features/dashboard/todos/target_state_spec.rb +++ b/spec/features/dashboard/todos/target_state_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > Todo target states' do +RSpec.describe 'Dashboard > Todo target states', feature_category: :team_planning do let_it_be(:user) { create(:user) } let_it_be(:author) { create(:user) } let_it_be(:project) { create(:project, :public) } diff --git a/spec/features/dashboard/todos/todos_filtering_spec.rb b/spec/features/dashboard/todos/todos_filtering_spec.rb index 938e42623f6..ea8c7e800c5 100644 --- a/spec/features/dashboard/todos/todos_filtering_spec.rb +++ b/spec/features/dashboard/todos/todos_filtering_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > User filters todos', :js do +RSpec.describe 'Dashboard > User filters todos', :js, feature_category: :team_planning do let(:user_1) { create(:user, username: 'user_1', name: 'user_1') } let(:user_2) { create(:user, username: 'user_2', name: 'user_2') } @@ -58,9 +58,9 @@ RSpec.describe 'Dashboard > User filters todos', :js do wait_for_requests - expect(page).to have_content "issue #{issue1.to_reference} \"issue\" at #{group1.name} / project_1" - expect(page).to have_content "merge request #{merge_request.to_reference}" - expect(page).not_to have_content "issue #{issue2.to_reference} \"issue\" at #{group2.name} / project_3" + expect(page).to have_content "issue · #{group1.name} / project_1 #{issue1.to_reference}" + expect(page).to have_content merge_request.to_reference.to_s + expect(page).not_to have_content "issue · #{group2.name} / project_3 #{issue2.to_reference}" end context 'Author filter' do @@ -74,8 +74,8 @@ RSpec.describe 'Dashboard > User filters todos', :js do wait_for_requests - expect(find('.todos-list')).to have_content 'merge request' - expect(find('.todos-list')).not_to have_content 'issue' + expect(find('.todos-list')).to have_content '!' + expect(find('.todos-list')).not_to have_content '#' end it 'shows only authors of existing todos' do @@ -174,11 +174,11 @@ RSpec.describe 'Dashboard > User filters todos', :js do def expect_to_see_action(action_name) action_names = { - assigned: ' assigned you ', - review_requested: ' requested a review of ', - mentioned: ' mentioned ', - marked: ' added a todo for ', - build_failed: ' pipeline failed in ' + assigned: ' assigned you', + review_requested: ' requested a review', + mentioned: ' mentioned', + marked: ' added a to-do item', + build_failed: ' pipeline failed' } action_name_text = action_names.delete(action_name) diff --git a/spec/features/dashboard/todos/todos_sorting_spec.rb b/spec/features/dashboard/todos/todos_sorting_spec.rb index a0fa53b761b..e449f71878b 100644 --- a/spec/features/dashboard/todos/todos_sorting_spec.rb +++ b/spec/features/dashboard/todos/todos_sorting_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > User sorts todos' do +RSpec.describe 'Dashboard > User sorts todos', feature_category: :team_planning do let(:user) { create(:user) } let(:project) { create(:project) } diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index e02cd182b2c..606bc82a7bb 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard Todos' do +RSpec.describe 'Dashboard Todos', feature_category: :team_planning do include DesignManagementTestHelpers let_it_be(:user) { create(:user, username: 'john') } @@ -49,29 +49,8 @@ RSpec.describe 'Dashboard Todos' do visit dashboard_todos_path end - it 'renders the mr link with the extra attributes' do - link = page.find_link(referenced_mr.to_reference) - - expect(link).not_to be_nil - expect(link['data-iid']).to eq(referenced_mr.iid.to_s) - expect(link['data-project-path']).to eq(referenced_mr.project.full_path) - expect(link['title']).to eq(referenced_mr.title) - expect(link['data-reference-type']).to eq('merge_request') - end - end - - context 'when todo references an issue of type task' do - let(:task) { create(:issue, :task, project: project) } - let!(:task_todo) { create(:todo, :mentioned, user: user, project: project, target: task, author: author) } - - before do - sign_in(user) - - visit dashboard_todos_path - end - - it 'displays the correct issue type name' do - expect(page).to have_content('mentioned you on task') + it 'renders the mr reference' do + expect(page).to have_content(referenced_mr.to_reference) end end @@ -100,10 +79,6 @@ RSpec.describe 'Dashboard Todos' do visit dashboard_todos_path end - it 'displays the correct issue type name' do - expect(page).to have_content('mentioned you on issue') - end - it 'has todo present' do expect(page).to have_selector('.todos-list .todo', count: 1) end @@ -117,7 +92,7 @@ RSpec.describe 'Dashboard Todos' do shared_examples 'deleting the todo' do before do within first('.todo') do - click_link 'Done' + find('[data-testid="check-icon"]').click end end @@ -143,9 +118,9 @@ RSpec.describe 'Dashboard Todos' do shared_examples 'deleting and restoring the todo' do before do within first('.todo') do - click_link 'Done' + find('[data-testid="check-icon"]').click wait_for_requests - click_link 'Undo' + find('[data-testid="redo-icon"]').click end end @@ -192,7 +167,8 @@ RSpec.describe 'Dashboard Todos' do it 'shows issue assigned to yourself message' do page.within('.js-todos-all') do - expect(page).to have_content("You assigned issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name} to yourself") + expect(page).to have_content("Fix bug · #{project.namespace.owner_name} / #{project.name} #{issue.to_reference}") + expect(page).to have_content("You assigned to yourself.") end end end @@ -203,10 +179,10 @@ RSpec.describe 'Dashboard Todos' do visit dashboard_todos_path end - it 'shows you added a todo message' do + it 'shows you added a to-do item message' do page.within('.js-todos-all') do - expect(page).to have_content("You added a todo for issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}") - expect(page).not_to have_content('to yourself') + expect(page).to have_content("Fix bug · #{project.namespace.owner_name} / #{project.name} #{issue.to_reference}") + expect(page).to have_content("You added a to-do item.") end end end @@ -219,8 +195,8 @@ RSpec.describe 'Dashboard Todos' do it 'shows you mentioned yourself message' do page.within('.js-todos-all') do - expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}") - expect(page).not_to have_content('to yourself') + expect(page).to have_content("Fix bug · #{project.namespace.owner_name} / #{project.name} #{issue.to_reference}") + expect(page).to have_content("You mentioned yourself.") end end end @@ -233,8 +209,8 @@ RSpec.describe 'Dashboard Todos' do it 'shows you directly addressed yourself message being displayed as mentioned yourself' do page.within('.js-todos-all') do - expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}") - expect(page).not_to have_content('to yourself') + expect(page).to have_content("Fix bug · #{project.namespace.owner_name} / #{project.name} #{issue.to_reference}") + expect(page).to have_content("You mentioned yourself.") end end end @@ -249,8 +225,8 @@ RSpec.describe 'Dashboard Todos' do it 'shows you set yourself as an approver message' do page.within('.js-todos-all') do - expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference} \"Fixes issue\" at #{project.namespace.owner_name} / #{project.name}") - expect(page).not_to have_content('to yourself') + expect(page).to have_content("Fixes issue · #{project.namespace.owner_name} / #{project.name} #{merge_request.to_reference}") + expect(page).to have_content("You set yourself as an approver.") end end end @@ -265,7 +241,28 @@ RSpec.describe 'Dashboard Todos' do it 'shows you set yourself as an reviewer message' do page.within('.js-todos-all') do - expect(page).to have_content("You requested a review of merge request #{merge_request.to_reference} \"Fixes issue\" at #{project.namespace.owner_name} / #{project.name} from yourself") + expect(page).to have_content("Fixes issue · #{project.namespace.owner_name} / #{project.name} #{merge_request.to_reference}") + expect(page).to have_content("You requested a review from yourself.") + end + end + end + end + + context 'User has automatically created todos' do + before do + sign_in(user) + end + + context 'unmergeable todo' do + before do + create(:todo, :unmergeable, user: user, project: project, target: issue, author: user) + visit dashboard_todos_path + end + + it 'shows unmergeable message' do + page.within('.js-todos-all') do + expect(page).to have_content("Fix bug · #{project.namespace.owner_name} / #{project.name} #{issue.to_reference}") + expect(page).to have_content("Could not merge.") end end end @@ -285,7 +282,7 @@ RSpec.describe 'Dashboard Todos' do describe 'restoring the todo' do before do within first('.todo') do - click_link 'Add a to do' + find('[data-testid="todo-add-icon"]').click end end @@ -391,7 +388,7 @@ RSpec.describe 'Dashboard Todos' do context 'User has deleted a todo' do before do within first('.todo') do - click_link 'Done' + find('[data-testid="check-icon"]').click end end @@ -420,13 +417,7 @@ RSpec.describe 'Dashboard Todos' do end it 'shows the todo' do - expect(page).to have_content 'The pipeline failed in merge request' - end - - it 'links to the pipelines for the merge request' do - href = pipelines_project_merge_request_path(project, todo.target) - - expect(page).to have_link "merge request #{todo.target.to_reference}", href: href + expect(page).to have_content 'The pipeline failed.' end end @@ -453,15 +444,29 @@ RSpec.describe 'Dashboard Todos' do it 'has todo present' do expect(page).to have_selector('.todos-list .todo', count: 1) end + end - it 'has a link that will take me to the design page' do - click_link "design #{target.to_reference}" + context 'User has a todo for an access requested raised for group membership' do + let_it_be(:group) { create(:group, :public) } - expectation = Gitlab::Routing.url_helpers.designs_project_issue_path( - target.project, target.issue, target.filename - ) + let_it_be(:todo) do + create(:todo, :member_access_requested, + user: user, + target: group, + author: author, + group: group) + end + + before do + group.add_owner(user) + sign_in(user) - expect(page).to have_current_path(expectation, ignore_query: true) + visit dashboard_todos_path + end + + it 'has todo present with access request content' do + expect(page).to have_selector('.todos-list .todo', count: 1) + expect(page).to have_content "#{author.name} has requested access to group #{group.name}" end end end diff --git a/spec/features/dashboard/user_filters_projects_spec.rb b/spec/features/dashboard/user_filters_projects_spec.rb index e25da5854ab..1168a6827fd 100644 --- a/spec/features/dashboard/user_filters_projects_spec.rb +++ b/spec/features/dashboard/user_filters_projects_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > User filters projects' do +RSpec.describe 'Dashboard > User filters projects', feature_category: :projects do let(:user) { create(:user) } let(:project) { create(:project, name: 'Victorialand', namespace: user.namespace, created_at: 2.seconds.ago, updated_at: 2.seconds.ago) } let(:user2) { create(:user) } @@ -16,7 +16,6 @@ RSpec.describe 'Dashboard > User filters projects' do describe 'filtering personal projects' do before do - stub_feature_flags(project_list_filter_bar: false) project2.add_developer(user) visit dashboard_projects_path @@ -33,7 +32,6 @@ RSpec.describe 'Dashboard > User filters projects' do describe 'filtering starred projects', :js do before do - stub_feature_flags(project_list_filter_bar: false) user.toggle_star(project) visit dashboard_projects_path @@ -49,8 +47,6 @@ RSpec.describe 'Dashboard > User filters projects' do describe 'without search bar', :js do before do - stub_feature_flags(project_list_filter_bar: false) - project2.add_developer(user) visit dashboard_projects_path end @@ -65,175 +61,4 @@ RSpec.describe 'Dashboard > User filters projects' do expect(page).not_to have_content 'Treasure' end end - - describe 'with search bar', :js do - before do - stub_feature_flags(project_list_filter_bar: true) - - project2.add_developer(user) - visit dashboard_projects_path - end - - # TODO: move these helpers somewhere more useful - def click_sort_direction - page.find('.filtered-search-block #filtered-search-sorting-dropdown .reverse-sort-btn').click - end - - def select_dropdown_option(selector, label, option_selector = '.dropdown-menu a') - dropdown = page.find(selector) - dropdown.click - - dropdown.find(option_selector, text: label, match: :first).click - end - - def expect_to_see_projects(sorted_projects) - list = page.all('.projects-list .project-name').map(&:text) - expect(list).to match(sorted_projects) - end - - describe 'Search' do - it 'executes when the search button is clicked' do - expect(page).to have_content 'Victorialand' - expect(page).to have_content 'Treasure' - - fill_in 'project-filter-form-field', with: 'Lord vegeta\n' - find('.filtered-search .btn').click - - expect(page).not_to have_content 'Victorialand' - expect(page).not_to have_content 'Treasure' - end - - it 'will execute when i press enter' do - expect(page).to have_content 'Victorialand' - expect(page).to have_content 'Treasure' - - fill_in 'project-filter-form-field', with: 'Lord frieza\n' - find('#project-filter-form-field').native.send_keys :enter - - expect(page).not_to have_content 'Victorialand' - expect(page).not_to have_content 'Treasure' - end - end - - describe 'Filter' do - before do - private_project = create(:project, :private, name: 'Private project', namespace: user.namespace) - internal_project = create(:project, :internal, name: 'Internal project', namespace: user.namespace) - - private_project.add_maintainer(user) - internal_project.add_maintainer(user) - end - - it 'filters private projects only' do - select_dropdown_option '#filtered-search-visibility-dropdown > .dropdown', 'Private', '.dropdown-item' - - expect(current_url).to match(/visibility_level=0/) - - list = page.all('.projects-list .project-name').map(&:text) - - expect(list).to contain_exactly("Private project", "Treasure", "Victorialand") - end - - it 'filters internal projects only' do - select_dropdown_option '#filtered-search-visibility-dropdown > .dropdown', 'Internal', '.dropdown-item' - - expect(current_url).to match(/visibility_level=10/) - - list = page.all('.projects-list .project-name').map(&:text) - - expect(list).to contain_exactly('Internal project') - end - - it 'filters any project' do - # Selecting the same option in the `GlListbox` does not emit `select` event - # and that is why URL update won't be triggered. Given that `Any` is a default option - # we need to explicitly switch from some other option (e.g. `Internal`) to `Any` - # to trigger the page update - select_dropdown_option '#filtered-search-visibility-dropdown > .dropdown', 'Internal', '.dropdown-item' - - select_dropdown_option '#filtered-search-visibility-dropdown > .dropdown', 'Any', '.dropdown-item' - - list = page.all('.projects-list .project-name').map(&:text) - - expect(list).to contain_exactly("Internal project", "Private project", "Treasure", "Victorialand") - end - end - - describe 'Sorting' do - let(:desc_sorted_project_names) { %w[Treasure Victorialand] } - - before do - user.toggle_star(project) - user.toggle_star(project2) - user2.toggle_star(project2) - end - - it 'has all sorting options', :js do - sorting_dropdown = page.find('.filtered-search-block #filtered-search-sorting-dropdown') - - expect(sorting_dropdown).to have_css '.reverse-sort-btn' - - sorting_dropdown.click - - ['Updated date', 'Created date', 'Name', 'Stars'].each do |label| - expect(sorting_dropdown).to have_content(label) - end - end - - it 'defaults to "Name"', :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') - - expect(active_sorting_option).to have_content 'Name' - end - - context 'Sorting by name' do - it 'sorts the project list' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Name' - - expect_to_see_projects(desc_sorted_project_names) - - click_sort_direction - - expect_to_see_projects(desc_sorted_project_names.reverse) - end - end - - context 'Sorting by Updated date' do - it 'sorts the project list' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Updated date' - - expect_to_see_projects(desc_sorted_project_names) - - click_sort_direction - - expect_to_see_projects(desc_sorted_project_names.reverse) - end - end - - context 'Sorting by Created date' do - it 'sorts the project list' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Created date' - - expect_to_see_projects(desc_sorted_project_names) - - click_sort_direction - - expect_to_see_projects(desc_sorted_project_names.reverse) - end - end - - context 'Sorting by Stars' do - it 'sorts the project list' do - select_dropdown_option '#filtered-search-sorting-dropdown', 'Stars' - - expect_to_see_projects(desc_sorted_project_names) - - click_sort_direction - - expect_to_see_projects(desc_sorted_project_names.reverse) - end - end - end - end end |