Use navigation handler in onClick to view full results
Full results button in searchModal was not correctly navigating onClick. This switches the onClick to the correct handler function to navigate. Signed-off-by: Ciprianna Engel <ciprianna.engel@wpengine.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user