Bug 152289 - Fix search only for DS (#5040)
* Bug 152289 - Fix search only for DS * Make it more readable * whoops * Fixes * Name change * test
This commit is contained in:
Родитель
bc5999e75b
Коммит
397d4c5994
|
@ -135,8 +135,14 @@ export class BaseContent extends React.PureComponent {
|
|||
const prefs = props.Prefs.values;
|
||||
|
||||
const shouldBeFixedToTop = PrerenderData.arePrefsValid(name => prefs[name]);
|
||||
const noSectionsEnabled = !prefs["feeds.topsites"] && props.Sections.filter(section => section.enabled).length === 0;
|
||||
const isDiscoveryStream = props.DiscoveryStream.config && props.DiscoveryStream.config.enabled;
|
||||
let filteredSections = props.Sections;
|
||||
|
||||
// Filter out highlights for DS
|
||||
if (isDiscoveryStream) {
|
||||
filteredSections = filteredSections.filter(section => section.id !== "highlights");
|
||||
}
|
||||
const noSectionsEnabled = !prefs["feeds.topsites"] && filteredSections.filter(section => section.enabled).length === 0;
|
||||
const searchHandoffEnabled = prefs["improvesearch.handoffToAwesomebar"];
|
||||
|
||||
const outerClassName = [
|
||||
|
|
|
@ -48,4 +48,20 @@ describe("<BaseContent>", () => {
|
|||
|
||||
assert.isTrue(wrapper.find(Search).parent().is(ErrorBoundary));
|
||||
});
|
||||
|
||||
it("should render only search if no Sections are enabled", () => {
|
||||
const onlySearchProps =
|
||||
Object.assign({}, DEFAULT_PROPS, {Sections: [{id: "highlights", enabled: false}], Prefs: {values: {showSearch: true}}});
|
||||
|
||||
const wrapper = shallow(<BaseContent {...onlySearchProps} />);
|
||||
assert.lengthOf(wrapper.find(".only-search"), 1);
|
||||
});
|
||||
|
||||
it("should render only search if only highlights is available in DS", () => {
|
||||
const onlySearchProps =
|
||||
Object.assign({}, DEFAULT_PROPS, {Sections: [{id: "highlights", enabled: true}], DiscoveryStream: {config: {enabled: true}}, Prefs: {values: {showSearch: true}}});
|
||||
|
||||
const wrapper = shallow(<BaseContent {...onlySearchProps} />);
|
||||
assert.lengthOf(wrapper.find(".only-search"), 1);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче