First pass at the mobile experimental sidebar improvement. Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
65 lines
1.8 KiB
JavaScript
65 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({ experimental_sidebar_enabled: 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(".btn-sidebar-toggle");
|
|
|
|
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(".btn-sidebar-toggle");
|
|
await click(".sidebar-section-link-tracked");
|
|
|
|
assert.ok(
|
|
!exists(".sidebar-container"),
|
|
"sidebar is collapsed when a button in sidebar is clicked"
|
|
);
|
|
|
|
await click(".btn-sidebar-toggle");
|
|
await click(".sidebar-section-header-link");
|
|
|
|
assert.ok(
|
|
!exists(".sidebar-container"),
|
|
"sidebar is collapsed when a link in sidebar is clicked"
|
|
);
|
|
});
|
|
|
|
test("collpasing sidebar sections does not collapse sidebar", async function (assert) {
|
|
await visit("/");
|
|
|
|
await click(".btn-sidebar-toggle");
|
|
await click(".sidebar-section-header-caret");
|
|
|
|
assert.ok(
|
|
!exists(".sidebar-section-topics .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"
|
|
);
|
|
});
|
|
});
|