diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-25 21:08:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-25 21:08:55 +0300 |
commit | 1e3f5ab634699e9d50779f05d2ae8dfc8a3ab9b3 (patch) | |
tree | c96727e136f4dc4fdbc1190895439d41e0b07fc5 /spec/frontend/work_items | |
parent | ba8e92f7c9938d7dba333d2396cdd14bfa0de726 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/work_items')
-rw-r--r-- | spec/frontend/work_items/components/work_item_links/work_item_links_spec.js | 24 | ||||
-rw-r--r-- | spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js | 13 |
2 files changed, 11 insertions, 26 deletions
diff --git a/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js index 4bf7d0c57a3..1d78f35615a 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_links_spec.js @@ -14,7 +14,6 @@ import WorkItemLinkChild from '~/work_items/components/work_item_links/work_item import WorkItemDetailModal from '~/work_items/components/work_item_detail_modal.vue'; import AbuseCategorySelector from '~/abuse_reports/components/abuse_category_selector.vue'; import { FORM_TYPES } from '~/work_items/constants'; -import workItemQuery from '~/work_items/graphql/work_item.query.graphql'; import changeWorkItemParentMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; import getWorkItemLinksQuery from '~/work_items/graphql/work_item_links.query.graphql'; import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; @@ -24,8 +23,8 @@ import { workItemHierarchyEmptyResponse, workItemHierarchyNoUpdatePermissionResponse, changeWorkItemParentMutationResponse, + workItemByIidResponseFactory, workItemQueryResponse, - projectWorkItemResponse, mockWorkItemCommentNote, } from '../../mock_data'; @@ -46,9 +45,7 @@ describe('WorkItemLinks', () => { const mutationChangeParentHandler = jest .fn() .mockResolvedValue(changeWorkItemParentMutationResponse); - - const childWorkItemQueryHandler = jest.fn().mockResolvedValue(workItemQueryResponse); - const childWorkItemByIidHandler = jest.fn().mockResolvedValue(projectWorkItemResponse); + const childWorkItemByIidHandler = jest.fn().mockResolvedValue(workItemByIidResponseFactory()); const createComponent = async ({ data = {}, @@ -61,7 +58,6 @@ describe('WorkItemLinks', () => { [ [getWorkItemLinksQuery, fetchHandler], [changeWorkItemParentMutation, mutationHandler], - [workItemQuery, childWorkItemQueryHandler], [issueDetailsQuery, issueDetailsQueryHandler], [workItemByIidQuery, childWorkItemByIidHandler], ], @@ -308,18 +304,10 @@ describe('WorkItemLinks', () => { expect(childWorkItemByIidHandler).not.toHaveBeenCalled(); }); - - it('does not fetch work item by id if link is hovered for 250+ ms', async () => { - firstChild.vm.$emit('mouseover', firstChild.vm.childItem.id); - jest.advanceTimersByTime(DEFAULT_DEBOUNCE_AND_THROTTLE_MS); - await waitForPromises(); - - expect(childWorkItemQueryHandler).not.toHaveBeenCalled(); - }); }); - it('starts prefetching work item by iid if URL contains work item id', async () => { - setWindowLocation('?work_item_iid=5&iid_path=true'); + it('starts prefetching work item by iid if URL contains work_item_iid query parameter', async () => { + setWindowLocation('?work_item_iid=5'); await createComponent(); expect(childWorkItemByIidHandler).toHaveBeenCalledWith({ @@ -329,7 +317,7 @@ describe('WorkItemLinks', () => { }); it('does not open the modal if work item iid URL parameter is not found in child items', async () => { - setWindowLocation('?work_item_iid=555&iid_path=true'); + setWindowLocation('?work_item_iid=555'); await createComponent(); expect(showModal).not.toHaveBeenCalled(); @@ -337,7 +325,7 @@ describe('WorkItemLinks', () => { }); it('opens the modal if work item iid URL parameter is found in child items', async () => { - setWindowLocation('?work_item_iid=2&iid_path=true'); + setWindowLocation('?work_item_iid=2'); await createComponent(); expect(showModal).toHaveBeenCalled(); diff --git a/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js b/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js index ab69ba7ee1b..f6b70d0161a 100644 --- a/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js +++ b/spec/frontend/work_items/components/work_item_links/work_item_tree_spec.js @@ -4,11 +4,11 @@ import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import waitForPromises from 'helpers/wait_for_promises'; -import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; import WorkItemTree from '~/work_items/components/work_item_links/work_item_tree.vue'; import WorkItemLinksForm from '~/work_items/components/work_item_links/work_item_links_form.vue'; import WorkItemLinkChild from '~/work_items/components/work_item_links/work_item_link_child.vue'; import OkrActionsSplitButton from '~/work_items/components/work_item_links/okr_actions_split_button.vue'; +import workItemByIidQuery from '~/work_items/graphql/work_item_by_iid.query.graphql'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; @@ -17,12 +17,13 @@ import { WORK_ITEM_TYPE_ENUM_OBJECTIVE, WORK_ITEM_TYPE_ENUM_KEY_RESULT, } from '~/work_items/constants'; -import { childrenWorkItems, projectWorkItemResponse } from '../../mock_data'; +import { childrenWorkItems, workItemByIidResponseFactory } from '../../mock_data'; describe('WorkItemTree', () => { - let getWorkItemQueryHandler; let wrapper; + const getWorkItemQueryHandler = jest.fn().mockResolvedValue(workItemByIidResponseFactory()); + const findEmptyState = () => wrapper.findByTestId('tree-empty'); const findToggleFormSplitButton = () => wrapper.findComponent(OkrActionsSplitButton); const findForm = () => wrapper.findComponent(WorkItemLinksForm); @@ -35,13 +36,9 @@ describe('WorkItemTree', () => { parentWorkItemType = 'Objective', confidential = false, children = childrenWorkItems, - apolloProvider = null, } = {}) => { - getWorkItemQueryHandler = jest.fn().mockResolvedValue(projectWorkItemResponse); - wrapper = shallowMountExtended(WorkItemTree, { - apolloProvider: - apolloProvider || createMockApollo([[workItemByIidQuery, getWorkItemQueryHandler]]), + apolloProvider: createMockApollo([[workItemByIidQuery, getWorkItemQueryHandler]]), propsData: { workItemType, parentWorkItemType, |