diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 13:34:23 -0600 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/frontend/members/components | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) | |
download | gitlab-ce-9c92629b014f99bee07847e53f057eabe7f1fea0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/frontend/members/components')
17 files changed, 65 insertions, 61 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 9a8434a1222..30166e2d5ae 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 @@ -49,7 +49,7 @@ describe('AccessRequestActionButtons', () => { 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.name}"`, + `Are you sure you want to withdraw your access request for "${member.source.fullName}"`, ); }); }); @@ -64,7 +64,7 @@ describe('AccessRequestActionButtons', () => { }); expect(findRemoveMemberButton().props('message')).toBe( - `Are you sure you want to deny ${member.user.name}'s request to join "${member.source.name}"`, + `Are you sure you want to deny ${member.user.name}'s request to join "${member.source.fullName}"`, ); }); }); 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 887b21dc1d0..fe63f9bfaa7 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 @@ -39,7 +39,7 @@ describe('InviteActionButtons', () => { it('sets props correctly', () => { expect(findRemoveMemberButton().props()).toEqual({ memberId: member.id, - message: `Are you sure you want to revoke the invitation for ${member.invite.email} to join "${member.source.name}"`, + message: `Are you sure you want to revoke the invitation for ${member.invite.email} to join "${member.source.fullName}"`, title: 'Revoke invite', isAccessRequest: false, icon: 'remove', 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 a48942dd277..05ea0dc2886 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 @@ -57,10 +57,8 @@ describe('ResendInviteButton', () => { it('displays form with correct action and inputs', () => { expect(findForm().attributes('action')).toBe('/groups/foo-bar/-/group_members/1/resend_invite'); - expect( - findForm() - .find('input[name="authenticity_token"]') - .attributes('value'), - ).toBe('mock-csrf-token'); + expect(findForm().find('input[name="authenticity_token"]').attributes('value')).toBe( + 'mock-csrf-token', + ); }); }); diff --git a/spec/frontend/members/components/action_buttons/user_action_buttons_spec.js b/spec/frontend/members/components/action_buttons/user_action_buttons_spec.js index b03e80a537d..f28e5040006 100644 --- a/spec/frontend/members/components/action_buttons/user_action_buttons_spec.js +++ b/spec/frontend/members/components/action_buttons/user_action_buttons_spec.js @@ -39,7 +39,7 @@ describe('UserActionButtons', () => { it('sets props correctly', () => { expect(findRemoveMemberButton().props()).toEqual({ memberId: member.id, - message: `Are you sure you want to remove ${member.user.name} from "${member.source.name}"`, + message: `Are you sure you want to remove ${member.user.name} from "${member.source.fullName}"`, title: 'Remove member', isAccessRequest: false, icon: 'remove', @@ -56,7 +56,7 @@ describe('UserActionButtons', () => { }); expect(findRemoveMemberButton().props('message')).toBe( - `Are you sure you want to remove this orphaned member from "${orphanedMember.source.name}"`, + `Are you sure you want to remove this orphaned member from "${orphanedMember.source.fullName}"`, ); }); }); diff --git a/spec/frontend/members/components/avatars/user_avatar_spec.js b/spec/frontend/members/components/avatars/user_avatar_spec.js index 7d6a9065975..411ec1a54de 100644 --- a/spec/frontend/members/components/avatars/user_avatar_spec.js +++ b/spec/frontend/members/components/avatars/user_avatar_spec.js @@ -22,7 +22,7 @@ describe('UserAvatar', () => { const getByText = (text, options) => createWrapper(within(wrapper.element).findByText(text, options)); - const findStatusEmoji = emoji => wrapper.find(`gl-emoji[data-name="${emoji}"]`); + const findStatusEmoji = (emoji) => wrapper.find(`gl-emoji[data-name="${emoji}"]`); afterEach(() => { wrapper.destroy(); diff --git a/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js b/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js index 91277ae6d03..0d9f9acbbeb 100644 --- a/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js +++ b/spec/frontend/members/components/filter_sort/filter_sort_container_spec.js @@ -10,7 +10,7 @@ localVue.use(Vuex); describe('FilterSortContainer', () => { let wrapper; - const createComponent = state => { + const createComponent = (state) => { const store = new Vuex.Store({ state: { filteredSearchBar: { 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 ca885000c2f..2bed1e803ca 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 @@ -10,7 +10,7 @@ localVue.use(Vuex); describe('MembersFilteredSearchBar', () => { let wrapper; - const createComponent = state => { + const createComponent = (state) => { const store = new Vuex.Store({ state: { sourceId: 1, @@ -86,7 +86,10 @@ describe('MembersFilteredSearchBar', () => { token: GlFilteredSearchToken, unique: true, operators: [{ value: '=', description: 'is' }], - options: [{ value: 'exclude', title: 'Direct' }, { value: 'only', title: 'Inherited' }], + options: [ + { value: 'exclude', title: 'Direct' }, + { value: 'only', title: 'Inherited' }, + ], }, ]); }); 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 6fe67aded3d..d98c9116512 100644 --- a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js +++ b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js @@ -12,7 +12,7 @@ describe('SortDropdown', () => { const URL_HOST = 'https://localhost/'; - const createComponent = state => { + const createComponent = (state) => { const store = new Vuex.Store({ state: { sourceId: 1, @@ -38,10 +38,10 @@ describe('SortDropdown', () => { const findSortDirectionToggle = () => findSortingComponent().find('button[title="Sort direction"]'); const findDropdownToggle = () => wrapper.find('button[aria-haspopup="true"]'); - const findDropdownItemByText = text => + const findDropdownItemByText = (text) => wrapper .findAll(GlSortingItem) - .wrappers.find(dropdownItemWrapper => dropdownItemWrapper.text() === text); + .wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.text() === text); describe('dropdown options', () => { beforeEach(() => { @@ -76,7 +76,7 @@ describe('SortDropdown', () => { createComponent(); - expectedDropdownItems.forEach(expectedDropdownItem => { + expectedDropdownItems.forEach((expectedDropdownItem) => { const dropdownItem = findDropdownItemByText(expectedDropdownItem.label); expect(dropdownItem).not.toBe(null); diff --git a/spec/frontend/members/components/modals/leave_modal_spec.js b/spec/frontend/members/components/modals/leave_modal_spec.js index d7acf12212c..dca47d1f6af 100644 --- a/spec/frontend/members/components/modals/leave_modal_spec.js +++ b/spec/frontend/members/components/modals/leave_modal_spec.js @@ -60,11 +60,11 @@ describe('LeaveModal', () => { }); it('displays modal title', () => { - expect(getByText(`Leave "${member.source.name}"`).exists()).toBe(true); + expect(getByText(`Leave "${member.source.fullName}"`).exists()).toBe(true); }); it('displays modal body', () => { - expect(getByText(`Are you sure you want to leave "${member.source.name}"?`).exists()).toBe( + expect(getByText(`Are you sure you want to leave "${member.source.fullName}"?`).exists()).toBe( true, ); }); 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 593dbcd28ba..234857419b6 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 @@ -31,7 +31,7 @@ describe('RemoveGroupLinkModal', () => { }); }; - const createComponent = state => { + const createComponent = (state) => { wrapper = mount(RemoveGroupLinkModal, { localVue, store: createStore(state), diff --git a/spec/frontend/members/components/table/created_at_spec.js b/spec/frontend/members/components/table/created_at_spec.js index a9f809cd805..dc1f62722ab 100644 --- a/spec/frontend/members/components/table/created_at_spec.js +++ b/spec/frontend/members/components/table/created_at_spec.js @@ -13,7 +13,7 @@ describe('CreatedAt', () => { let wrapper; - const createComponent = propsData => { + const createComponent = (propsData) => { wrapper = mount(CreatedAt, { propsData: { date, diff --git a/spec/frontend/members/components/table/expiration_datepicker_spec.js b/spec/frontend/members/components/table/expiration_datepicker_spec.js index ba1b2256e76..0caaafb8d7b 100644 --- a/spec/frontend/members/components/table/expiration_datepicker_spec.js +++ b/spec/frontend/members/components/table/expiration_datepicker_spec.js @@ -25,7 +25,7 @@ describe('ExpirationDatepicker', () => { actions = { updateMemberExpiration: jest.fn( () => - new Promise(resolve => { + new Promise((resolve) => { resolveUpdateMemberExpiration = resolve; }), ), @@ -72,11 +72,9 @@ describe('ExpirationDatepicker', () => { }); it('sets `minDate` prop as tomorrow', () => { - expect( - findDatepicker() - .props('minDate') - .toISOString(), - ).toBe(new Date('2020-3-16').toISOString()); + expect(findDatepicker().props('minDate').toISOString()).toBe( + new Date('2020-3-16').toISOString(), + ); }); it('sets `target` prop as `null` so datepicker opens on focus', () => { diff --git a/spec/frontend/members/components/table/expires_at_spec.js b/spec/frontend/members/components/table/expires_at_spec.js index cf0fc78656e..321008727cd 100644 --- a/spec/frontend/members/components/table/expires_at_spec.js +++ b/spec/frontend/members/components/table/expires_at_spec.js @@ -10,7 +10,7 @@ describe('ExpiresAt', () => { let wrapper; - const createComponent = propsData => { + const createComponent = (propsData) => { wrapper = mount(ExpiresAt, { propsData, directives: { @@ -22,7 +22,7 @@ describe('ExpiresAt', () => { const getByText = (text, options) => createWrapper(within(wrapper.element).getByText(text, options)); - const getTooltipDirective = elementWrapper => getBinding(elementWrapper.element, 'gl-tooltip'); + const getTooltipDirective = (elementWrapper) => getBinding(elementWrapper.element, 'gl-tooltip'); afterEach(() => { wrapper.destroy(); diff --git a/spec/frontend/members/components/table/member_avatar_spec.js b/spec/frontend/members/components/table/member_avatar_spec.js index 98177893c18..4341dfbbaf9 100644 --- a/spec/frontend/members/components/table/member_avatar_spec.js +++ b/spec/frontend/members/components/table/member_avatar_spec.js @@ -9,7 +9,7 @@ import InviteAvatar from '~/members/components/avatars/invite_avatar.vue'; describe('MemberList', () => { let wrapper; - const createComponent = propsData => { + const createComponent = (propsData) => { wrapper = shallowMount(MemberAvatar, { propsData: { isCurrentUser: false, diff --git a/spec/frontend/members/components/table/member_source_spec.js b/spec/frontend/members/components/table/member_source_spec.js index 48ac06f32f6..95547090aed 100644 --- a/spec/frontend/members/components/table/member_source_spec.js +++ b/spec/frontend/members/components/table/member_source_spec.js @@ -6,12 +6,12 @@ import MemberSource from '~/members/components/table/member_source.vue'; describe('MemberSource', () => { let wrapper; - const createComponent = propsData => { + const createComponent = (propsData) => { wrapper = mount(MemberSource, { propsData: { memberSource: { id: 102, - name: 'Foo bar', + fullName: 'Foo bar', webUrl: 'https://gitlab.com/groups/foo-bar', }, ...propsData, @@ -25,7 +25,7 @@ describe('MemberSource', () => { const getByText = (text, options) => createWrapper(getByTextHelper(wrapper.element, text, options)); - const getTooltipDirective = elementWrapper => getBinding(elementWrapper.element, 'gl-tooltip'); + const getTooltipDirective = (elementWrapper) => getBinding(elementWrapper.element, 'gl-tooltip'); afterEach(() => { wrapper.destroy(); diff --git a/spec/frontend/members/components/table/members_table_spec.js b/spec/frontend/members/components/table/members_table_spec.js index 9945cc7ee57..dbaccde069c 100644 --- a/spec/frontend/members/components/table/members_table_spec.js +++ b/spec/frontend/members/components/table/members_table_spec.js @@ -39,7 +39,7 @@ describe('MembersTable', () => { }); }; - const createComponent = state => { + const createComponent = (state) => { wrapper = mount(MembersTable, { localVue, store: createStore(state), @@ -63,6 +63,10 @@ describe('MembersTable', () => { createWrapper(getByTestIdHelper(wrapper.element, id, options)); const findTable = () => wrapper.find(GlTable); + const findTableCellByMemberId = (tableCellLabel, memberId) => + getByTestId(`members-table-row-${memberId}`).find( + `[data-label="${tableCellLabel}"][role="cell"]`, + ); afterEach(() => { wrapper.destroy(); @@ -100,10 +104,7 @@ describe('MembersTable', () => { if (expectedComponent) { expect( - wrapper - .find(`[data-label="${label}"][role="cell"]`) - .find(expectedComponent) - .exists(), + wrapper.find(`[data-label="${label}"][role="cell"]`).find(expectedComponent).exists(), ).toBe(true); } }); @@ -117,10 +118,7 @@ describe('MembersTable', () => { expect(actionField.exists()).toBe(true); expect(actionField.classes('gl-sr-only')).toBe(true); expect( - wrapper - .find(`[data-label="Actions"][role="cell"]`) - .find(MemberActionButtons) - .exists(), + wrapper.find(`[data-label="Actions"][role="cell"]`).find(MemberActionButtons).exists(), ).toBe(true); }); @@ -137,16 +135,30 @@ describe('MembersTable', () => { canRemove: true, }; + const memberNoPermissions = { + ...memberMock, + id: 2, + }; + describe.each` permission | members - ${'canUpdate'} | ${[memberCanUpdate]} - ${'canRemove'} | ${[memberCanRemove]} - ${'canResend'} | ${[invite]} + ${'canUpdate'} | ${[memberNoPermissions, memberCanUpdate]} + ${'canRemove'} | ${[memberNoPermissions, memberCanRemove]} + ${'canResend'} | ${[memberNoPermissions, invite]} `('when one of the members has $permission permissions', ({ members }) => { it('renders the "Actions" field', () => { createComponent({ members, tableFields: ['actions'] }); expect(getByTestId('col-actions').exists()).toBe(true); + + expect(findTableCellByMemberId('Actions', members[0].id).classes()).toStrictEqual([ + 'col-actions', + 'gl-display-none!', + 'gl-display-lg-table-cell!', + ]); + expect(findTableCellByMemberId('Actions', members[1].id).classes()).toStrictEqual([ + 'col-actions', + ]); }); }); @@ -177,12 +189,9 @@ describe('MembersTable', () => { it('renders badge in "Max role" field', () => { createComponent({ members: [memberMock], tableFields: ['maxRole'] }); - expect( - wrapper - .find(`[data-label="Max role"][role="cell"]`) - .find(GlBadge) - .text(), - ).toBe(memberMock.accessLevel.stringValue); + expect(wrapper.find(`[data-label="Max role"][role="cell"]`).find(GlBadge).text()).toBe( + memberMock.accessLevel.stringValue, + ); }); }); @@ -203,10 +212,6 @@ describe('MembersTable', () => { it('adds QA selector to table row', () => { createComponent(); - expect( - findTable() - .find('tbody tr') - .attributes('data-qa-selector'), - ).toBe('member_row'); + expect(findTable().find('tbody tr').attributes('data-qa-selector')).toBe('member_row'); }); }); diff --git a/spec/frontend/members/components/table/role_dropdown_spec.js b/spec/frontend/members/components/table/role_dropdown_spec.js index 6c6abf35bd7..96a388614f3 100644 --- a/spec/frontend/members/components/table/role_dropdown_spec.js +++ b/spec/frontend/members/components/table/role_dropdown_spec.js @@ -44,7 +44,7 @@ describe('RoleDropdown', () => { const getDropdownMenu = () => within(wrapper.element).getByRole('menu'); const getByTextInDropdownMenu = (text, options = {}) => createWrapper(within(getDropdownMenu()).getByText(text, options)); - const getDropdownItemByText = text => + const getDropdownItemByText = (text) => createWrapper( within(getDropdownMenu()) .getByText(text, { selector: '[role="menuitem"] p' }) @@ -53,7 +53,7 @@ describe('RoleDropdown', () => { const getCheckedDropdownItem = () => wrapper .findAll(GlDropdownItem) - .wrappers.find(dropdownItemWrapper => dropdownItemWrapper.props('isChecked')); + .wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.props('isChecked')); const findDropdownToggle = () => wrapper.find('button[aria-haspopup="true"]'); const findDropdown = () => wrapper.find(GlDropdown); @@ -63,7 +63,7 @@ describe('RoleDropdown', () => { }); describe('when dropdown is open', () => { - beforeEach(done => { + beforeEach((done) => { createComponent(); findDropdownToggle().trigger('click'); @@ -73,7 +73,7 @@ describe('RoleDropdown', () => { }); it('renders all valid roles', () => { - Object.keys(member.validRoles).forEach(role => { + Object.keys(member.validRoles).forEach((role) => { expect(getDropdownItemByText(role).exists()).toBe(true); }); }); |