diff --git a/app/assets/javascripts/work_items/components/work_item_description.vue b/app/assets/javascripts/work_items/components/work_item_description.vue index 61dec21cae4b5f0d1617b97772401818d21533e7..7e062776f98bbabfd8602ddb5429b77564b4e13b 100644 --- a/app/assets/javascripts/work_items/components/work_item_description.vue +++ b/app/assets/javascripts/work_items/components/work_item_description.vue @@ -9,7 +9,6 @@ import EditedAt from '~/issues/show/components/edited.vue'; import Tracking from '~/tracking'; import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue'; import { autocompleteDataSources, markdownPreviewPath } from '../utils'; -import workItemDescriptionSubscription from '../graphql/work_item_description.subscription.graphql'; import updateWorkItemMutation from '../graphql/update_work_item.mutation.graphql'; import workItemByIidQuery from '../graphql/work_item_by_iid.query.graphql'; import { i18n, TRACKING_CATEGORY_SHOW, WIDGET_TYPE_DESCRIPTION } from '../constants'; @@ -75,14 +74,6 @@ export default { error() { this.$emit('error', i18n.fetchError); }, - subscribeToMore: { - document: workItemDescriptionSubscription, - variables() { - return { - issuableId: this.workItemId, - }; - }, - }, }, }, computed: { diff --git a/app/assets/javascripts/work_items/components/work_item_detail.vue b/app/assets/javascripts/work_items/components/work_item_detail.vue index 1ac40fe7dcbcf775c5e376c355462842b8561fb5..5539226e84e1536ae31fe264b58771a2a0befbf1 100644 --- a/app/assets/javascripts/work_items/components/work_item_detail.vue +++ b/app/assets/javascripts/work_items/components/work_item_detail.vue @@ -39,10 +39,7 @@ import { WIDGET_TYPE_NOTES, } from '../constants'; -import workItemDatesSubscription from '../../graphql_shared/subscriptions/work_item_dates.subscription.graphql'; -import workItemTitleSubscription from '../graphql/work_item_title.subscription.graphql'; -import workItemAssigneesSubscription from '../graphql/work_item_assignees.subscription.graphql'; -import workItemMilestoneSubscription from '../graphql/work_item_milestone.subscription.graphql'; +import workItemUpdatedSubscription from '../graphql/work_item_updated.subscription.graphql'; import updateWorkItemMutation from '../graphql/update_work_item.mutation.graphql'; import updateWorkItemTaskMutation from '../graphql/update_work_item_task.mutation.graphql'; import workItemByIidQuery from '../graphql/work_item_by_iid.query.graphql'; @@ -165,52 +162,17 @@ export default { document.title = `${this.workItem.title} · ${this.workItem?.workItemType?.name}${path}`; } }, - subscribeToMore: [ - { - document: workItemTitleSubscription, - variables() { - return { - issuableId: this.workItem.id, - }; - }, - skip() { - return !this.workItem?.id; - }, - }, - { - document: workItemDatesSubscription, - variables() { - return { - issuableId: this.workItem.id, - }; - }, - skip() { - return !this.isWidgetPresent(WIDGET_TYPE_START_AND_DUE_DATE) || !this.workItem?.id; - }, - }, - { - document: workItemAssigneesSubscription, - variables() { - return { - issuableId: this.workItem.id, - }; - }, - skip() { - return !this.isWidgetPresent(WIDGET_TYPE_ASSIGNEES) || !this.workItem?.id; - }, + subscribeToMore: { + document: workItemUpdatedSubscription, + variables() { + return { + id: this.workItem.id, + }; }, - { - document: workItemMilestoneSubscription, - variables() { - return { - issuableId: this.workItem.id, - }; - }, - skip() { - return !this.isWidgetPresent(WIDGET_TYPE_MILESTONE) || !this.workItem?.id; - }, + skip() { + return !this.workItem?.id; }, - ], + }, }, }, computed: { diff --git a/app/assets/javascripts/work_items/components/work_item_labels.vue b/app/assets/javascripts/work_items/components/work_item_labels.vue index 015c86ba04336130ba02bbf223cd70e2ce5b7002..662ba880753949171de097a37f95ffc0dedbd4d6 100644 --- a/app/assets/javascripts/work_items/components/work_item_labels.vue +++ b/app/assets/javascripts/work_items/components/work_item_labels.vue @@ -7,7 +7,6 @@ import labelSearchQuery from '~/sidebar/components/labels/labels_select_widget/g import LabelItem from '~/sidebar/components/labels/labels_select_widget/label_item.vue'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import { isScopedLabel } from '~/lib/utils/common_utils'; -import workItemLabelsSubscription from 'ee_else_ce/work_items/graphql/work_item_labels.subscription.graphql'; import updateWorkItemMutation from '../graphql/update_work_item.mutation.graphql'; import workItemByIidQuery from '../graphql/work_item_by_iid.query.graphql'; @@ -87,14 +86,6 @@ export default { error() { this.$emit('error', i18n.fetchError); }, - subscribeToMore: { - document: workItemLabelsSubscription, - variables() { - return { - issuableId: this.workItemId, - }; - }, - }, }, searchLabels: { query: labelSearchQuery, diff --git a/app/assets/javascripts/work_items/graphql/work_item_assignees.subscription.graphql b/app/assets/javascripts/work_items/graphql/work_item_assignees.subscription.graphql deleted file mode 100644 index d5b2de8c4c6493b52c7b1e0ff51dc0900d1f7ed3..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/work_items/graphql/work_item_assignees.subscription.graphql +++ /dev/null @@ -1,21 +0,0 @@ -#import "~/graphql_shared/fragments/user.fragment.graphql" - -subscription issuableAssignees($issuableId: IssuableID!) { - issuableAssigneesUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetAssignees { - type - allowsMultipleAssignees - canInviteMembers - assignees { - nodes { - ...User - } - } - } - } - } - } -} diff --git a/app/assets/javascripts/work_items/graphql/work_item_description.subscription.graphql b/app/assets/javascripts/work_items/graphql/work_item_description.subscription.graphql deleted file mode 100644 index 4eb3d8067d9363a8e9dfb1d127f48549b7b8ce18..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/work_items/graphql/work_item_description.subscription.graphql +++ /dev/null @@ -1,20 +0,0 @@ -subscription issuableDescription($issuableId: IssuableID!) { - issuableDescriptionUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetDescription { - type - description - descriptionHtml - lastEditedAt - lastEditedBy { - id - name - webPath - } - } - } - } - } -} diff --git a/app/assets/javascripts/work_items/graphql/work_item_labels.subscription.graphql b/app/assets/javascripts/work_items/graphql/work_item_labels.subscription.graphql deleted file mode 100644 index 86d936bf4ddb5de5f3ebc7a43e7d313670048700..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/work_items/graphql/work_item_labels.subscription.graphql +++ /dev/null @@ -1,19 +0,0 @@ -#import "~/graphql_shared/fragments/label.fragment.graphql" - -subscription workItemLabels($issuableId: IssuableID!) { - issuableLabelsUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetLabels { - type - labels { - nodes { - ...Label - } - } - } - } - } - } -} diff --git a/app/assets/javascripts/work_items/graphql/work_item_milestone.subscription.graphql b/app/assets/javascripts/work_items/graphql/work_item_milestone.subscription.graphql deleted file mode 100644 index f5163003fe54fe0dca961d5c40f2d1dc6d0c4f35..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/work_items/graphql/work_item_milestone.subscription.graphql +++ /dev/null @@ -1,17 +0,0 @@ -#import "~/work_items/graphql/milestone.fragment.graphql" - -subscription issuableMilestone($issuableId: IssuableID!) { - issuableMilestoneUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetMilestone { - type - milestone { - ...MilestoneFragment - } - } - } - } - } -} diff --git a/app/assets/javascripts/work_items/graphql/work_item_title.subscription.graphql b/app/assets/javascripts/work_items/graphql/work_item_title.subscription.graphql deleted file mode 100644 index 2ac01b79d6fa689799d2a0328760c286b5b70ca5..0000000000000000000000000000000000000000 --- a/app/assets/javascripts/work_items/graphql/work_item_title.subscription.graphql +++ /dev/null @@ -1,8 +0,0 @@ -subscription issuableTitleUpdated($issuableId: IssuableID!) { - issuableTitleUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - title - } - } -} diff --git a/app/assets/javascripts/work_items/graphql/work_item_updated.subscription.graphql b/app/assets/javascripts/work_items/graphql/work_item_updated.subscription.graphql new file mode 100644 index 0000000000000000000000000000000000000000..8b63f46ab288f1882a4f78d40f4b0f7e2a9fc1b8 --- /dev/null +++ b/app/assets/javascripts/work_items/graphql/work_item_updated.subscription.graphql @@ -0,0 +1,7 @@ +#import "./work_item.fragment.graphql" + +subscription workItemUpdated($id: WorkItemID!) { + workItemUpdated(workItemId: $id) { + ...WorkItem + } +} diff --git a/ee/app/assets/javascripts/work_items/components/work_item_health_status.vue b/ee/app/assets/javascripts/work_items/components/work_item_health_status.vue index 9aff8cd2b2b2940d025618b6858a3a9cbe332565..ac3222cdf2f2392e77b99e3399fe1604b8ac83c3 100644 --- a/ee/app/assets/javascripts/work_items/components/work_item_health_status.vue +++ b/ee/app/assets/javascripts/work_items/components/work_item_health_status.vue @@ -2,7 +2,6 @@ import { GlDropdown, GlDropdownItem, GlFormGroup, GlBadge } from '@gitlab/ui'; import * as Sentry from '@sentry/browser'; -import workItemHealthStatusSubscription from 'ee/work_items/graphql/work_item_health_status.subscription.graphql'; import { s__ } from '~/locale'; import { HEALTH_STATUS_I18N_NONE, @@ -12,13 +11,11 @@ import { } from 'ee/sidebar/constants'; import { issueHealthStatusVariantMapping } from 'ee/related_items_tree/constants'; import { - i18n, sprintfWorkItem, I18N_WORK_ITEM_ERROR_UPDATING, TRACKING_CATEGORY_SHOW, } from '~/work_items/constants'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; -import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; import Tracking from '~/tracking'; export default { @@ -91,34 +88,6 @@ export default { }; }, }, - apollo: { - workItem: { - query: workItemByIidQuery, - variables() { - return { - fullPath: this.fullPath, - iid: this.workItemIid, - }; - }, - update(data) { - return data.workspace.workItems.nodes[0]; - }, - skip() { - return !this.workItemIid; - }, - error() { - this.$emit('error', i18n.fetchError); - }, - subscribeToMore: { - document: workItemHealthStatusSubscription, - variables() { - return { - issuableId: this.workItemId, - }; - }, - }, - }, - }, methods: { isSelected(healthStatus) { return this.healthStatus === healthStatus; diff --git a/ee/app/assets/javascripts/work_items/components/work_item_iteration.vue b/ee/app/assets/javascripts/work_items/components/work_item_iteration.vue index 44bc3969aba3272d9547b85972c7a02ca409b9b5..25b033777c321a6bc005dfeeec7c9d45cdc36806 100644 --- a/ee/app/assets/javascripts/work_items/components/work_item_iteration.vue +++ b/ee/app/assets/javascripts/work_items/components/work_item_iteration.vue @@ -15,7 +15,6 @@ import Tracking from '~/tracking'; import { s__ } from '~/locale'; import { groupByIterationCadences, getIterationPeriod } from 'ee/iterations/utils'; import { - i18n, I18N_WORK_ITEM_ERROR_UPDATING, sprintfWorkItem, TRACKING_CATEGORY_SHOW, @@ -25,8 +24,6 @@ import { STATUS_OPEN } from '~/issues/constants'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import projectIterationsQuery from 'ee/work_items/graphql/project_iterations.query.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; -import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import workItemIterationSubscription from 'ee/work_items/graphql/work_item_iteration.subscription.graphql'; const noIterationId = 'no-iteration-id'; @@ -128,32 +125,6 @@ export default { }, }, apollo: { - workItem: { - query: workItemByIidQuery, - variables() { - return { - fullPath: this.fullPath, - iid: this.workItemIid, - }; - }, - update(data) { - return data.workspace.workItems.nodes[0]; - }, - skip() { - return !this.workItemIid; - }, - error() { - this.$emit('error', i18n.fetchError); - }, - subscribeToMore: { - document: workItemIterationSubscription, - variables() { - return { - issuableId: this.workItemId, - }; - }, - }, - }, iterations: { query: projectIterationsQuery, variables() { diff --git a/ee/app/assets/javascripts/work_items/components/work_item_weight.vue b/ee/app/assets/javascripts/work_items/components/work_item_weight.vue index b6f1b2a78749b7121b67e6c7dbab52293b330ff6..d3c2587d899595d4597acf2b5ca73dbdae7da283 100644 --- a/ee/app/assets/javascripts/work_items/components/work_item_weight.vue +++ b/ee/app/assets/javascripts/work_items/components/work_item_weight.vue @@ -1,17 +1,14 @@ <script> import { GlForm, GlFormGroup, GlFormInput } from '@gitlab/ui'; import * as Sentry from '@sentry/browser'; -import workItemWeightSubscription from 'ee/graphql_shared/subscriptions/issuable_weight.subscription.graphql'; import { __ } from '~/locale'; import Tracking from '~/tracking'; import { sprintfWorkItem, - i18n, I18N_WORK_ITEM_ERROR_UPDATING, TRACKING_CATEGORY_SHOW, } from '~/work_items/constants'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; -import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; /* eslint-disable @gitlab/require-i18n-strings */ const allowedKeys = [ @@ -81,34 +78,6 @@ export default { isEditing: false, }; }, - apollo: { - workItem: { - query: workItemByIidQuery, - variables() { - return { - fullPath: this.fullPath, - iid: this.workItemIid, - }; - }, - update(data) { - return data.workspace.workItems.nodes[0]; - }, - skip() { - return !this.workItemIid; - }, - error() { - this.$emit('error', i18n.fetchError); - }, - subscribeToMore: { - document: workItemWeightSubscription, - variables() { - return { - issuableId: this.workItemId, - }; - }, - }, - }, - }, computed: { placeholder() { return this.canUpdate && this.isEditing ? __('Enter a number') : __('None'); diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item_health_status.subscription.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item_health_status.subscription.graphql deleted file mode 100644 index 89e688420565b87de0c2e5e3ab45823b842d147b..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/work_items/graphql/work_item_health_status.subscription.graphql +++ /dev/null @@ -1,13 +0,0 @@ -subscription issuableHealthStatusUpdated($issuableId: IssuableID!) { - issuableHealthStatusUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetHealthStatus { - type - healthStatus - } - } - } - } -} diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item_iteration.subscription.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item_iteration.subscription.graphql deleted file mode 100644 index e85766ca5ea5570c9f21da3ac84dc4e9197538ee..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/work_items/graphql/work_item_iteration.subscription.graphql +++ /dev/null @@ -1,20 +0,0 @@ -subscription issuableIterationUpdated($issuableId: IssuableID!) { - issuableIterationUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetIteration { - type - iteration { - description - id - iid - title - startDate - dueDate - } - } - } - } - } -} diff --git a/ee/app/assets/javascripts/work_items/graphql/work_item_labels.subscription.graphql b/ee/app/assets/javascripts/work_items/graphql/work_item_labels.subscription.graphql deleted file mode 100644 index a2c6ffc6607e2c652e12e94bdd0a27443debd20f..0000000000000000000000000000000000000000 --- a/ee/app/assets/javascripts/work_items/graphql/work_item_labels.subscription.graphql +++ /dev/null @@ -1,20 +0,0 @@ -#import "~/graphql_shared/fragments/label.fragment.graphql" - -subscription workItemLabelsEE($issuableId: IssuableID!) { - issuableLabelsUpdated(issuableId: $issuableId) { - ... on WorkItem { - id - widgets { - ... on WorkItemWidgetLabels { - type - allowsScopedLabels - labels { - nodes { - ...Label - } - } - } - } - } - } -} diff --git a/ee/spec/frontend/work_items/components/work_item_detail_spec.js b/ee/spec/frontend/work_items/components/work_item_detail_spec.js index 14abfb8a26b3bd5e118349cfb21c18e741197fec..5ba69c1ea25ad744510d883d0adcfc219eee87d7 100644 --- a/ee/spec/frontend/work_items/components/work_item_detail_spec.js +++ b/ee/spec/frontend/work_items/components/work_item_detail_spec.js @@ -6,28 +6,13 @@ import WorkItemWeight from 'ee/work_items/components/work_item_weight.vue'; import WorkItemProgress from 'ee/work_items/components/work_item_progress.vue'; import WorkItemIteration from 'ee/work_items/components/work_item_iteration.vue'; import WorkItemHealthStatus from 'ee/work_items/components/work_item_health_status.vue'; -import workItemWeightSubscription from 'ee/graphql_shared/subscriptions/issuable_weight.subscription.graphql'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import { - workItemDatesSubscriptionResponse, - workItemTitleSubscriptionResponse, - workItemByIidResponseFactory, - workItemWeightSubscriptionResponse, - workItemAssigneesSubscriptionResponse, - workItemIterationSubscriptionResponse, - workItemMilestoneSubscriptionResponse, - workItemHealthStatusSubscriptionResponse, -} from 'jest/work_items/mock_data'; +import { workItemByIidResponseFactory } from 'jest/work_items/mock_data'; import WorkItemDetail from '~/work_items/components/work_item_detail.vue'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import workItemDatesSubscription from '~/graphql_shared/subscriptions/work_item_dates.subscription.graphql'; -import workItemTitleSubscription from '~/work_items/graphql/work_item_title.subscription.graphql'; -import workItemAssigneesSubscription from '~/work_items/graphql/work_item_assignees.subscription.graphql'; -import workItemMilestoneSubscription from '~/work_items/graphql/work_item_milestone.subscription.graphql'; -import workItemIterationSubscription from 'ee/work_items/graphql/work_item_iteration.subscription.graphql'; -import workItemHealthStatusSubscription from 'ee/work_items/graphql/work_item_health_status.subscription.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; +import workItemUpdatedSubscription from '~/work_items/graphql/work_item_updated.subscription.graphql'; describe('WorkItemDetail component', () => { let wrapper; @@ -36,21 +21,9 @@ describe('WorkItemDetail component', () => { const workItemQueryResponse = workItemByIidResponseFactory({ canUpdate: true, canDelete: true }); const successHandler = jest.fn().mockResolvedValue(workItemQueryResponse); - const datesSubscriptionHandler = jest.fn().mockResolvedValue(workItemDatesSubscriptionResponse); - const titleSubscriptionHandler = jest.fn().mockResolvedValue(workItemTitleSubscriptionResponse); - const weightSubscriptionHandler = jest.fn().mockResolvedValue(workItemWeightSubscriptionResponse); - const assigneesSubscriptionHandler = jest + const workItemUpdatedSubscriptionHandler = jest .fn() - .mockResolvedValue(workItemAssigneesSubscriptionResponse); - const milestoneSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemMilestoneSubscriptionResponse); - const iterationSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemIterationSubscriptionResponse); - const healthStatusSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemHealthStatusSubscriptionResponse); + .mockResolvedValue({ data: { workItemUpdated: null } }); const findAlert = () => wrapper.findComponent(GlAlert); const findWorkItemWeight = () => wrapper.findComponent(WorkItemWeight); @@ -66,13 +39,7 @@ describe('WorkItemDetail component', () => { wrapper = shallowMount(WorkItemDetail, { apolloProvider: createMockApollo([ [workItemByIidQuery, handler], - [workItemDatesSubscription, datesSubscriptionHandler], - [workItemTitleSubscription, titleSubscriptionHandler], - [workItemWeightSubscription, weightSubscriptionHandler], - [workItemAssigneesSubscription, assigneesSubscriptionHandler], - [workItemIterationSubscription, iterationSubscriptionHandler], - [workItemMilestoneSubscription, milestoneSubscriptionHandler], - [workItemHealthStatusSubscription, healthStatusSubscriptionHandler], + [workItemUpdatedSubscription, workItemUpdatedSubscriptionHandler], confidentialityMock, ]), provide: { diff --git a/ee/spec/frontend/work_items/components/work_item_health_status_spec.js b/ee/spec/frontend/work_items/components/work_item_health_status_spec.js index 2fd1126dcd286f6dda898ea6c4a75748d4dd14cb..3b6f0d037225fc327c1608d05a3661ebfecfdae9 100644 --- a/ee/spec/frontend/work_items/components/work_item_health_status_spec.js +++ b/ee/spec/frontend/work_items/components/work_item_health_status_spec.js @@ -8,7 +8,6 @@ import { mockTracking } from 'helpers/tracking_helper'; import waitForPromises from 'helpers/wait_for_promises'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import workItemHealthStatusSubscription from 'ee/work_items/graphql/work_item_health_status.subscription.graphql'; import { TRACKING_CATEGORY_SHOW } from '~/work_items/constants'; import { HEALTH_STATUS_AT_RISK, @@ -21,7 +20,6 @@ import { import { updateWorkItemMutationResponse, workItemByIidResponseFactory, - workItemHealthStatusSubscriptionResponse, } from 'jest/work_items/mock_data'; describe('WorkItemHealthStatus component', () => { @@ -29,10 +27,6 @@ describe('WorkItemHealthStatus component', () => { let wrapper; - const healthStatusSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemHealthStatusSubscriptionResponse); - const workItemId = 'gid://gitlab/WorkItem/1'; const workItemType = 'Task'; const workItemQueryResponse = workItemByIidResponseFactory({ canUpdate: true, canDelete: true }); @@ -54,7 +48,6 @@ describe('WorkItemHealthStatus component', () => { apolloProvider: createMockApollo([ [workItemByIidQuery, workItemQueryHandler], [updateWorkItemMutation, mutationHandler], - [workItemHealthStatusSubscription, healthStatusSubscriptionHandler], ]), propsData: { canUpdate, diff --git a/ee/spec/frontend/work_items/components/work_item_iteration_spec.js b/ee/spec/frontend/work_items/components/work_item_iteration_spec.js index b98e3c9cf97d0d62a20798a74a602f601224dd96..7c72776befb03241b6113ddf086f292ebc9f2f6c 100644 --- a/ee/spec/frontend/work_items/components/work_item_iteration_spec.js +++ b/ee/spec/frontend/work_items/components/work_item_iteration_spec.js @@ -17,15 +17,11 @@ import { getIterationPeriod } from 'ee/iterations/utils'; import { TRACKING_CATEGORY_SHOW } from '~/work_items/constants'; import projectIterationsQuery from 'ee/work_items/graphql/project_iterations.query.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; -import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import workItemIterationSubscription from 'ee/work_items/graphql/work_item_iteration.subscription.graphql'; import { groupIterationsResponse, groupIterationsResponseWithNoIterations, mockIterationWidgetResponse, updateWorkItemMutationResponse, - workItemByIidResponseFactory, - workItemIterationSubscriptionResponse, updateWorkItemMutationErrorResponse, } from 'jest/work_items/mock_data'; @@ -49,14 +45,8 @@ describe('WorkItemIteration component', () => { const findDropdownTextAtIndex = (index) => findDropdownTexts().at(index); const findInputGroup = () => wrapper.findComponent(GlFormGroup); - const workItemQueryResponse = workItemByIidResponseFactory({ canUpdate: true, canDelete: true }); - const workItemQueryHandler = jest.fn().mockResolvedValue(workItemQueryResponse); - const networkResolvedValue = new Error(); - const iterationSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemIterationSubscriptionResponse); const successSearchQueryHandler = jest.fn().mockResolvedValue(groupIterationsResponse); const successSearchWithNoMatchingIterations = jest .fn() @@ -83,8 +73,6 @@ describe('WorkItemIteration component', () => { } = {}) => { wrapper = shallowMountExtended(WorkItemIteration, { apolloProvider: createMockApollo([ - [workItemByIidQuery, workItemQueryHandler], - [workItemIterationSubscription, iterationSubscriptionHandler], [projectIterationsQuery, searchQueryHandler], [updateWorkItemMutation, mutationHandler], ]), @@ -252,18 +240,4 @@ describe('WorkItemIteration component', () => { }); }); }); - - it('calls the work item query', async () => { - createComponent(); - await waitForPromises(); - - expect(workItemQueryHandler).toHaveBeenCalled(); - }); - - it('skips calling the work item query when missing workItemIid', async () => { - createComponent({ workItemIid: '' }); - await waitForPromises(); - - expect(workItemQueryHandler).not.toHaveBeenCalled(); - }); }); diff --git a/ee/spec/frontend/work_items/components/work_item_labels_spec.js b/ee/spec/frontend/work_items/components/work_item_labels_spec.js index 0f51c2936125b2edaab86d0fe4d69cb05b89b042..508896cb62f783346c2651b7b4009641ee5319cb 100644 --- a/ee/spec/frontend/work_items/components/work_item_labels_spec.js +++ b/ee/spec/frontend/work_items/components/work_item_labels_spec.js @@ -5,7 +5,6 @@ import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import waitForPromises from 'helpers/wait_for_promises'; import labelSearchQuery from '~/sidebar/components/labels/labels_select_widget/graphql/project_labels.query.graphql'; -import workItemLabelsSubscription from 'ee_else_ce/work_items/graphql/work_item_labels.subscription.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; import WorkItemLabels from '~/work_items/components/work_item_labels.vue'; @@ -13,7 +12,6 @@ import { projectLabelsResponse, workItemByIidResponseFactory, updateWorkItemMutationResponse, - workItemLabelsSubscriptionResponse, } from 'jest/work_items/mock_data'; Vue.use(VueApollo); @@ -31,7 +29,6 @@ describe('WorkItemLabels component', () => { const successUpdateWorkItemMutationHandler = jest .fn() .mockResolvedValue(updateWorkItemMutationResponse); - const subscriptionHandler = jest.fn().mockResolvedValue(workItemLabelsSubscriptionResponse); const createComponent = ({ canUpdate = true, @@ -44,7 +41,6 @@ describe('WorkItemLabels component', () => { [workItemByIidQuery, workItemQueryHandler], [labelSearchQuery, searchQueryHandler], [updateWorkItemMutation, updateWorkItemMutationHandler], - [workItemLabelsSubscription, subscriptionHandler], ]), provide: { fullPath: 'test-project-path', diff --git a/ee/spec/frontend/work_items/components/work_item_weight_spec.js b/ee/spec/frontend/work_items/components/work_item_weight_spec.js index 1f94f443141c9cad0df5b026d99781c8df00abe8..ebfb8ae9dddcfec17b5e7268481385b324c70e9d 100644 --- a/ee/spec/frontend/work_items/components/work_item_weight_spec.js +++ b/ee/spec/frontend/work_items/components/work_item_weight_spec.js @@ -2,7 +2,6 @@ import { GlForm, GlFormInput } from '@gitlab/ui'; import Vue, { nextTick } from 'vue'; import VueApollo from 'vue-apollo'; import WorkItemWeight from 'ee/work_items/components/work_item_weight.vue'; -import workItemWeightSubscription from 'ee/graphql_shared/subscriptions/issuable_weight.subscription.graphql'; import createMockApollo from 'helpers/mock_apollo_helper'; import { mockTracking } from 'helpers/tracking_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper'; @@ -10,12 +9,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import { __ } from '~/locale'; import { TRACKING_CATEGORY_SHOW } from '~/work_items/constants'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; -import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import { - updateWorkItemMutationResponse, - workItemByIidResponseFactory, - workItemWeightSubscriptionResponse, -} from 'jest/work_items/mock_data'; +import { updateWorkItemMutationResponse } from 'jest/work_items/mock_data'; describe('WorkItemWeight component', () => { Vue.use(VueApollo); @@ -24,9 +18,6 @@ describe('WorkItemWeight component', () => { const workItemId = 'gid://gitlab/WorkItem/1'; const workItemType = 'Task'; - const workItemQueryResponse = workItemByIidResponseFactory({ canUpdate: true, canDelete: true }); - const workItemQueryHandler = jest.fn().mockResolvedValue(workItemQueryResponse); - const weightSubscriptionHandler = jest.fn().mockResolvedValue(workItemWeightSubscriptionResponse); const findForm = () => wrapper.findComponent(GlForm); const findInput = () => wrapper.findComponent(GlFormInput); @@ -40,11 +31,7 @@ describe('WorkItemWeight component', () => { mutationHandler = jest.fn().mockResolvedValue(updateWorkItemMutationResponse), } = {}) => { wrapper = mountExtended(WorkItemWeight, { - apolloProvider: createMockApollo([ - [workItemByIidQuery, workItemQueryHandler], - [workItemWeightSubscription, weightSubscriptionHandler], - [updateWorkItemMutation, mutationHandler], - ]), + apolloProvider: createMockApollo([[updateWorkItemMutation, mutationHandler]]), propsData: { canUpdate, weight, @@ -63,12 +50,6 @@ describe('WorkItemWeight component', () => { } }; - it('has a subscription', () => { - createComponent(); - - expect(weightSubscriptionHandler).toHaveBeenCalledWith({ issuableId: workItemId }); - }); - describe('`issue_weights` licensed feature', () => { describe.each` description | hasIssueWeightsFeature | exists @@ -237,18 +218,4 @@ describe('WorkItemWeight component', () => { }); }); }); - - it('fetches the work item', async () => { - createComponent(); - await waitForPromises(); - - expect(workItemQueryHandler).toHaveBeenCalled(); - }); - - it('skips fetching the work item when missing workItemIid', async () => { - createComponent({ workItemIid: '' }); - await waitForPromises(); - - expect(workItemQueryHandler).not.toHaveBeenCalled(); - }); }); diff --git a/spec/frontend/work_items/components/work_item_description_spec.js b/spec/frontend/work_items/components/work_item_description_spec.js index b910e9854f881d9e20ee715d4ace61f8abf52457..2b3fdd1b31cfa174eb1488b36e3e855e696c1be4 100644 --- a/spec/frontend/work_items/components/work_item_description_spec.js +++ b/spec/frontend/work_items/components/work_item_description_spec.js @@ -12,14 +12,12 @@ import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue import WorkItemDescription from '~/work_items/components/work_item_description.vue'; import WorkItemDescriptionRendered from '~/work_items/components/work_item_description_rendered.vue'; import { TRACKING_CATEGORY_SHOW } from '~/work_items/constants'; -import workItemDescriptionSubscription from '~/work_items/graphql/work_item_description.subscription.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; import { autocompleteDataSources, markdownPreviewPath } from '~/work_items/utils'; import { updateWorkItemMutationResponse, workItemByIidResponseFactory, - workItemDescriptionSubscriptionResponse, workItemQueryResponse, } from '../mock_data'; @@ -34,7 +32,6 @@ describe('WorkItemDescription', () => { Vue.use(VueApollo); const mutationSuccessHandler = jest.fn().mockResolvedValue(updateWorkItemMutationResponse); - const subscriptionHandler = jest.fn().mockResolvedValue(workItemDescriptionSubscriptionResponse); let workItemResponseHandler; const findForm = () => wrapper.findComponent(GlForm); @@ -63,7 +60,6 @@ describe('WorkItemDescription', () => { apolloProvider: createMockApollo([ [workItemByIidQuery, workItemResponseHandler], [updateWorkItemMutation, mutationHandler], - [workItemDescriptionSubscription, subscriptionHandler], ]), propsData: { workItemId: id, @@ -83,14 +79,6 @@ describe('WorkItemDescription', () => { } }; - it('has a subscription', async () => { - await createComponent(); - - expect(subscriptionHandler).toHaveBeenCalledWith({ - issuableId: workItemQueryResponse.data.workItem.id, - }); - }); - describe('editing description', () => { it('passes correct autocompletion data and preview markdown sources and enables quick actions', async () => { const { diff --git a/spec/frontend/work_items/components/work_item_detail_spec.js b/spec/frontend/work_items/components/work_item_detail_spec.js index d8ba8ea74f23cabd869035b3728bd9acc9c0eb33..0266533a11ca6c0082194eddfdcb6bbeca9b5976 100644 --- a/spec/frontend/work_items/components/work_item_detail_spec.js +++ b/spec/frontend/work_items/components/work_item_detail_spec.js @@ -31,20 +31,13 @@ import AbuseCategorySelector from '~/abuse_reports/components/abuse_category_sel import WorkItemTodos from '~/work_items/components/work_item_todos.vue'; import { i18n } from '~/work_items/constants'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import workItemDatesSubscription from '~/graphql_shared/subscriptions/work_item_dates.subscription.graphql'; -import workItemTitleSubscription from '~/work_items/graphql/work_item_title.subscription.graphql'; -import workItemAssigneesSubscription from '~/work_items/graphql/work_item_assignees.subscription.graphql'; -import workItemMilestoneSubscription from '~/work_items/graphql/work_item_milestone.subscription.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; import updateWorkItemTaskMutation from '~/work_items/graphql/update_work_item_task.mutation.graphql'; +import workItemUpdatedSubscription from '~/work_items/graphql/work_item_updated.subscription.graphql'; import { mockParent, - workItemDatesSubscriptionResponse, workItemByIidResponseFactory, - workItemTitleSubscriptionResponse, - workItemAssigneesSubscriptionResponse, - workItemMilestoneSubscriptionResponse, objectiveType, mockWorkItemCommentNote, } from '../mock_data'; @@ -63,16 +56,11 @@ describe('WorkItemDetail component', () => { canDelete: true, }); const successHandler = jest.fn().mockResolvedValue(workItemQueryResponse); - const datesSubscriptionHandler = jest.fn().mockResolvedValue(workItemDatesSubscriptionResponse); - const titleSubscriptionHandler = jest.fn().mockResolvedValue(workItemTitleSubscriptionResponse); - const milestoneSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemMilestoneSubscriptionResponse); - const assigneesSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemAssigneesSubscriptionResponse); const showModalHandler = jest.fn(); const { id } = workItemQueryResponse.data.workspace.workItems.nodes[0]; + const workItemUpdatedSubscriptionHandler = jest + .fn() + .mockResolvedValue({ data: { workItemUpdated: null } }); const findAlert = () => wrapper.findComponent(GlAlert); const findEmptyState = () => wrapper.findComponent(GlEmptyState); @@ -102,17 +90,13 @@ describe('WorkItemDetail component', () => { updateInProgress = false, workItemIid = '1', handler = successHandler, - subscriptionHandler = titleSubscriptionHandler, confidentialityMock = [updateWorkItemMutation, jest.fn()], error = undefined, workItemsMvc2Enabled = false, } = {}) => { const handlers = [ [workItemByIidQuery, handler], - [workItemTitleSubscription, subscriptionHandler], - [workItemDatesSubscription, datesSubscriptionHandler], - [workItemAssigneesSubscription, assigneesSubscriptionHandler], - [workItemMilestoneSubscription, milestoneSubscriptionHandler], + [workItemUpdatedSubscription, workItemUpdatedSubscriptionHandler], confidentialityMock, ]; @@ -163,13 +147,18 @@ describe('WorkItemDetail component', () => { }); describe('when there is no `workItemIid` prop', () => { - beforeEach(() => { + beforeEach(async () => { createComponent({ workItemIid: null }); + await waitForPromises(); }); it('skips the work item query', () => { expect(successHandler).not.toHaveBeenCalled(); }); + + it('skips the work item updated subscription', () => { + expect(workItemUpdatedSubscriptionHandler).not.toHaveBeenCalled(); + }); }); describe('when loading', () => { @@ -203,6 +192,10 @@ describe('WorkItemDetail component', () => { it('renders todos widget if logged in', () => { expect(findWorkItemTodos().exists()).toBe(true); }); + + it('calls the work item updated subscription', () => { + expect(workItemUpdatedSubscriptionHandler).toHaveBeenCalledWith({ id }); + }); }); describe('close button', () => { @@ -487,60 +480,6 @@ describe('WorkItemDetail component', () => { expect(findAlert().text()).toBe(updateError); }); - - describe('subscriptions', () => { - it('calls the title subscription', async () => { - createComponent(); - await waitForPromises(); - - expect(titleSubscriptionHandler).toHaveBeenCalledWith({ issuableId: id }); - }); - - describe('assignees subscription', () => { - describe('when the assignees widget exists', () => { - it('calls the assignees subscription', async () => { - createComponent(); - await waitForPromises(); - - expect(assigneesSubscriptionHandler).toHaveBeenCalledWith({ issuableId: id }); - }); - }); - - describe('when the assignees widget does not exist', () => { - it('does not call the assignees subscription', async () => { - const response = workItemByIidResponseFactory({ assigneesWidgetPresent: false }); - const handler = jest.fn().mockResolvedValue(response); - createComponent({ handler }); - await waitForPromises(); - - expect(assigneesSubscriptionHandler).not.toHaveBeenCalled(); - }); - }); - }); - - describe('dates subscription', () => { - describe('when the due date widget exists', () => { - it('calls the dates subscription', async () => { - createComponent(); - await waitForPromises(); - - expect(datesSubscriptionHandler).toHaveBeenCalledWith({ issuableId: id }); - }); - }); - - describe('when the due date widget does not exist', () => { - it('does not call the dates subscription', async () => { - const response = workItemByIidResponseFactory({ datesWidgetPresent: false }); - const handler = jest.fn().mockResolvedValue(response); - createComponent({ handler }); - await waitForPromises(); - - expect(datesSubscriptionHandler).not.toHaveBeenCalled(); - }); - }); - }); - }); - describe('assignees widget', () => { it('renders assignees component when widget is returned from the API', async () => { createComponent(); @@ -617,28 +556,6 @@ describe('WorkItemDetail component', () => { expect(findWorkItemMilestone().exists()).toBe(exists); }); - - describe('milestone subscription', () => { - describe('when the milestone widget exists', () => { - it('calls the milestone subscription', async () => { - createComponent(); - await waitForPromises(); - - expect(milestoneSubscriptionHandler).toHaveBeenCalledWith({ issuableId: id }); - }); - }); - - describe('when the assignees widget does not exist', () => { - it('does not call the milestone subscription', async () => { - const response = workItemByIidResponseFactory({ milestoneWidgetPresent: false }); - const handler = jest.fn().mockResolvedValue(response); - createComponent({ handler }); - await waitForPromises(); - - expect(milestoneSubscriptionHandler).not.toHaveBeenCalled(); - }); - }); - }); }); it('calls the work item query', async () => { diff --git a/spec/frontend/work_items/components/work_item_labels_spec.js b/spec/frontend/work_items/components/work_item_labels_spec.js index 6894aa236e3e9bac3d118e6ae20a5e865b0b6d16..4a20e6540602ff25f3ab3ddf401e5872b43b3c72 100644 --- a/spec/frontend/work_items/components/work_item_labels_spec.js +++ b/spec/frontend/work_items/components/work_item_labels_spec.js @@ -6,7 +6,6 @@ import waitForPromises from 'helpers/wait_for_promises'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import labelSearchQuery from '~/sidebar/components/labels/labels_select_widget/graphql/project_labels.query.graphql'; -import workItemLabelsSubscription from 'ee_else_ce/work_items/graphql/work_item_labels.subscription.graphql'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; import WorkItemLabels from '~/work_items/components/work_item_labels.vue'; @@ -16,7 +15,6 @@ import { mockLabels, workItemByIidResponseFactory, updateWorkItemMutationResponse, - workItemLabelsSubscriptionResponse, } from '../mock_data'; Vue.use(VueApollo); @@ -38,7 +36,6 @@ describe('WorkItemLabels component', () => { const successUpdateWorkItemMutationHandler = jest .fn() .mockResolvedValue(updateWorkItemMutationResponse); - const subscriptionHandler = jest.fn().mockResolvedValue(workItemLabelsSubscriptionResponse); const errorHandler = jest.fn().mockRejectedValue('Houston, we have a problem'); const createComponent = ({ @@ -53,7 +50,6 @@ describe('WorkItemLabels component', () => { [workItemByIidQuery, workItemQueryHandler], [labelSearchQuery, searchQueryHandler], [updateWorkItemMutation, updateWorkItemMutationHandler], - [workItemLabelsSubscription, subscriptionHandler], ]), provide: { fullPath: 'test-project-path', @@ -246,16 +242,6 @@ describe('WorkItemLabels component', () => { expect(updateWorkItemMutationHandler).not.toHaveBeenCalled(); }); - - it('has a subscription', async () => { - createComponent(); - - await waitForPromises(); - - expect(subscriptionHandler).toHaveBeenCalledWith({ - issuableId: workItemId, - }); - }); }); it('calls the work item query', async () => { diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index a873462ea633d13b49ff933186bef705568657b9..c9c73d299039cb376c595ca1620f34b692364da2 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -803,154 +803,6 @@ export const deleteWorkItemMutationErrorResponse = { }, }; -export const workItemDatesSubscriptionResponse = { - data: { - issuableDatesUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetStartAndDueDate', - dueDate: '2022-12-31', - startDate: '2022-01-01', - }, - ], - }, - }, -}; - -export const workItemTitleSubscriptionResponse = { - data: { - issuableTitleUpdated: { - id: 'gid://gitlab/WorkItem/1', - title: 'new title', - }, - }, -}; - -export const workItemDescriptionSubscriptionResponse = { - data: { - issuableDescriptionUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetDescription', - type: 'DESCRIPTION', - description: 'New description', - descriptionHtml: '<p>New description</p>', - lastEditedAt: '2022-09-21T06:18:42Z', - lastEditedBy: { - id: 'gid://gitlab/User/2', - name: 'Someone else', - webPath: '/not-you', - }, - }, - ], - }, - }, -}; - -export const workItemWeightSubscriptionResponse = { - data: { - issuableWeightUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetWeight', - weight: 1, - }, - ], - }, - }, -}; - -export const workItemAssigneesSubscriptionResponse = { - data: { - issuableAssigneesUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemAssigneesWeight', - assignees: { - nodes: [mockAssignees[0]], - }, - }, - ], - }, - }, -}; - -export const workItemLabelsSubscriptionResponse = { - data: { - issuableLabelsUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetLabels', - type: 'LABELS', - allowsScopedLabels: false, - labels: { - nodes: mockLabels, - }, - }, - ], - }, - }, -}; - -export const workItemIterationSubscriptionResponse = { - data: { - issuableIterationUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetIteration', - iteration: { - description: 'Iteration description', - dueDate: '2022-07-29', - id: 'gid://gitlab/Iteration/1125', - iid: '95', - startDate: '2022-06-22', - title: 'Iteration subcription title', - }, - }, - ], - }, - }, -}; - -export const workItemHealthStatusSubscriptionResponse = { - data: { - issuableHealthStatusUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetHealthStatus', - healthStatus: 'needsAttention', - }, - ], - }, - }, -}; - -export const workItemMilestoneSubscriptionResponse = { - data: { - issuableMilestoneUpdated: { - id: 'gid://gitlab/WorkItem/1', - widgets: [ - { - __typename: 'WorkItemWidgetMilestone', - type: 'MILESTONE', - milestone: { - id: 'gid://gitlab/Milestone/1125', - expired: false, - title: 'Milestone title', - }, - }, - ], - }, - }, -}; - export const workItemHierarchyEmptyResponse = { data: { workspace: { diff --git a/spec/frontend/work_items/router_spec.js b/spec/frontend/work_items/router_spec.js index b5d54a7c3192286a51580c90fd30bc103bfa8df2..4e31ee3055238e9ce34e4b83277295335f995dff 100644 --- a/spec/frontend/work_items/router_spec.js +++ b/spec/frontend/work_items/router_spec.js @@ -2,28 +2,14 @@ import { mount } from '@vue/test-utils'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; -import { - currentUserResponse, - workItemAssigneesSubscriptionResponse, - workItemDatesSubscriptionResponse, - workItemByIidResponseFactory, - workItemTitleSubscriptionResponse, - workItemLabelsSubscriptionResponse, - workItemMilestoneSubscriptionResponse, - workItemDescriptionSubscriptionResponse, -} from 'jest/work_items/mock_data'; +import { currentUserResponse, workItemByIidResponseFactory } from 'jest/work_items/mock_data'; import currentUserQuery from '~/graphql_shared/queries/current_user.query.graphql'; import App from '~/work_items/components/app.vue'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; -import workItemDatesSubscription from '~/graphql_shared/subscriptions/work_item_dates.subscription.graphql'; -import workItemTitleSubscription from '~/work_items/graphql/work_item_title.subscription.graphql'; -import workItemAssigneesSubscription from '~/work_items/graphql/work_item_assignees.subscription.graphql'; -import workItemLabelsSubscription from 'ee_else_ce/work_items/graphql/work_item_labels.subscription.graphql'; -import workItemMilestoneSubscription from '~/work_items/graphql/work_item_milestone.subscription.graphql'; -import workItemDescriptionSubscription from '~/work_items/graphql/work_item_description.subscription.graphql'; import CreateWorkItem from '~/work_items/pages/create_work_item.vue'; import WorkItemsRoot from '~/work_items/pages/work_item_root.vue'; import { createRouter } from '~/work_items/router'; +import workItemUpdatedSubscription from '~/work_items/graphql/work_item_updated.subscription.graphql'; jest.mock('~/behaviors/markdown/render_gfm'); @@ -34,18 +20,9 @@ describe('Work items router', () => { const workItemQueryHandler = jest.fn().mockResolvedValue(workItemByIidResponseFactory()); const currentUserQueryHandler = jest.fn().mockResolvedValue(currentUserResponse); - const datesSubscriptionHandler = jest.fn().mockResolvedValue(workItemDatesSubscriptionResponse); - const titleSubscriptionHandler = jest.fn().mockResolvedValue(workItemTitleSubscriptionResponse); - const assigneesSubscriptionHandler = jest + const workItemUpdatedSubscriptionHandler = jest .fn() - .mockResolvedValue(workItemAssigneesSubscriptionResponse); - const labelsSubscriptionHandler = jest.fn().mockResolvedValue(workItemLabelsSubscriptionResponse); - const milestoneSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemMilestoneSubscriptionResponse); - const descriptionSubscriptionHandler = jest - .fn() - .mockResolvedValue(workItemDescriptionSubscriptionResponse); + .mockResolvedValue({ data: { workItemUpdated: null } }); const createComponent = async (routeArg) => { const router = createRouter('/work_item'); @@ -56,12 +33,7 @@ describe('Work items router', () => { const handlers = [ [workItemByIidQuery, workItemQueryHandler], [currentUserQuery, currentUserQueryHandler], - [workItemDatesSubscription, datesSubscriptionHandler], - [workItemTitleSubscription, titleSubscriptionHandler], - [workItemAssigneesSubscription, assigneesSubscriptionHandler], - [workItemLabelsSubscription, labelsSubscriptionHandler], - [workItemMilestoneSubscription, milestoneSubscriptionHandler], - [workItemDescriptionSubscription, descriptionSubscriptionHandler], + [workItemUpdatedSubscription, workItemUpdatedSubscriptionHandler], ]; wrapper = mount(App, {