diff options
Diffstat (limited to 'spec/frontend/members')
-rw-r--r-- | spec/frontend/members/components/action_buttons/access_request_action_buttons_spec.js | 90 | ||||
-rw-r--r-- | spec/frontend/members/components/members_tabs_spec.js | 5 |
2 files changed, 32 insertions, 63 deletions
diff --git a/spec/frontend/members/components/action_buttons/access_request_action_buttons_spec.js b/spec/frontend/members/components/action_buttons/access_request_action_buttons_spec.js index 3dac47974e7..df5c884f42e 100644 --- a/spec/frontend/members/components/action_buttons/access_request_action_buttons_spec.js +++ b/spec/frontend/members/components/action_buttons/access_request_action_buttons_spec.js @@ -24,86 +24,52 @@ describe('AccessRequestActionButtons', () => { wrapper.destroy(); }); - describe('when user has `canRemove` permissions', () => { - beforeEach(() => { - createComponent({ - permissions: { - canRemove: true, - }, - }); - }); + it('renders remove member button', () => { + createComponent(); - it('renders remove member button', () => { - expect(findRemoveMemberButton().exists()).toBe(true); - }); - - it('sets props correctly', () => { - expect(findRemoveMemberButton().props()).toMatchObject({ - memberId: member.id, - title: 'Deny access', - isAccessRequest: true, - isInvite: false, - icon: 'close', - }); - }); - - describe('when member is the current user', () => { - it('sets `message` prop correctly', () => { - expect(findRemoveMemberButton().props('message')).toBe( - `Are you sure you want to withdraw your access request for "${member.source.fullName}"`, - ); - }); - }); + expect(findRemoveMemberButton().exists()).toBe(true); + }); - describe('when member is not the current user', () => { - it('sets `message` prop correctly', () => { - createComponent({ - isCurrentUser: false, - permissions: { - canRemove: true, - }, - }); + it('sets props correctly on remove member button', () => { + createComponent(); - expect(findRemoveMemberButton().props('message')).toBe( - `Are you sure you want to deny ${member.user.name}'s request to join "${member.source.fullName}"`, - ); - }); + expect(findRemoveMemberButton().props()).toMatchObject({ + memberId: member.id, + title: 'Deny access', + isAccessRequest: true, + isInvite: false, + icon: 'close', }); }); - describe('when user does not have `canRemove` permissions', () => { - it('does not render remove member button', () => { - createComponent({ - permissions: { - canRemove: false, - }, - }); + describe('when member is the current user', () => { + it('sets `message` prop correctly', () => { + createComponent(); - expect(findRemoveMemberButton().exists()).toBe(false); + expect(findRemoveMemberButton().props('message')).toBe( + `Are you sure you want to withdraw your access request for "${member.source.fullName}"`, + ); }); }); - describe('when user has `canUpdate` permissions', () => { - it('renders the approve button', () => { + describe('when member is not the current user', () => { + it('sets `message` prop correctly', () => { createComponent({ + isCurrentUser: false, permissions: { - canUpdate: true, + canRemove: true, }, }); - expect(findApproveButton().exists()).toBe(true); + expect(findRemoveMemberButton().props('message')).toBe( + `Are you sure you want to deny ${member.user.name}'s request to join "${member.source.fullName}"`, + ); }); }); - describe('when user does not have `canUpdate` permissions', () => { - it('does not render the approve button', () => { - createComponent({ - permissions: { - canUpdate: false, - }, - }); + it('renders the approve button', () => { + createComponent(); - expect(findApproveButton().exists()).toBe(false); - }); + expect(findApproveButton().exists()).toBe(true); }); }); diff --git a/spec/frontend/members/components/members_tabs_spec.js b/spec/frontend/members/components/members_tabs_spec.js index 1354b938d77..77af5e7293e 100644 --- a/spec/frontend/members/components/members_tabs_spec.js +++ b/spec/frontend/members/components/members_tabs_spec.js @@ -81,6 +81,7 @@ describe('MembersTabs', () => { stubs: ['members-app'], provide: { canManageMembers: true, + canManageAccessRequests: true, canExportMembers: true, exportCsvPath: '', ...provide, @@ -181,7 +182,9 @@ describe('MembersTabs', () => { describe('when `canManageMembers` is `false`', () => { it('shows all tabs except `Invited` and `Access requests`', async () => { - await createComponent({ provide: { canManageMembers: false } }); + await createComponent({ + provide: { canManageMembers: false, canManageAccessRequests: false }, + }); expect(findTabByText('Members')).not.toBeUndefined(); expect(findTabByText('Groups')).not.toBeUndefined(); |