diff --git a/app/assets/javascripts/groups/components/transfer_group_form.vue b/app/assets/javascripts/groups/components/transfer_group_form.vue index 2d0d6b41c99d156557e8f19beff4dd556d982b2c..fd3c4d5fc8ae90074aac85922f997edf43a48830 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 161a8a7a203707807cb4d0f1739761dcf36c4448..30a813335476f3dd46487186f776de383c15f885 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)