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-user-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

64 lines
1.5 KiB
JavaScript

import { test } from "qunit";
import { click, visit } from "@ember/test-helpers";
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
acceptance("Sidebar - Anonymous User", function (needs) {
needs.settings({
navigation_menu: "sidebar",
});
test("sidebar is displayed", async function (assert) {
await visit("/");
assert.ok(
document.body.classList.contains("has-sidebar-page"),
"adds sidebar utility class to body"
);
assert.ok(
exists(".sidebar-container"),
"sidebar exists for anonymous user"
);
assert.ok(
exists(".header-sidebar-toggle"),
"toggle button for anonymous user"
);
});
test("sidebar hamburger panel dropdown when sidebar has been disabled", async function (assert) {
this.siteSettings.navigation_menu = "header dropdown";
await visit("/");
await click(".hamburger-dropdown");
assert.ok(
exists(".sidebar-hamburger-dropdown .sidebar-sections-anonymous"),
"sidebar hamburger panel dropdown renders anonymous sidebar sections"
);
});
});
acceptance("Sidebar - Anonymous User - Login Required", function (needs) {
needs.settings({
navigation_menu: "sidebar",
login_required: true,
});
test("sidebar and toggle button is hidden", async function (assert) {
await visit("/");
assert.ok(
!exists(".sidebar-container"),
"sidebar is hidden for anonymous user"
);
assert.ok(
!exists(".header-sidebar-toggle"),
"toggle button is hidden for anonymous user"
);
});
});