diff options
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 | 88 |
1 files changed, 41 insertions, 47 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 69f62a4c1e2..d7b52d9e07a 100644 --- a/spec/features/search/user_searches_for_merge_requests_spec.rb +++ b/spec/features/search/user_searches_for_merge_requests_spec.rb @@ -3,12 +3,10 @@ require 'spec_helper' RSpec.describe 'User searches for merge requests', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - using RSpec::Parameterized::TableSyntax - - let(:user) { create(:user) } - let(:project) { create(:project, namespace: user.namespace) } - 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) } + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, namespace: user.namespace) } + let_it_be(:merge_request1) { create(:merge_request, title: 'Merge Request Foo', source_project: project, target_project: project, created_at: 1.hour.ago) } + let_it_be(: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) @@ -16,64 +14,60 @@ RSpec.describe 'User searches for merge requests', :js, :clean_gitlab_redis_rate select_search_scope('Merge requests') end - where(search_page_vertical_nav_enabled: [true, false]) - with_them do - before do - stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled) - sign_in(user) + before do + sign_in(user) - visit(search_path) - end + visit(search_path) + end - include_examples 'top right search form' - include_examples 'search timeouts', 'merge_requests' + include_examples 'top right search form' + include_examples 'search timeouts', 'merge_requests' - it 'finds a merge request' do - search_for_mr(merge_request1.title) + it 'finds a merge request' do + search_for_mr(merge_request1.title) - page.within('.results') do - expect(page).to have_link(merge_request1.title) - expect(page).not_to have_link(merge_request2.title) + page.within('.results') do + expect(page).to have_link(merge_request1.title) + expect(page).not_to have_link(merge_request2.title) - # Each result should have MR refs like `gitlab-org/gitlab!1` - page.all('.search-result-row').each do |e| - expect(e.text).to match(/!\d+/) - end + # Each result should have MR refs like `gitlab-org/gitlab!1` + page.all('.search-result-row').each do |e| + expect(e.text).to match(/!\d+/) end end + end - it 'sorts by created date' do - search_for_mr('Merge Request') + 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 + 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 + 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 + 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 + context 'when on a project page' do + it 'finds a merge request' do + find('[data-testid="project-filter"]').click - wait_for_requests + wait_for_requests - page.within('[data-testid="project-filter"]') do - click_on(project.name) - end + page.within('[data-testid="project-filter"]') do + click_on(project.name) + end - search_for_mr(merge_request1.title) + search_for_mr(merge_request1.title) - page.within('.results') do - expect(page).to have_link(merge_request1.title) - expect(page).not_to have_link(merge_request2.title) - end + page.within('.results') do + expect(page).to have_link(merge_request1.title) + expect(page).not_to have_link(merge_request2.title) end end end |