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/acceptance/sidebar-anonymous-community-section-test.js
Alan Guo Xiang Tan fde9e6bc25
DEV: Migrate sidebar site settings (#19336)
This new site setting replaces the
`enable_experimental_sidebar_hamburger` and `enable_sidebar` site
settings as the sidebar feature exits the experimental phase.

Note that we're replacing this without depreciation since the previous
site setting was considered experimental.

Internal Ref: /t/86563
2022-12-08 09:44:29 +08:00

110 lines
3.1 KiB
JavaScript

import I18n from "I18n";
import { test } from "qunit";
import {
acceptance,
exists,
query,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers";
acceptance("Sidebar - Anonymous user - Community Section", function (needs) {
needs.settings({
navigation_menu: "sidebar",
});
test("display short site description site setting when it is set", async function (assert) {
this.siteSettings.short_site_description =
"This is a short description about the site";
await visit("/");
assert.strictEqual(
query(
".sidebar-section-community .sidebar-section-message"
).textContent.trim(),
this.siteSettings.short_site_description,
"displays the short site description under the community section"
);
const sectionLinks = queryAll(
".sidebar-section-community .sidebar-section-link"
);
assert.strictEqual(
sectionLinks[0].textContent.trim(),
I18n.t("sidebar.sections.community.links.about.content"),
"displays the about section link first"
);
});
test("everything, users, about and FAQ section links are shown by default ", async function (assert) {
await visit("/");
const sectionLinks = queryAll(
".sidebar-section-community .sidebar-section-link"
);
assert.strictEqual(
sectionLinks[0].textContent.trim(),
I18n.t("sidebar.sections.community.links.everything.content"),
"displays the everything section link first"
);
assert.strictEqual(
sectionLinks[1].textContent.trim(),
I18n.t("sidebar.sections.community.links.users.content"),
"displays the users section link second"
);
assert.strictEqual(
sectionLinks[2].textContent.trim(),
I18n.t("sidebar.sections.community.links.about.content"),
"displays the about section link third"
);
assert.strictEqual(
sectionLinks[3].textContent.trim(),
I18n.t("sidebar.sections.community.links.faq.content"),
"displays the FAQ section link last"
);
});
test("users section link is not shown when hide_user_profiles_from_public site setting is enabled", async function (assert) {
this.siteSettings.hide_user_profiles_from_public = true;
await visit("/");
assert.notOk(
exists(".sidebar-section-community .sidebar-section-link-users"),
"users section link is not shown in sidebar"
);
});
test("groups and badges section links are shown in more...", async function (assert) {
await visit("/");
await click(
".sidebar-section-community .sidebar-more-section-links-details-summary"
);
const sectionLinks = queryAll(
".sidebar-more-section-links-details-content-main .sidebar-section-link"
);
assert.strictEqual(
sectionLinks[0].textContent.trim(),
I18n.t("sidebar.sections.community.links.groups.content"),
"displays the groups section link first"
);
assert.strictEqual(
sectionLinks[1].textContent.trim(),
I18n.t("sidebar.sections.community.links.badges.content"),
"displays the badges section link second"
);
});
});