2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-06 10:59:48 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Import multiple repositories by uploading a manifest file', :js do
|
2018-07-06 10:59:48 +00:00
|
|
|
include Select2Helper
|
|
|
|
|
|
|
|
let(:user) { create(:admin) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
|
|
|
|
2018-07-06 12:06:44 +00:00
|
|
|
it 'parses manifest file and list repositories' do
|
2018-07-06 10:59:48 +00:00
|
|
|
visit new_import_manifest_path
|
|
|
|
|
|
|
|
attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
|
2018-07-09 07:55:10 +00:00
|
|
|
click_on 'List available repositories'
|
2018-07-06 10:59:48 +00:00
|
|
|
|
2020-09-09 12:08:22 +00:00
|
|
|
expect(page).to have_button('Import 660 repositories')
|
2018-07-06 10:59:48 +00:00
|
|
|
expect(page).to have_content('https://android-review.googlesource.com/platform/build/blueprint')
|
|
|
|
end
|
2018-07-06 12:06:44 +00:00
|
|
|
|
2020-08-19 00:10:34 +00:00
|
|
|
it 'imports a project successfully', :sidekiq_inline, :js do
|
2018-07-06 12:06:44 +00:00
|
|
|
visit new_import_manifest_path
|
|
|
|
|
|
|
|
attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
|
2018-07-09 07:55:10 +00:00
|
|
|
click_on 'List available repositories'
|
2018-07-06 12:06:44 +00:00
|
|
|
|
2020-01-08 12:07:59 +00:00
|
|
|
page.within(second_row) do
|
2018-07-06 12:06:44 +00:00
|
|
|
click_on 'Import'
|
2020-08-19 00:10:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
2018-07-06 12:06:44 +00:00
|
|
|
|
2020-08-19 00:10:34 +00:00
|
|
|
page.within(second_row) do
|
2021-03-16 09:11:17 +00:00
|
|
|
expect(page).to have_content 'Complete'
|
2020-01-08 12:07:59 +00:00
|
|
|
expect(page).to have_content("#{group.full_path}/build/blueprint")
|
2018-07-06 12:06:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-03-24 09:09:10 +00:00
|
|
|
it 'renders an error if the remote url scheme starts with javascript' do
|
|
|
|
visit new_import_manifest_path
|
|
|
|
|
|
|
|
attach_file('manifest', Rails.root.join('spec/fixtures/unsafe_javascript.xml'))
|
|
|
|
click_on 'List available repositories'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Make sure the url does not start with javascript'
|
|
|
|
end
|
|
|
|
|
2018-07-09 11:59:07 +00:00
|
|
|
it 'renders an error if invalid file was provided' do
|
|
|
|
visit new_import_manifest_path
|
|
|
|
|
|
|
|
attach_file('manifest', Rails.root.join('spec/fixtures/banana_sample.gif'))
|
|
|
|
click_on 'List available repositories'
|
|
|
|
|
|
|
|
expect(page).to have_content 'The uploaded file is not a valid XML file.'
|
|
|
|
end
|
|
|
|
|
2020-01-08 12:07:59 +00:00
|
|
|
def second_row
|
2021-02-16 15:09:50 +00:00
|
|
|
page.all('table tbody tr')[1]
|
2018-07-06 12:06:44 +00:00
|
|
|
end
|
2018-07-06 10:59:48 +00:00
|
|
|
end
|