From 6f50405e3431ad7803f51dca9dfe7ca39dca5205 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 27 Nov 2023 09:59:09 +0000
Subject: [PATCH] Default bundled emoji font to on (#11935)
* Update Settings.tsx
* Update tests
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Update snapshot
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Update assertion
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
.../appearance-user-settings-tab.spec.ts | 1 +
src/settings/Settings.tsx | 2 +-
.../__snapshots__/MatrixChat-test.tsx.snap | 4 ++-
test/settings/watchers/FontWatcher-test.tsx | 26 +++++++++----------
4 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/cypress/e2e/settings/appearance-user-settings-tab.spec.ts b/cypress/e2e/settings/appearance-user-settings-tab.spec.ts
index c9c822acde..46de23f591 100644
--- a/cypress/e2e/settings/appearance-user-settings-tab.spec.ts
+++ b/cypress/e2e/settings/appearance-user-settings-tab.spec.ts
@@ -219,6 +219,7 @@ describe("Appearance user settings tab", () => {
cy.findByRole("button", { name: "Show advanced" }).click();
// force click as checkbox size is zero
+ cy.findByLabelText("Use bundled emoji font").click({ force: true });
cy.findByLabelText("Use a system font").click({ force: true });
// Assert that the font-family value was removed
diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx
index c4c9a6c2b9..c02e4b8cbc 100644
--- a/src/settings/Settings.tsx
+++ b/src/settings/Settings.tsx
@@ -713,7 +713,7 @@ export const SETTINGS: { [setting: string]: ISetting } = {
},
"useBundledEmojiFont": {
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
- default: false,
+ default: true,
displayName: _td("settings|appearance|bundled_emoji_font"),
controller: new SystemFontController(),
},
diff --git a/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap b/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap
index 338499ac3d..cc9efb1228 100644
--- a/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap
+++ b/test/components/structures/__snapshots__/MatrixChat-test.tsx.snap
@@ -16,7 +16,9 @@ exports[` Multi-tab lockout shows the lockout page when a second t
`;
exports[` Multi-tab lockout shows the lockout page when a second tab opens during crypto init 1`] = `
-
+
{
const watcher = new FontWatcher();
await setSystemFont("Font Name");
- expect(getFontFamily()).toBe("");
+ expect(getFontFamily()).toMatchInlineSnapshot(`""`);
await watcher.start();
- expect(getFontFamily()).toBe('"Font Name"');
+ expect(getFontFamily()).toMatchInlineSnapshot(`""Font Name", Twemoji"`);
});
it("should load font on Action.OnLoggedIn", async () => {
@@ -58,16 +58,16 @@ describe("FontWatcher", function () {
await new FontWatcher().start();
document.body.style.removeProperty(FontWatcher.FONT_FAMILY_CUSTOM_PROPERTY); // clear the fontFamily which was by start which we tested already
defaultDispatcher.fire(Action.OnLoggedIn, true);
- expect(getFontFamily()).toBe('"Font Name"');
+ expect(getFontFamily()).toMatchInlineSnapshot(`""Font Name", Twemoji"`);
});
it("should reset font on Action.OnLoggedOut", async () => {
await setSystemFont("Font Name");
const watcher = new FontWatcher();
await watcher.start();
- expect(getFontFamily()).toBe('"Font Name"');
+ expect(getFontFamily()).toMatchInlineSnapshot(`""Font Name", Twemoji"`);
defaultDispatcher.fire(Action.OnLoggedOut, true);
- expect(getFontFamily()).toBe("");
+ expect(getFontFamily()).toMatchInlineSnapshot(`""`);
});
describe("Sets font as expected", () => {
@@ -82,15 +82,15 @@ describe("FontWatcher", function () {
it("encloses the fonts by double quotes and sets them as the system font", async () => {
await setSystemFont("Fira Sans Thin, Commodore 64");
- expect(getFontFamily()).toBe(`"Fira Sans Thin","Commodore 64"`);
+ expect(getFontFamily()).toMatchInlineSnapshot(`""Fira Sans Thin","Commodore 64", Twemoji"`);
});
it("does not add double quotes if already present and sets the font as the system font", async () => {
await setSystemFont(`"Commodore 64"`);
- expect(getFontFamily()).toBe(`"Commodore 64"`);
+ expect(getFontFamily()).toMatchInlineSnapshot(`""Commodore 64", Twemoji"`);
});
it("trims whitespace, encloses the fonts by double quotes, and sets them as the system font", async () => {
await setSystemFont(` Fira Code , "Commodore 64" `);
- expect(getFontFamily()).toBe(`"Fira Code","Commodore 64"`);
+ expect(getFontFamily()).toMatchInlineSnapshot(`""Fira Code","Commodore 64", Twemoji"`);
});
});
@@ -105,13 +105,13 @@ describe("FontWatcher", function () {
fontWatcher.stop();
});
- it("by default does not add Twemoji font", async () => {
- expect(getEmojiFontFamily()).toMatchInlineSnapshot(`""`);
- });
- it("adds Twemoji font when enabled", async () => {
- await setUseBundledEmojiFont(true);
+ it("by default adds Twemoji font", async () => {
expect(getEmojiFontFamily()).toMatchInlineSnapshot(`"Twemoji"`);
});
+ it("does not add Twemoji font when disabled", async () => {
+ await setUseBundledEmojiFont(false);
+ expect(getEmojiFontFamily()).toMatchInlineSnapshot(`""`);
+ });
it("works in conjunction with useSystemFont", async () => {
await setSystemFont(`"Commodore 64"`);
await setUseBundledEmojiFont(true);