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-mobile-test.js
Alan Guo Xiang Tan 3bd5f2d411
DEV: Introduce SiteSetting to enable/disable Sidebar. (#17662)
This commit removes the ability to enable/disable the Sidebar on a per
user basis and introduces a site wide setting. For testing purposes, sidebar can be enabled/disabled via the `enable_sidebar=1` or `enable_sidebar=0` query param.
2022-07-27 13:42:26 +08:00

70 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 - Mobile - User with sidebar enabled", function (needs) {
needs.user();
needs.settings({
enable_experimental_sidebar_hamburger: true,
enable_sidebar: true,
});
needs.mobileView();
test("hidden by default", async function (assert) {
await visit("/");
assert.ok(!exists(".sidebar-container"), "sidebar is not displayed");
});
test("clicking outside sidebar collapses it", async function (assert) {
await visit("/");
await click(".hamburger-dropdown");
assert.ok(exists(".sidebar-container"), "sidebar is displayed");
await click("#main-outlet");
assert.ok(!exists(".sidebar-container"), "sidebar is collapsed");
});
test("clicking on a link or button in sidebar collapses it", async function (assert) {
await visit("/");
await click(".hamburger-dropdown");
await click(".sidebar-section-link-tracked");
assert.ok(
!exists(".sidebar-container"),
"sidebar is collapsed when a button in sidebar is clicked"
);
await click(".hamburger-dropdown");
await click(".sidebar-section-header-link");
assert.ok(
!exists(".sidebar-container"),
"sidebar is collapsed when a link in sidebar is clicked"
);
});
test("collapsing sidebar sections does not collapse sidebar", async function (assert) {
await visit("/");
await click(".hamburger-dropdown");
await click(".sidebar-section-header-caret");
assert.ok(
!exists(".sidebar-section-community .sidebar-section-content"),
"topics section is collapsed"
);
assert.ok(
exists(".sidebar-container"),
"sidebar is not collapsed when clicking on caret to collapse a section in sidebar"
);
});
});