Commit b5f2a7e1 authored by James Lopez's avatar James Lopez

fixed integration test

parent 07ab6c2e
...@@ -6,14 +6,19 @@ feature 'project import', feature: true, js: true do ...@@ -6,14 +6,19 @@ feature 'project import', feature: true, js: true do
let(:user) { create(:admin) } let(:user) { create(:admin) }
let!(:namespace) { create(:namespace, name: "asd", owner: user) } let!(:namespace) { create(:namespace, name: "asd", owner: user) }
let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') } let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
let(:export_path) { "#{Dir::tmpdir}/import_file_spec" }
background do background do
export_path = "#{Dir::tmpdir}/import_file_spec"
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
login_as(user) login_as(user)
end end
after(:each) do
FileUtils.rm_rf(export_path, secure: true)
end
scenario 'user imports an exported project successfully' do scenario 'user imports an exported project successfully' do
expect(Project.all.count).to be_zero
visit new_project_path visit new_project_path
select2('2', from: '#project_namespace_id') select2('2', from: '#project_namespace_id')
...@@ -22,29 +27,13 @@ feature 'project import', feature: true, js: true do ...@@ -22,29 +27,13 @@ feature 'project import', feature: true, js: true do
expect(page).to have_content('GitLab export file') expect(page).to have_content('GitLab export file')
expect(URI.parse(current_url).query).to eq('namespace_id=2&path=test-project-path') expect(URI.parse(current_url).query).to eq('namespace_id=2&path=test-project-path')
attach_file('file', file)
#TODO check timings
sleep 1 attach_file('file', file)
click_on 'Continue to the next step' click_on 'Continue to the next step' # import starts
end
def drop_in_dropzone(file_path) expect(Project.last).not_to be_nil
# Generate a fake input selector expect(Project.last.issues).not_to be_empty
page.execute_script <<-JS expect(Project.last.repo_exists?).to be true
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 } });
$('.div-dropzone')[0].dropzone.listeners[0].events.drop(e);
JS
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment