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:
ScottDowne 2019-05-17 15:45:16 -04:00 коммит произвёл GitHub
Родитель bc5999e75b
Коммит 397d4c5994
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -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);
});
});