Merge pull request #18407 from ciprianna/master

Use navigation handler in onClick to view full results
This commit is contained in:
Ben Lambert
2023-07-10 14:18:39 +02:00
committed by GitHub
3 changed files with 40 additions and 1 deletions
+5
View File
@@ -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.
@@ -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(
<ApiProvider apis={apiRegistry}>
<SearchContextProvider initialState={initialState}>
<SearchModal open hidden={false} toggleModal={toggleModal} />
</SearchContextProvider>
</ApiProvider>,
{
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');
});
});
@@ -154,7 +154,7 @@ export const Modal = ({ toggleModal }: SearchModalChildrenProps) => {
className={classes.button}
color="primary"
endIcon={<ArrowForwardIcon />}
onClick={handleSearchResultClick}
onClick={handleSearchBarSubmit}
disableRipple
>
View Full Results