Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-10 15:07:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-10 15:07:58 +0300
commit8731c2348e508e52cad156bd819b0accbf88d495 (patch)
treef4cc019badc699aad7115f1db78bd48029d202c7 /spec/frontend/vue_shared/components
parentb6ccb96a5bae907504efd05955c2d188caa0d2f0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components')
-rw-r--r--spec/frontend/vue_shared/components/user_select_spec.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/user_select_spec.js b/spec/frontend/vue_shared/components/user_select_spec.js
index 119b892392f..e1b79ad7b14 100644
--- a/spec/frontend/vue_shared/components/user_select_spec.js
+++ b/spec/frontend/vue_shared/components/user_select_spec.js
@@ -3,6 +3,7 @@ import { cloneDeep } from 'lodash';
import Vue, { nextTick } from 'vue';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
+import { stubComponent } from 'helpers/stub_component';
import waitForPromises from 'helpers/wait_for_promises';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import searchUsersQuery from '~/graphql_shared/queries/project_autocomplete_users.query.graphql';
@@ -39,6 +40,8 @@ const waitForSearch = async () => {
await waitForPromises();
};
+const focusInput = jest.fn();
+
Vue.use(VueApollo);
describe('User select dropdown', () => {
@@ -100,6 +103,11 @@ describe('User select dropdown', () => {
hide: hideDropdownMock,
},
},
+ GlSearchBoxByType: stubComponent(GlSearchBoxByType, {
+ methods: {
+ focusInput,
+ },
+ }),
},
});
};
@@ -409,6 +417,43 @@ describe('User select dropdown', () => {
expect(findUnselectedParticipants()).toHaveLength(0);
expect(findEmptySearchResults().exists()).toBe(true);
});
+
+ it('clears search term and focuses search field after selecting a user', async () => {
+ createComponent({
+ searchQueryHandler: jest.fn().mockResolvedValue(searchAutocompleteQueryResponse),
+ });
+ await waitForPromises();
+
+ findSearchField().vm.$emit('input', 'roo');
+ await waitForSearch();
+
+ findUnselectedParticipants().at(0).trigger('click');
+ await nextTick();
+
+ expect(findSearchField().props('value')).toBe('');
+ expect(focusInput).toHaveBeenCalled();
+ });
+
+ it('clears search term and focuses search field after unselecting a user', async () => {
+ createComponent({
+ props: {
+ value: [searchAutocompleteQueryResponse.data.workspace.users[0]],
+ },
+ searchQueryHandler: jest.fn().mockResolvedValue(searchAutocompleteQueryResponse),
+ });
+ await waitForPromises();
+
+ expect(findSelectedParticipants()).toHaveLength(1);
+
+ findSearchField().vm.$emit('input', 'roo');
+ await waitForSearch();
+
+ findSelectedParticipants().at(0).trigger('click');
+ await nextTick();
+
+ expect(findSearchField().props('value')).toBe('');
+ expect(focusInput).toHaveBeenCalled();
+ });
});
describe('when on merge request sidebar', () => {