зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616956 - Ensure collections with no title is hidden r=gvn
Differential Revision: https://phabricator.services.mozilla.com/D63540 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
95d86374ba
Коммит
2bf255b05a
|
@ -17,6 +17,11 @@ export class _CollectionCardGrid extends React.PureComponent {
|
|||
|
||||
const { title, context } = DiscoveryStream.spocs.data[placement.name] || {};
|
||||
|
||||
// Just in case of bad data, don't display a broken collection.
|
||||
if (!title) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Generally a card grid displays recs with spocs already injected.
|
||||
// Normally it doesn't care which rec is a spoc and which isn't,
|
||||
// it just displays content in a grid.
|
||||
|
|
|
@ -6382,7 +6382,11 @@ class _CollectionCardGrid extends react__WEBPACK_IMPORTED_MODULE_1___default.a.P
|
|||
const {
|
||||
title,
|
||||
context
|
||||
} = DiscoveryStream.spocs.data[placement.name] || {}; // Generally a card grid displays recs with spocs already injected.
|
||||
} = DiscoveryStream.spocs.data[placement.name] || {}; // Just in case of bad data, don't display a broken collection.
|
||||
|
||||
if (!title) {
|
||||
return null;
|
||||
} // Generally a card grid displays recs with spocs already injected.
|
||||
// Normally it doesn't care which rec is a spoc and which isn't,
|
||||
// it just displays content in a grid.
|
||||
// For collections, we're only displaying a list of spocs.
|
||||
|
@ -6391,6 +6395,7 @@ class _CollectionCardGrid extends react__WEBPACK_IMPORTED_MODULE_1___default.a.P
|
|||
// Think of it as injecting all rec positions with spocs.
|
||||
// Consider maybe making recommendations in CardGrid use a more generic name.
|
||||
|
||||
|
||||
const recsData = {
|
||||
recommendations: data.spocs
|
||||
};
|
||||
|
|
|
@ -100,4 +100,30 @@ describe("<CollectionCardGrid>", () => {
|
|||
"context"
|
||||
);
|
||||
});
|
||||
|
||||
it("should render nothing without a title", () => {
|
||||
const initialSpocs = [{ id: 123 }, { id: 456 }, { id: 789 }];
|
||||
wrapper = mountCollectionWithProps(
|
||||
{
|
||||
placement: {
|
||||
name: "spocs",
|
||||
},
|
||||
data: {
|
||||
spocs: initialSpocs,
|
||||
},
|
||||
},
|
||||
{
|
||||
data: {
|
||||
spocs: {
|
||||
title: "",
|
||||
context: "context",
|
||||
items: initialSpocs,
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
assert.ok(wrapper.exists());
|
||||
assert.ok(!wrapper.exists(".ds-collection-card-grid"));
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче