element-web/test/unit-tests/settings/controllers/ThemeController-test.ts
Richard van der Hoff 5f07fbbc1b
Allow the Login screen to use the dark theme (#31293)
* Allow the Login screen to use the dark theme

There is a whole bunch of code dedicated to attempting to force a "light" theme
onto the login view, even if the deployment is configured to prioritise the
dark theme.

Apparently this was done because, in the old days, the
login view looked rubbish with the dark theme, but now it looks fine.

Fixes https://github.com/element-hq/element-web/issues/31292

* Fix up background colour of auth screen in dark theme

In dark theme, the background of the login/register/welcome box needs to be
translucent black rather than translucent white.

To make this work, I've moved the style from inline to CSS, and used a PostCSS
variable to define the colour.

* Fix up Welcome page colours in dark theme

Make the text and image white, not black, in short.

* Fix incorrect merge

that will teach me to use the Github UI to address merge conflicts.
2025-11-26 07:54:40 +00:00

46 lines
1.5 KiB
TypeScript

/*
Copyright 2024 New Vector Ltd.
Copyright 2022 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import ThemeController from "../../../../src/settings/controllers/ThemeController";
import { SettingLevel } from "../../../../src/settings/SettingLevel";
import SettingsStore from "../../../../src/settings/SettingsStore";
import { DEFAULT_THEME } from "../../../../src/theme";
describe("ThemeController", () => {
jest.spyOn(SettingsStore, "getValue").mockReturnValue([]);
it("returns null when calculatedValue is falsy", () => {
const controller = new ThemeController();
expect(
controller.getValueOverride(
SettingLevel.ACCOUNT,
"$room:server",
undefined /* calculatedValue */,
SettingLevel.ACCOUNT,
),
).toEqual(null);
});
it("returns default theme when value is not a valid theme", () => {
const controller = new ThemeController();
expect(
controller.getValueOverride(SettingLevel.ACCOUNT, "$room:server", "my-test-theme", SettingLevel.ACCOUNT),
).toEqual(DEFAULT_THEME);
});
it("returns null when value is a valid theme", () => {
const controller = new ThemeController();
expect(controller.getValueOverride(SettingLevel.ACCOUNT, "$room:server", "dark", SettingLevel.ACCOUNT)).toEqual(
null,
);
});
});