diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-24 03:07:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-24 03:07:14 +0300 |
commit | c4e4f0d16733caba766d9c1ae3b4b9a3f0bfb0ca (patch) | |
tree | 6008465efc7b0ef017dd04afeddcfd23ee84999c /spec/features/search | |
parent | 08a284ca5e259f685b32ae255e42c7307891aed1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/search')
-rw-r--r-- | spec/features/search/user_searches_for_code_spec.rb | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/spec/features/search/user_searches_for_code_spec.rb b/spec/features/search/user_searches_for_code_spec.rb index 14d67bac85f..dd7095107f4 100644 --- a/spec/features/search/user_searches_for_code_spec.rb +++ b/spec/features/search/user_searches_for_code_spec.rb @@ -17,20 +17,24 @@ RSpec.describe 'User searches for code', :js, :disable_rate_limiter, feature_cat sign_in(user) end - it 'finds a file' do - visit(project_path(project)) + context 'when on a project page' do + before do + visit(project_path(project)) + end - submit_search('application.js') - select_search_scope('Code') + it 'finds a file' do + submit_search('application.js') + select_search_scope('Code') - expect(page).to have_selector('.results', text: 'application.js') - expect(page).to have_selector('.file-content .code') - expect(page).to have_selector("span.line[lang='javascript']") - expect(page).to have_link('application.js', href: %r{master/files/js/application.js}) - expect(page).to have_button('Copy file path') + expect(page).to have_selector('.results', text: 'application.js') + expect(page).to have_selector('.file-content .code') + expect(page).to have_selector("span.line[lang='javascript']") + expect(page).to have_link('application.js', href: %r{master/files/js/application.js}) + expect(page).to have_button('Copy file path') + end end - context 'when on a project page' do + context 'when on a project search page' do before do visit(search_path) find('[data-testid="project-filter"]').click @@ -47,28 +51,31 @@ RSpec.describe 'User searches for code', :js, :disable_rate_limiter, feature_cat let(:additional_params) { { project_id: project.id } } end - it 'finds code and links to blob' do - expected_result = 'Update capybara, rspec-rails, poltergeist to recent versions' - - fill_in('dashboard_search', with: 'rspec') - find('.gl-search-box-by-click-search-button').click + context 'when searching code' do + let(:expected_result) { 'Update capybara, rspec-rails, poltergeist to recent versions' } - expect(page).to have_selector('.results', text: expected_result) + before do + fill_in('dashboard_search', with: 'rspec') + find('.gl-search-box-by-click-search-button').click + end - find("#blob-L3").click - expect(current_url).to match(%r{blob/master/.gitignore#L3}) - end + it 'finds code and links to blob' do + expect(page).to have_selector('.results', text: expected_result) - it 'finds code and links to blame' do - expected_result = 'Update capybara, rspec-rails, poltergeist to recent versions' + find("#blob-L3").click + expect(current_url).to match(%r{blob/master/.gitignore#L3}) + end - fill_in('dashboard_search', with: 'rspec') - find('.gl-search-box-by-click-search-button').click + it 'finds code and links to blame' do + expect(page).to have_selector('.results', text: expected_result) - expect(page).to have_selector('.results', text: expected_result) + find("#blame-L3").click + expect(current_url).to match(%r{blame/master/.gitignore#L3}) + end - find("#blame-L3").click - expect(current_url).to match(%r{blame/master/.gitignore#L3}) + it_behaves_like 'code highlight' do + subject { page } + end end it 'search multiple words with refs switching' do |