2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-06 06:59:48 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Import multiple repositories by uploading a manifest file', :js do
|
2018-07-06 06:59:48 -04:00
|
|
|
include Select2Helper
|
|
|
|
|
|
|
|
let(:user) { create(:admin) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
|
|
|
|
2018-07-06 08:06:44 -04:00
|
|
|
it 'parses manifest file and list repositories' do
|
2018-07-06 06:59:48 -04:00
|
|
|
visit new_import_manifest_path
|
|
|
|
|
|
|
|
attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
|
2018-07-09 03:55:10 -04:00
|
|
|
click_on 'List available repositories'
|
2018-07-06 06:59:48 -04:00
|
|
|
|
2020-09-09 08:08:22 -04:00
|
|
|
expect(page).to have_button('Import 660 repositories')
|
2018-07-06 06:59:48 -04:00
|
|
|
expect(page).to have_content('https://android-review.googlesource.com/platform/build/blueprint')
|
|
|
|
end
|
2018-07-06 08:06:44 -04:00
|
|
|
|
2020-08-18 20:10:34 -04:00
|
|
|
it 'imports a project successfully', :sidekiq_inline, :js do
|
2018-07-06 08:06:44 -04:00
|
|
|
visit new_import_manifest_path
|
|
|
|
|
|
|
|
attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
|
2018-07-09 03:55:10 -04:00
|
|
|
click_on 'List available repositories'
|
2018-07-06 08:06:44 -04:00
|
|
|
|
2020-01-08 07:07:59 -05:00
|
|
|
page.within(second_row) do
|
2018-07-06 08:06:44 -04:00
|
|
|
click_on 'Import'
|
2020-08-18 20:10:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
2018-07-06 08:06:44 -04:00
|
|
|
|
2020-08-18 20:10:34 -04:00
|
|
|
page.within(second_row) do
|
2018-07-06 08:06:44 -04:00
|
|
|
expect(page).to have_content 'Done'
|
2020-01-08 07:07:59 -05:00
|
|
|
expect(page).to have_content("#{group.full_path}/build/blueprint")
|
2018-07-06 08:06:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-07-09 07:59:07 -04: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 07:07:59 -05:00
|
|
|
def second_row
|
2020-08-18 20:10:34 -04:00
|
|
|
page.all('table.import-table tbody tr')[1]
|
2018-07-06 08:06:44 -04:00
|
|
|
end
|
2018-07-06 06:59:48 -04:00
|
|
|
end
|