diff --git a/src/__tests__/Search/CompareWithBase.test.tsx b/src/__tests__/Search/CompareWithBase.test.tsx index aa9f5abc9..5dcb408dd 100644 --- a/src/__tests__/Search/CompareWithBase.test.tsx +++ b/src/__tests__/Search/CompareWithBase.test.tsx @@ -63,6 +63,7 @@ describe('Compare With Base', () => { }); await user.click(frameworkDropdown); + expect(screen.getByRole('listbox')).toMatchSnapshot(); const buildMetricsItem = screen.getByRole('option', { name: 'build_metrics', }); diff --git a/src/__tests__/Search/__snapshots__/CompareWithBase.test.tsx.snap b/src/__tests__/Search/__snapshots__/CompareWithBase.test.tsx.snap index 4079af0a3..d08cebb6a 100644 --- a/src/__tests__/Search/__snapshots__/CompareWithBase.test.tsx.snap +++ b/src/__tests__/Search/__snapshots__/CompareWithBase.test.tsx.snap @@ -381,3 +381,133 @@ exports[`Compare With Base renders correctly when there are no results 1`] = ` `; + +exports[`Compare With Base selects and displays new framework when clicked 1`] = ` + +`; diff --git a/src/components/Search/FrameworkDropdown.tsx b/src/components/Search/FrameworkDropdown.tsx index 684b3c6d6..bdfd77aa3 100644 --- a/src/components/Search/FrameworkDropdown.tsx +++ b/src/components/Search/FrameworkDropdown.tsx @@ -29,6 +29,22 @@ interface FrameworkDropdownProps { const strings = Strings.components.searchDefault.sharedCollasped.framkework; +const sortFrameworks = ( + frameworks: Record, +) => { + const unsortedArray = Object.entries(frameworks); + + // Sort the array based on values + + const sortedArray = unsortedArray.sort((a, b) => { + return a[1].localeCompare(b[1]); + }); + + return sortedArray; +}; + +const sortedFrameworks = sortFrameworks(frameworkMap); + function FrameworkDropdown({ mode }: FrameworkDropdownProps) { cssRule('.MuiTooltip-popper', { ...(mode === 'light' ? TooltipRaw.Light : TooltipRaw.Dark), @@ -115,7 +131,7 @@ function FrameworkDropdown({ mode }: FrameworkDropdownProps) { onChange={(e) => void handleFrameworkSelect(e)} name='Framework' > - {Object.entries(frameworkMap).map(([id, name]) => ( + {sortedFrameworks.map(([id, name]) => ( {name}