Skip to content
Snippets Groups Projects
Commit be14be4e authored by Eduardo Sanz-Garcia's avatar Eduardo Sanz-Garcia
Browse files

Merge branch '390531-follow-up-from-migrate-import-from-a-project-dropdown-2' into 'master'

parents 0ba8de32 c0f82c6f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,7 +2,7 @@
import { GlFormGroup, GlModal, GlSprintf } from '@gitlab/ui';
import { uniqueId } from 'lodash';
import { importProjectMembers } from '~/api/projects_api';
import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import { BV_SHOW_MODAL, BV_HIDE_MODAL } from '~/lib/utils/constants';
import { s__, __, sprintf } from '~/locale';
import eventHub from '../event_hub';
import {
Loading
Loading
@@ -81,11 +81,17 @@ export default {
openModal() {
this.$root.$emit(BV_SHOW_MODAL, this.$options.modalId);
},
closeModal() {
this.$root.$emit(BV_HIDE_MODAL, this.$options.modalId);
},
resetFields() {
this.invalidFeedbackMessage = '';
this.projectToBeImported = {};
},
submitImport() {
submitImport(e) {
// We never want to hide when submitting
e.preventDefault();
this.isLoading = true;
return importProjectMembers(this.projectId, this.projectToBeImported.id)
.then(this.onInviteSuccess)
Loading
Loading
import { GlFormGroup, GlSprintf, GlModal } from '@gitlab/ui';
import MockAdapter from 'axios-mock-adapter';
import { nextTick } from 'vue';
import { createWrapper } from '@vue/test-utils';
import { BV_HIDE_MODAL } from '~/lib/utils/constants';
import { stubComponent } from 'helpers/stub_component';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import waitForPromises from 'helpers/wait_for_promises';
Loading
Loading
@@ -107,6 +109,15 @@ describe('ImportProjectMembersModal', () => {
});
 
describe('submitting the import', () => {
it('prevents closing', () => {
const evt = { preventDefault: jest.fn() };
createComponent();
findGlModal().vm.$emit('primary', evt);
expect(evt.preventDefault).toHaveBeenCalledTimes(1);
});
describe('when the import is successful with reloadPageOnSubmit', () => {
beforeEach(() => {
createComponent({
Loading
Loading
@@ -161,6 +172,12 @@ describe('ImportProjectMembersModal', () => {
);
});
 
it('hides the modal', () => {
const rootWrapper = createWrapper(wrapper.vm.$root);
expect(rootWrapper.emitted(BV_HIDE_MODAL)).toHaveLength(1);
});
it('does not call displaySuccessfulInvitationAlert on mount', () => {
expect(displaySuccessfulInvitationAlert).not.toHaveBeenCalled();
});
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment