Skip to content
Snippets Groups Projects
Verified Commit 1f5043d0 authored by Chad Lavimoniere's avatar Chad Lavimoniere Committed by GitLab
Browse files

Merge branch '456346-deduplicate-milestone-results-in-search-bar-filter' into 'master'

Filter out duplicate milestone results in filter search bar

See merge request !166947



Merged-by: default avatarChad Lavimoniere <clavimoniere@gitlab.com>
Approved-by: Nick Leonard's avatarNick Leonard <nleonard@gitlab.com>
Reviewed-by: Nick Leonard's avatarNick Leonard <nleonard@gitlab.com>
parents b0904c39 8e696e5f
No related branches found
No related tags found
No related merge requests found
Pipeline #1467232930 failed
Pipeline: E2E GDK

#1467259258

    Pipeline: Ruby 3.2.5 as-if-foss

    #1467236242

      ......@@ -79,10 +79,20 @@ export default {
      .then((response) => {
      const data = Array.isArray(response) ? response : response.data;
      const uniqueData = data.reduce((acc, current) => {
      const existingItem = acc.find((item) => item.title === current.title);
      if (!existingItem) {
      acc.push(current);
      }
      return acc;
      }, []);
      if (this.config.shouldSkipSort) {
      this.milestones = data;
      this.milestones = uniqueData;
      } else {
      this.milestones = data.slice().sort(sortMilestonesByDueDate);
      this.milestones = uniqueData.slice().sort(sortMilestonesByDueDate);
      }
      })
      .catch(() => {
      ......
      ......@@ -74,6 +74,19 @@ export const mockEscapedMilestone = {
      title: '5.0 RC1',
      };
      export const mockDuplicateMilestones = [
      {
      id: 99,
      name: '99.0',
      title: '99.0',
      },
      {
      id: 100,
      name: '99.0',
      title: '99.0',
      },
      ];
      export const mockMilestones = [
      {
      id: 2,
      ......
      ......@@ -21,6 +21,7 @@ import {
      mockMilestones,
      mockRegularMilestone,
      projectMilestonesResponse,
      mockDuplicateMilestones,
      } from '../mock_data';
      Vue.use(VueApollo);
      ......@@ -92,6 +93,23 @@ describe('MilestoneToken', () => {
      expect(findBaseToken().props('suggestionsLoading')).toBe(true);
      });
      describe('when there are duplicate milestones in the data', () => {
      it('only shows the milestone title once in results', async () => {
      wrapper = createComponent({
      config: {
      fetchMilestones: jest.fn().mockResolvedValue({
      data: mockDuplicateMilestones,
      }),
      },
      });
      await triggerFetchMilestones();
      expect(findBaseToken().props('suggestions')).toHaveLength(1);
      expect(findBaseToken().props('suggestions')[0].title).toEqual('99.0');
      });
      });
      describe('when config.shouldSkipSort is true', () => {
      it('does not call sortMilestonesByDueDate', async () => {
      wrapper = createComponent({
      ......
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Finish editing this message first!
      Please register or to comment