FEATURE: User selectable color schemes (#10544)

This commit is contained in:
Penar Musaraj
2020-08-28 10:36:52 -04:00
committed by GitHub
parent cff57c1883
commit b7cfc9e861
35 changed files with 799 additions and 115 deletions
@@ -2,7 +2,6 @@ import I18n from "I18n";
import { acceptance, updateCurrentUser } from "helpers/qunit-helpers";
import selectKit from "helpers/select-kit-helper";
import User from "discourse/models/user";
import cookie, { removeCookie } from "discourse/lib/cookie";
function preferencesPretender(server, helper) {
server.post("/u/second_factors.json", () => {
@@ -122,51 +121,6 @@ QUnit.test("update some fields", async assert => {
);
});
QUnit.test("font size change", async assert => {
removeCookie("text_size");
const savePreferences = async () => {
assert.ok(!exists(".saved"), "it hasn't been saved yet");
await click(".save-changes");
assert.ok(exists(".saved"), "it displays the saved message");
find(".saved").remove();
};
await visit("/u/eviltrout/preferences/interface");
// Live changes without reload
await selectKit(".text-size .combobox").expand();
await selectKit(".text-size .combobox").selectRowByValue("larger");
assert.ok(document.documentElement.classList.contains("text-size-larger"));
await selectKit(".text-size .combobox").expand();
await selectKit(".text-size .combobox").selectRowByValue("largest");
assert.ok(document.documentElement.classList.contains("text-size-largest"));
assert.equal(cookie("text_size"), null, "cookie is not set");
// Click save (by default this sets for all browsers, no cookie)
await savePreferences();
assert.equal(cookie("text_size"), null, "cookie is not set");
await selectKit(".text-size .combobox").expand();
await selectKit(".text-size .combobox").selectRowByValue("larger");
await click(".text-size input[type=checkbox]");
await savePreferences();
assert.equal(cookie("text_size"), "larger|1", "cookie is set");
await click(".text-size input[type=checkbox]");
await selectKit(".text-size .combobox").expand();
await selectKit(".text-size .combobox").selectRowByValue("largest");
await savePreferences();
assert.equal(cookie("text_size"), null, "cookie is removed");
removeCookie("text_size");
});
QUnit.test("username", async assert => {
await visit("/u/eviltrout/preferences/username");
assert.ok(exists("#change_username"), "it has the input element");
@@ -483,16 +437,3 @@ QUnit.test("can select an option from a dropdown", async assert => {
await field.selectRowByValue("Cat");
assert.equal(field.header().value(), "Cat", "it sets the value of the field");
});
acceptance("User Preferences disabling dark mode", {
loggedIn: true,
settings: { default_dark_mode_color_scheme_id: 1 }
});
QUnit.test("shows option to disable dark mode", async assert => {
await visit("/u/eviltrout/preferences/interface");
assert.ok(
$(".control-group.dark-mode").length,
"it has the option to disable dark mode"
);
});