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-test.js
Alan Guo Xiang Tan d1d760ae7b
UX: Move links in Sidebar footer under community section (#17774)
Now that we have a "more..." links drawer, we can move some of the links
in footer into the links drawer. The footer itself does not have much
horizontal or vertical space for us to work with and hence limits the
amount of links which we can add to it.
2022-08-03 14:47:03 +08:00

175 lines
4.5 KiB
JavaScript

import I18n from "I18n";
import { test } from "qunit";
import { click, visit } from "@ember/test-helpers";
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
acceptance("Sidebar - Anon User", function () {
// Don't show sidebar for anon user until we know what we want to display
test("sidebar is not displayed", async function (assert) {
await visit("/");
assert.ok(
!document.body.classList.contains("has-sidebar-page"),
"does not add sidebar utility class to body"
);
assert.ok(!exists(".sidebar-container"));
});
});
acceptance(
"Sidebar - Experimental sidebar and hamburger setting disabled",
function (needs) {
needs.user();
needs.settings({
enable_experimental_sidebar_hamburger: false,
});
test("clicking header hamburger icon displays old hamburger drodown", async function (assert) {
await visit("/");
await click(".hamburger-dropdown");
assert.ok(exists(".menu-container-general-links"));
});
}
);
acceptance(
"Sidebar - Experimental sidebar and hamburger setting enabled - Sidebar disabled",
function (needs) {
needs.user();
needs.settings({
enable_experimental_sidebar_hamburger: true,
enable_sidebar: false,
});
test("showing and hiding sidebar", async function (assert) {
await visit("/");
await click(".hamburger-dropdown");
assert.ok(
exists(".sidebar-hamburger-dropdown"),
"displays the sidebar dropdown"
);
await click(".hamburger-dropdown");
assert.notOk(
exists(".sidebar-hamburger-dropdown"),
"hides the sidebar dropdown"
);
});
test("'enable_sidebar' query param override to enable sidebar", async function (assert) {
await visit("/?enable_sidebar=1");
assert.ok(exists(".sidebar-container"), "sidebar is displayed");
await click(".hamburger-dropdown");
assert.notOk(
exists(".sidebar-hamburger-dropdown"),
"does not display the sidebar dropdown"
);
assert.notOk(exists(".sidebar-container"), "sidebar is hidden");
await click(".hamburger-dropdown");
assert.ok(exists(".sidebar-container"), "sidebar is displayed");
});
}
);
acceptance(
"Sidebar - Experimental sidebar and hamburger setting enabled - Sidebar enabled",
function (needs) {
needs.user();
needs.settings({
enable_experimental_sidebar_hamburger: true,
enable_sidebar: true,
});
test("viewing keyboard shortcuts using sidebar", async function (assert) {
await visit("/");
await click(
`.sidebar-footer-actions-keyboard-shortcuts[title="${I18n.t(
"keyboard_shortcuts_help.title"
)}"]`
);
assert.ok(
exists("#keyboard-shortcuts-help"),
"keyboard shortcuts help is displayed"
);
});
test("sidebar is disabled on wizard route", async function (assert) {
await visit("/wizard");
assert.notOk(
exists(".sidebar-container"),
"does not display the sidebar on wizard route"
);
await click(".hamburger-dropdown");
assert.ok(
exists(".sidebar-hamburger-dropdown"),
"navigation around the site can still be done via the sidebar hamburger"
);
});
test("showing and hiding sidebar", 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"),
"displays the sidebar by default"
);
await click(".hamburger-dropdown");
assert.ok(
!document.body.classList.contains("has-sidebar-page"),
"removes sidebar utility class from body"
);
assert.ok(!exists(".sidebar-container"), "hides the sidebar");
await click(".hamburger-dropdown");
assert.ok(exists(".sidebar-container"), "displays the sidebar");
});
test("'enable_sidebar' query param override to disable sidebar", async function (assert) {
await visit("/?enable_sidebar=0");
assert.notOk(exists(".sidebar-container"), "sidebar is not displayed");
await click(".hamburger-dropdown");
assert.ok(
exists(".sidebar-hamburger-dropdown"),
"displays the sidebar dropdown"
);
await click(".hamburger-dropdown");
assert.notOk(
exists(".sidebar-hamburger-dropdown"),
"hides the sidebar dropdown"
);
});
}
);