diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 16:05:49 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-17 16:05:49 +0000 |
commit | 43a25d93ebdabea52f99b05e15b06250cd8f07d7 (patch) | |
tree | dceebdc68925362117480a5d672bcff122fb625b /spec/frontend/members | |
parent | 20c84b99005abd1c82101dfeff264ac50d2df211 (diff) | |
download | gitlab-ce-0f94cf6ca9d272d8e0fda4a7a597866cf3dc1fc0.tar.gz |
Add latest changes from gitlab-org/gitlab@16-0-stable-eev16.0.0-rc4216-0-stable
Diffstat (limited to 'spec/frontend/members')
29 files changed, 85 insertions, 139 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 b94964dc482..c2e0e44f97f 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 @@ -20,10 +20,6 @@ describe('AccessRequestActionButtons', () => { const findRemoveMemberButton = () => wrapper.findComponent(RemoveMemberButton); const findApproveButton = () => wrapper.findComponent(ApproveAccessRequestButton); - afterEach(() => { - wrapper.destroy(); - }); - it('renders remove member button', () => { createComponent(); diff --git a/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js b/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js index 15bb03480e1..7a4cd844425 100644 --- a/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js +++ b/spec/frontend/members/components/action_buttons/approve_access_request_button_spec.js @@ -38,7 +38,7 @@ describe('ApproveAccessRequestButton', () => { ...propsData, }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, }); }; @@ -50,10 +50,6 @@ describe('ApproveAccessRequestButton', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('displays a tooltip', () => { const button = findButton(); diff --git a/spec/frontend/members/components/action_buttons/invite_action_buttons_spec.js b/spec/frontend/members/components/action_buttons/invite_action_buttons_spec.js index 68009708c99..a852443844b 100644 --- a/spec/frontend/members/components/action_buttons/invite_action_buttons_spec.js +++ b/spec/frontend/members/components/action_buttons/invite_action_buttons_spec.js @@ -19,10 +19,6 @@ describe('InviteActionButtons', () => { const findRemoveMemberButton = () => wrapper.findComponent(RemoveMemberButton); const findResendInviteButton = () => wrapper.findComponent(ResendInviteButton); - afterEach(() => { - wrapper.destroy(); - }); - describe('when user has `canRemove` permissions', () => { beforeEach(() => { createComponent({ diff --git a/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js b/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js index b511cebdf28..1d83a2e0e71 100644 --- a/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js +++ b/spec/frontend/members/components/action_buttons/remove_group_link_button_spec.js @@ -37,7 +37,7 @@ describe('RemoveGroupLinkButton', () => { groupLink: group, }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, }); }; @@ -48,11 +48,6 @@ describe('RemoveGroupLinkButton', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - it('displays a tooltip', () => { const button = findButton(); diff --git a/spec/frontend/members/components/action_buttons/remove_member_button_spec.js b/spec/frontend/members/components/action_buttons/remove_member_button_spec.js index cca340169b7..3879279b559 100644 --- a/spec/frontend/members/components/action_buttons/remove_member_button_spec.js +++ b/spec/frontend/members/components/action_buttons/remove_member_button_spec.js @@ -47,7 +47,7 @@ describe('RemoveMemberButton', () => { ...propsData, }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, }); }; @@ -58,10 +58,6 @@ describe('RemoveMemberButton', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('sets attributes on button', () => { expect(wrapper.attributes()).toMatchObject({ 'aria-label': 'Remove member', diff --git a/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js b/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js index 51cfd47ddf4..a6b5978b566 100644 --- a/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js +++ b/spec/frontend/members/components/action_buttons/resend_invite_button_spec.js @@ -38,7 +38,7 @@ describe('ResendInviteButton', () => { ...propsData, }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, }); }; @@ -50,10 +50,6 @@ describe('ResendInviteButton', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('displays a tooltip', () => { expect(getBinding(findButton().element, 'gl-tooltip')).not.toBeUndefined(); expect(findButton().attributes('title')).toBe('Resend invite'); diff --git a/spec/frontend/members/components/action_dropdowns/leave_group_dropdown_item_spec.js b/spec/frontend/members/components/action_dropdowns/leave_group_dropdown_item_spec.js index 90f5b217007..679ad7897ed 100644 --- a/spec/frontend/members/components/action_dropdowns/leave_group_dropdown_item_spec.js +++ b/spec/frontend/members/components/action_dropdowns/leave_group_dropdown_item_spec.js @@ -18,7 +18,7 @@ describe('LeaveGroupDropdownItem', () => { ...propsData, }, directives: { - GlModal: createMockDirective(), + GlModal: createMockDirective('gl-modal'), }, slots: { default: text, @@ -32,10 +32,6 @@ describe('LeaveGroupDropdownItem', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('renders a slot with red text', () => { expect(findDropdownItem().html()).toContain(`<span class="gl-text-red-500">${text}</span>`); }); diff --git a/spec/frontend/members/components/action_dropdowns/remove_member_dropdown_item_spec.js b/spec/frontend/members/components/action_dropdowns/remove_member_dropdown_item_spec.js index e1c498249d7..125f1f8fff3 100644 --- a/spec/frontend/members/components/action_dropdowns/remove_member_dropdown_item_spec.js +++ b/spec/frontend/members/components/action_dropdowns/remove_member_dropdown_item_spec.js @@ -58,10 +58,6 @@ describe('RemoveMemberDropdownItem', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('renders a slot with red text', () => { expect(findDropdownItem().html()).toContain(`<span class="gl-text-red-500">${text}</span>`); }); diff --git a/spec/frontend/members/components/action_dropdowns/user_action_dropdown_spec.js b/spec/frontend/members/components/action_dropdowns/user_action_dropdown_spec.js index 5a2de1cac80..448c04bcb69 100644 --- a/spec/frontend/members/components/action_dropdowns/user_action_dropdown_spec.js +++ b/spec/frontend/members/components/action_dropdowns/user_action_dropdown_spec.js @@ -24,17 +24,13 @@ describe('UserActionDropdown', () => { ...propsData, }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, }); }; const findRemoveMemberDropdownItem = () => wrapper.findComponent(RemoveMemberDropdownItem); - afterEach(() => { - wrapper.destroy(); - }); - describe('when user has `canRemove` permissions', () => { beforeEach(() => { createComponent({ diff --git a/spec/frontend/members/components/app_spec.js b/spec/frontend/members/components/app_spec.js index d105a4d9fde..b2147163233 100644 --- a/spec/frontend/members/components/app_spec.js +++ b/spec/frontend/members/components/app_spec.js @@ -49,7 +49,6 @@ describe('MembersApp', () => { }); afterEach(() => { - wrapper.destroy(); store = null; }); diff --git a/spec/frontend/members/components/avatars/group_avatar_spec.js b/spec/frontend/members/components/avatars/group_avatar_spec.js index 13c50de9835..8e4263f88fe 100644 --- a/spec/frontend/members/components/avatars/group_avatar_spec.js +++ b/spec/frontend/members/components/avatars/group_avatar_spec.js @@ -25,10 +25,6 @@ describe('MemberList', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('renders link to group', () => { const link = wrapper.findComponent(GlAvatarLink); diff --git a/spec/frontend/members/components/avatars/invite_avatar_spec.js b/spec/frontend/members/components/avatars/invite_avatar_spec.js index b197a46c0d1..84878fb9be2 100644 --- a/spec/frontend/members/components/avatars/invite_avatar_spec.js +++ b/spec/frontend/members/components/avatars/invite_avatar_spec.js @@ -24,10 +24,6 @@ describe('MemberList', () => { createComponent(); }); - afterEach(() => { - wrapper.destroy(); - }); - it('renders email as name', () => { expect(getByText(invite.email).exists()).toBe(true); }); diff --git a/spec/frontend/members/components/avatars/user_avatar_spec.js b/spec/frontend/members/components/avatars/user_avatar_spec.js index 9172876e76f..4808bcb9363 100644 --- a/spec/frontend/members/components/avatars/user_avatar_spec.js +++ b/spec/frontend/members/components/avatars/user_avatar_spec.js @@ -26,10 +26,6 @@ describe('UserAvatar', () => { const findStatusEmoji = (emoji) => wrapper.find(`gl-emoji[data-name="${emoji}"]`); - afterEach(() => { - wrapper.destroy(); - }); - it("renders link to user's profile", () => { createComponent(); diff --git a/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js b/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js index f346967121c..29b7ceae0e3 100644 --- a/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js +++ b/spec/frontend/members/components/filter_sort/members_filtered_search_bar_spec.js @@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import setWindowLocation from 'helpers/set_window_location_helper'; -import { redirectTo } from '~/lib/utils/url_utility'; +import { redirectTo } from '~/lib/utils/url_utility'; // eslint-disable-line import/no-deprecated import MembersFilteredSearchBar from '~/members/components/filter_sort/members_filtered_search_bar.vue'; import { MEMBER_TYPES, @@ -167,7 +167,7 @@ describe('MembersFilteredSearchBar', () => { { type: FILTERED_SEARCH_TOKEN_TWO_FACTOR.type, value: { data: 'enabled', operator: '=' } }, ]); - expect(redirectTo).toHaveBeenCalledWith('https://localhost/?two_factor=enabled'); + expect(redirectTo).toHaveBeenCalledWith('https://localhost/?two_factor=enabled'); // eslint-disable-line import/no-deprecated }); it('adds search query param', () => { @@ -178,6 +178,7 @@ describe('MembersFilteredSearchBar', () => { { type: FILTERED_SEARCH_TERM, value: { data: 'foobar' } }, ]); + // eslint-disable-next-line import/no-deprecated expect(redirectTo).toHaveBeenCalledWith( 'https://localhost/?two_factor=enabled&search=foobar', ); @@ -191,6 +192,7 @@ describe('MembersFilteredSearchBar', () => { { type: FILTERED_SEARCH_TERM, value: { data: 'foo bar baz' } }, ]); + // eslint-disable-next-line import/no-deprecated expect(redirectTo).toHaveBeenCalledWith( 'https://localhost/?two_factor=enabled&search=foo+bar+baz', ); @@ -206,6 +208,7 @@ describe('MembersFilteredSearchBar', () => { { type: FILTERED_SEARCH_TERM, value: { data: 'foobar' } }, ]); + // eslint-disable-next-line import/no-deprecated expect(redirectTo).toHaveBeenCalledWith( 'https://localhost/?two_factor=enabled&search=foobar&sort=name_asc', ); @@ -220,7 +223,7 @@ describe('MembersFilteredSearchBar', () => { { type: FILTERED_SEARCH_TERM, value: { data: 'foobar' } }, ]); - expect(redirectTo).toHaveBeenCalledWith('https://localhost/?search=foobar&tab=invited'); + expect(redirectTo).toHaveBeenCalledWith('https://localhost/?search=foobar&tab=invited'); // eslint-disable-line import/no-deprecated }); }); }); diff --git a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js index ef3c8bde3cf..526f839ece8 100644 --- a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js +++ b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js @@ -46,7 +46,7 @@ describe('SortDropdown', () => { const findSortingComponent = () => wrapper.findComponent(GlSorting); const findSortDirectionToggle = () => findSortingComponent().find('button[title^="Sort direction"]'); - const findDropdownToggle = () => wrapper.find('button[aria-haspopup="true"]'); + const findDropdownToggle = () => wrapper.find('button[aria-haspopup="menu"]'); const findDropdownItemByText = (text) => wrapper .findAllComponents(GlSortingItem) diff --git a/spec/frontend/members/components/members_tabs_spec.js b/spec/frontend/members/components/members_tabs_spec.js index 77af5e7293e..9078bd87d62 100644 --- a/spec/frontend/members/components/members_tabs_spec.js +++ b/spec/frontend/members/components/members_tabs_spec.js @@ -100,10 +100,6 @@ describe('MembersTabs', () => { setWindowLocation('https://localhost'); }); - afterEach(() => { - wrapper.destroy(); - }); - it('renders `GlTabs` with `syncActiveTabWithQueryParams` and `queryParamName` props set', async () => { await createComponent(); diff --git a/spec/frontend/members/components/modals/leave_modal_spec.js b/spec/frontend/members/components/modals/leave_modal_spec.js index ba587c6f0b3..cec5f192e59 100644 --- a/spec/frontend/members/components/modals/leave_modal_spec.js +++ b/spec/frontend/members/components/modals/leave_modal_spec.js @@ -60,10 +60,6 @@ describe('LeaveModal', () => { const findForm = () => findModal().findComponent(GlForm); const findUserDeletionObstaclesList = () => findModal().findComponent(UserDeletionObstaclesList); - afterEach(() => { - wrapper.destroy(); - }); - it('sets modal ID', async () => { await createComponent(); diff --git a/spec/frontend/members/components/modals/remove_group_link_modal_spec.js b/spec/frontend/members/components/modals/remove_group_link_modal_spec.js index af96396f09f..e4782ac7f2e 100644 --- a/spec/frontend/members/components/modals/remove_group_link_modal_spec.js +++ b/spec/frontend/members/components/modals/remove_group_link_modal_spec.js @@ -52,11 +52,6 @@ describe('RemoveGroupLinkModal', () => { const getByText = (text, options) => createWrapper(within(findModal().element).getByText(text, options)); - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - describe('when modal is open', () => { beforeEach(async () => { createComponent(); diff --git a/spec/frontend/members/components/modals/remove_member_modal_spec.js b/spec/frontend/members/components/modals/remove_member_modal_spec.js index 47a03b5083a..baef0b30b02 100644 --- a/spec/frontend/members/components/modals/remove_member_modal_spec.js +++ b/spec/frontend/members/components/modals/remove_member_modal_spec.js @@ -54,10 +54,6 @@ describe('RemoveMemberModal', () => { const findGlModal = () => wrapper.findComponent(GlModal); const findUserDeletionObstaclesList = () => wrapper.findComponent(UserDeletionObstaclesList); - afterEach(() => { - wrapper.destroy(); - }); - describe.each` state | memberModelType | isAccessRequest | isInvite | actionText | removeSubMembershipsCheckboxExpected | unassignIssuablesCheckboxExpected | message | userDeletionObstacles | isPartOfOncall ${'removing a group member'} | ${MEMBER_MODEL_TYPE_GROUP_MEMBER} | ${false} | ${false} | ${'Remove member'} | ${true} | ${true} | ${'Are you sure you want to remove Jane Doe from the Gitlab Org / Gitlab Test project?'} | ${{}} | ${false} diff --git a/spec/frontend/members/components/table/created_at_spec.js b/spec/frontend/members/components/table/created_at_spec.js index fa31177564b..2c0493e7c59 100644 --- a/spec/frontend/members/components/table/created_at_spec.js +++ b/spec/frontend/members/components/table/created_at_spec.js @@ -20,10 +20,6 @@ describe('CreatedAt', () => { }); }; - afterEach(() => { - wrapper.destroy(); - }); - describe('created at text', () => { beforeEach(() => { createComponent(); diff --git a/spec/frontend/members/components/table/expiration_datepicker_spec.js b/spec/frontend/members/components/table/expiration_datepicker_spec.js index 9b8f053348b..9176a02a447 100644 --- a/spec/frontend/members/components/table/expiration_datepicker_spec.js +++ b/spec/frontend/members/components/table/expiration_datepicker_spec.js @@ -58,10 +58,6 @@ describe('ExpirationDatepicker', () => { const findInput = () => wrapper.find('input'); const findDatepicker = () => wrapper.findComponent(GlDatepicker); - afterEach(() => { - wrapper.destroy(); - }); - describe('datepicker input', () => { it('sets `member.expiresAt` as initial date', async () => { createComponent({ member: { ...member, expiresAt: '2020-03-17T00:00:00Z' } }); @@ -97,7 +93,7 @@ describe('ExpirationDatepicker', () => { }); describe('when datepicker is changed', () => { - beforeEach(async () => { + beforeEach(() => { createComponent(); findDatepicker().vm.$emit('input', new Date('2020-03-17')); diff --git a/spec/frontend/members/components/table/member_action_buttons_spec.js b/spec/frontend/members/components/table/member_action_buttons_spec.js index 95db30a3683..3a04d1dcb0a 100644 --- a/spec/frontend/members/components/table/member_action_buttons_spec.js +++ b/spec/frontend/members/components/table/member_action_buttons_spec.js @@ -23,10 +23,6 @@ describe('MemberActions', () => { }); }; - afterEach(() => { - wrapper.destroy(); - }); - it.each` memberType | member | expectedComponent | expectedComponentName ${MEMBER_TYPES.user} | ${memberMock} | ${UserActionDropdown} | ${'UserActionDropdown'} diff --git a/spec/frontend/members/components/table/member_avatar_spec.js b/spec/frontend/members/components/table/member_avatar_spec.js index dc5c97f41df..369f8a06cfd 100644 --- a/spec/frontend/members/components/table/member_avatar_spec.js +++ b/spec/frontend/members/components/table/member_avatar_spec.js @@ -18,10 +18,6 @@ describe('MemberList', () => { }); }; - afterEach(() => { - wrapper.destroy(); - }); - it.each` memberType | member | expectedComponent | expectedComponentName ${MEMBER_TYPES.user} | ${memberMock} | ${UserAvatar} | ${'UserAvatar'} diff --git a/spec/frontend/members/components/table/member_source_spec.js b/spec/frontend/members/components/table/member_source_spec.js index fbfd0ca7ae7..bbfbb19fd92 100644 --- a/spec/frontend/members/components/table/member_source_spec.js +++ b/spec/frontend/members/components/table/member_source_spec.js @@ -23,17 +23,13 @@ describe('MemberSource', () => { ...propsData, }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, }); }; const getTooltipDirective = (elementWrapper) => getBinding(elementWrapper.element, 'gl-tooltip'); - afterEach(() => { - wrapper.destroy(); - }); - describe('direct member', () => { describe('when created by is available', () => { it('displays "Direct member by <user name>"', () => { diff --git a/spec/frontend/members/components/table/members_table_cell_spec.js b/spec/frontend/members/components/table/members_table_cell_spec.js index ac5d83d028d..1c6f1b086cf 100644 --- a/spec/frontend/members/components/table/members_table_cell_spec.js +++ b/spec/frontend/members/components/table/members_table_cell_spec.js @@ -97,11 +97,6 @@ describe('MembersTableCell', () => { }); }; - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - it.each` member | expectedMemberType ${memberMock} | ${MEMBER_TYPES.user} diff --git a/spec/frontend/members/components/table/members_table_spec.js b/spec/frontend/members/components/table/members_table_spec.js index b8e0d73d8f6..e3c89bfed53 100644 --- a/spec/frontend/members/components/table/members_table_spec.js +++ b/spec/frontend/members/components/table/members_table_spec.js @@ -96,10 +96,6 @@ describe('MembersTable', () => { ); }; - afterEach(() => { - wrapper.destroy(); - }); - describe('fields', () => { const memberCanUpdate = { ...directMember, diff --git a/spec/frontend/members/components/table/role_dropdown_spec.js b/spec/frontend/members/components/table/role_dropdown_spec.js index a11f67be8f5..1045e3f9849 100644 --- a/spec/frontend/members/components/table/role_dropdown_spec.js +++ b/spec/frontend/members/components/table/role_dropdown_spec.js @@ -1,5 +1,6 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; +import * as Sentry from '@sentry/browser'; import { within } from '@testing-library/dom'; import { mount, createWrapper } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; @@ -12,6 +13,7 @@ import { member } from '../../mock_data'; Vue.use(Vuex); jest.mock('ee_else_ce/members/guest_overage_confirm_action'); +jest.mock('@sentry/browser'); describe('RoleDropdown', () => { let wrapper; @@ -20,9 +22,9 @@ describe('RoleDropdown', () => { show: jest.fn(), }; - const createStore = () => { + const createStore = ({ updateMemberRoleReturn = Promise.resolve() } = {}) => { actions = { - updateMemberRole: jest.fn(() => Promise.resolve()), + updateMemberRole: jest.fn(() => updateMemberRoleReturn), }; return new Vuex.Store({ @@ -32,7 +34,7 @@ describe('RoleDropdown', () => { }); }; - const createComponent = (propsData = {}) => { + const createComponent = (propsData = {}, store = createStore()) => { wrapper = mount(RoleDropdown, { provide: { namespace: MEMBER_TYPES.user, @@ -46,7 +48,7 @@ describe('RoleDropdown', () => { permissions: {}, ...propsData, }, - store: createStore(), + store, mocks: { $toast, }, @@ -67,27 +69,19 @@ describe('RoleDropdown', () => { .findAllComponents(GlDropdownItem) .wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.props('isChecked')); - const findDropdownToggle = () => wrapper.find('button[aria-haspopup="true"]'); + const findDropdownToggle = () => wrapper.find('button[aria-haspopup="menu"]'); const findDropdown = () => wrapper.findComponent(GlDropdown); - let originalGon; - beforeEach(() => { - originalGon = window.gon; gon.features = { showOverageOnRolePromotion: true }; }); - afterEach(() => { - window.gon = originalGon; - wrapper.destroy(); - }); - describe('when dropdown is open', () => { - beforeEach(() => { + beforeEach(async () => { guestOverageConfirmAction.mockReturnValue(true); createComponent(); - return findDropdownToggle().trigger('click'); + await findDropdownToggle().trigger('click'); }); it('renders all valid roles', () => { @@ -121,26 +115,74 @@ describe('RoleDropdown', () => { }); }); - it('displays toast when successful', async () => { - await getDropdownItemByText('Developer').trigger('click'); + describe('when updateMemberRole is successful', () => { + it('displays toast', async () => { + await getDropdownItemByText('Developer').trigger('click'); - await nextTick(); + await nextTick(); - expect($toast.show).toHaveBeenCalledWith('Role updated successfully.'); - }); + expect($toast.show).toHaveBeenCalledWith('Role updated successfully.'); + }); - it('puts dropdown in loading state while waiting for `updateMemberRole` to resolve', async () => { - await getDropdownItemByText('Developer').trigger('click'); + it('puts dropdown in loading state while waiting for `updateMemberRole` to resolve', async () => { + await getDropdownItemByText('Developer').trigger('click'); - expect(findDropdown().props('loading')).toBe(true); + expect(findDropdown().props('loading')).toBe(true); + }); + + it('enables dropdown after `updateMemberRole` resolves', async () => { + await getDropdownItemByText('Developer').trigger('click'); + + await waitForPromises(); + + expect(findDropdown().props('disabled')).toBe(false); + }); + + it('does not log error to Sentry', async () => { + await getDropdownItemByText('Developer').trigger('click'); + + await waitForPromises(); + + expect(Sentry.captureException).not.toHaveBeenCalled(); + }); }); - it('enables dropdown after `updateMemberRole` resolves', async () => { - await getDropdownItemByText('Developer').trigger('click'); + describe('when updateMemberRole is not successful', () => { + const reason = 'Rejected ☹️'; + + beforeEach(() => { + createComponent({}, createStore({ updateMemberRoleReturn: Promise.reject(reason) })); + }); + + it('does not display toast', async () => { + await getDropdownItemByText('Developer').trigger('click'); + + await nextTick(); + + expect($toast.show).not.toHaveBeenCalled(); + }); + + it('puts dropdown in loading state while waiting for `updateMemberRole` to resolve', async () => { + await getDropdownItemByText('Developer').trigger('click'); - await waitForPromises(); + expect(findDropdown().props('loading')).toBe(true); + }); + + it('enables dropdown after `updateMemberRole` resolves', async () => { + await getDropdownItemByText('Developer').trigger('click'); + + await waitForPromises(); + + expect(findDropdown().props('disabled')).toBe(false); + }); + + it('logs error to Sentry', async () => { + await getDropdownItemByText('Developer').trigger('click'); - expect(findDropdown().props('disabled')).toBe(false); + await waitForPromises(); + + expect(Sentry.captureException).toHaveBeenCalledWith(reason); + }); }); }); }); diff --git a/spec/frontend/members/index_spec.js b/spec/frontend/members/index_spec.js index 5c813eb2a67..b1730cf3746 100644 --- a/spec/frontend/members/index_spec.js +++ b/spec/frontend/members/index_spec.js @@ -31,9 +31,6 @@ describe('initMembersApp', () => { afterEach(() => { el = null; - - wrapper.destroy(); - wrapper = null; }); it('renders `MembersTabs`', () => { diff --git a/spec/frontend/members/utils_spec.js b/spec/frontend/members/utils_spec.js index 4f276e8c9df..c4357e9c1f0 100644 --- a/spec/frontend/members/utils_spec.js +++ b/spec/frontend/members/utils_spec.js @@ -213,7 +213,7 @@ describe('Members Utils', () => { ${'recent_sign_in'} | ${{ sortByKey: 'lastSignIn', sortDesc: false }} ${'oldest_sign_in'} | ${{ sortByKey: 'lastSignIn', sortDesc: true }} `('when `sort` query string param is `$sortParam`', ({ sortParam, expected }) => { - it(`returns ${JSON.stringify(expected)}`, async () => { + it(`returns ${JSON.stringify(expected)}`, () => { setWindowLocation(`?sort=${sortParam}`); expect(parseSortParam(['account', 'granted', 'expires', 'maxRole', 'lastSignIn'])).toEqual( |