This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/d-navigation-test.js
Krzysztof Kotlarek ea3a58d051
FIX: indirectly muted categories for topic-tracking-state (#16067)
Topics belonging to indirectly muted categories should be excluded from topic-tracking-state report.
2022-03-02 15:02:09 +11:00

45 lines
1.3 KiB
JavaScript

import { click } from "@ember/test-helpers";
import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import { discourseModule, query } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
discourseModule("Integration | Component | d-navigation", function (hooks) {
setupRenderingTest(hooks);
componentTest("filters indirectly muted categories", {
template: hbs`
{{d-navigation
filterType="categories"
}}
`,
beforeEach() {
const categories = this.site.categoriesList
.filter((category) => !category.parent_category_id)
.slice(0, 4);
this.site.setProperties({
categoriesList: categories,
});
this.currentUser.set(
"indirectly_muted_category_ids",
categories.slice(0, 3).map((category) => category.id)
);
},
async test(assert) {
await click(".category-drop .select-kit-header-wrapper");
assert.strictEqual(
document.querySelectorAll(".category-row").length,
1,
"displays only categories that are not muted"
);
assert.strictEqual(
query(".category-row .badge-category span").textContent.trim(),
"dev"
);
},
});
});