Commit 352dc136 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '336385-fix-selected-items-filtering' into 'master'

VSA: Ensure selected projects are always visible

See merge request gitlab-org/gitlab!72115
parents 531de311 bbb108e6
......@@ -101,9 +101,7 @@ export default {
return !loading && !availableProjects.length;
},
selectedItems() {
return sortByProjectName(
this.availableProjects.filter(({ id }) => this.selectedProjectIds.includes(id)),
);
return sortByProjectName(this.selectedProjects);
},
unselectedItems() {
return this.availableProjects.filter(({ id }) => !this.selectedProjectIds.includes(id));
......
......@@ -2,6 +2,7 @@ import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import { stubComponent } from 'helpers/stub_component';
import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises';
import ProjectsDropdownFilter from '~/analytics/shared/components/projects_dropdown_filter.vue';
import getProjects from '~/analytics/shared/graphql/projects.query.graphql';
......@@ -65,7 +66,7 @@ describe('ProjectsDropdownFilter component', () => {
const createWithMockDropdown = (props) => {
createComponent(props, { GlDropdown: MockGlDropdown });
return wrapper.vm.$nextTick();
return waitForPromises();
};
afterEach(() => {
......@@ -73,6 +74,7 @@ describe('ProjectsDropdownFilter component', () => {
});
const findHighlightedItems = () => wrapper.findByTestId('vsa-highlighted-items');
const findUnhighlightedItems = () => wrapper.findByTestId('vsa-default-items');
const findHighlightedItemsTitle = () => wrapper.findByText('Selected');
const findClearAllButton = () => wrapper.findByText('Clear all');
......@@ -197,6 +199,24 @@ describe('ProjectsDropdownFilter component', () => {
});
});
describe('with a selected project and search term', () => {
beforeEach(async () => {
await createWithMockDropdown({ multiSelect: true });
selectDropdownItemAtIndex(0);
wrapper.setData({ searchTerm: 'this is a very long search string' });
});
it('renders the highlighted items', async () => {
expect(findUnhighlightedItems().findAll('li').length).toBe(1);
});
it('hides the unhighlighted items that do not match the string', async () => {
expect(findUnhighlightedItems().findAll('li').length).toBe(1);
expect(findUnhighlightedItems().text()).toContain('No matching results');
});
});
describe('when passed an array of defaultProject as prop', () => {
beforeEach(() => {
createComponent({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment