From cd2c72622f6730f32264d7e7c55a1d4a60543e56 Mon Sep 17 00:00:00 2001 From: Ezekiel Kigbo <ekigbo@gitlab.com> Date: Wed, 9 Feb 2022 09:06:29 +0000 Subject: [PATCH] Add feature spec for group transfer settings Updates the group settings spec to include tests for transferring a subgroup or a root level group to another namespace --- .../groups/components/transfer_group_form.vue | 1 + spec/features/groups/group_settings_spec.rb | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/app/assets/javascripts/groups/components/transfer_group_form.vue b/app/assets/javascripts/groups/components/transfer_group_form.vue index 2d0d6b41c99d..fd3c4d5fc8ae 100644 --- a/app/assets/javascripts/groups/components/transfer_group_form.vue +++ b/app/assets/javascripts/groups/components/transfer_group_form.vue @@ -64,6 +64,7 @@ export default { :empty-namespace-title="$options.i18n.emptyNamespaceTitle" :include-headers="false" include-empty-namespace + data-testid="transfer-group-namespace-select" @select="handleSelected" /> <input type="hidden" name="new_parent_group_id" :value="selectedId" /> diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb index 161a8a7a2037..30a813335476 100644 --- a/spec/features/groups/group_settings_spec.rb +++ b/spec/features/groups/group_settings_spec.rb @@ -138,6 +138,51 @@ end end + describe 'transfer group', :js do + let(:namespace_select) { page.find('[data-testid="transfer-group-namespace-select"]') } + let(:confirm_modal) { page.find('[data-testid="confirm-danger-modal"]') } + + shared_examples 'can transfer the group' do + before do + selected_group.add_owner(user) + end + + it 'can successfully transfer the group' do + visit edit_group_path(selected_group) + + page.within('.js-group-transfer-form') do + namespace_select.find('button').click + namespace_select.find('.dropdown-menu p', text: target_group_name, match: :first).click + + click_button "Transfer group" + end + + page.within(confirm_modal) do + expect(page).to have_text "You are going to transfer #{selected_group.name} to another namespace. Are you ABSOLUTELY sure? " + + fill_in "confirm_name_input", with: selected_group.name + click_button "Confirm" + end + + expect(page).to have_text "Group '#{selected_group.name}' was successfully transferred." + end + end + + context 'with a sub group' do + let(:selected_group) { create(:group, path: 'foo-subgroup', parent: group) } + let(:target_group_name) { "No parent group" } + + it_behaves_like 'can transfer the group' + end + + context 'with a root group' do + let(:selected_group) { create(:group, path: 'foo-rootgroup') } + let(:target_group_name) { group.name } + + it_behaves_like 'can transfer the group' + end + end + context 'disable email notifications' do it 'is visible' do visit edit_group_path(group) -- GitLab