diff options
Diffstat (limited to 'spec/frontend/invite_members')
3 files changed, 34 insertions, 37 deletions
diff --git a/spec/frontend/invite_members/components/import_project_members_modal_spec.js b/spec/frontend/invite_members/components/import_project_members_modal_spec.js index b4d42d90d99..8b2d13be309 100644 --- a/spec/frontend/invite_members/components/import_project_members_modal_spec.js +++ b/spec/frontend/invite_members/components/import_project_members_modal_spec.js @@ -53,7 +53,7 @@ afterEach(() => { describe('ImportProjectMembersModal', () => { const findGlModal = () => wrapper.findComponent(GlModal); - const findIntroText = () => wrapper.find({ ref: 'modalIntro' }).text(); + const findIntroText = () => wrapper.findComponent({ ref: 'modalIntro' }).text(); const clickImportButton = () => findGlModal().vm.$emit('primary', { preventDefault: jest.fn() }); const closeModal = () => findGlModal().vm.$emit('hidden', { preventDefault: jest.fn() }); const findFormGroup = () => wrapper.findByTestId('form-group'); diff --git a/spec/frontend/invite_members/components/invite_members_modal_spec.js b/spec/frontend/invite_members/components/invite_members_modal_spec.js index 2058784b033..e9e1fbad07b 100644 --- a/spec/frontend/invite_members/components/invite_members_modal_spec.js +++ b/spec/frontend/invite_members/components/invite_members_modal_spec.js @@ -19,6 +19,7 @@ import { MEMBERS_TO_PROJECT_CELEBRATE_INTRO_TEXT, LEARN_GITLAB, EXPANDED_ERRORS, + EMPTY_INVITES_ERROR_TEXT, } from '~/invite_members/constants'; import eventHub from '~/invite_members/event_hub'; import ContentTransition from '~/vue_shared/components/content_transition.vue'; @@ -255,6 +256,8 @@ describe('InviteMembersModal', () => { it('tracks the submit for invite_members_for_task', async () => { await setupComponentWithTasks(); + await triggerMembersTokenSelect([user1]); + clickInviteButton(); expect(ExperimentTracking).toHaveBeenCalledWith(INVITE_MEMBERS_FOR_TASK.name, { @@ -265,6 +268,16 @@ describe('InviteMembersModal', () => { INVITE_MEMBERS_FOR_TASK.submit, ); }); + + it('does not track the submit for invite_members_for_task when invites have not been entered', async () => { + await setupComponentWithTasks(); + clickInviteButton(); + + expect(ExperimentTracking).not.toHaveBeenCalledWith( + INVITE_MEMBERS_FOR_TASK.name, + expect.any, + ); + }); }); }); @@ -380,6 +393,25 @@ describe('InviteMembersModal', () => { "The member's email address is not allowed for this project. Go to the Admin area > Sign-up restrictions, and check Allowed domains for sign-ups."; const expectedSyntaxError = 'email contains an invalid email address'; + describe('when no invites have been entered in the form and then some are entered', () => { + beforeEach(async () => { + createInviteMembersToGroupWrapper(); + }); + + it('displays an error', async () => { + clickInviteButton(); + + await waitForPromises(); + + expect(membersFormGroupInvalidFeedback()).toBe(EMPTY_INVITES_ERROR_TEXT); + expect(findMembersSelect().props('exceptionState')).toBe(false); + + await triggerMembersTokenSelect([user1]); + + expect(membersFormGroupInvalidFeedback()).toBe(''); + }); + }); + describe('when inviting an existing user to group by user ID', () => { const postData = { user_id: '1,2', diff --git a/spec/frontend/invite_members/components/user_limit_notification_spec.js b/spec/frontend/invite_members/components/user_limit_notification_spec.js index 543fc28a342..1ff2e86412f 100644 --- a/spec/frontend/invite_members/components/user_limit_notification_spec.js +++ b/spec/frontend/invite_members/components/user_limit_notification_spec.js @@ -1,12 +1,7 @@ import { GlAlert, GlSprintf } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import UserLimitNotification from '~/invite_members/components/user_limit_notification.vue'; - -import { - REACHED_LIMIT_MESSAGE, - REACHED_LIMIT_UPGRADE_SUGGESTION_MESSAGE, -} from '~/invite_members/constants'; - +import { REACHED_LIMIT_UPGRADE_SUGGESTION_MESSAGE } from '~/invite_members/constants'; import { freeUsersLimit, membersCount } from '../mock_data/member_modal'; const WARNING_ALERT_TITLE = 'You only have space for 2 more members in name'; @@ -52,22 +47,6 @@ describe('UserLimitNotification', () => { }); }); - describe('when close to limit within a personal namepace', () => { - beforeEach(() => { - createComponent(true, false, { membersCount: 3, userNamespace: true }); - }); - - it('renders the limit for a personal namespace', () => { - const alert = findAlert(); - - expect(alert.attributes('title')).toEqual(WARNING_ALERT_TITLE); - - expect(alert.text()).toEqual( - 'To make more space, you can remove members who no longer need access.', - ); - }); - }); - describe('when close to limit within a group', () => { it("renders user's limit notification", () => { createComponent(true, false, { membersCount: 3 }); @@ -91,19 +70,5 @@ describe('UserLimitNotification', () => { expect(alert.attributes('title')).toEqual("You've reached your 5 members limit for name"); expect(alert.text()).toEqual(REACHED_LIMIT_UPGRADE_SUGGESTION_MESSAGE); }); - - describe('when free user namespace', () => { - it("renders user's limit notification", () => { - createComponent(true, true, { userNamespace: true }); - - const alert = findAlert(); - - expect(alert.attributes('title')).toEqual( - "You've reached your 5 members limit for your personal projects", - ); - - expect(alert.text()).toEqual(REACHED_LIMIT_MESSAGE); - }); - }); }); }); |