diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/frontend/invite_members/components | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/frontend/invite_members/components')
3 files changed, 71 insertions, 7 deletions
diff --git a/spec/frontend/invite_members/components/invite_members_trigger_spec.js b/spec/frontend/invite_members/components/invite_members_trigger_spec.js index 28402c8331c..c522abe63c5 100644 --- a/spec/frontend/invite_members/components/invite_members_trigger_spec.js +++ b/spec/frontend/invite_members/components/invite_members_trigger_spec.js @@ -2,7 +2,11 @@ import { GlButton, GlLink, GlIcon } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import InviteMembersTrigger from '~/invite_members/components/invite_members_trigger.vue'; import eventHub from '~/invite_members/event_hub'; -import { TRIGGER_ELEMENT_BUTTON, TRIGGER_ELEMENT_SIDE_NAV } from '~/invite_members/constants'; +import { + TRIGGER_ELEMENT_BUTTON, + TRIGGER_ELEMENT_SIDE_NAV, + TRIGGER_DEFAULT_QA_SELECTOR, +} from '~/invite_members/constants'; jest.mock('~/experimentation/experiment_tracking'); @@ -50,12 +54,24 @@ describe.each(triggerItems)('with triggerElement as %s', (triggerItem) => { wrapper.destroy(); }); - describe('displayText', () => { + describe('configurable attributes', () => { it('includes the correct displayText for the button', () => { createComponent(); expect(findButton().text()).toBe(displayText); }); + + it('uses the default qa selector value', () => { + createComponent(); + + expect(findButton().attributes('data-qa-selector')).toBe(TRIGGER_DEFAULT_QA_SELECTOR); + }); + + it('sets the qa selector value', () => { + createComponent({ qaSelector: '_qaSelector_' }); + + expect(findButton().attributes('data-qa-selector')).toBe('_qaSelector_'); + }); }); describe('clicking the link', () => { diff --git a/spec/frontend/invite_members/components/invite_modal_base_spec.js b/spec/frontend/invite_members/components/invite_modal_base_spec.js index 010f7b999fc..cc19e90a5fa 100644 --- a/spec/frontend/invite_members/components/invite_modal_base_spec.js +++ b/spec/frontend/invite_members/components/invite_modal_base_spec.js @@ -200,6 +200,30 @@ describe('InviteModalBase', () => { }); }); + describe('when user limit is close on a personal namespace', () => { + beforeEach(() => { + createComponent( + { + closeToLimit: true, + reachedLimit: false, + usersLimitDataset: { membersPath, userNamespace: true }, + }, + { GlModal, GlFormGroup }, + ); + }); + + it('renders correct buttons', () => { + const cancelButton = findCancelButton(); + const actionButton = findActionButton(); + + expect(cancelButton.text()).toBe(INVITE_BUTTON_TEXT_DISABLED); + expect(cancelButton.attributes('href')).toBe(membersPath); + + expect(actionButton.text()).toBe(INVITE_BUTTON_TEXT); + expect(actionButton.attributes('href')).toBe(); // default submit button + }); + }); + describe('when users limit is not reached', () => { const textRegex = /Select a role.+Read more about role permissions Access expiration date \(optional\)/; 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 4c9adbfcc44..bbc17932a49 100644 --- a/spec/frontend/invite_members/components/user_limit_notification_spec.js +++ b/spec/frontend/invite_members/components/user_limit_notification_spec.js @@ -14,9 +14,15 @@ describe('UserLimitNotification', () => { const findAlert = () => wrapper.findComponent(GlAlert); - const createComponent = (reachedLimit = false, usersLimitDataset = {}) => { + const createComponent = ( + closeToLimit = false, + reachedLimit = false, + usersLimitDataset = {}, + props = {}, + ) => { wrapper = shallowMountExtended(UserLimitNotification, { propsData: { + closeToLimit, reachedLimit, usersLimitDataset: { freeUsersLimit, @@ -25,6 +31,7 @@ describe('UserLimitNotification', () => { purchasePath: 'purchasePath', ...usersLimitDataset, }, + ...props, }, provide: { name: 'my group' }, stubs: { GlSprintf }, @@ -43,9 +50,26 @@ describe('UserLimitNotification', () => { }); }); + describe('when close to limit with 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( + 'You only have space for 2 more members in your personal projects', + ); + expect(alert.text()).toEqual( + 'To make more space, you can remove members who no longer need access.', + ); + }); + }); + describe('when close to limit', () => { it("renders user's limit notification", () => { - createComponent(false, { membersCount: 3 }); + createComponent(true, false, { membersCount: 3 }); const alert = findAlert(); @@ -61,7 +85,7 @@ describe('UserLimitNotification', () => { describe('when limit is reached', () => { it("renders user's limit notification", () => { - createComponent(true); + createComponent(true, true); const alert = findAlert(); @@ -71,12 +95,12 @@ describe('UserLimitNotification', () => { describe('when free user namespace', () => { it("renders user's limit notification", () => { - createComponent(true, { userNamespace: true }); + createComponent(true, true, { userNamespace: true }); const alert = findAlert(); expect(alert.attributes('title')).toEqual( - "You've reached your 5 members limit for my group", + "You've reached your 5 members limit for your personal projects", ); expect(alert.text()).toEqual(REACHED_LIMIT_MESSAGE); |