diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 16:37:47 +0300 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /spec/frontend/sidebar | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'spec/frontend/sidebar')
-rw-r--r-- | spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/attention_requested_toggle_spec.js (renamed from spec/frontend/sidebar/components/attention_required_toggle_spec.js) | 4 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/crm_contacts_spec.js | 87 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js | 9 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js | 12 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/mock_data.js | 56 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/reference/sidebar_reference_widget_spec.js | 2 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js | 16 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/time_tracking/mock_data.js | 10 | ||||
-rw-r--r-- | spec/frontend/sidebar/mock_data.js | 31 | ||||
-rw-r--r-- | spec/frontend/sidebar/sidebar_labels_spec.js | 190 |
11 files changed, 208 insertions, 211 deletions
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 39f63b2a9f4..07da4acef8c 100644 --- a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js +++ b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js @@ -5,7 +5,7 @@ import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import createFlash from '~/flash'; -import { IssuableType } from '~/issue_show/constants'; +import { IssuableType } from '~/issues/constants'; import SidebarAssigneesRealtime from '~/sidebar/components/assignees/assignees_realtime.vue'; import IssuableAssignees from '~/sidebar/components/assignees/issuable_assignees.vue'; import SidebarAssigneesWidget from '~/sidebar/components/assignees/sidebar_assignees_widget.vue'; diff --git a/spec/frontend/sidebar/components/attention_required_toggle_spec.js b/spec/frontend/sidebar/components/attention_requested_toggle_spec.js index 8555068cdd8..0939297a754 100644 --- a/spec/frontend/sidebar/components/attention_required_toggle_spec.js +++ b/spec/frontend/sidebar/components/attention_requested_toggle_spec.js @@ -23,8 +23,8 @@ describe('Attention require toggle', () => { it.each` attentionRequested | icon - ${true} | ${'star'} - ${false} | ${'star-o'} + ${true} | ${'attention-solid'} + ${false} | ${'attention'} `( 'renders $icon icon when attention_requested is $attentionRequested', ({ attentionRequested, icon }) => { diff --git a/spec/frontend/sidebar/components/crm_contacts_spec.js b/spec/frontend/sidebar/components/crm_contacts_spec.js new file mode 100644 index 00000000000..758cff30e2d --- /dev/null +++ b/spec/frontend/sidebar/components/crm_contacts_spec.js @@ -0,0 +1,87 @@ +import Vue from 'vue'; +import VueApollo from 'vue-apollo'; +import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; +import createMockApollo from 'helpers/mock_apollo_helper'; +import waitForPromises from 'helpers/wait_for_promises'; +import createFlash from '~/flash'; +import CrmContacts from '~/sidebar/components/crm_contacts/crm_contacts.vue'; +import getIssueCrmContactsQuery from '~/sidebar/components/crm_contacts/queries/get_issue_crm_contacts.query.graphql'; +import issueCrmContactsSubscription from '~/sidebar/components/crm_contacts/queries/issue_crm_contacts.subscription.graphql'; +import { + getIssueCrmContactsQueryResponse, + issueCrmContactsUpdateResponse, + issueCrmContactsUpdateNullResponse, +} from './mock_data'; + +jest.mock('~/flash'); + +describe('Issue crm contacts component', () => { + Vue.use(VueApollo); + let wrapper; + let fakeApollo; + + const successQueryHandler = jest.fn().mockResolvedValue(getIssueCrmContactsQueryResponse); + const successSubscriptionHandler = jest.fn().mockResolvedValue(issueCrmContactsUpdateResponse); + const nullSubscriptionHandler = jest.fn().mockResolvedValue(issueCrmContactsUpdateNullResponse); + + const mountComponent = ({ + queryHandler = successQueryHandler, + subscriptionHandler = successSubscriptionHandler, + } = {}) => { + fakeApollo = createMockApollo([ + [getIssueCrmContactsQuery, queryHandler], + [issueCrmContactsSubscription, subscriptionHandler], + ]); + wrapper = shallowMountExtended(CrmContacts, { + propsData: { issueId: '123' }, + apolloProvider: fakeApollo, + }); + }; + + afterEach(() => { + wrapper.destroy(); + fakeApollo = null; + }); + + it('should render error message on reject', async () => { + mountComponent({ queryHandler: jest.fn().mockRejectedValue('ERROR') }); + await waitForPromises(); + + expect(createFlash).toHaveBeenCalled(); + }); + + it('calls the query with correct variables', () => { + mountComponent(); + + expect(successQueryHandler).toHaveBeenCalledWith({ + id: 'gid://gitlab/Issue/123', + }); + }); + + it('calls the subscription with correct variable for issue', () => { + mountComponent(); + + expect(successSubscriptionHandler).toHaveBeenCalledWith({ + id: 'gid://gitlab/Issue/123', + }); + }); + + it('renders correct initial results', async () => { + mountComponent({ subscriptionHandler: nullSubscriptionHandler }); + await waitForPromises(); + + expect(wrapper.find('#contact_0').text()).toContain('Someone Important'); + expect(wrapper.find('#contact_container_0').text()).toContain('si@gitlab.com'); + expect(wrapper.find('#contact_1').text()).toContain('Marty McFly'); + }); + + it('renders correct results after subscription update', async () => { + mountComponent(); + await waitForPromises(); + + const contact = ['Dave Davies', 'dd@gitlab.com', '+44 20 1111 2222', 'Vice President']; + contact.forEach((property) => { + expect(wrapper.find('#contact_container_0').text()).toContain(property); + }); + }); +}); diff --git a/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js b/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js index 619e89beb23..1e2173e2988 100644 --- a/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js +++ b/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js @@ -145,13 +145,20 @@ describe('Sidebar date Widget', () => { ${false} | ${SidebarInheritDate} | ${'SidebarInheritDate'} | ${false} `( 'when canInherit is $canInherit, $componentName display is $expected', - ({ canInherit, component, expected }) => { + async ({ canInherit, component, expected }) => { createComponent({ canInherit }); + await waitForPromises(); expect(wrapper.find(component).exists()).toBe(expected); }, ); + it('does not render SidebarInheritDate when canInherit is true and date is loading', async () => { + createComponent({ canInherit: true }); + + expect(wrapper.find(SidebarInheritDate).exists()).toBe(false); + }); + it('displays a flash message when query is rejected', async () => { createComponent({ dueDateQueryHandler: jest.fn().mockRejectedValue('Houston, we have a problem'), 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 4d38eba8035..fda21e06987 100644 --- a/spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js +++ b/spec/frontend/sidebar/components/date/sidebar_inherit_date_spec.js @@ -10,7 +10,7 @@ describe('SidebarInheritDate', () => { const findFixedRadio = () => wrapper.findAll(GlFormRadio).at(0); const findInheritRadio = () => wrapper.findAll(GlFormRadio).at(1); - const createComponent = () => { + const createComponent = ({ dueDateIsFixed = false } = {}) => { wrapper = shallowMount(SidebarInheritDate, { provide: { canUpdate: true, @@ -18,11 +18,10 @@ describe('SidebarInheritDate', () => { propsData: { issuable: { dueDate: '2021-04-15', - dueDateIsFixed: true, + dueDateIsFixed, dueDateFixed: '2021-04-15', dueDateFromMilestones: '2021-05-15', }, - isLoading: false, dateType: 'dueDate', }, }); @@ -45,6 +44,13 @@ describe('SidebarInheritDate', () => { expect(findInheritRadio().text()).toBe('Inherited:'); }); + it('does not emit set-date if fixed value does not change', () => { + createComponent({ dueDateIsFixed: true }); + findFixedRadio().vm.$emit('input', true); + + expect(wrapper.emitted('set-date')).toBeUndefined(); + }); + it('emits set-date event on click on radio button', () => { findFixedRadio().vm.$emit('input', true); diff --git a/spec/frontend/sidebar/components/mock_data.js b/spec/frontend/sidebar/components/mock_data.js new file mode 100644 index 00000000000..70c3f8a3012 --- /dev/null +++ b/spec/frontend/sidebar/components/mock_data.js @@ -0,0 +1,56 @@ +export const getIssueCrmContactsQueryResponse = { + data: { + issue: { + id: 'gid://gitlab/Issue/123', + customerRelationsContacts: { + nodes: [ + { + id: 'gid://gitlab/CustomerRelations::Contact/1', + firstName: 'Someone', + lastName: 'Important', + email: 'si@gitlab.com', + phone: null, + description: null, + organization: null, + }, + { + id: 'gid://gitlab/CustomerRelations::Contact/5', + firstName: 'Marty', + lastName: 'McFly', + email: null, + phone: null, + description: null, + organization: null, + }, + ], + }, + }, + }, +}; + +export const issueCrmContactsUpdateNullResponse = { + data: { + issueCrmContactsUpdated: null, + }, +}; + +export const issueCrmContactsUpdateResponse = { + data: { + issueCrmContactsUpdated: { + id: 'gid://gitlab/Issue/123', + customerRelationsContacts: { + nodes: [ + { + id: 'gid://gitlab/CustomerRelations::Contact/13', + firstName: 'Dave', + lastName: 'Davies', + email: 'dd@gitlab.com', + phone: '+44 20 1111 2222', + description: 'Vice President', + organization: null, + }, + ], + }, + }, + }, +}; diff --git a/spec/frontend/sidebar/components/reference/sidebar_reference_widget_spec.js b/spec/frontend/sidebar/components/reference/sidebar_reference_widget_spec.js index cc428693930..69e35cd1d05 100644 --- a/spec/frontend/sidebar/components/reference/sidebar_reference_widget_spec.js +++ b/spec/frontend/sidebar/components/reference/sidebar_reference_widget_spec.js @@ -3,7 +3,7 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { IssuableType } from '~/issue_show/constants'; +import { IssuableType } from '~/issues/constants'; import SidebarReferenceWidget from '~/sidebar/components/reference/sidebar_reference_widget.vue'; import issueReferenceQuery from '~/sidebar/queries/issue_reference.query.graphql'; import mergeRequestReferenceQuery from '~/sidebar/queries/merge_request_reference.query.graphql'; diff --git a/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js b/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js index ca6e5ac5e7f..d7471d99477 100644 --- a/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js +++ b/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js @@ -17,7 +17,7 @@ import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; import createFlash from '~/flash'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; -import { IssuableType } from '~/issue_show/constants'; +import { IssuableType } from '~/issues/constants'; import { timeFor } from '~/lib/utils/datetime_utility'; import SidebarDropdownWidget from '~/sidebar/components/sidebar_dropdown_widget.vue'; import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue'; @@ -369,16 +369,18 @@ describe('SidebarDropdownWidget', () => { describe('when a user is searching', () => { describe('when search result is not found', () => { - it('renders "No milestone found"', async () => { - createComponent(); + describe('when milestone', () => { + it('renders "No milestone found"', async () => { + createComponent(); - await toggleDropdown(); + await toggleDropdown(); - findSearchBox().vm.$emit('input', 'non existing milestones'); + findSearchBox().vm.$emit('input', 'non existing milestones'); - await wrapper.vm.$nextTick(); + await wrapper.vm.$nextTick(); - expect(findDropdownText().text()).toBe('No milestone found'); + expect(findDropdownText().text()).toBe('No milestone found'); + }); }); }); }); diff --git a/spec/frontend/sidebar/components/time_tracking/mock_data.js b/spec/frontend/sidebar/components/time_tracking/mock_data.js index 938750bd58b..3f1b3fa8ec1 100644 --- a/spec/frontend/sidebar/components/time_tracking/mock_data.js +++ b/spec/frontend/sidebar/components/time_tracking/mock_data.js @@ -11,11 +11,13 @@ export const getIssueTimelogsQueryResponse = { __typename: 'Timelog', timeSpent: 14400, user: { + id: 'user-1', name: 'John Doe18', __typename: 'UserCore', }, spentAt: '2020-05-01T00:00:00Z', note: { + id: 'note-1', body: 'A note', __typename: 'Note', }, @@ -25,6 +27,7 @@ export const getIssueTimelogsQueryResponse = { __typename: 'Timelog', timeSpent: 1800, user: { + id: 'user-2', name: 'Administrator', __typename: 'UserCore', }, @@ -36,11 +39,13 @@ export const getIssueTimelogsQueryResponse = { __typename: 'Timelog', timeSpent: 14400, user: { + id: 'user-2', name: 'Administrator', __typename: 'UserCore', }, spentAt: '2021-05-01T00:00:00Z', note: { + id: 'note-2', body: 'A note', __typename: 'Note', }, @@ -65,11 +70,13 @@ export const getMrTimelogsQueryResponse = { __typename: 'Timelog', timeSpent: 1800, user: { + id: 'user-1', name: 'Administrator', __typename: 'UserCore', }, spentAt: '2021-05-07T14:44:55Z', note: { + id: 'note-1', body: 'Thirty minutes!', __typename: 'Note', }, @@ -79,6 +86,7 @@ export const getMrTimelogsQueryResponse = { __typename: 'Timelog', timeSpent: 3600, user: { + id: 'user-1', name: 'Administrator', __typename: 'UserCore', }, @@ -90,11 +98,13 @@ export const getMrTimelogsQueryResponse = { __typename: 'Timelog', timeSpent: 300, user: { + id: 'user-1', name: 'Administrator', __typename: 'UserCore', }, spentAt: '2021-03-10T00:00:00Z', note: { + id: 'note-2', body: 'A note with some time', __typename: 'Note', }, diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js index 1ebd3c622ca..42e89a3ba84 100644 --- a/spec/frontend/sidebar/mock_data.js +++ b/spec/frontend/sidebar/mock_data.js @@ -223,6 +223,7 @@ const mockData = { export const issueConfidentialityResponse = (confidential = false) => ({ data: { workspace: { + id: '1', __typename: 'Project', issuable: { __typename: 'Issue', @@ -236,6 +237,7 @@ export const issueConfidentialityResponse = (confidential = false) => ({ export const issuableDueDateResponse = (dueDate = null) => ({ data: { workspace: { + id: '1', __typename: 'Project', issuable: { __typename: 'Issue', @@ -249,6 +251,7 @@ export const issuableDueDateResponse = (dueDate = null) => ({ export const issuableStartDateResponse = (startDate = null) => ({ data: { workspace: { + id: '1', __typename: 'Group', issuable: { __typename: 'Epic', @@ -265,6 +268,7 @@ export const issuableStartDateResponse = (startDate = null) => ({ export const epicParticipantsResponse = () => ({ data: { workspace: { + id: '1', __typename: 'Group', issuable: { __typename: 'Epic', @@ -290,6 +294,7 @@ export const epicParticipantsResponse = () => ({ export const issueReferenceResponse = (reference) => ({ data: { workspace: { + id: '1', __typename: 'Project', issuable: { __typename: 'Issue', @@ -303,6 +308,7 @@ export const issueReferenceResponse = (reference) => ({ export const issueSubscriptionsResponse = (subscribed = false, emailsDisabled = false) => ({ data: { workspace: { + id: '1', __typename: 'Project', issuable: { __typename: 'Issue', @@ -318,6 +324,7 @@ export const issuableQueryResponse = { data: { workspace: { __typename: 'Project', + id: '1', issuable: { __typename: 'Issue', id: 'gid://gitlab/Issue/1', @@ -344,6 +351,7 @@ export const searchQueryResponse = { data: { workspace: { __typename: 'Project', + id: '1', users: { nodes: [ { @@ -428,12 +436,15 @@ export const searchResponse = { data: { workspace: { __typename: 'Project', + id: '1', users: { nodes: [ { + id: 'gid://gitlab/User/1', user: mockUser1, }, { + id: 'gid://gitlab/User/4', user: mockUser2, }, ], @@ -445,6 +456,7 @@ export const searchResponse = { export const projectMembersResponse = { data: { workspace: { + id: '1', __typename: 'Project', users: { nodes: [ @@ -452,10 +464,11 @@ export const projectMembersResponse = { null, null, // Remove duplicated entry https://gitlab.com/gitlab-org/gitlab/-/issues/327822 - { user: mockUser1 }, - { user: mockUser1 }, - { user: mockUser2 }, + { id: 'user-1', user: mockUser1 }, + { id: 'user-2', user: mockUser1 }, + { id: 'user-3', user: mockUser2 }, { + id: 'user-4', user: { id: 'gid://gitlab/User/2', avatarUrl: @@ -477,16 +490,18 @@ export const projectMembersResponse = { export const groupMembersResponse = { data: { workspace: { - __typename: 'roup', + id: '1', + __typename: 'Group', users: { nodes: [ // Remove nulls https://gitlab.com/gitlab-org/gitlab/-/issues/329750 null, null, // Remove duplicated entry https://gitlab.com/gitlab-org/gitlab/-/issues/327822 - { user: mockUser1 }, - { user: mockUser1 }, + { id: 'user-1', user: mockUser1 }, + { id: 'user-2', user: mockUser1 }, { + id: 'user-3', user: { id: 'gid://gitlab/User/2', avatarUrl: @@ -509,6 +524,7 @@ export const participantsQueryResponse = { data: { workspace: { __typename: 'Project', + id: '1', issuable: { __typename: 'Issue', id: 'gid://gitlab/Issue/1', @@ -578,6 +594,7 @@ export const mockMilestone2 = { export const mockProjectMilestonesResponse = { data: { workspace: { + id: 'gid://gitlab/Project/1', attributes: { nodes: [mockMilestone1, mockMilestone2], }, @@ -663,6 +680,7 @@ export const todosResponse = { data: { workspace: { __typename: 'Group', + id: '1', issuable: { __typename: 'Epic', id: 'gid://gitlab/Epic/4', @@ -681,6 +699,7 @@ export const todosResponse = { export const noTodosResponse = { data: { workspace: { + id: '1', __typename: 'Group', issuable: { __typename: 'Epic', diff --git a/spec/frontend/sidebar/sidebar_labels_spec.js b/spec/frontend/sidebar/sidebar_labels_spec.js deleted file mode 100644 index 8437ee1b723..00000000000 --- a/spec/frontend/sidebar/sidebar_labels_spec.js +++ /dev/null @@ -1,190 +0,0 @@ -import { shallowMount } from '@vue/test-utils'; -import { - mockLabels, - mockRegularLabel, -} from 'jest/vue_shared/components/sidebar/labels_select_vue/mock_data'; -import updateIssueLabelsMutation from '~/boards/graphql/issue_set_labels.mutation.graphql'; -import { MutationOperationMode } from '~/graphql_shared/utils'; -import { IssuableType } from '~/issue_show/constants'; -import SidebarLabels from '~/sidebar/components/labels/sidebar_labels.vue'; -import updateMergeRequestLabelsMutation from '~/sidebar/queries/update_merge_request_labels.mutation.graphql'; -import { toLabelGid } from '~/sidebar/utils'; -import { DropdownVariant } from '~/vue_shared/components/sidebar/labels_select_vue/constants'; -import LabelsSelect from '~/vue_shared/components/sidebar/labels_select_vue/labels_select_root.vue'; - -describe('sidebar labels', () => { - let wrapper; - - const defaultProps = { - allowLabelCreate: true, - allowLabelEdit: true, - allowScopedLabels: true, - canEdit: true, - iid: '1', - initiallySelectedLabels: mockLabels, - issuableType: 'issue', - labelsFetchPath: '/gitlab-org/gitlab-test/-/labels.json?include_ancestor_groups=true', - labelsManagePath: '/gitlab-org/gitlab-test/-/labels', - projectIssuesPath: '/gitlab-org/gitlab-test/-/issues', - projectPath: 'gitlab-org/gitlab-test', - fullPath: 'gitlab-org/gitlab-test', - }; - - const $apollo = { - mutate: jest.fn().mockResolvedValue(), - }; - - const userUpdatedLabels = [ - { - ...mockRegularLabel, - set: false, - }, - { - id: 40, - title: 'Security', - color: '#ddd', - text_color: '#fff', - set: true, - }, - { - id: 55, - title: 'Tooling', - color: '#ddd', - text_color: '#fff', - set: false, - }, - ]; - - const findLabelsSelect = () => wrapper.find(LabelsSelect); - - const mountComponent = (props = {}) => { - wrapper = shallowMount(SidebarLabels, { - provide: { - ...defaultProps, - ...props, - }, - mocks: { - $apollo, - }, - }); - }; - - afterEach(() => { - wrapper.destroy(); - wrapper = null; - }); - - describe('LabelsSelect props', () => { - beforeEach(() => { - mountComponent(); - }); - - it('are as expected', () => { - expect(findLabelsSelect().props()).toMatchObject({ - allowLabelCreate: defaultProps.allowLabelCreate, - allowLabelEdit: defaultProps.allowLabelEdit, - allowMultiselect: true, - allowScopedLabels: defaultProps.allowScopedLabels, - footerCreateLabelTitle: 'Create project label', - footerManageLabelTitle: 'Manage project labels', - labelsCreateTitle: 'Create project label', - labelsFetchPath: defaultProps.labelsFetchPath, - labelsFilterBasePath: defaultProps.projectIssuesPath, - labelsManagePath: defaultProps.labelsManagePath, - labelsSelectInProgress: false, - selectedLabels: defaultProps.initiallySelectedLabels, - variant: DropdownVariant.Sidebar, - }); - }); - }); - - describe('when type is issue', () => { - beforeEach(() => { - mountComponent({ issuableType: IssuableType.Issue }); - }); - - describe('when labels are updated', () => { - it('invokes a mutation', () => { - findLabelsSelect().vm.$emit('updateSelectedLabels', userUpdatedLabels); - - const expected = { - mutation: updateIssueLabelsMutation, - variables: { - input: { - iid: defaultProps.iid, - projectPath: defaultProps.projectPath, - labelIds: [toLabelGid(29), toLabelGid(28), toLabelGid(27), toLabelGid(40)], - }, - }, - }; - - expect($apollo.mutate).toHaveBeenCalledWith(expected); - }); - }); - - describe('when label `x` is clicked', () => { - it('invokes a mutation', () => { - findLabelsSelect().vm.$emit('onLabelRemove', 27); - - const expected = { - mutation: updateIssueLabelsMutation, - variables: { - input: { - iid: defaultProps.iid, - projectPath: defaultProps.projectPath, - removeLabelIds: [27], - }, - }, - }; - - expect($apollo.mutate).toHaveBeenCalledWith(expected); - }); - }); - }); - - describe('when type is merge_request', () => { - beforeEach(() => { - mountComponent({ issuableType: IssuableType.MergeRequest }); - }); - - describe('when labels are updated', () => { - it('invokes a mutation', () => { - findLabelsSelect().vm.$emit('updateSelectedLabels', userUpdatedLabels); - - const expected = { - mutation: updateMergeRequestLabelsMutation, - variables: { - input: { - iid: defaultProps.iid, - labelIds: [toLabelGid(29), toLabelGid(28), toLabelGid(27), toLabelGid(40)], - operationMode: MutationOperationMode.Replace, - projectPath: defaultProps.projectPath, - }, - }, - }; - - expect($apollo.mutate).toHaveBeenCalledWith(expected); - }); - }); - - describe('when label `x` is clicked', () => { - it('invokes a mutation', () => { - findLabelsSelect().vm.$emit('onLabelRemove', 27); - - const expected = { - mutation: updateMergeRequestLabelsMutation, - variables: { - input: { - iid: defaultProps.iid, - labelIds: [toLabelGid(27)], - operationMode: MutationOperationMode.Remove, - projectPath: defaultProps.projectPath, - }, - }, - }; - - expect($apollo.mutate).toHaveBeenCalledWith(expected); - }); - }); - }); -}); |