summaryrefslogtreecommitdiff
path: root/spec/features/projects/files/user_find_file_spec.rb
blob: 72f6ccb20d696508676df9b879946870a5c91d05 (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
64
65
66
67
68
# frozen_string_literal: true

require 'spec_helper'

describe 'User find project file' do
  let(:user)    { create :user }
  let(:project) { create :project, :repository }

  before do
    sign_in(user)
    project.add_maintainer(user)

    visit project_tree_path(project, project.repository.root_ref)
  end

  def active_main_tab
    find('.sidebar-top-level-items > li.active')
  end

  def find_file(text)
    fill_in 'file_find', with: text
  end

  it 'navigates to find file by shortcut', :js do
    find('body').native.send_key('t')

    expect(active_main_tab).to have_content('Repository')
    expect(page).to have_selector('.file-finder-holder', count: 1)
  end

  it 'navigates to find file' do
    click_link 'Find file'

    expect(active_main_tab).to have_content('Repository')
    expect(page).to have_selector('.file-finder-holder', count: 1)
  end

  it 'searches CHANGELOG file', :js do
    click_link 'Find file'

    find_file 'change'

    expect(page).to have_content('CHANGELOG')
    expect(page).not_to have_content('.gitignore')
    expect(page).not_to have_content('VERSION')
  end

  it 'does not find file when search not exist file', :js do
    click_link 'Find file'

    find_file 'asdfghjklqwertyuizxcvbnm'

    expect(page).not_to have_content('CHANGELOG')
    expect(page).not_to have_content('.gitignore')
    expect(page).not_to have_content('VERSION')
  end

  it 'searches file by partially matches', :js do
    click_link 'Find file'

    find_file 'git'

    expect(page).to have_content('.gitignore')
    expect(page).to have_content('.gitmodules')
    expect(page).not_to have_content('CHANGELOG')
    expect(page).not_to have_content('VERSION')
  end
end