diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-18 03:08:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-18 03:08:06 +0300 |
commit | 977fd0aff3a3fe6bcb6f4c76d6f2f7696b958412 (patch) | |
tree | a3348a3353c8b9fcd9b0542603be4f9983d92bc6 /spec/frontend/work_items/components | |
parent | c766b837cfcba1a652b781f1f725ae034c9755e1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/work_items/components')
-rw-r--r-- | spec/frontend/work_items/components/work_item_assignees_spec.js | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/spec/frontend/work_items/components/work_item_assignees_spec.js b/spec/frontend/work_items/components/work_item_assignees_spec.js index 50a8847032e..972dd4a13fd 100644 --- a/spec/frontend/work_items/components/work_item_assignees_spec.js +++ b/spec/frontend/work_items/components/work_item_assignees_spec.js @@ -6,7 +6,8 @@ import waitForPromises from 'helpers/wait_for_promises'; import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mockTracking } from 'helpers/tracking_helper'; import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; -import userSearchQuery from '~/graphql_shared/queries/users_search.query.graphql'; +import groupUsersSearchQuery from '~/graphql_shared/queries/group_users_search.query.graphql'; +import usersSearchQuery from '~/graphql_shared/queries/users_search.query.graphql'; import currentUserQuery from '~/graphql_shared/queries/current_user.query.graphql'; import InviteMembersTrigger from '~/invite_members/components/invite_members_trigger.vue'; import updateWorkItemMutation from '~/work_items/graphql/update_work_item.mutation.graphql'; @@ -53,6 +54,9 @@ describe('WorkItemAssignees component', () => { const successSearchQueryHandler = jest .fn() .mockResolvedValue(projectMembersResponseWithCurrentUser); + const successGroupSearchQueryHandler = jest + .fn() + .mockResolvedValue(projectMembersResponseWithCurrentUser); const successSearchQueryHandlerWithMoreAssignees = jest .fn() .mockResolvedValue(projectMembersResponseWithCurrentUserWithNextPage); @@ -75,9 +79,11 @@ describe('WorkItemAssignees component', () => { allowsMultipleAssignees = true, canInviteMembers = false, canUpdate = true, + isGroup = false, } = {}) => { const apolloProvider = createMockApollo([ - [userSearchQuery, searchQueryHandler], + [usersSearchQuery, searchQueryHandler], + [groupUsersSearchQuery, successGroupSearchQueryHandler], [currentUserQuery, currentUserQueryHandler], [updateWorkItemMutation, updateWorkItemMutationHandler], ]); @@ -85,6 +91,7 @@ describe('WorkItemAssignees component', () => { wrapper = mountExtended(WorkItemAssignees, { provide: { fullPath: 'test-project-path', + isGroup, }, propsData: { assignees, @@ -540,4 +547,36 @@ describe('WorkItemAssignees component', () => { expect(findTokenSelector().props('dropdownItems')).toHaveLength(2); }); + + describe('when project context', () => { + beforeEach(() => { + createComponent(); + findTokenSelector().vm.$emit('focus'); + findTokenSelector().vm.$emit('text-input', 'jane'); + }); + + it('calls the project users search query', () => { + expect(successSearchQueryHandler).toHaveBeenCalled(); + }); + + it('does not call the group users search query', () => { + expect(successGroupSearchQueryHandler).not.toHaveBeenCalled(); + }); + }); + + describe('when group context', () => { + beforeEach(() => { + createComponent({ isGroup: true }); + findTokenSelector().vm.$emit('focus'); + findTokenSelector().vm.$emit('text-input', 'jane'); + }); + + it('does not call the project users search query', () => { + expect(successSearchQueryHandler).not.toHaveBeenCalled(); + }); + + it('calls the group users search query', () => { + expect(successGroupSearchQueryHandler).toHaveBeenCalled(); + }); + }); }); |