diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-23 18:11:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-23 18:11:27 +0300 |
commit | 003d7f2a09668af85f94e48ed49d60862b96d8f8 (patch) | |
tree | 10f9baf4674416a5a7ca376bcc651973a56917b5 /spec/frontend/sidebar | |
parent | e10ea43772b9a6be150a074be7e26bfd6fa0380e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/sidebar')
-rw-r--r-- | spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js | 39 | ||||
-rw-r--r-- | spec/frontend/sidebar/mock_data.js | 11 |
2 files changed, 49 insertions, 1 deletions
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 b9c8655d5d8..be3fee148da 100644 --- a/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js +++ b/spec/frontend/sidebar/components/date/sidebar_date_widget_spec.js @@ -11,7 +11,12 @@ import SidebarInheritDate from '~/sidebar/components/date/sidebar_inherit_date.v import SidebarEditableItem from '~/sidebar/components/sidebar_editable_item.vue'; import epicStartDateQuery from '~/sidebar/queries/epic_start_date.query.graphql'; import issueDueDateQuery from '~/sidebar/queries/issue_due_date.query.graphql'; -import { issuableDueDateResponse, issuableStartDateResponse } from '../../mock_data'; +import issueDueDateSubscription from '~/graphql_shared/subscriptions/work_item_dates.subscription.graphql'; +import { + issuableDueDateResponse, + issuableStartDateResponse, + issueDueDateSubscriptionResponse, +} from '../../mock_data'; jest.mock('~/alert'); @@ -29,19 +34,25 @@ describe('Sidebar date Widget', () => { const createComponent = ({ dueDateQueryHandler = jest.fn().mockResolvedValue(issuableDueDateResponse()), startDateQueryHandler = jest.fn().mockResolvedValue(issuableStartDateResponse()), + dueDateSubscriptionHandler = jest.fn().mockResolvedValue(issueDueDateSubscriptionResponse()), canInherit = false, dateType = undefined, issuableType = 'issue', + realTimeIssueDueDate = true, } = {}) => { fakeApollo = createMockApollo([ [issueDueDateQuery, dueDateQueryHandler], [epicStartDateQuery, startDateQueryHandler], + [issueDueDateSubscription, dueDateSubscriptionHandler], ]); wrapper = shallowMount(SidebarDateWidget, { apolloProvider: fakeApollo, provide: { canUpdate: true, + glFeatures: { + realTimeIssueDueDate, + }, }, propsData: { fullPath: 'group/project', @@ -136,6 +147,32 @@ describe('Sidebar date Widget', () => { }); }); + describe('real time issue due date feature', () => { + describe('when :real_time_issue_due_date feature is enabled', () => { + it('should call the subscription', async () => { + const dueDateSubscriptionHandler = jest + .fn() + .mockResolvedValue(issueDueDateSubscriptionResponse()); + createComponent({ realTimeIssueDueDate: true, dueDateSubscriptionHandler }); + await waitForPromises(); + + expect(dueDateSubscriptionHandler).toHaveBeenCalled(); + }); + }); + + describe('when :real_time_issue_due_date feature is disabled', () => { + it('should not call the subscription', async () => { + const dueDateSubscriptionHandler = jest + .fn() + .mockResolvedValue(issueDueDateSubscriptionResponse()); + createComponent({ realTimeIssueDueDate: false, dueDateSubscriptionHandler }); + await waitForPromises(); + + expect(dueDateSubscriptionHandler).not.toHaveBeenCalled(); + }); + }); + }); + it.each` canInherit | component | componentName | expected ${true} | ${SidebarFormattedDate} | ${'SidebarFormattedDate'} | ${false} diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js index 844320efc1c..05a7f504fd4 100644 --- a/spec/frontend/sidebar/mock_data.js +++ b/spec/frontend/sidebar/mock_data.js @@ -249,6 +249,17 @@ export const issuableDueDateResponse = (dueDate = null) => ({ }, }); +export const issueDueDateSubscriptionResponse = () => ({ + data: { + issuableDatesUpdated: { + issue: { + id: 'gid://gitlab/Issue/4', + dueDate: '2022-12-31', + }, + }, + }, +}); + export const issuableStartDateResponse = (startDate = null) => ({ data: { workspace: { |