FIX: Show featured topics for categories on mobile (#27715)

The featured topics have not been rendered correctly since 2190c9b and
it has been fixed for desktop recently in commit d2a52c3. This commit
implements similar changes that initialize Category and Topic object
instances from the serialized data.
This commit is contained in:
Bianca Nenciu 2024-07-05 14:44:35 +03:00 committed by GitHub
parent 1bc18a5bf4
commit 487fb1da22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 3 deletions

View File

@ -25,7 +25,7 @@
{{/if}}
{{#unless this.isMuted}}
{{#if this.showTopics}}
{{#each this.category.topics as |t|}}
{{#each this.category.featuredTopics as |t|}}
<MobileCategoryTopic @topic={{t}} />
{{/each}}
{{/if}}

View File

@ -7,7 +7,7 @@
}}</span>
</div>
<div class="subcategories">
{{#each category.subcategories as |subCategory|}}
{{#each category.serializedSubcategories as |subCategory|}}
<ParentCategoryRow @category={{subCategory}} @showTopics={{true}} />
{{else}}
{{! No subcategories... so just show the parent to avoid confusion }}

View File

@ -78,7 +78,7 @@ acceptance("Categories - 'categories_with_featured_topics'", function (needs) {
});
acceptance(
"Categories - 'subcategories_with_featured_topics'",
"Categories - 'subcategories_with_featured_topics' (desktop)",
function (needs) {
needs.settings({
desktop_category_page_style: "subcategories_with_featured_topics",
@ -103,6 +103,33 @@ acceptance(
}
);
acceptance(
"Categories - 'subcategories_with_featured_topics' (mobile)",
function (needs) {
needs.mobileView();
needs.settings({
desktop_category_page_style: "subcategories_with_featured_topics",
});
test("basic functionality", async function (assert) {
await visit("/categories");
assert.ok(
exists("div.subcategory-list.with-topics h3 .category-name"),
"shows heading for top-level category"
);
assert.ok(
exists(
"div.subcategory-list.with-topics div[data-category-id=26] h3 .category-name"
),
"shows element for subcategories"
);
assert.ok(
exists("div.category-list.with-topics a[data-topic-id=11994]"),
"shows a featured topic"
);
});
}
);
acceptance("Categories - preloadStore handling", function () {
const styles = [
"categories_only",