From 6bc5802cd2c4ddb13756ae249d38ce8a7e0e029c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Sep 2024 15:04:38 +0100 Subject: [PATCH 1/3] Fix flaky mobile registration tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/theme.ts | 4 ++-- test/components/structures/MatrixChat-test.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/theme.ts b/src/theme.ts index c0fb087159..f7a3a15e36 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -113,8 +113,8 @@ export function getOrderedThemes(): ITheme[] { function clearCustomTheme(): void { // remove all css variables, we assume these are there because of the custom theme - const inlineStyleProps = Object.values(document.body.style); - for (const prop of inlineStyleProps) { + for (let i = 0; i < document.body.style.length; i++) { + const prop = document.body.style[i]; if (prop.startsWith("--")) { document.body.style.removeProperty(prop); } diff --git a/test/components/structures/MatrixChat-test.tsx b/test/components/structures/MatrixChat-test.tsx index 83b4feea3a..677b6e8dd1 100644 --- a/test/components/structures/MatrixChat-test.tsx +++ b/test/components/structures/MatrixChat-test.tsx @@ -60,6 +60,7 @@ import { UIFeature } from "../../../src/settings/UIFeature"; jest.mock("matrix-js-sdk/src/oidc/authorize", () => ({ completeAuthorizationCodeGrant: jest.fn(), })); +jest.mock("../../../src/settings/watchers/ThemeWatcher"); /** The matrix versions our mock server claims to support */ const SERVER_SUPPORTED_MATRIX_VERSIONS = ["v1.1", "v1.5", "v1.6", "v1.8", "v1.9"]; From 9a0d2458091a0c600440ac26d7bd82bb4d141ded Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Sep 2024 17:13:48 +0100 Subject: [PATCH 2/3] Discard changes to src/theme.ts --- src/theme.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/theme.ts b/src/theme.ts index f7a3a15e36..c0fb087159 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -113,8 +113,8 @@ export function getOrderedThemes(): ITheme[] { function clearCustomTheme(): void { // remove all css variables, we assume these are there because of the custom theme - for (let i = 0; i < document.body.style.length; i++) { - const prop = document.body.style[i]; + const inlineStyleProps = Object.values(document.body.style); + for (const prop of inlineStyleProps) { if (prop.startsWith("--")) { document.body.style.removeProperty(prop); } From 1ec0d882de1cc033732e51fee226bc7ccbb5d230 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 30 Sep 2024 17:14:45 +0100 Subject: [PATCH 3/3] Add comment Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- test/components/structures/MatrixChat-test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/components/structures/MatrixChat-test.tsx b/test/components/structures/MatrixChat-test.tsx index 677b6e8dd1..8c9cfb1e78 100644 --- a/test/components/structures/MatrixChat-test.tsx +++ b/test/components/structures/MatrixChat-test.tsx @@ -60,6 +60,9 @@ import { UIFeature } from "../../../src/settings/UIFeature"; jest.mock("matrix-js-sdk/src/oidc/authorize", () => ({ completeAuthorizationCodeGrant: jest.fn(), })); + +// Stub out ThemeWatcher as the necessary bits for themes are done in element-web's index.html and thus are lacking here, +// plus JSDOM's implementation of CSSStyleDeclaration has a bunch of differences to real browsers which cause issues. jest.mock("../../../src/settings/watchers/ThemeWatcher"); /** The matrix versions our mock server claims to support */