diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/features/search/user_searches_for_merge_requests_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/features/search/user_searches_for_merge_requests_spec.rb')
-rw-r--r-- | spec/features/search/user_searches_for_merge_requests_spec.rb | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/spec/features/search/user_searches_for_merge_requests_spec.rb b/spec/features/search/user_searches_for_merge_requests_spec.rb index 21e8075739f..7271716644b 100644 --- a/spec/features/search/user_searches_for_merge_requests_spec.rb +++ b/spec/features/search/user_searches_for_merge_requests_spec.rb @@ -5,8 +5,14 @@ require 'spec_helper' RSpec.describe 'User searches for merge requests', :js do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } - let!(:merge_request1) { create(:merge_request, title: 'Foo', source_project: project, target_project: project) } - let!(:merge_request2) { create(:merge_request, :simple, title: 'Bar', source_project: project, target_project: project) } + let!(:merge_request1) { create(:merge_request, title: 'Merge Request Foo', source_project: project, target_project: project, created_at: 1.hour.ago) } + let!(:merge_request2) { create(:merge_request, :simple, title: 'Merge Request Bar', source_project: project, target_project: project) } + + def search_for_mr(search) + fill_in('dashboard_search', with: search) + find('.btn-search').click + select_search_scope('Merge requests') + end before do project.add_maintainer(user) @@ -18,9 +24,7 @@ RSpec.describe 'User searches for merge requests', :js do include_examples 'top right search form' it 'finds a merge request' do - fill_in('dashboard_search', with: merge_request1.title) - find('.btn-search').click - select_search_scope('Merge requests') + search_for_mr(merge_request1.title) page.within('.results') do expect(page).to have_link(merge_request1.title) @@ -28,6 +32,22 @@ RSpec.describe 'User searches for merge requests', :js do end end + it 'sorts by created date' do + search_for_mr('Merge Request') + + page.within('.results') do + expect(page.all('.search-result-row').first).to have_link(merge_request2.title) + expect(page.all('.search-result-row').last).to have_link(merge_request1.title) + end + + find('[data-testid="sort-highest-icon"]').click + + page.within('.results') do + expect(page.all('.search-result-row').first).to have_link(merge_request1.title) + expect(page.all('.search-result-row').last).to have_link(merge_request2.title) + end + end + context 'when on a project page' do it 'finds a merge request' do find('[data-testid="project-filter"]').click @@ -38,9 +58,7 @@ RSpec.describe 'User searches for merge requests', :js do click_on(project.full_name) end - fill_in('dashboard_search', with: merge_request1.title) - find('.btn-search').click - select_search_scope('Merge requests') + search_for_mr(merge_request1.title) page.within('.results') do expect(page).to have_link(merge_request1.title) |