diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-08 18:18:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-08 18:18:11 +0300 |
commit | dcc56fe601580b5d8f6c3da32550c6523f2baff3 (patch) | |
tree | f68c28bf7c8715de7242464b344620ae5c394036 /spec/frontend/work_items | |
parent | 571b02efc9442e73538c3438eb593a83d7807779 (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 | 20 | ||||
-rw-r--r-- | spec/frontend/work_items/mock_data.js | 13 |
2 files changed, 32 insertions, 1 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 b889836023d..0d726b0635a 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 @@ -46,10 +46,14 @@ describe('WorkItemLinks', () => { .fn() .mockResolvedValue(changeWorkItemParentMutationResponse); const childWorkItemByIidHandler = jest.fn().mockResolvedValue(workItemByIidResponseFactory()); + const responseWithAddChildPermission = jest.fn().mockResolvedValue(workItemHierarchyResponse); + const responseWithoutAddChildPermission = jest + .fn() + .mockResolvedValue(workItemByIidResponseFactory({ adminParentLink: false })); const createComponent = async ({ data = {}, - fetchHandler = jest.fn().mockResolvedValue(workItemHierarchyResponse), + fetchHandler = responseWithAddChildPermission, mutationHandler = mutationChangeParentHandler, issueDetailsQueryHandler = jest.fn().mockResolvedValue(getIssueDetailsResponse()), hasIterationsFeature = false, @@ -111,6 +115,20 @@ describe('WorkItemLinks', () => { setWindowLocation(''); }); + it.each` + expectedAssertion | workItemFetchHandler | value + ${'renders'} | ${responseWithAddChildPermission} | ${true} + ${'does not render'} | ${responseWithoutAddChildPermission} | ${false} + `( + '$expectedAssertion "Add" button in hierarchy widget header when "userPermissions.adminParentLink" is $value', + async ({ workItemFetchHandler, value }) => { + createComponent({ fetchHandler: workItemFetchHandler }); + await waitForPromises(); + + expect(findToggleFormDropdown().exists()).toBe(value); + }, + ); + describe('add link form', () => { it('displays add work item form on click add dropdown then add existing button and hides form on cancel', async () => { await createComponent(); diff --git a/spec/frontend/work_items/mock_data.js b/spec/frontend/work_items/mock_data.js index 1c319844af3..0a0835bcb36 100644 --- a/spec/frontend/work_items/mock_data.js +++ b/spec/frontend/work_items/mock_data.js @@ -83,6 +83,7 @@ export const workItemQueryResponse = { deleteWorkItem: false, updateWorkItem: false, setWorkItemMetadata: false, + adminParentLink: false, __typename: 'WorkItemPermissions', }, widgets: [ @@ -185,6 +186,7 @@ export const updateWorkItemMutationResponse = { deleteWorkItem: false, updateWorkItem: false, setWorkItemMetadata: false, + adminParentLink: false, __typename: 'WorkItemPermissions', }, widgets: [ @@ -288,6 +290,7 @@ export const convertWorkItemMutationResponse = { deleteWorkItem: false, updateWorkItem: false, setWorkItemMetadata: false, + adminParentLink: false, __typename: 'WorkItemPermissions', }, widgets: [ @@ -381,6 +384,7 @@ export const objectiveType = { export const workItemResponseFactory = ({ canUpdate = false, canDelete = false, + adminParentLink = false, notificationsWidgetPresent = true, subscribed = true, allowsMultipleAssignees = true, @@ -430,6 +434,7 @@ export const workItemResponseFactory = ({ deleteWorkItem: canDelete, updateWorkItem: canUpdate, setWorkItemMetadata: canUpdate, + adminParentLink, __typename: 'WorkItemPermissions', }, widgets: [ @@ -665,6 +670,7 @@ export const createWorkItemMutationResponse = { deleteWorkItem: false, updateWorkItem: false, setWorkItemMetadata: false, + adminParentLink: false, __typename: 'WorkItemPermissions', }, widgets: [], @@ -902,6 +908,7 @@ export const workItemHierarchyEmptyResponse = { deleteWorkItem: false, updateWorkItem: false, setWorkItemMetadata: false, + adminParentLink: false, __typename: 'WorkItemPermissions', }, confidential: false, @@ -944,6 +951,7 @@ export const workItemHierarchyNoUpdatePermissionResponse = { deleteWorkItem: false, updateWorkItem: false, setWorkItemMetadata: false, + adminParentLink: false, __typename: 'WorkItemPermissions', }, project: { @@ -1086,6 +1094,7 @@ export const workItemHierarchyResponse = { deleteWorkItem: true, updateWorkItem: true, setWorkItemMetadata: true, + adminParentLink: true, __typename: 'WorkItemPermissions', }, author: { @@ -1176,6 +1185,7 @@ export const workItemObjectiveWithChild = { deleteWorkItem: true, updateWorkItem: true, setWorkItemMetadata: true, + adminParentLink: true, __typename: 'WorkItemPermissions', }, author: { @@ -1244,6 +1254,7 @@ export const workItemHierarchyTreeResponse = { deleteWorkItem: true, updateWorkItem: true, setWorkItemMetadata: true, + adminParentLink: true, __typename: 'WorkItemPermissions', }, confidential: false, @@ -1322,6 +1333,7 @@ export const changeIndirectWorkItemParentMutationResponse = { deleteWorkItem: true, updateWorkItem: true, setWorkItemMetadata: true, + adminParentLink: true, __typename: 'WorkItemPermissions', }, description: null, @@ -1384,6 +1396,7 @@ export const changeWorkItemParentMutationResponse = { deleteWorkItem: true, updateWorkItem: true, setWorkItemMetadata: true, + adminParentLink: true, __typename: 'WorkItemPermissions', }, description: null, |