From 8ad7cb7788b964a7c9e4ca11c4308e0bbc1d4bbc Mon Sep 17 00:00:00 2001 From: Semyon Pupkov Date: Tue, 24 Apr 2018 09:20:11 +0000 Subject: [PATCH] Replace find file project spinach tests with RSpec --- features/project/find_file.feature | 42 ----------- features/steps/project/project_find_file.rb | 72 ------------------- features/steps/shared/paths.rb | 4 -- .../projects/files/user_find_file_spec.rb | 66 +++++++++++++++++ 4 files changed, 66 insertions(+), 118 deletions(-) delete mode 100644 features/project/find_file.feature delete mode 100644 features/steps/project/project_find_file.rb create mode 100644 spec/features/projects/files/user_find_file_spec.rb diff --git a/features/project/find_file.feature b/features/project/find_file.feature deleted file mode 100644 index ae8fa245923..00000000000 --- a/features/project/find_file.feature +++ /dev/null @@ -1,42 +0,0 @@ -@dashboard -Feature: Project Find File - Background: - Given I sign in as a user - And I own a project - And I visit my project's files page - - @javascript - Scenario: Navigate to find file by shortcut - Given I press "t" - Then I should see "find file" page - - Scenario: Navigate to find file - Given I click Find File button - Then I should see "find file" page - - @javascript - Scenario: I search file - Given I visit project find file page - And I fill in file find with "change" - Then I should not see ".gitignore" in files - And I should not see ".gitmodules" in files - And I should see "CHANGELOG" in files - And I should not see "VERSION" in files - - @javascript - Scenario: I search file that not exist - Given I visit project find file page - And I fill in file find with "asdfghjklqwertyuizxcvbnm" - Then I should not see ".gitignore" in files - And I should not see ".gitmodules" in files - And I should not see "CHANGELOG" in files - And I should not see "VERSION" in files - - @javascript - Scenario: I search file that partially matches - Given I visit project find file page - And I fill in file find with "git" - Then I should see ".gitignore" in files - And I should see ".gitmodules" in files - And I should not see "CHANGELOG" in files - And I should not see "VERSION" in files diff --git a/features/steps/project/project_find_file.rb b/features/steps/project/project_find_file.rb deleted file mode 100644 index 461160b8430..00000000000 --- a/features/steps/project/project_find_file.rb +++ /dev/null @@ -1,72 +0,0 @@ -class Spinach::Features::ProjectFindFile < Spinach::FeatureSteps - include SharedAuthentication - include SharedPaths - include SharedProject - include SharedProjectTab - - step 'I press "t"' do - find('body').native.send_key('t') - end - - step 'I click Find File button' do - click_link 'Find file' - end - - step 'I should see "find file" page' do - ensure_active_main_tab('Repository') - expect(page).to have_selector('.file-finder-holder', count: 1) - end - - step 'I fill in Find by path with "git"' do - ensure_active_main_tab('Repository') - expect(page).to have_selector('.file-finder-holder', count: 1) - end - - step 'I fill in file find with "git"' do - find_file "git" - end - - step 'I fill in file find with "change"' do - find_file "change" - end - - step 'I fill in file find with "asdfghjklqwertyuizxcvbnm"' do - find_file "asdfghjklqwertyuizxcvbnm" - end - - step 'I should see "VERSION" in files' do - expect(page).to have_content("VERSION") - end - - step 'I should not see "VERSION" in files' do - expect(page).not_to have_content("VERSION") - end - - step 'I should see "CHANGELOG" in files' do - expect(page).to have_content("CHANGELOG") - end - - step 'I should not see "CHANGELOG" in files' do - expect(page).not_to have_content("CHANGELOG") - end - - step 'I should see ".gitmodules" in files' do - expect(page).to have_content(".gitmodules") - end - - step 'I should not see ".gitmodules" in files' do - expect(page).not_to have_content(".gitmodules") - end - - step 'I should see ".gitignore" in files' do - expect(page).to have_content(".gitignore") - end - - step 'I should not see ".gitignore" in files' do - expect(page).not_to have_content(".gitignore") - end - - def find_file(text) - fill_in 'file_find', with: text - end -end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index d16c127f6e6..014e6ad625b 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -200,10 +200,6 @@ module SharedPaths visit edit_project_path(@project) end - step "I visit my project's files page" do - visit project_tree_path(@project, root_ref) - end - step 'I visit a binary file in the repo' do visit project_blob_path(@project, File.join(root_ref, 'files/images/logo-black.png')) diff --git a/spec/features/projects/files/user_find_file_spec.rb b/spec/features/projects/files/user_find_file_spec.rb new file mode 100644 index 00000000000..df405e70dd4 --- /dev/null +++ b/spec/features/projects/files/user_find_file_spec.rb @@ -0,0 +1,66 @@ +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_master(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