2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'User find project file', feature_category: :projects do
|
2023-04-23 21:23:45 +05:30
|
|
|
include ListboxHelpers
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:user) { create :user }
|
|
|
|
let(:project) { create :project, :repository }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-10-15 14:42:47 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
def ref_selector_dropdown
|
|
|
|
find('.gl-button-text')
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
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
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
context 'when refs are switched', :js do
|
|
|
|
before do
|
|
|
|
click_link 'Find file'
|
|
|
|
end
|
|
|
|
|
|
|
|
specify 'the ref switcher lists all the branches and tags' do
|
|
|
|
ref = 'add-ipython-files'
|
|
|
|
expect(ref_selector_dropdown).not_to have_text(ref)
|
|
|
|
|
|
|
|
find('.ref-selector').click
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within('.ref-selector') do
|
|
|
|
expect(page).to have_selector('li', text: ref)
|
|
|
|
expect(page).to have_selector('li', text: 'v1.0.0')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
specify 'the search result changes when refs switched' do
|
|
|
|
ref = 'add-ipython-files'
|
|
|
|
expect(ref_selector_dropdown).not_to have_text(ref)
|
|
|
|
|
|
|
|
find('.ref-selector button').click
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within('.ref-selector') do
|
|
|
|
fill_in _('Switch branch/tag'), with: ref
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
select_listbox_item(ref)
|
|
|
|
end
|
|
|
|
expect(ref_selector_dropdown).to have_text(ref)
|
|
|
|
end
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|