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
Kris 56c0d8cf92
UX: mobile experimental sidebar improvement (#17302)
First pass at the mobile experimental sidebar improvement.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2022-07-05 11:45:02 +08:00

66 lines
1.8 KiB
JavaScript

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.strictEqual(
document.querySelectorAll("body.has-sidebar-page").length,
0,
"does not add sidebar utility class to body"
);
assert.ok(!exists(".sidebar-container"));
});
});
acceptance("Sidebar - User with sidebar disabled", function (needs) {
needs.user({ experimental_sidebar_enabled: false });
test("sidebar is not displayed", async function (assert) {
await visit("/");
assert.strictEqual(
document.querySelectorAll("body.has-sidebar-page").length,
0,
"does not add sidebar utility class to body"
);
assert.ok(!exists(".sidebar-container"));
});
});
acceptance("Sidebar - User with sidebar enabled", function (needs) {
needs.user({ experimental_sidebar_enabled: true });
test("hiding and displaying sidebar", async function (assert) {
await visit("/");
assert.strictEqual(
document.querySelectorAll("body.has-sidebar-page").length,
1,
"adds sidebar utility class to body"
);
assert.ok(exists(".sidebar-container"), "displays the sidebar by default");
await click(".header-sidebar-toggle .btn");
assert.strictEqual(
document.querySelectorAll("body.has-sidebar-page").length,
0,
"removes sidebar utility class to body"
);
assert.ok(!exists(".sidebar-container"), "hides the sidebar");
await click(".header-sidebar-toggle .btn");
assert.ok(exists(".sidebar-container"), "displays the sidebar");
});
});