Commit bce037cf authored by Andrejs Cunskis's avatar Andrejs Cunskis

Add group bulk import spec

Data fabrication

Use non admin user for group import test

Clean up user

Full flow of bulk import test

Explicitly fail via rspec expectation instead of generic retry error

Fix prettier formatting

Enable and disable bulk import for test

Add retrier for user removal

Validate group has been imported

Fix return value in doc
parent 0fac8411
...@@ -242,7 +242,7 @@ export default { ...@@ -242,7 +242,7 @@ export default {
:description="s__('Check your source instance permissions.')" :description="s__('Check your source instance permissions.')"
/> />
<template v-else> <template v-else>
<table class="gl-w-full"> <table class="gl-w-full" data-qa-selector="import_group_table">
<thead class="gl-border-solid gl-border-gray-200 gl-border-0 gl-border-b-1"> <thead class="gl-border-solid gl-border-gray-200 gl-border-0 gl-border-b-1">
<th class="gl-py-4 import-jobs-from-col">{{ s__('BulkImport|From source group') }}</th> <th class="gl-py-4 import-jobs-from-col">{{ s__('BulkImport|From source group') }}</th>
<th class="gl-py-4 import-jobs-to-col">{{ s__('BulkImport|To new group') }}</th> <th class="gl-py-4 import-jobs-to-col">{{ s__('BulkImport|To new group') }}</th>
......
...@@ -119,7 +119,10 @@ export default { ...@@ -119,7 +119,10 @@ export default {
</script> </script>
<template> <template>
<tr class="gl-border-gray-200 gl-border-0 gl-border-b-1 gl-border-solid"> <tr
class="gl-border-gray-200 gl-border-0 gl-border-b-1 gl-border-solid"
data-qa-selector="import_item"
>
<td class="gl-p-4"> <td class="gl-p-4">
<gl-link <gl-link
:href="group.web_url" :href="group.web_url"
...@@ -150,6 +153,7 @@ export default { ...@@ -150,6 +153,7 @@ export default {
:disabled="isAlreadyImported" :disabled="isAlreadyImported"
toggle-class="gl-rounded-top-right-none! gl-rounded-bottom-right-none!" toggle-class="gl-rounded-top-right-none! gl-rounded-bottom-right-none!"
class="import-entities-namespace-dropdown gl-h-7 gl-flex-fill-1" class="import-entities-namespace-dropdown gl-h-7 gl-flex-fill-1"
data-qa-selector="target_namespace_selector_dropdown"
> >
<gl-dropdown-item @click="$emit('update-target-namespace', '')">{{ <gl-dropdown-item @click="$emit('update-target-namespace', '')">{{
s__('BulkImport|No parent') s__('BulkImport|No parent')
...@@ -192,7 +196,7 @@ export default { ...@@ -192,7 +196,7 @@ export default {
</div> </div>
</div> </div>
</td> </td>
<td class="gl-p-4 gl-white-space-nowrap"> <td class="gl-p-4 gl-white-space-nowrap" data-qa-selector="import_status_indicator">
<import-status :status="group.progress.status" class="gl-mt-2" /> <import-status :status="group.progress.status" class="gl-mt-2" />
</td> </td>
<td class="gl-p-4"> <td class="gl-p-4">
...@@ -201,6 +205,7 @@ export default { ...@@ -201,6 +205,7 @@ export default {
:disabled="isInvalid" :disabled="isInvalid"
variant="confirm" variant="confirm"
category="secondary" category="secondary"
data-qa-selector="import_group_button"
@click="$emit('import-group')" @click="$emit('import-group')"
>{{ __('Import') }}</gl-button >{{ __('Import') }}</gl-button
> >
......
...@@ -225,6 +225,7 @@ module QA ...@@ -225,6 +225,7 @@ module QA
autoload :Show, 'qa/page/group/show' autoload :Show, 'qa/page/group/show'
autoload :Menu, 'qa/page/group/menu' autoload :Menu, 'qa/page/group/menu'
autoload :Members, 'qa/page/group/members' autoload :Members, 'qa/page/group/members'
autoload :BulkImport, 'qa/page/group/bulk_import'
module Milestone module Milestone
autoload :Index, 'qa/page/group/milestone/index' autoload :Index, 'qa/page/group/milestone/index'
......
# frozen_string_literal: true
module QA
module Page
module Group
class BulkImport < Page::Base
view "app/assets/javascripts/import_entities/import_groups/components/import_table.vue" do
element :import_group_table
end
view "app/assets/javascripts/import_entities/import_groups/components/import_table_row.vue" do
element :import_item
element :target_namespace_selector_dropdown
element :import_status_indicator
element :import_group_button
end
# Wait until list of groups has been loaded
#
# @return [void]
def wait_for_groups_to_load
has_element?(:import_group_table)
end
# Import source group in to target group
#
# @param [String] source_group_name
# @param [String] target_group_name
# @return [Boolean]
def import_group(source_group_name, target_group_name)
source_group = all_elements(:import_item, minimum: 1).detect { |el| el.has_text?(source_group_name) }
raise("Import entry for #{source_group_name} not found!") unless source_group
within(source_group) do
click_element(:target_namespace_selector_dropdown)
find_button(target_group_name).click
click_element(:import_group_button)
wait_until(sleep_interval: 0.5, reload: false, raise_on_failure: false) do
find_element(:import_status_indicator).text == "Complete"
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
RSpec.describe "Manage", :requires_admin do
describe "Group bulk import" do
let!(:api_client) { Runtime::API::Client.as_admin }
let!(:user) { Resource::User.fabricate_via_api! { |usr| usr.api_client = api_client } }
let!(:personal_access_token) { Runtime::API::Client.new(user: user).personal_access_token }
let(:source_group) do
Resource::Sandbox.fabricate_via_api! do |group|
group.api_client = api_client
group.path = "source-group-for-import-#{SecureRandom.hex(4)}"
end
end
let(:target_group) do
Resource::Sandbox.fabricate_via_api! do |group|
group.api_client = api_client
group.path = "target-group-for-import-#{SecureRandom.hex(4)}"
end
end
let(:imported_group) do
Resource::Group.fabricate_via_api! do |group|
group.api_client = api_client
group.sandbox = target_group
group.path = source_group.path
end
end
before do
Runtime::Feature.enable(:bulk_import)
source_group.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
target_group.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
Flow::Login.sign_in(as: user)
Page::Main::Menu.new.go_to_import_group
Page::Group::New.new.connect_gitlab_instance(Runtime::Scenario.gitlab_address, personal_access_token)
end
it "performs bulk group import from another gitlab instance" do
import = Page::Group::BulkImport.perform do |import_page|
import_page.wait_for_groups_to_load
import_page.import_group(source_group.path, target_group.path)
end
aggregate_failures do
expect(import).to be_truthy, "Group bulk import did not finish successfully"
expect(imported_group.path).to eq(source_group.path)
end
end
after do
Runtime::Feature.disable(:bulk_import)
source_group&.remove_via_api!
target_group&.remove_via_api!
# Imported group might not be immediately removed and 'user' is sole maintainer, so remove might fail
QA::Support::Retrier.retry_on_exception do
user&.remove_via_api!
end
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