diff --git a/.changeset/afraid-windows-rule.md b/.changeset/afraid-windows-rule.md new file mode 100644 index 0000000000..5ed217d3a3 --- /dev/null +++ b/.changeset/afraid-windows-rule.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-search': patch +--- + +Fixed bug in "View Full Results" link of Search Modal that did not navigate to the full results page. diff --git a/plugins/search/src/components/SearchModal/SearchModal.test.tsx b/plugins/search/src/components/SearchModal/SearchModal.test.tsx index 1ab7952a2b..33c2df9ab8 100644 --- a/plugins/search/src/components/SearchModal/SearchModal.test.tsx +++ b/plugins/search/src/components/SearchModal/SearchModal.test.tsx @@ -45,6 +45,7 @@ describe('SearchModal', () => { beforeEach(() => { query.mockClear(); + navigate.mockClear(); }); const toggleModal = jest.fn(); @@ -207,4 +208,37 @@ describe('SearchModal', () => { expect(navigate).toHaveBeenCalledWith('/search?query=new term'); }); + + it('should navigate with correct search terms to full results', async () => { + const initialState = { + term: 'term', + filters: {}, + types: [], + pageCursor: '', + }; + + await renderInTestApp( + + + + , + { + mountedRoutes: { + '/search': rootRouteRef, + }, + }, + ); + + expect(query).toHaveBeenCalledWith( + expect.objectContaining({ term: 'term' }), + ); + + const fullResultsBtn = screen.getByRole('button', { + name: /view full results/i, + }); + await userEvent.click(fullResultsBtn); + + expect(navigate).toHaveBeenCalledWith('/search?query=term'); + }); }); diff --git a/plugins/search/src/components/SearchModal/SearchModal.tsx b/plugins/search/src/components/SearchModal/SearchModal.tsx index 777a285107..dec0f9f482 100644 --- a/plugins/search/src/components/SearchModal/SearchModal.tsx +++ b/plugins/search/src/components/SearchModal/SearchModal.tsx @@ -154,7 +154,7 @@ export const Modal = ({ toggleModal }: SearchModalChildrenProps) => { className={classes.button} color="primary" endIcon={} - onClick={handleSearchResultClick} + onClick={handleSearchBarSubmit} disableRipple > View Full Results