summaryrefslogtreecommitdiff
path: root/spec/features/projects/files/user_find_file_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/projects/files/user_find_file_spec.rb')
-rw-r--r--spec/features/projects/files/user_find_file_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/features/projects/files/user_find_file_spec.rb b/spec/features/projects/files/user_find_file_spec.rb
index 1b53189da83..9cc2ce6a7b4 100644
--- a/spec/features/projects/files/user_find_file_spec.rb
+++ b/spec/features/projects/files/user_find_file_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'User find project file', feature_category: :projects do
+ include ListboxHelpers
+
let(:user) { create :user }
let(:project) { create :project, :repository }
@@ -21,6 +23,10 @@ RSpec.describe 'User find project file', feature_category: :projects do
fill_in 'file_find', with: text
end
+ def ref_selector_dropdown
+ find('.gl-button-text')
+ end
+
it 'navigates to find file by shortcut', :js do
find('body').native.send_key('t')
@@ -65,4 +71,39 @@ RSpec.describe 'User find project file', feature_category: :projects do
expect(page).not_to have_content('CHANGELOG')
expect(page).not_to have_content('VERSION')
end
+
+ 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
end