debian-mirror-gitlab/features/steps/project/source/browse_files.rb

436 lines
12 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
# coding: utf-8
2015-04-26 12:48:37 +05:30
class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include RepoHelpers
2017-09-10 17:25:29 +05:30
include WaitForRequests
2015-04-26 12:48:37 +05:30
step "I don't have write access" do
2017-08-17 22:00:37 +05:30
@project = create(:project, :repository, name: "Other Project", path: "other-project")
2018-03-17 18:26:18 +05:30
@project.add_reporter(@user)
2017-09-10 17:25:29 +05:30
visit project_tree_path(@project, root_ref)
end
2015-04-26 12:48:37 +05:30
step 'I should see files from repository' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "VERSION"
expect(page).to have_content ".gitignore"
expect(page).to have_content "LICENSE"
2015-04-26 12:48:37 +05:30
end
step 'I should see files from repository for "6d39438"' do
2017-09-10 17:25:29 +05:30
expect(current_path).to eq project_tree_path(@project, "6d39438")
2015-09-11 14:41:01 +05:30
expect(page).to have_content ".gitignore"
expect(page).to have_content "LICENSE"
2015-04-26 12:48:37 +05:30
end
step 'I see the ".gitignore"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content '.gitignore'
2015-04-26 12:48:37 +05:30
end
step 'I don\'t see the ".gitignore"' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content '.gitignore'
2015-04-26 12:48:37 +05:30
end
step 'I click on ".gitignore" file in repo' do
click_link ".gitignore"
end
step 'I should see its content' do
2017-09-10 17:25:29 +05:30
wait_for_requests
2015-09-11 14:41:01 +05:30
expect(page).to have_content old_gitignore_content
2015-04-26 12:48:37 +05:30
end
step 'I should see its new content' do
2017-09-10 17:25:29 +05:30
wait_for_requests
2015-09-11 14:41:01 +05:30
expect(page).to have_content new_gitignore_content
2015-04-26 12:48:37 +05:30
end
step 'I click link "Raw"' do
2017-08-17 22:00:37 +05:30
click_link 'Open raw'
2015-04-26 12:48:37 +05:30
end
step 'I should see raw file content' do
2016-04-02 18:10:28 +05:30
expect(source).to eq '' # Body is filled in by gitlab-workhorse
2015-04-26 12:48:37 +05:30
end
step 'I click button "Edit"' do
2017-08-17 22:00:37 +05:30
find('.js-edit-blob').click
2015-04-26 12:48:37 +05:30
end
step 'I cannot see the edit button' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_link 'edit'
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
step 'I click button "Fork"' do
click_link 'Fork'
end
2015-04-26 12:48:37 +05:30
step 'I edit code' do
2016-09-13 17:45:13 +05:30
expect(page).to have_selector('.file-editor')
2015-04-26 12:48:37 +05:30
set_new_content
end
step 'I fill the new file name' do
fill_in :file_name, with: new_file_name
end
step 'I fill the new branch name' do
2017-09-10 17:25:29 +05:30
fill_in :branch_name, with: 'new_branch_name', visible: true
2015-04-26 12:48:37 +05:30
end
2015-11-26 14:37:03 +05:30
step 'I fill the new file name with a new directory' do
fill_in :file_name, with: new_file_name_with_directory
end
2015-04-26 12:48:37 +05:30
step 'I fill the commit message' do
fill_in :commit_message, with: 'New commit message', visible: true
2015-04-26 12:48:37 +05:30
end
step 'I click link "Diff"' do
2017-08-17 22:00:37 +05:30
click_link 'Preview changes'
2015-04-26 12:48:37 +05:30
end
2017-08-17 22:00:37 +05:30
step 'I click on "Commit changes"' do
click_button 'Commit changes'
2015-04-26 12:48:37 +05:30
end
2016-11-03 12:29:30 +05:30
step 'I click on "Changes" tab' do
click_link 'Changes'
end
2015-10-24 18:46:33 +05:30
step 'I click on "Create directory"' do
click_button 'Create directory'
end
2015-11-26 14:37:03 +05:30
step 'I click on "Delete"' do
click_on 'Delete'
2015-04-26 12:48:37 +05:30
end
2015-11-26 14:37:03 +05:30
step 'I click on "Delete file"' do
click_button 'Delete file'
2015-04-26 12:48:37 +05:30
end
2015-09-25 12:07:36 +05:30
step 'I click on "Replace"' do
click_on "Replace"
2015-09-25 12:07:36 +05:30
end
step 'I click on "Replace file"' do
click_button 'Replace file'
end
2015-04-26 12:48:37 +05:30
step 'I see diff' do
2015-09-11 14:41:01 +05:30
expect(page).to have_css '.line_holder.new'
2015-04-26 12:48:37 +05:30
end
2015-10-24 18:46:33 +05:30
step 'I click on "New file" link in repo' do
find('.add-to-tree').click
click_link 'New file'
2016-09-13 17:45:13 +05:30
expect(page).to have_selector('.file-editor')
2015-04-26 12:48:37 +05:30
end
2015-10-24 18:46:33 +05:30
step 'I click on "Upload file" link in repo' do
find('.add-to-tree').click
click_link 'Upload file'
end
step 'I click on "New directory" link in repo' do
find('.add-to-tree').click
click_link 'New directory'
end
step 'I fill the new directory name' do
fill_in :dir_name, with: new_dir_name
2015-04-26 12:48:37 +05:30
end
2015-10-24 18:46:33 +05:30
step 'I fill an existing directory name' do
fill_in :dir_name, with: 'files'
2015-09-25 12:07:36 +05:30
end
2015-10-24 18:46:33 +05:30
step 'I can see new file page' do
2015-12-23 02:04:40 +05:30
expect(page).to have_content "New File"
2015-10-24 18:46:33 +05:30
expect(page).to have_content "Commit message"
2015-09-25 12:07:36 +05:30
end
step 'I click on "Upload file"' do
click_button 'Upload file'
end
step 'I can see the new commit message' do
expect(page).to have_content "New commit message"
2015-09-25 12:07:36 +05:30
end
step 'I upload a new text file' do
drop_in_dropzone test_text_file
end
step 'I fill the upload file commit message' do
page.within('#modal-upload-blob') do
fill_in :commit_message, with: 'New commit message'
2015-09-25 12:07:36 +05:30
end
end
step 'I replace it with a text file' do
drop_in_dropzone test_text_file
end
step 'I fill the replace file commit message' do
page.within('#modal-upload-blob') do
fill_in :commit_message, with: 'Replacement file commit message'
end
end
step 'I can see the replacement commit message' do
expect(page).to have_content "Replacement file commit message"
end
step 'I can see the new text file' do
expect(page).to have_content "Lorem ipsum dolor sit amet"
expect(page).to have_content "Sed ut perspiciatis unde omnis"
end
2015-04-26 12:48:37 +05:30
step 'I click on files directory' do
click_link 'files'
end
step 'I click on History link' do
click_link 'History'
end
step 'I see Browse dir link' do
2016-06-22 15:30:34 +05:30
expect(page).to have_link 'Browse Directory'
expect(page).not_to have_link 'Browse Code'
2015-04-26 12:48:37 +05:30
end
step 'I click on readme file' do
2015-09-11 14:41:01 +05:30
page.within '.tree-table' do
2015-04-26 12:48:37 +05:30
click_link 'README.md'
end
end
step 'I see Browse file link' do
2016-06-02 11:05:42 +05:30
expect(page).to have_link 'Browse File'
expect(page).not_to have_link 'Browse Files'
2015-04-26 12:48:37 +05:30
end
step 'I see Browse code link' do
2016-06-02 11:05:42 +05:30
expect(page).to have_link 'Browse Files'
2016-06-22 15:30:34 +05:30
expect(page).not_to have_link 'Browse Directory'
2015-04-26 12:48:37 +05:30
end
step 'I click on Permalink' do
click_link 'Permalink'
end
step 'I am redirected to the files URL' do
2017-09-10 17:25:29 +05:30
expect(current_path).to eq project_tree_path(@project, 'master')
2015-04-26 12:48:37 +05:30
end
step 'I am redirected to the ".gitignore"' do
2017-09-10 17:25:29 +05:30
expect(current_path).to eq(project_blob_path(@project, 'master/.gitignore'))
2015-04-26 12:48:37 +05:30
end
step 'I am redirected to the permalink URL' do
expect(current_path).to(
2017-09-10 17:25:29 +05:30
eq(project_blob_path(@project,
2015-04-26 12:48:37 +05:30
@project.repository.commit.sha +
'/.gitignore'))
)
end
step 'I am redirected to the new file' do
2015-12-23 02:04:40 +05:30
expect(current_path).to eq(
2017-09-10 17:25:29 +05:30
project_blob_path(@project, 'master/' + new_file_name))
2015-04-26 12:48:37 +05:30
end
2015-11-26 14:37:03 +05:30
step 'I am redirected to the new file with directory' do
2015-12-23 02:04:40 +05:30
expect(current_path).to eq(
2017-09-10 17:25:29 +05:30
project_blob_path(@project, 'master/' + new_file_name_with_directory))
2015-04-26 12:48:37 +05:30
end
2015-11-26 14:37:03 +05:30
step 'I am redirected to the new merge request page' do
2017-09-10 17:25:29 +05:30
expect(current_path).to eq(project_new_merge_request_path(@project))
2015-10-24 18:46:33 +05:30
end
step "I am redirected to the fork's new merge request page" do
fork = @user.fork_of(@project)
2017-09-10 17:25:29 +05:30
expect(current_path).to eq(project_new_merge_request_path(fork))
end
2015-10-24 18:46:33 +05:30
step 'I am redirected to the root directory' do
2015-12-23 02:04:40 +05:30
expect(current_path).to eq(
2017-09-10 17:25:29 +05:30
project_tree_path(@project, 'master'))
2015-10-24 18:46:33 +05:30
end
2015-04-26 12:48:37 +05:30
step "I don't see the permalink link" do
expect(page).not_to have_link('permalink')
end
2015-10-24 18:46:33 +05:30
step 'I see "Unable to create directory"' do
2017-08-17 22:00:37 +05:30
expect(page).to have_content('A directory with this name already exists')
end
step 'I see "Path can contain only..."' do
expect(page).to have_content('Path can contain only')
2015-10-24 18:46:33 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I see a commit error message' do
expect(page).to have_content('Your changes could not be committed')
end
2015-09-11 14:41:01 +05:30
step "I switch ref to 'test'" do
2016-06-22 15:30:34 +05:30
first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
2016-09-13 17:45:13 +05:30
click_link "'test'"
2016-06-22 15:30:34 +05:30
end
2015-09-11 14:41:01 +05:30
end
2015-10-24 18:46:33 +05:30
step "I switch ref to fix" do
2016-06-22 15:30:34 +05:30
first('.js-project-refs-dropdown').click
page.within '.project-refs-form' do
click_link 'fix'
end
2015-10-24 18:46:33 +05:30
end
2015-09-11 14:41:01 +05:30
step "I see the ref 'test' has been selected" do
2016-06-22 15:30:34 +05:30
expect(page).to have_selector '.dropdown-toggle-text', text: "'test'"
2015-09-11 14:41:01 +05:30
end
step "I visit the 'test' tree" do
2017-09-10 17:25:29 +05:30
visit project_tree_path(@project, "'test'")
2015-09-11 14:41:01 +05:30
end
2015-10-24 18:46:33 +05:30
step "I visit the fix tree" do
2017-09-10 17:25:29 +05:30
visit project_tree_path(@project, "fix/.testdir")
2015-10-24 18:46:33 +05:30
end
2015-09-11 14:41:01 +05:30
step 'I see the commit data' do
expect(page).to have_css('.tree-commit-link', visible: true)
expect(page).not_to have_content('Loading commit data...')
end
2015-10-24 18:46:33 +05:30
step 'I see the commit data for a directory with a leading dot' do
expect(page).to have_css('.tree-commit-link', visible: true)
expect(page).not_to have_content('Loading commit data...')
end
2015-12-23 02:04:40 +05:30
step 'I click on "files/lfs/lfs_object.iso" file in repo' do
2017-08-17 22:00:37 +05:30
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
2017-09-10 17:25:29 +05:30
visit project_tree_path(@project, "lfs")
2015-12-23 02:04:40 +05:30
click_link 'files'
click_link "lfs"
click_link "lfs_object.iso"
end
step 'I should see download link and object size' do
expect(page).to have_content 'Download (1.5 MB)'
end
step 'I should not see lfs pointer details' do
expect(page).not_to have_content 'version https://git-lfs.github.com/spec/v1'
expect(page).not_to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
expect(page).not_to have_content 'size 1575078'
end
step 'I should see buttons for allowed commands' do
page.within '.content' do
2017-08-17 22:00:37 +05:30
expect(page).to have_link 'Download'
expect(page).to have_content 'History'
expect(page).to have_content 'Permalink'
expect(page).not_to have_content 'Edit'
expect(page).not_to have_content 'Blame'
expect(page).to have_content 'Delete'
expect(page).to have_content 'Replace'
end
end
2017-08-17 22:00:37 +05:30
step 'I should see a Fork/Cancel combo' do
expect(page).to have_link 'Fork'
expect(page).to have_button 'Cancel'
end
step 'I should see a notice about a new fork having been created' do
expect(page).to have_content "You're not allowed to make changes to this project directly. A fork of this project has been created that you can make changes in, so you can submit a merge request."
2015-12-23 02:04:40 +05:30
end
2016-04-02 18:10:28 +05:30
# SVG files
step 'I upload a new SVG file' do
drop_in_dropzone test_svg_file
end
step 'I visit the SVG file' do
2017-09-10 17:25:29 +05:30
visit project_blob_path(@project, 'new_branch_name/logo_sample.svg')
2016-04-02 18:10:28 +05:30
end
step 'I can see the new rendered SVG image' do
2016-06-02 11:05:42 +05:30
expect(page).to have_css('.file-content img')
2016-04-02 18:10:28 +05:30
end
2015-04-26 12:48:37 +05:30
private
def set_new_content
2018-03-17 18:26:18 +05:30
find('#editor')
2016-09-13 17:45:13 +05:30
execute_script("ace.edit('editor').setValue('#{new_gitignore_content}')")
2015-04-26 12:48:37 +05:30
end
# Content of the gitignore file on the seed repository.
def old_gitignore_content
'*.rbc'
end
# Constant value that differs from the content
# of the gitignore of the seed repository.
def new_gitignore_content
old_gitignore_content + 'a'
end
# Constant value that is a valid filename and
# not a filename present at root of the seed repository.
def new_file_name
'not_a_file.md'
end
2015-09-25 12:07:36 +05:30
2015-11-26 14:37:03 +05:30
# Constant value that is a valid filename with directory and
# not a filename present at root of the seed repository.
def new_file_name_with_directory
'foo/bar/baz.txt'
end
2015-10-24 18:46:33 +05:30
# Constant value that is a valid directory and
# not a directory present at root of the seed repository.
def new_dir_name
'new_dir/subdir'
end
2015-09-25 12:07:36 +05:30
def drop_in_dropzone(file_path)
# Generate a fake input selector
page.execute_script <<-JS
var fakeFileInput = window.$('<input/>').attr(
{id: 'fakeFileInput', type: 'file'}
).appendTo('body');
JS
# Attach the file to the fake input selector with Capybara
attach_file("fakeFileInput", file_path)
# Add the file to a fileList array and trigger the fake drop event
page.execute_script <<-JS
var fileList = [$('#fakeFileInput')[0].files[0]];
var e = jQuery.Event('drop', { dataTransfer : { files : fileList } });
$('.dropzone')[0].dropzone.listeners[0].events.drop(e);
JS
end
def test_text_file
File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt')
end
def test_image_file
File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
end
2016-04-02 18:10:28 +05:30
def test_svg_file
File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg')
end
2015-04-26 12:48:37 +05:30
end