Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_searches_for_commits_spec.rb « search « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e5d86c2794207784dfaee13178cbdf6c9ee8017e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'User searches for commits', :js, :clean_gitlab_redis_rate_limiting do
  using RSpec::Parameterized::TableSyntax

  let_it_be(:user) { create(:user) }

  let(:project) { create(:project, :repository) }
  let(:sha) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }

  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)
      project.add_reporter(user)
      sign_in(user)

      visit(search_path(project_id: project.id))
    end

    include_examples 'search timeouts', 'commits' do
      let(:additional_params) { { project_id: project.id } }
    end

    context 'when searching by SHA' do
      it 'finds a commit and redirects to its page' do
        submit_search(sha)

        expect(page).to have_current_path(project_commit_path(project, sha))
      end

      it 'finds a commit in uppercase and redirects to its page' do
        submit_search(sha.upcase)

        expect(page).to have_current_path(project_commit_path(project, sha))
      end
    end

    context 'when searching by message' do
      it 'finds a commit and holds on /search page' do
        project.repository.commit_files(
          user,
          message: 'Message referencing another sha: "deadbeef"',
          branch_name: 'master',
          actions: [{ action: :create, file_path: 'a/new.file', contents: 'new file' }]
        )

        submit_search('deadbeef')

        expect(page).to have_current_path('/search', ignore_query: true)
      end

      it 'finds multiple commits' do
        submit_search('See merge request')
        select_search_scope('Commits')

        expect(page).to have_selector('.commit-row-description', visible: false, count: 9)
      end
    end
  end
end