diff options
Diffstat (limited to 'spec/frontend/sidebar')
20 files changed, 87 insertions, 63 deletions
diff --git a/spec/frontend/sidebar/assignee_title_spec.js b/spec/frontend/sidebar/assignee_title_spec.js index 3079cb28406..e29e3d489a5 100644 --- a/spec/frontend/sidebar/assignee_title_spec.js +++ b/spec/frontend/sidebar/assignee_title_spec.js @@ -85,7 +85,7 @@ describe('AssigneeTitle component', () => { editable: false, }); - expect(wrapper.find(GlLoadingIcon).exists()).toBeFalsy(); + expect(wrapper.find(GlLoadingIcon).exists()).toBe(false); }); it('renders spinner when loading', () => { @@ -95,7 +95,7 @@ describe('AssigneeTitle component', () => { editable: false, }); - expect(wrapper.find(GlLoadingIcon).exists()).toBeTruthy(); + expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); }); it('does not render edit link when not editable', () => { diff --git a/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js b/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js index 517b4f12559..8cde70ff8da 100644 --- a/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js +++ b/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js @@ -143,7 +143,7 @@ describe('AssigneeAvatarLink component', () => { issuableType | userId ${'merge_request'} | ${undefined} ${'issue'} | ${'1'} - `('it sets data-user-id as $userId for $issuableType', ({ issuableType, userId }) => { + `('sets data-user-id as $userId for $issuableType', ({ issuableType, userId }) => { createComponent({ issuableType, }); diff --git a/spec/frontend/sidebar/components/assignees/collapsed_assignee_list_spec.js b/spec/frontend/sidebar/components/assignees/collapsed_assignee_list_spec.js index 5aa8264b98c..81ff51133bf 100644 --- a/spec/frontend/sidebar/components/assignees/collapsed_assignee_list_spec.js +++ b/spec/frontend/sidebar/components/assignees/collapsed_assignee_list_spec.js @@ -23,7 +23,7 @@ describe('CollapsedAssigneeList component', () => { const findNoUsersIcon = () => wrapper.find(GlIcon); const findAvatarCounter = () => wrapper.find('.avatar-counter'); - const findAssignees = () => wrapper.findAll(CollapsedAssignee); + const findAssignees = () => wrapper.findAllComponents(CollapsedAssignee); const getTooltipTitle = () => wrapper.attributes('title'); afterEach(() => { diff --git a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js index 88015ed42a3..3644a51c7fd 100644 --- a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js +++ b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js @@ -65,6 +65,7 @@ describe('Sidebar assignees widget', () => { issuableId: 0, fullPath: '/mygroup/myProject', allowMultipleAssignees: true, + editable: true, ...props, }, provide: { @@ -350,6 +351,17 @@ describe('Sidebar assignees widget', () => { }); }); + describe('when issuable is not editable by the user', () => { + beforeEach(async () => { + createComponent({ props: { editable: false } }); + await waitForPromises(); + }); + + it('passes editable prop as false to IssuableAssignees', () => { + expect(findAssignees().props('editable')).toBe(false); + }); + }); + it('includes the real-time assignees component', async () => { createComponent(); await waitForPromises(); diff --git a/spec/frontend/sidebar/components/assignees/uncollapsed_assignee_list_spec.js b/spec/frontend/sidebar/components/assignees/uncollapsed_assignee_list_spec.js index f7437386814..b902d7313fd 100644 --- a/spec/frontend/sidebar/components/assignees/uncollapsed_assignee_list_spec.js +++ b/spec/frontend/sidebar/components/assignees/uncollapsed_assignee_list_spec.js @@ -42,7 +42,7 @@ describe('UncollapsedAssigneeList component', () => { }); it('only has one user', () => { - expect(wrapper.findAll(AssigneeAvatarLink).length).toBe(1); + expect(wrapper.findAllComponents(AssigneeAvatarLink).length).toBe(1); }); it('calls the AssigneeAvatarLink with the proper props', () => { @@ -79,7 +79,7 @@ describe('UncollapsedAssigneeList component', () => { }); it('shows truncated users', () => { - expect(wrapper.findAll(AssigneeAvatarLink).length).toBe(DEFAULT_RENDER_COUNT); + expect(wrapper.findAllComponents(AssigneeAvatarLink).length).toBe(DEFAULT_RENDER_COUNT); }); describe('when more button is clicked', () => { @@ -94,7 +94,9 @@ describe('UncollapsedAssigneeList component', () => { }); it('shows all users', () => { - expect(wrapper.findAll(AssigneeAvatarLink).length).toBe(DEFAULT_RENDER_COUNT + 1); + expect(wrapper.findAllComponents(AssigneeAvatarLink).length).toBe( + DEFAULT_RENDER_COUNT + 1, + ); }); }); }); diff --git a/spec/frontend/sidebar/components/assignees/user_name_with_status_spec.js b/spec/frontend/sidebar/components/assignees/user_name_with_status_spec.js index 4dbf3d426bb..37c16bc9235 100644 --- a/spec/frontend/sidebar/components/assignees/user_name_with_status_spec.js +++ b/spec/frontend/sidebar/components/assignees/user_name_with_status_spec.js @@ -1,5 +1,5 @@ import { mount } from '@vue/test-utils'; -import { AVAILABILITY_STATUS } from '~/set_status_modal/utils'; +import { AVAILABILITY_STATUS } from '~/set_status_modal/constants'; import UserNameWithStatus from '~/sidebar/components/assignees/user_name_with_status.vue'; const name = 'Administrator'; diff --git a/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_form_spec.js b/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_form_spec.js index 7775ed6aa37..1ea035c7184 100644 --- a/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_form_spec.js +++ b/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_form_spec.js @@ -71,12 +71,7 @@ describe('Sidebar Confidentiality Form', () => { it('creates a flash if mutation contains errors', async () => { createComponent({ mutate: jest.fn().mockResolvedValue({ - data: { - issuableSetConfidential: { - issuable: { confidential: false }, - errors: ['Houston, we have a problem!'], - }, - }, + data: { issuableSetConfidential: { errors: ['Houston, we have a problem!'] } }, }), }); findConfidentialToggle().vm.$emit('click', new MouseEvent('click')); @@ -87,24 +82,6 @@ describe('Sidebar Confidentiality Form', () => { }); }); - it('emits `closeForm` event with confidentiality value when mutation is successful', async () => { - createComponent({ - mutate: jest.fn().mockResolvedValue({ - data: { - issuableSetConfidential: { - issuable: { confidential: true }, - errors: [], - }, - }, - }), - }); - - findConfidentialToggle().vm.$emit('click', new MouseEvent('click')); - await waitForPromises(); - - expect(wrapper.emitted('closeForm')).toEqual([[{ confidential: true }]]); - }); - describe('when issue is not confidential', () => { beforeEach(() => { createComponent(); diff --git a/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_widget_spec.js b/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_widget_spec.js index 18ee423d12e..3a3f0b1d9fa 100644 --- a/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_widget_spec.js +++ b/spec/frontend/sidebar/components/confidential/sidebar_confidentiality_widget_spec.js @@ -132,7 +132,6 @@ describe('Sidebar Confidentiality Widget', () => { it('closes the form and dispatches an event when `closeForm` is emitted', async () => { createComponent(); const el = wrapper.vm.$el; - const closeFormPayload = { confidential: true }; jest.spyOn(el, 'dispatchEvent'); await waitForPromises(); @@ -141,12 +140,12 @@ describe('Sidebar Confidentiality Widget', () => { expect(findConfidentialityForm().isVisible()).toBe(true); - findConfidentialityForm().vm.$emit('closeForm', closeFormPayload); + findConfidentialityForm().vm.$emit('closeForm'); await nextTick(); expect(findConfidentialityForm().isVisible()).toBe(false); expect(el.dispatchEvent).toHaveBeenCalled(); - expect(wrapper.emitted('closeForm')).toEqual([[closeFormPayload]]); + expect(wrapper.emitted('closeForm')).toEqual([[]]); }); it('emits `expandSidebar` event when it is emitted from child component', async () => { diff --git a/spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js b/spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js index fda21e06987..a7556b9110c 100644 --- a/spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js +++ b/spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js @@ -5,10 +5,10 @@ import SidebarInheritDate from '~/sidebar/components/date/sidebar_inherit_date.v describe('SidebarInheritDate', () => { let wrapper; - const findFixedFormattedDate = () => wrapper.findAll(SidebarFormattedDate).at(0); - const findInheritFormattedDate = () => wrapper.findAll(SidebarFormattedDate).at(1); - const findFixedRadio = () => wrapper.findAll(GlFormRadio).at(0); - const findInheritRadio = () => wrapper.findAll(GlFormRadio).at(1); + const findFixedFormattedDate = () => wrapper.findAllComponents(SidebarFormattedDate).at(0); + const findInheritFormattedDate = () => wrapper.findAllComponents(SidebarFormattedDate).at(1); + const findFixedRadio = () => wrapper.findAllComponents(GlFormRadio).at(0); + const findInheritRadio = () => wrapper.findAllComponents(GlFormRadio).at(1); const createComponent = ({ dueDateIsFixed = false } = {}) => { wrapper = shallowMount(SidebarInheritDate, { @@ -36,8 +36,8 @@ describe('SidebarInheritDate', () => { }); it('displays formatted fixed and inherited dates with radio buttons', () => { - expect(wrapper.findAll(SidebarFormattedDate)).toHaveLength(2); - expect(wrapper.findAll(GlFormRadio)).toHaveLength(2); + expect(wrapper.findAllComponents(SidebarFormattedDate)).toHaveLength(2); + expect(wrapper.findAllComponents(GlFormRadio)).toHaveLength(2); expect(findFixedFormattedDate().props('formattedDate')).toBe('Apr 15, 2021'); expect(findInheritFormattedDate().props('formattedDate')).toBe('May 15, 2021'); expect(findFixedRadio().text()).toBe('Fixed:'); diff --git a/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js b/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js index 2c24df2436a..d00c8dcb653 100644 --- a/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js +++ b/spec/frontend/sidebar/components/reviewers/uncollapsed_reviewer_list_spec.js @@ -52,7 +52,7 @@ describe('UncollapsedReviewerList component', () => { }); it('only has one user', () => { - expect(wrapper.findAll(ReviewerAvatarLink).length).toBe(1); + expect(wrapper.findAllComponents(ReviewerAvatarLink).length).toBe(1); }); it('shows one user with avatar, and author name', () => { @@ -96,7 +96,7 @@ describe('UncollapsedReviewerList component', () => { }); it('has both users', () => { - expect(wrapper.findAll(ReviewerAvatarLink).length).toBe(2); + expect(wrapper.findAllComponents(ReviewerAvatarLink).length).toBe(2); }); it('shows both users with avatar, and author name', () => { diff --git a/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js b/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js index 5d80a221d8e..83eb9a18597 100644 --- a/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js +++ b/spec/frontend/sidebar/components/severity/sidebar_severity_spec.js @@ -97,7 +97,7 @@ describe('SidebarSeverity', () => { }); }); - it('shows error alert when severity update fails ', async () => { + it('shows error alert when severity update fails', async () => { const errorMsg = 'Something went wrong'; jest.spyOn(wrapper.vm.$apollo, 'mutate').mockRejectedValueOnce(errorMsg); findCriticalSeverityDropdownItem().vm.$emit('click'); diff --git a/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js b/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js index 8ebd2dabfc2..6761731c093 100644 --- a/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js +++ b/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js @@ -238,6 +238,24 @@ describe('SidebarDropdownWidget', () => { expect(findSelectedAttribute().text()).toBe('None'); }); }); + + describe("when user doesn't have permission to view current attribute", () => { + it('renders no permission text', () => { + createComponent({ + data: { + hasCurrentAttribute: true, + currentAttribute: null, + }, + queries: { + currentAttribute: { loading: false }, + }, + }); + + expect(findSelectedAttribute().text()).toBe( + `You don't have permission to view this ${wrapper.props('issuableAttribute')}.`, + ); + }); + }); }); describe('when a user can edit', () => { diff --git a/spec/frontend/sidebar/components/subscriptions/sidebar_subscriptions_widget_spec.js b/spec/frontend/sidebar/components/subscriptions/sidebar_subscriptions_widget_spec.js index 9a68940590d..430acf9f9e7 100644 --- a/spec/frontend/sidebar/components/subscriptions/sidebar_subscriptions_widget_spec.js +++ b/spec/frontend/sidebar/components/subscriptions/sidebar_subscriptions_widget_spec.js @@ -156,7 +156,7 @@ describe('Sidebar Subscriptions Widget', () => { }); await waitForPromises(); - await wrapper.find('.dropdown-item').trigger('click'); + await wrapper.find('[data-testid="notifications-toggle"]').vm.$emit('change'); await waitForPromises(); diff --git a/spec/frontend/sidebar/components/time_tracking/report_spec.js b/spec/frontend/sidebar/components/time_tracking/report_spec.js index 5ed8810e95e..4e619a4e609 100644 --- a/spec/frontend/sidebar/components/time_tracking/report_spec.js +++ b/spec/frontend/sidebar/components/time_tracking/report_spec.js @@ -161,7 +161,6 @@ describe('Issuable Time Tracking Report', () => { id: timelogToRemoveId, }, }, - update: expect.anything(), }); }); @@ -179,7 +178,6 @@ describe('Issuable Time Tracking Report', () => { id: timelogToRemoveId, }, }, - update: expect.anything(), }); expect(createFlash).toHaveBeenCalledWith({ diff --git a/spec/frontend/sidebar/issuable_assignees_spec.js b/spec/frontend/sidebar/issuable_assignees_spec.js index 3563d478f3f..dc59b68bbd4 100644 --- a/spec/frontend/sidebar/issuable_assignees_spec.js +++ b/spec/frontend/sidebar/issuable_assignees_spec.js @@ -12,6 +12,7 @@ describe('IssuableAssignees', () => { }, propsData: { users: [], + editable: true, ...props, }, }); @@ -25,15 +26,19 @@ describe('IssuableAssignees', () => { }); describe('when no assignees are present', () => { - it('renders "None - assign yourself" when user is logged in', () => { - createComponent({ signedIn: true }); - expect(findEmptyAssignee().text()).toBe('None - assign yourself'); - }); - - it('renders "None" when user is not logged in', () => { - createComponent(); - expect(findEmptyAssignee().text()).toBe('None'); - }); + it.each` + signedIn | editable | message + ${true} | ${true} | ${'None - assign yourself'} + ${true} | ${false} | ${'None'} + ${false} | ${true} | ${'None'} + ${false} | ${false} | ${'None'} + `( + 'renders "$message" when signedIn is $signedIn and editable is $editable', + ({ signedIn, editable, message }) => { + createComponent({ signedIn, editable }); + expect(findEmptyAssignee().text()).toBe(message); + }, + ); }); describe('when assignees are present', () => { diff --git a/spec/frontend/sidebar/lock/issuable_lock_form_spec.js b/spec/frontend/sidebar/lock/issuable_lock_form_spec.js index bb757fdf63b..986ccaea4b6 100644 --- a/spec/frontend/sidebar/lock/issuable_lock_form_spec.js +++ b/spec/frontend/sidebar/lock/issuable_lock_form_spec.js @@ -130,7 +130,7 @@ describe('IssuableLockForm', () => { expect(findEditForm().exists()).toBe(true); }); - it('tracks the event ', () => { + it('tracks the event', () => { const spy = mockTracking('_category_', wrapper.element, jest.spyOn); triggerEvent(findEditLink().element); diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js index 9c6e23e928c..2afe9647cbe 100644 --- a/spec/frontend/sidebar/mock_data.js +++ b/spec/frontend/sidebar/mock_data.js @@ -497,6 +497,11 @@ export const searchResponse = { user: mockUser2, }, ], + pageInfo: { + hasNextPage: false, + endCursor: null, + startCursor: null, + }, }, }, }, @@ -559,6 +564,11 @@ export const projectMembersResponse = { }, }, ], + pageInfo: { + hasNextPage: false, + startCursor: null, + endCursor: null, + }, }, }, }, diff --git a/spec/frontend/sidebar/sidebar_mediator_spec.js b/spec/frontend/sidebar/sidebar_mediator_spec.js index e32694abcce..355f0c45bbe 100644 --- a/spec/frontend/sidebar/sidebar_mediator_spec.js +++ b/spec/frontend/sidebar/sidebar_mediator_spec.js @@ -27,7 +27,7 @@ describe('Sidebar mediator', () => { mock.restore(); }); - it('assigns yourself ', () => { + it('assigns yourself', () => { mediator.assignYourself(); expect(mediator.store.currentUser).toEqual(mediatorMockData.currentUser); diff --git a/spec/frontend/sidebar/sidebar_move_issue_spec.js b/spec/frontend/sidebar/sidebar_move_issue_spec.js index 7bb7b18adf8..2e6807ed9d8 100644 --- a/spec/frontend/sidebar/sidebar_move_issue_spec.js +++ b/spec/frontend/sidebar/sidebar_move_issue_spec.js @@ -7,6 +7,7 @@ import SidebarMoveIssue from '~/sidebar/lib/sidebar_move_issue'; import SidebarService from '~/sidebar/services/sidebar_service'; import SidebarMediator from '~/sidebar/sidebar_mediator'; import SidebarStore from '~/sidebar/stores/sidebar_store'; +import { GitLabDropdown } from '~/deprecated_jquery_dropdown/gl_dropdown'; import Mock from './mock_data'; jest.mock('~/flash'); @@ -75,7 +76,9 @@ describe('SidebarMoveIssue', () => { it('should initialize the deprecatedJQueryDropdown', () => { test.sidebarMoveIssue.initDropdown(); - expect(test.sidebarMoveIssue.$dropdownToggle.data('deprecatedJQueryDropdown')).toBeTruthy(); + expect(test.sidebarMoveIssue.$dropdownToggle.data('deprecatedJQueryDropdown')).toBeInstanceOf( + GitLabDropdown, + ); }); it('escapes html from project name', async () => { @@ -97,7 +100,7 @@ describe('SidebarMoveIssue', () => { test.sidebarMoveIssue.onConfirmClicked(); expect(test.mediator.moveIssue).toHaveBeenCalled(); - expect(test.$confirmButton.prop('disabled')).toBeTruthy(); + expect(test.$confirmButton.prop('disabled')).toBe(true); expect(test.$confirmButton.hasClass('is-loading')).toBe(true); }); @@ -113,7 +116,7 @@ describe('SidebarMoveIssue', () => { await waitForPromises(); expect(createFlash).toHaveBeenCalled(); - expect(test.$confirmButton.prop('disabled')).toBeFalsy(); + expect(test.$confirmButton.prop('disabled')).toBe(false); expect(test.$confirmButton.hasClass('is-loading')).toBe(false); }); @@ -139,7 +142,7 @@ describe('SidebarMoveIssue', () => { test.$content.find('.js-move-issue-dropdown-item').eq(0).trigger('click'); expect(test.mediator.setMoveToProjectId).toHaveBeenCalledWith(0); - expect(test.$confirmButton.prop('disabled')).toBeTruthy(); + expect(test.$confirmButton.prop('disabled')).toBe(true); }); it('should set moveToProjectId on dropdown item click', async () => { diff --git a/spec/frontend/sidebar/todo_spec.js b/spec/frontend/sidebar/todo_spec.js index 9316268d2ad..5f696b237e0 100644 --- a/spec/frontend/sidebar/todo_spec.js +++ b/spec/frontend/sidebar/todo_spec.js @@ -55,7 +55,7 @@ describe('SidebarTodo', () => { wrapper.find('button').trigger('click'); await nextTick(); - expect(wrapper.emitted().toggleTodo).toBeTruthy(); + expect(wrapper.emitted().toggleTodo).toHaveLength(1); }); it('renders component container element with proper data attributes', () => { |