diff --git a/packages/catalog-search/src/PrequerySearchSuggestionItem.jsx b/packages/catalog-search/src/PrequerySearchSuggestionItem.jsx
index 96ff0caf..f1f3b5e1 100644
--- a/packages/catalog-search/src/PrequerySearchSuggestionItem.jsx
+++ b/packages/catalog-search/src/PrequerySearchSuggestionItem.jsx
@@ -4,13 +4,12 @@ import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
const PrequerySearchSuggestionItem = ({
- url, hit, optimizelySuggestionClickHandler,
+ url, hit,
}) => (
optimizelySuggestionClickHandler(hit.key)}
>
@@ -43,7 +42,6 @@ PrequerySearchSuggestionItem.propTypes = {
),
learning_type: PropTypes.string,
}).isRequired,
- optimizelySuggestionClickHandler: PropTypes.func.isRequired,
};
export default PrequerySearchSuggestionItem;
diff --git a/packages/catalog-search/src/SearchBox.jsx b/packages/catalog-search/src/SearchBox.jsx
index 54c5ec66..0afbdab5 100644
--- a/packages/catalog-search/src/SearchBox.jsx
+++ b/packages/catalog-search/src/SearchBox.jsx
@@ -53,8 +53,6 @@ export const SearchBoxBase = ({
enterpriseSlug,
suggestionSubmitOverride,
disableSuggestionRedirect,
- isPreQueryEnabled,
- optimizelySuggestionClickHandler,
}) => {
const { dispatch, trackingName } = useContext(SearchContext);
@@ -122,8 +120,8 @@ export const SearchBoxBase = ({
// If there are no results of the suggested search, hide the empty suggestion component
setShowSuggestions(false);
}
- // If isPreQueryEnabled is true display the prequery results when user clicks on search box but has not began typing
- } else if (query === '' && isPreQueryEnabled) {
+ // Display the prequery results when user clicks on search box but has not began typing
+ } else if (query === '') {
const { hits } = await index.search(query, {
filters,
attributesToHighlight: ['title'],
@@ -200,7 +198,6 @@ export const SearchBoxBase = ({
handleSubmit={() => handleSubmit(searchQuery)}
handleSuggestionClickSubmit={hit => handleSuggestionSubmit(hit)}
disableSuggestionRedirect={disableSuggestionRedirect}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>
)}
@@ -218,8 +215,6 @@ SearchBoxBase.propTypes = {
enterpriseSlug: PropTypes.string,
suggestionSubmitOverride: PropTypes.func,
disableSuggestionRedirect: PropTypes.bool,
- isPreQueryEnabled: PropTypes.bool,
- optimizelySuggestionClickHandler: PropTypes.func,
};
SearchBoxBase.defaultProps = {
@@ -233,8 +228,6 @@ SearchBoxBase.defaultProps = {
index: undefined,
suggestionSubmitOverride: undefined,
disableSuggestionRedirect: false,
- isPreQueryEnabled: false,
- optimizelySuggestionClickHandler: undefined,
};
export default connectSearchBox(SearchBoxBase);
diff --git a/packages/catalog-search/src/SearchHeader.jsx b/packages/catalog-search/src/SearchHeader.jsx
index 3fa72799..96af606f 100644
--- a/packages/catalog-search/src/SearchHeader.jsx
+++ b/packages/catalog-search/src/SearchHeader.jsx
@@ -23,8 +23,6 @@ const SearchHeader = ({
suggestionSubmitOverride,
enterpriseConfig: { slug, enablePathways },
disableSuggestionRedirect,
- optimizelySuggestionClickHandler,
- isPreQueryEnabled,
hideSearchBox,
}) => {
const { refinements } = useContext(SearchContext);
@@ -61,8 +59,6 @@ const SearchHeader = ({
enterpriseSlug={slug}
suggestionSubmitOverride={suggestionSubmitOverride}
disableSuggestionRedirect={disableSuggestionRedirect}
- isPreQueryEnabled={isPreQueryEnabled}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>
)}
@@ -89,8 +85,6 @@ SearchHeader.defaultProps = {
suggestionSubmitOverride: undefined,
disableSuggestionRedirect: false,
index: undefined,
- optimizelySuggestionClickHandler: undefined,
- isPreQueryEnabled: false,
hideSearchBox: false,
};
@@ -105,15 +99,10 @@ SearchHeader.propTypes = {
{
slug: PropTypes.string,
enablePathways: PropTypes.bool,
- enterpriseFeatures: PropTypes.shape({
- featurePrequerySearchSuggestions: PropTypes.bool,
- }),
},
),
suggestionSubmitOverride: PropTypes.func,
disableSuggestionRedirect: PropTypes.bool,
- optimizelySuggestionClickHandler: PropTypes.func,
- isPreQueryEnabled: PropTypes.bool,
hideSearchBox: PropTypes.bool,
};
diff --git a/packages/catalog-search/src/SearchSuggestionItem.jsx b/packages/catalog-search/src/SearchSuggestionItem.jsx
index 38e1362b..4898301f 100644
--- a/packages/catalog-search/src/SearchSuggestionItem.jsx
+++ b/packages/catalog-search/src/SearchSuggestionItem.jsx
@@ -3,7 +3,7 @@ import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
const SearchSuggestionItem = ({
- url, suggestionItemHandler, hit, disableSuggestionRedirect, optimizelySuggestionClickHandler,
+ url, suggestionItemHandler, hit, disableSuggestionRedirect,
}) => {
const authoringOrganization = hit.key && hit.key.split('+')[0];
// If the disable redirect bool is provided, prevent the redirect from happening and instead call the provided submit
@@ -13,7 +13,6 @@ const SearchSuggestionItem = ({
e.preventDefault();
suggestionItemHandler(hit);
}
- optimizelySuggestionClickHandler(hit.key || hit.course_keys);
};
return (
@@ -57,12 +56,10 @@ SearchSuggestionItem.propTypes = {
learning_type: PropTypes.string,
}).isRequired,
disableSuggestionRedirect: PropTypes.bool.isRequired,
- optimizelySuggestionClickHandler: PropTypes.func,
};
SearchSuggestionItem.defaultProps = {
suggestionItemHandler: undefined,
- optimizelySuggestionClickHandler: undefined,
};
export default SearchSuggestionItem;
diff --git a/packages/catalog-search/src/SearchSuggestions.jsx b/packages/catalog-search/src/SearchSuggestions.jsx
index 77bf2fd8..540f7cb9 100644
--- a/packages/catalog-search/src/SearchSuggestions.jsx
+++ b/packages/catalog-search/src/SearchSuggestions.jsx
@@ -17,7 +17,6 @@ const SearchSuggestions = ({
handleSubmit,
handleSuggestionClickSubmit,
disableSuggestionRedirect,
- optimizelySuggestionClickHandler,
}) => {
const getLinkToCourse = (course) => {
const { learning_type: learningType } = course;
@@ -71,7 +70,6 @@ const SearchSuggestions = ({
key={hit.title}
url={getUrl(hit)}
hit={hit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>
);
})
@@ -96,7 +94,6 @@ const SearchSuggestions = ({
hit={hit}
disableSuggestionRedirect={disableSuggestionRedirect}
suggestionItemHandler={handleSuggestionClickSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>
))
}
@@ -120,7 +117,6 @@ const SearchSuggestions = ({
hit={hit}
disableSuggestionRedirect={disableSuggestionRedirect}
suggestionItemHandler={handleSuggestionClickSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>
))
}
@@ -144,7 +140,6 @@ const SearchSuggestions = ({
hit={hit}
disableSuggestionRedirect={disableSuggestionRedirect}
suggestionItemHandler={handleSuggestionClickSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>
))
}
@@ -172,7 +167,6 @@ SearchSuggestions.propTypes = {
handleSuggestionClickSubmit: PropTypes.func,
disableSuggestionRedirect: PropTypes.bool,
preQueryHits: PropTypes.arrayOf(PropTypes.shape()),
- optimizelySuggestionClickHandler: PropTypes.func,
};
SearchSuggestions.defaultProps = {
@@ -181,7 +175,6 @@ SearchSuggestions.defaultProps = {
handleSuggestionClickSubmit: undefined,
disableSuggestionRedirect: false,
preQueryHits: undefined,
- optimizelySuggestionClickHandler: undefined,
};
export default SearchSuggestions;
diff --git a/packages/catalog-search/src/tests/PrequerySearchSuggestionItem.test.jsx b/packages/catalog-search/src/tests/PrequerySearchSuggestionItem.test.jsx
deleted file mode 100644
index 65cf2a67..00000000
--- a/packages/catalog-search/src/tests/PrequerySearchSuggestionItem.test.jsx
+++ /dev/null
@@ -1,36 +0,0 @@
-import { renderWithRouter } from '@edx/frontend-enterprise-utils';
-import React from 'react';
-import { screen } from '@testing-library/react';
-import userEvent from '@testing-library/user-event';
-import '@testing-library/jest-dom/extend-expect';
-import PrequerySearchSuggestionItem from '../PrequerySearchSuggestionItem';
-
-describe('', () => {
- test('sends optimizely event on prequery click', () => {
- const mockData = {
- url: '/test-enterprise/course/edX+courseX',
- optimizelySuggestionClickHandler: jest.fn(),
- hit: {
- partners: [{
- name: 'edX',
- }],
- learning_type: 'course',
- content_type: 'course',
- card_image_url: 'url.com',
- key: 'edX+courseX',
- title: 'basket weaving',
- _highlightResult: { title: { value: 'basket weaving' } },
- },
- };
-
- renderWithRouter();
- expect(screen.getByRole('link', { name: 'basket weaving edX | course' }))
- .toHaveAttribute('href', '/test-enterprise/course/edX+courseX');
- userEvent.click(screen.getByText('basket weaving'));
- expect(mockData.optimizelySuggestionClickHandler.mock.calls.length).toBe(1);
- });
-});
diff --git a/packages/catalog-search/src/tests/SearchBox.test.jsx b/packages/catalog-search/src/tests/SearchBox.test.jsx
index 07380fa0..f337185a 100644
--- a/packages/catalog-search/src/tests/SearchBox.test.jsx
+++ b/packages/catalog-search/src/tests/SearchBox.test.jsx
@@ -131,7 +131,6 @@ describe('', () => {
});
test('search box renders search suggestion and can override redirect', async () => {
const suggestionSubmitOverride = jest.fn();
- const optimizelySuggestionClickHandler = jest.fn();
SearchBoxBase.handleSuggestionSubmit = jest.fn();
const hits = [
{ learning_type: 'course', _highlightResult: { title: { value: 'test-title' } } },
@@ -150,7 +149,6 @@ describe('', () => {
index={index}
suggestionSubmitOverride={suggestionSubmitOverride}
disableSuggestionRedirect
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>,
);
@@ -163,7 +161,6 @@ describe('', () => {
await act(async () => {
userEvent.click(screen.getByText('test-title'));
});
- expect(optimizelySuggestionClickHandler).toHaveBeenCalled();
expect(suggestionSubmitOverride).toHaveBeenCalledWith(
{ learning_type: 'course', _highlightResult: { title: { value: 'test-title' } } },
);
diff --git a/packages/catalog-search/src/tests/SearchHeader.test.jsx b/packages/catalog-search/src/tests/SearchHeader.test.jsx
index 2c84132f..9fa0e98e 100644
--- a/packages/catalog-search/src/tests/SearchHeader.test.jsx
+++ b/packages/catalog-search/src/tests/SearchHeader.test.jsx
@@ -21,9 +21,6 @@ jest.mock('../SearchFilters', () => ({
}));
const enterpriseConfig = {
slug: 'test-enterprise',
- enterpriseFeatures: {
- featurePrequerySearchSuggestions: true,
- },
};
describe('SearchHeader', () => {
test('displays a SearchBox', () => {
diff --git a/packages/catalog-search/src/tests/SearchSuggestionItem.test.jsx b/packages/catalog-search/src/tests/SearchSuggestionItem.test.jsx
index 7bc30929..2e45f796 100644
--- a/packages/catalog-search/src/tests/SearchSuggestionItem.test.jsx
+++ b/packages/catalog-search/src/tests/SearchSuggestionItem.test.jsx
@@ -17,7 +17,6 @@ describe('', () => {
title: 'test-course',
_highlightResult: { title: { value: 'course catalog' } },
},
- optimizelySuggestionClickHandler: jest.fn(),
},
};
@@ -26,7 +25,6 @@ describe('', () => {
suggestionItemHandler={mockData.course.suggestionItemHandler}
hit={mockData.course.hit}
disableSuggestionRedirect={mockData.course.disableSuggestionRedirect}
- optimizelySuggestionClickHandler={mockData.optimizelySuggestionClickHandler}
/>);
expect(screen.getByRole('link', { name: 'course catalog edX' })).not.toBeNull();
expect(screen.getByText('course')).not.toBeNull();
@@ -48,7 +46,6 @@ describe('', () => {
_highlightResult: { title: { value: 'program catalog' } },
},
},
- optimizelySuggestionClickHandler: jest.fn(),
};
renderWithRouter(', () => {
suggestionItemHandler={mockData.program.suggestionItemHandler}
hit={mockData.program.hit}
disableSuggestionRedirect={mockData.program.disableSuggestionRedirect}
- optimizelySuggestionClickHandler={mockData.optimizelySuggestionClickHandler}
/>);
expect(screen.getByRole('link', { name: 'program catalog edX Professional Program' })).not.toBeNull();
expect(screen.getByText('program')).not.toBeNull();
@@ -79,7 +75,6 @@ describe('', () => {
_highlightResult: { title: { value: 'program catalog' } },
},
},
- optimizelySuggestionClickHandler: jest.fn(),
};
const { container } = renderWithRouter(', () => {
suggestionItemHandler={mockData.program.suggestionItemHandler}
hit={mockData.program.hit}
disableSuggestionRedirect={mockData.program.disableSuggestionRedirect}
- optimizelySuggestionClickHandler={mockData.optimizelySuggestionClickHandler}
/>);
userEvent.click(container.getElementsByClassName('suggestion-item')[0]);
expect(window.location.pathname).toBe(mockData.program.url);
- expect(mockData.optimizelySuggestionClickHandler.mock.calls.length).toBe(1);
});
test('fires callback on click if disableSuggestionRedirect is true', () => {
@@ -108,7 +101,6 @@ describe('', () => {
_highlightResult: { title: { value: 'program catalog' } },
},
},
- optimizelySuggestionClickHandler: jest.fn(),
};
const { container } = renderWithRouter(', () => {
suggestionItemHandler={mockData.program.suggestionItemHandler}
hit={mockData.program.hit}
disableSuggestionRedirect={mockData.program.disableSuggestionRedirect}
- optimizelySuggestionClickHandler={mockData.optimizelySuggestionClickHandler}
/>);
userEvent.click(container.getElementsByClassName('suggestion-item')[0]);
expect(mockData.program.suggestionItemHandler).toHaveBeenCalledWith(mockData.program.hit);
- expect(mockData.optimizelySuggestionClickHandler.mock.calls.length).toBe(1);
});
});
diff --git a/packages/catalog-search/src/tests/SearchSuggestions.test.jsx b/packages/catalog-search/src/tests/SearchSuggestions.test.jsx
index 804cec4a..e5e7e296 100644
--- a/packages/catalog-search/src/tests/SearchSuggestions.test.jsx
+++ b/packages/catalog-search/src/tests/SearchSuggestions.test.jsx
@@ -62,7 +62,6 @@ const fakeSuggestionsDataEmptyAuthoringOrgs = {
};
const handleSubmit = jest.fn();
-const optimizelySuggestionClickHandler = jest.fn();
describe('', () => {
test('renders all data', () => {
@@ -70,7 +69,6 @@ describe('', () => {
enterpriseSlug="test-enterprise"
autoCompleteHits={fakeSuggestionsData.hits}
handleSubmit={handleSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>);
expect(screen.getByText('Courses')).not.toBeNull();
expect(screen.getByText('Programs')).not.toBeNull();
@@ -82,24 +80,12 @@ describe('', () => {
expect(screen.getByText('xSeries')).not.toBeNull();
expect(screen.getByText('View all results')).not.toBeNull();
});
- test('renders only prequery suggestions if isPreQueryEnabled is true', () => {
- renderWithIntlProvider();
- expect(screen.getByText('Top-rated courses')).not.toBeNull();
- expect(screen.queryByText('Courses')).toBeNull();
- expect(screen.queryByText('Programs')).toBeNull();
- });
+
test('renders no errors when no authoring orgs found for programs data', () => {
renderWithIntlProvider();
expect(screen.getByText('Programs')).not.toBeNull();
expect(screen.getAllByText('test-').length).toBe(1);
@@ -113,7 +99,6 @@ describe('', () => {
enterpriseSlug="test-enterprise"
autoCompleteHits={fakeSuggestionsData.hits}
handleSubmit={handleSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>);
userEvent.click(screen.getByText('View all results'));
@@ -125,12 +110,10 @@ describe('', () => {
enterpriseSlug="test-enterprise"
autoCompleteHits={fakeSuggestionsData.hits}
handleSubmit={handleSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>);
userEvent.click(container.getElementsByClassName('suggestion-item')[0]);
expect(window.location.pathname).toBe('/test-enterprise/course/edX+courseX');
- expect(optimizelySuggestionClickHandler).toHaveBeenCalled();
});
test('redirects to correct page on program click', () => {
@@ -138,11 +121,9 @@ describe('', () => {
enterpriseSlug="test-enterprise"
autoCompleteHits={fakeSuggestionsData.hits}
handleSubmit={handleSubmit}
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>);
userEvent.click(container.getElementsByClassName('suggestion-item')[1]);
expect(window.location.pathname).toBe('/test-enterprise/program/456');
- expect(optimizelySuggestionClickHandler).toHaveBeenCalled();
});
test('properly handles exec ed content', () => {
const { container } = renderWithIntlProvider(', () => {
autoCompleteHits={fakeSuggestionsDataOnlyExecEd.hits}
handleSubmit={handleSubmit}
disableSuggestionRedirect
- optimizelySuggestionClickHandler={optimizelySuggestionClickHandler}
/>);
expect(screen.getByText('Executive Education')).not.toBeNull();
expect(container.getElementsByClassName('suggestion-item')[0].href)
.toMatch(`http://localhost/test-enterprise/${COURSE_TYPE_EXECUTIVE_EDUCATION}/course/harvard+programX`);
- expect(optimizelySuggestionClickHandler).toHaveBeenCalled();
});
test('does not display containers it does not have results for', () => {
renderWithIntlProvider();
expect(() => { screen.getByText('Programs'); }).toThrow();
});