summaryrefslogtreecommitdiff
path: root/spec/features/groups/import_export
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-17 11:59:07 +0000
commit8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch)
tree544930fb309b30317ae9797a9683768705d664c4 /spec/features/groups/import_export
parent4b1de649d0168371549608993deac953eb692019 (diff)
downloadgitlab-ce-8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca.tar.gz
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/features/groups/import_export')
-rw-r--r--spec/features/groups/import_export/connect_instance_spec.rb88
-rw-r--r--spec/features/groups/import_export/import_file_spec.rb8
2 files changed, 92 insertions, 4 deletions
diff --git a/spec/features/groups/import_export/connect_instance_spec.rb b/spec/features/groups/import_export/connect_instance_spec.rb
new file mode 100644
index 00000000000..c0f967fd0b9
--- /dev/null
+++ b/spec/features/groups/import_export/connect_instance_spec.rb
@@ -0,0 +1,88 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Import/Export - Connect to another instance', :js do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:group) { create(:group) }
+
+ before_all do
+ group.add_owner(user)
+ end
+
+ before do
+ gitlab_sign_in(user)
+
+ visit new_group_path
+
+ find('#import-group-tab').click
+ end
+
+ context 'when the user provides valid credentials' do
+ it 'successfully connects to remote instance' do
+ source_url = 'https://gitlab.com'
+ pat = 'demo-pat'
+ stub_path = 'stub-group'
+
+ stub_request(:get, "%{url}/api/v4/groups?page=1&per_page=30&top_level_only=true" % { url: source_url }).to_return(
+ body: [{
+ id: 2595438,
+ web_url: 'https://gitlab.com/groups/auto-breakfast',
+ name: 'Stub',
+ path: stub_path,
+ full_name: 'Stub',
+ full_path: stub_path
+ }].to_json,
+ headers: { 'Content-Type' => 'application/json' }
+ )
+
+ expect(page).to have_content 'Import groups from another instance of GitLab'
+
+ fill_in :bulk_import_gitlab_url, with: source_url
+ fill_in :bulk_import_gitlab_access_token, with: pat
+
+ click_on 'Connect instance'
+
+ expect(page).to have_content 'Importing groups from %{url}' % { url: source_url }
+ expect(page).to have_content stub_path
+ end
+ end
+
+ context 'when the user provides invalid url' do
+ it 'reports an error' do
+ source_url = 'invalid-url'
+ pat = 'demo-pat'
+
+ fill_in :bulk_import_gitlab_url, with: source_url
+ fill_in :bulk_import_gitlab_access_token, with: pat
+
+ click_on 'Connect instance'
+
+ expect(page).to have_content 'Specified URL cannot be used'
+ end
+ end
+
+ context 'when the user does not fill in source URL' do
+ it 'reports an error' do
+ pat = 'demo-pat'
+
+ fill_in :bulk_import_gitlab_access_token, with: pat
+
+ click_on 'Connect instance'
+
+ expect(page).to have_content 'Please fill in GitLab source URL'
+ end
+ end
+
+ context 'when the user does not fill in access token' do
+ it 'reports an error' do
+ source_url = 'https://gitlab.com'
+
+ fill_in :bulk_import_gitlab_url, with: source_url
+
+ click_on 'Connect instance'
+
+ expect(page).to have_content 'Please fill in your personal access token'
+ end
+ end
+end
diff --git a/spec/features/groups/import_export/import_file_spec.rb b/spec/features/groups/import_export/import_file_spec.rb
index f117b5d56e9..7018f3b1086 100644
--- a/spec/features/groups/import_export/import_file_spec.rb
+++ b/spec/features/groups/import_export/import_file_spec.rb
@@ -32,12 +32,12 @@ RSpec.describe 'Import/Export - Group Import', :js do
fill_in :group_name, with: group_name
find('#import-group-tab').click
- expect(page).to have_content 'Import a GitLab group export file'
+ expect(page).to have_content 'Import group from file'
attach_file(file) do
find('.js-filepicker-button').click
end
- expect { click_on 'Import group' }.to change { Group.count }.by 1
+ expect { click_on 'Import' }.to change { Group.count }.by 1
group = Group.find_by(name: group_name)
@@ -60,7 +60,7 @@ RSpec.describe 'Import/Export - Group Import', :js do
find('.js-filepicker-button').click
end
- expect { click_on 'Import group' }.to change { Group.count }.by 1
+ expect { click_on 'Import' }.to change { Group.count }.by 1
group = Group.find_by(name: 'Test Group Import')
expect(group.path).to eq 'custom-path'
@@ -94,7 +94,7 @@ RSpec.describe 'Import/Export - Group Import', :js do
find('.js-filepicker-button').click
end
- expect { click_on 'Import group' }.not_to change { Group.count }
+ expect { click_on 'Import' }.not_to change { Group.count }
page.within('.flash-container') do
expect(page).to have_content('Unable to process group import file')